babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. private _useInstancing;
  11254. /**
  11255. * An event triggered when the manager is disposed.
  11256. */
  11257. onDisposeObservable: Observable<SpriteManager>;
  11258. private _onDisposeObserver;
  11259. /**
  11260. * Callback called when the manager is disposed
  11261. */
  11262. set onDispose(callback: () => void);
  11263. private _capacity;
  11264. private _fromPacked;
  11265. private _spriteTexture;
  11266. private _epsilon;
  11267. private _scene;
  11268. private _vertexData;
  11269. private _buffer;
  11270. private _vertexBuffers;
  11271. private _spriteBuffer;
  11272. private _indexBuffer;
  11273. private _effectBase;
  11274. private _effectFog;
  11275. private _vertexBufferSize;
  11276. /**
  11277. * Gets or sets the unique id of the sprite
  11278. */
  11279. uniqueId: number;
  11280. /**
  11281. * Gets the array of sprites
  11282. */
  11283. get children(): Sprite[];
  11284. /**
  11285. * Gets the hosting scene
  11286. */
  11287. get scene(): Scene;
  11288. /**
  11289. * Gets the capacity of the manager
  11290. */
  11291. get capacity(): number;
  11292. /**
  11293. * Gets or sets the spritesheet texture
  11294. */
  11295. get texture(): Texture;
  11296. set texture(value: Texture);
  11297. private _blendMode;
  11298. /**
  11299. * Blend mode use to render the particle, it can be any of
  11300. * the static Constants.ALPHA_x properties provided in this class.
  11301. * Default value is Constants.ALPHA_COMBINE
  11302. */
  11303. get blendMode(): number;
  11304. set blendMode(blendMode: number);
  11305. /** Disables writing to the depth buffer when rendering the sprites.
  11306. * It can be handy to disable depth writing when using textures without alpha channel
  11307. * and setting some specific blend modes.
  11308. */
  11309. disableDepthWrite: boolean;
  11310. /**
  11311. * Creates a new sprite manager
  11312. * @param name defines the manager's name
  11313. * @param imgUrl defines the sprite sheet url
  11314. * @param capacity defines the maximum allowed number of sprites
  11315. * @param cellSize defines the size of a sprite cell
  11316. * @param scene defines the hosting scene
  11317. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11318. * @param samplingMode defines the smapling mode to use with spritesheet
  11319. * @param fromPacked set to false; do not alter
  11320. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11321. */
  11322. constructor(
  11323. /** defines the manager's name */
  11324. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11325. /**
  11326. * Returns the string "SpriteManager"
  11327. * @returns "SpriteManager"
  11328. */
  11329. getClassName(): string;
  11330. private _makePacked;
  11331. private _appendSpriteVertex;
  11332. private _checkTextureAlpha;
  11333. /**
  11334. * Intersects the sprites with a ray
  11335. * @param ray defines the ray to intersect with
  11336. * @param camera defines the current active camera
  11337. * @param predicate defines a predicate used to select candidate sprites
  11338. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11339. * @returns null if no hit or a PickingInfo
  11340. */
  11341. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11342. /**
  11343. * Intersects the sprites with a ray
  11344. * @param ray defines the ray to intersect with
  11345. * @param camera defines the current active camera
  11346. * @param predicate defines a predicate used to select candidate sprites
  11347. * @returns null if no hit or a PickingInfo array
  11348. */
  11349. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11350. /**
  11351. * Render all child sprites
  11352. */
  11353. render(): void;
  11354. /**
  11355. * Release associated resources
  11356. */
  11357. dispose(): void;
  11358. /**
  11359. * Serializes the sprite manager to a JSON object
  11360. * @param serializeTexture defines if the texture must be serialized as well
  11361. * @returns the JSON object
  11362. */
  11363. serialize(serializeTexture?: boolean): any;
  11364. /**
  11365. * Parses a JSON object to create a new sprite manager.
  11366. * @param parsedManager The JSON object to parse
  11367. * @param scene The scene to create the sprite managerin
  11368. * @param rootUrl The root url to use to load external dependencies like texture
  11369. * @returns the new sprite manager
  11370. */
  11371. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11372. /**
  11373. * Creates a sprite manager from a snippet saved in a remote file
  11374. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11375. * @param url defines the url to load from
  11376. * @param scene defines the hosting scene
  11377. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11378. * @returns a promise that will resolve to the new sprite manager
  11379. */
  11380. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11381. /**
  11382. * Creates a sprite manager from a snippet saved by the sprite editor
  11383. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11384. * @param scene defines the hosting scene
  11385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11386. * @returns a promise that will resolve to the new sprite manager
  11387. */
  11388. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11389. }
  11390. }
  11391. declare module "babylonjs/Misc/gradients" {
  11392. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11393. /** Interface used by value gradients (color, factor, ...) */
  11394. export interface IValueGradient {
  11395. /**
  11396. * Gets or sets the gradient value (between 0 and 1)
  11397. */
  11398. gradient: number;
  11399. }
  11400. /** Class used to store color4 gradient */
  11401. export class ColorGradient implements IValueGradient {
  11402. /**
  11403. * Gets or sets the gradient value (between 0 and 1)
  11404. */
  11405. gradient: number;
  11406. /**
  11407. * Gets or sets first associated color
  11408. */
  11409. color1: Color4;
  11410. /**
  11411. * Gets or sets second associated color
  11412. */
  11413. color2?: Color4 | undefined;
  11414. /**
  11415. * Creates a new color4 gradient
  11416. * @param gradient gets or sets the gradient value (between 0 and 1)
  11417. * @param color1 gets or sets first associated color
  11418. * @param color2 gets or sets first second color
  11419. */
  11420. constructor(
  11421. /**
  11422. * Gets or sets the gradient value (between 0 and 1)
  11423. */
  11424. gradient: number,
  11425. /**
  11426. * Gets or sets first associated color
  11427. */
  11428. color1: Color4,
  11429. /**
  11430. * Gets or sets second associated color
  11431. */
  11432. color2?: Color4 | undefined);
  11433. /**
  11434. * Will get a color picked randomly between color1 and color2.
  11435. * If color2 is undefined then color1 will be used
  11436. * @param result defines the target Color4 to store the result in
  11437. */
  11438. getColorToRef(result: Color4): void;
  11439. }
  11440. /** Class used to store color 3 gradient */
  11441. export class Color3Gradient implements IValueGradient {
  11442. /**
  11443. * Gets or sets the gradient value (between 0 and 1)
  11444. */
  11445. gradient: number;
  11446. /**
  11447. * Gets or sets the associated color
  11448. */
  11449. color: Color3;
  11450. /**
  11451. * Creates a new color3 gradient
  11452. * @param gradient gets or sets the gradient value (between 0 and 1)
  11453. * @param color gets or sets associated color
  11454. */
  11455. constructor(
  11456. /**
  11457. * Gets or sets the gradient value (between 0 and 1)
  11458. */
  11459. gradient: number,
  11460. /**
  11461. * Gets or sets the associated color
  11462. */
  11463. color: Color3);
  11464. }
  11465. /** Class used to store factor gradient */
  11466. export class FactorGradient implements IValueGradient {
  11467. /**
  11468. * Gets or sets the gradient value (between 0 and 1)
  11469. */
  11470. gradient: number;
  11471. /**
  11472. * Gets or sets first associated factor
  11473. */
  11474. factor1: number;
  11475. /**
  11476. * Gets or sets second associated factor
  11477. */
  11478. factor2?: number | undefined;
  11479. /**
  11480. * Creates a new factor gradient
  11481. * @param gradient gets or sets the gradient value (between 0 and 1)
  11482. * @param factor1 gets or sets first associated factor
  11483. * @param factor2 gets or sets second associated factor
  11484. */
  11485. constructor(
  11486. /**
  11487. * Gets or sets the gradient value (between 0 and 1)
  11488. */
  11489. gradient: number,
  11490. /**
  11491. * Gets or sets first associated factor
  11492. */
  11493. factor1: number,
  11494. /**
  11495. * Gets or sets second associated factor
  11496. */
  11497. factor2?: number | undefined);
  11498. /**
  11499. * Will get a number picked randomly between factor1 and factor2.
  11500. * If factor2 is undefined then factor1 will be used
  11501. * @returns the picked number
  11502. */
  11503. getFactor(): number;
  11504. }
  11505. /**
  11506. * Helper used to simplify some generic gradient tasks
  11507. */
  11508. export class GradientHelper {
  11509. /**
  11510. * Gets the current gradient from an array of IValueGradient
  11511. * @param ratio defines the current ratio to get
  11512. * @param gradients defines the array of IValueGradient
  11513. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11514. */
  11515. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11516. }
  11517. }
  11518. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11519. import { Nullable } from "babylonjs/types";
  11520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11521. import { Scene } from "babylonjs/scene";
  11522. module "babylonjs/Engines/thinEngine" {
  11523. interface ThinEngine {
  11524. /**
  11525. * Creates a raw texture
  11526. * @param data defines the data to store in the texture
  11527. * @param width defines the width of the texture
  11528. * @param height defines the height of the texture
  11529. * @param format defines the format of the data
  11530. * @param generateMipMaps defines if the engine should generate the mip levels
  11531. * @param invertY defines if data must be stored with Y axis inverted
  11532. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11533. * @param compression defines the compression used (null by default)
  11534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11535. * @returns the raw texture inside an InternalTexture
  11536. */
  11537. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11538. /**
  11539. * Update a raw texture
  11540. * @param texture defines the texture to update
  11541. * @param data defines the data to store in the texture
  11542. * @param format defines the format of the data
  11543. * @param invertY defines if data must be stored with Y axis inverted
  11544. */
  11545. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11546. /**
  11547. * Update a raw texture
  11548. * @param texture defines the texture to update
  11549. * @param data defines the data to store in the texture
  11550. * @param format defines the format of the data
  11551. * @param invertY defines if data must be stored with Y axis inverted
  11552. * @param compression defines the compression used (null by default)
  11553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11554. */
  11555. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11556. /**
  11557. * Creates a new raw cube texture
  11558. * @param data defines the array of data to use to create each face
  11559. * @param size defines the size of the textures
  11560. * @param format defines the format of the data
  11561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11562. * @param generateMipMaps defines if the engine should generate the mip levels
  11563. * @param invertY defines if data must be stored with Y axis inverted
  11564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11565. * @param compression defines the compression used (null by default)
  11566. * @returns the cube texture as an InternalTexture
  11567. */
  11568. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11569. /**
  11570. * Update a raw cube texture
  11571. * @param texture defines the texture to udpdate
  11572. * @param data defines the data to store
  11573. * @param format defines the data format
  11574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11575. * @param invertY defines if data must be stored with Y axis inverted
  11576. */
  11577. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11578. /**
  11579. * Update a raw cube texture
  11580. * @param texture defines the texture to udpdate
  11581. * @param data defines the data to store
  11582. * @param format defines the data format
  11583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @param compression defines the compression used (null by default)
  11586. */
  11587. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11588. /**
  11589. * Update a raw cube texture
  11590. * @param texture defines the texture to udpdate
  11591. * @param data defines the data to store
  11592. * @param format defines the data format
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the compression used (null by default)
  11596. * @param level defines which level of the texture to update
  11597. */
  11598. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11599. /**
  11600. * Creates a new raw cube texture from a specified url
  11601. * @param url defines the url where the data is located
  11602. * @param scene defines the current scene
  11603. * @param size defines the size of the textures
  11604. * @param format defines the format of the data
  11605. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11606. * @param noMipmap defines if the engine should avoid generating the mip levels
  11607. * @param callback defines a callback used to extract texture data from loaded data
  11608. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11609. * @param onLoad defines a callback called when texture is loaded
  11610. * @param onError defines a callback called if there is an error
  11611. * @returns the cube texture as an InternalTexture
  11612. */
  11613. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11614. /**
  11615. * Creates a new raw cube texture from a specified url
  11616. * @param url defines the url where the data is located
  11617. * @param scene defines the current scene
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param noMipmap defines if the engine should avoid generating the mip levels
  11622. * @param callback defines a callback used to extract texture data from loaded data
  11623. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11624. * @param onLoad defines a callback called when texture is loaded
  11625. * @param onError defines a callback called if there is an error
  11626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11627. * @param invertY defines if data must be stored with Y axis inverted
  11628. * @returns the cube texture as an InternalTexture
  11629. */
  11630. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11631. /**
  11632. * Creates a new raw 3D texture
  11633. * @param data defines the data used to create the texture
  11634. * @param width defines the width of the texture
  11635. * @param height defines the height of the texture
  11636. * @param depth defines the depth of the texture
  11637. * @param format defines the format of the texture
  11638. * @param generateMipMaps defines if the engine must generate mip levels
  11639. * @param invertY defines if data must be stored with Y axis inverted
  11640. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11641. * @param compression defines the compressed used (can be null)
  11642. * @param textureType defines the compressed used (can be null)
  11643. * @returns a new raw 3D texture (stored in an InternalTexture)
  11644. */
  11645. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11646. /**
  11647. * Update a raw 3D texture
  11648. * @param texture defines the texture to update
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param invertY defines if data must be stored with Y axis inverted
  11652. */
  11653. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11654. /**
  11655. * Update a raw 3D texture
  11656. * @param texture defines the texture to update
  11657. * @param data defines the data to store
  11658. * @param format defines the data format
  11659. * @param invertY defines if data must be stored with Y axis inverted
  11660. * @param compression defines the used compression (can be null)
  11661. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11662. */
  11663. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11664. /**
  11665. * Creates a new raw 2D array texture
  11666. * @param data defines the data used to create the texture
  11667. * @param width defines the width of the texture
  11668. * @param height defines the height of the texture
  11669. * @param depth defines the number of layers of the texture
  11670. * @param format defines the format of the texture
  11671. * @param generateMipMaps defines if the engine must generate mip levels
  11672. * @param invertY defines if data must be stored with Y axis inverted
  11673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11674. * @param compression defines the compressed used (can be null)
  11675. * @param textureType defines the compressed used (can be null)
  11676. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11677. */
  11678. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11679. /**
  11680. * Update a raw 2D array texture
  11681. * @param texture defines the texture to update
  11682. * @param data defines the data to store
  11683. * @param format defines the data format
  11684. * @param invertY defines if data must be stored with Y axis inverted
  11685. */
  11686. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11687. /**
  11688. * Update a raw 2D array texture
  11689. * @param texture defines the texture to update
  11690. * @param data defines the data to store
  11691. * @param format defines the data format
  11692. * @param invertY defines if data must be stored with Y axis inverted
  11693. * @param compression defines the used compression (can be null)
  11694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11695. */
  11696. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11697. }
  11698. }
  11699. }
  11700. declare module "babylonjs/Materials/Textures/rawTexture" {
  11701. import { Texture } from "babylonjs/Materials/Textures/texture";
  11702. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11703. import { Nullable } from "babylonjs/types";
  11704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11705. import { Scene } from "babylonjs/scene";
  11706. /**
  11707. * Raw texture can help creating a texture directly from an array of data.
  11708. * This can be super useful if you either get the data from an uncompressed source or
  11709. * if you wish to create your texture pixel by pixel.
  11710. */
  11711. export class RawTexture extends Texture {
  11712. /**
  11713. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11714. */
  11715. format: number;
  11716. /**
  11717. * Instantiates a new RawTexture.
  11718. * Raw texture can help creating a texture directly from an array of data.
  11719. * This can be super useful if you either get the data from an uncompressed source or
  11720. * if you wish to create your texture pixel by pixel.
  11721. * @param data define the array of data to use to create the texture
  11722. * @param width define the width of the texture
  11723. * @param height define the height of the texture
  11724. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11725. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11726. * @param generateMipMaps define whether mip maps should be generated or not
  11727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11730. */
  11731. constructor(data: ArrayBufferView, width: number, height: number,
  11732. /**
  11733. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11734. */
  11735. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11736. /**
  11737. * Updates the texture underlying data.
  11738. * @param data Define the new data of the texture
  11739. */
  11740. update(data: ArrayBufferView): void;
  11741. /**
  11742. * Creates a luminance texture from some data.
  11743. * @param data Define the texture data
  11744. * @param width Define the width of the texture
  11745. * @param height Define the height of the texture
  11746. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11750. * @returns the luminance texture
  11751. */
  11752. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11753. /**
  11754. * Creates a luminance alpha texture from some data.
  11755. * @param data Define the texture data
  11756. * @param width Define the width of the texture
  11757. * @param height Define the height of the texture
  11758. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11759. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11762. * @returns the luminance alpha texture
  11763. */
  11764. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11765. /**
  11766. * Creates an alpha texture from some data.
  11767. * @param data Define the texture data
  11768. * @param width Define the width of the texture
  11769. * @param height Define the height of the texture
  11770. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11774. * @returns the alpha texture
  11775. */
  11776. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11777. /**
  11778. * Creates a RGB texture from some data.
  11779. * @param data Define the texture data
  11780. * @param width Define the width of the texture
  11781. * @param height Define the height of the texture
  11782. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11786. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11787. * @returns the RGB alpha texture
  11788. */
  11789. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11790. /**
  11791. * Creates a RGBA texture from some data.
  11792. * @param data Define the texture data
  11793. * @param width Define the width of the texture
  11794. * @param height Define the height of the texture
  11795. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11799. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11800. * @returns the RGBA texture
  11801. */
  11802. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11803. /**
  11804. * Creates a R texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the R texture
  11814. */
  11815. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. }
  11817. }
  11818. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11819. import { Scene } from "babylonjs/scene";
  11820. import { ISceneComponent } from "babylonjs/sceneComponent";
  11821. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11822. module "babylonjs/abstractScene" {
  11823. interface AbstractScene {
  11824. /**
  11825. * The list of procedural textures added to the scene
  11826. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11827. */
  11828. proceduralTextures: Array<ProceduralTexture>;
  11829. }
  11830. }
  11831. /**
  11832. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11833. * in a given scene.
  11834. */
  11835. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11836. /**
  11837. * The component name helpfull to identify the component in the list of scene components.
  11838. */
  11839. readonly name: string;
  11840. /**
  11841. * The scene the component belongs to.
  11842. */
  11843. scene: Scene;
  11844. /**
  11845. * Creates a new instance of the component for the given scene
  11846. * @param scene Defines the scene to register the component in
  11847. */
  11848. constructor(scene: Scene);
  11849. /**
  11850. * Registers the component in a given scene
  11851. */
  11852. register(): void;
  11853. /**
  11854. * Rebuilds the elements related to this component in case of
  11855. * context lost for instance.
  11856. */
  11857. rebuild(): void;
  11858. /**
  11859. * Disposes the component and the associated ressources.
  11860. */
  11861. dispose(): void;
  11862. private _beforeClear;
  11863. }
  11864. }
  11865. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11867. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11868. module "babylonjs/Engines/thinEngine" {
  11869. interface ThinEngine {
  11870. /**
  11871. * Creates a new render target cube texture
  11872. * @param size defines the size of the texture
  11873. * @param options defines the options used to create the texture
  11874. * @returns a new render target cube texture stored in an InternalTexture
  11875. */
  11876. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11877. }
  11878. }
  11879. }
  11880. declare module "babylonjs/Shaders/procedural.vertex" {
  11881. /** @hidden */
  11882. export var proceduralVertexShader: {
  11883. name: string;
  11884. shader: string;
  11885. };
  11886. }
  11887. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11888. import { Observable } from "babylonjs/Misc/observable";
  11889. import { Nullable } from "babylonjs/types";
  11890. import { Scene } from "babylonjs/scene";
  11891. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11892. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11893. import { Effect } from "babylonjs/Materials/effect";
  11894. import { Texture } from "babylonjs/Materials/Textures/texture";
  11895. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11896. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11897. import "babylonjs/Shaders/procedural.vertex";
  11898. /**
  11899. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11900. * This is the base class of any Procedural texture and contains most of the shareable code.
  11901. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11902. */
  11903. export class ProceduralTexture extends Texture {
  11904. isCube: boolean;
  11905. /**
  11906. * Define if the texture is enabled or not (disabled texture will not render)
  11907. */
  11908. isEnabled: boolean;
  11909. /**
  11910. * Define if the texture must be cleared before rendering (default is true)
  11911. */
  11912. autoClear: boolean;
  11913. /**
  11914. * Callback called when the texture is generated
  11915. */
  11916. onGenerated: () => void;
  11917. /**
  11918. * Event raised when the texture is generated
  11919. */
  11920. onGeneratedObservable: Observable<ProceduralTexture>;
  11921. /** @hidden */
  11922. _generateMipMaps: boolean;
  11923. /** @hidden **/
  11924. _effect: Effect;
  11925. /** @hidden */
  11926. _textures: {
  11927. [key: string]: Texture;
  11928. };
  11929. /** @hidden */
  11930. protected _fallbackTexture: Nullable<Texture>;
  11931. private _size;
  11932. private _currentRefreshId;
  11933. private _frameId;
  11934. private _refreshRate;
  11935. private _vertexBuffers;
  11936. private _indexBuffer;
  11937. private _uniforms;
  11938. private _samplers;
  11939. private _fragment;
  11940. private _floats;
  11941. private _ints;
  11942. private _floatsArrays;
  11943. private _colors3;
  11944. private _colors4;
  11945. private _vectors2;
  11946. private _vectors3;
  11947. private _matrices;
  11948. private _fallbackTextureUsed;
  11949. private _fullEngine;
  11950. private _cachedDefines;
  11951. private _contentUpdateId;
  11952. private _contentData;
  11953. /**
  11954. * Instantiates a new procedural texture.
  11955. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11956. * This is the base class of any Procedural texture and contains most of the shareable code.
  11957. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11958. * @param name Define the name of the texture
  11959. * @param size Define the size of the texture to create
  11960. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11961. * @param scene Define the scene the texture belongs to
  11962. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11963. * @param generateMipMaps Define if the texture should creates mip maps or not
  11964. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11965. */
  11966. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11967. /**
  11968. * The effect that is created when initializing the post process.
  11969. * @returns The created effect corresponding the the postprocess.
  11970. */
  11971. getEffect(): Effect;
  11972. /**
  11973. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11974. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11975. */
  11976. getContent(): Nullable<ArrayBufferView>;
  11977. private _createIndexBuffer;
  11978. /** @hidden */
  11979. _rebuild(): void;
  11980. /**
  11981. * Resets the texture in order to recreate its associated resources.
  11982. * This can be called in case of context loss
  11983. */
  11984. reset(): void;
  11985. protected _getDefines(): string;
  11986. /**
  11987. * Is the texture ready to be used ? (rendered at least once)
  11988. * @returns true if ready, otherwise, false.
  11989. */
  11990. isReady(): boolean;
  11991. /**
  11992. * Resets the refresh counter of the texture and start bak from scratch.
  11993. * Could be useful to regenerate the texture if it is setup to render only once.
  11994. */
  11995. resetRefreshCounter(): void;
  11996. /**
  11997. * Set the fragment shader to use in order to render the texture.
  11998. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11999. */
  12000. setFragment(fragment: any): void;
  12001. /**
  12002. * Define the refresh rate of the texture or the rendering frequency.
  12003. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12004. */
  12005. get refreshRate(): number;
  12006. set refreshRate(value: number);
  12007. /** @hidden */
  12008. _shouldRender(): boolean;
  12009. /**
  12010. * Get the size the texture is rendering at.
  12011. * @returns the size (texture is always squared)
  12012. */
  12013. getRenderSize(): number;
  12014. /**
  12015. * Resize the texture to new value.
  12016. * @param size Define the new size the texture should have
  12017. * @param generateMipMaps Define whether the new texture should create mip maps
  12018. */
  12019. resize(size: number, generateMipMaps: boolean): void;
  12020. private _checkUniform;
  12021. /**
  12022. * Set a texture in the shader program used to render.
  12023. * @param name Define the name of the uniform samplers as defined in the shader
  12024. * @param texture Define the texture to bind to this sampler
  12025. * @return the texture itself allowing "fluent" like uniform updates
  12026. */
  12027. setTexture(name: string, texture: Texture): ProceduralTexture;
  12028. /**
  12029. * Set a float in the shader.
  12030. * @param name Define the name of the uniform as defined in the shader
  12031. * @param value Define the value to give to the uniform
  12032. * @return the texture itself allowing "fluent" like uniform updates
  12033. */
  12034. setFloat(name: string, value: number): ProceduralTexture;
  12035. /**
  12036. * Set a int in the shader.
  12037. * @param name Define the name of the uniform as defined in the shader
  12038. * @param value Define the value to give to the uniform
  12039. * @return the texture itself allowing "fluent" like uniform updates
  12040. */
  12041. setInt(name: string, value: number): ProceduralTexture;
  12042. /**
  12043. * Set an array of floats in the shader.
  12044. * @param name Define the name of the uniform as defined in the shader
  12045. * @param value Define the value to give to the uniform
  12046. * @return the texture itself allowing "fluent" like uniform updates
  12047. */
  12048. setFloats(name: string, value: number[]): ProceduralTexture;
  12049. /**
  12050. * Set a vec3 in the shader from a Color3.
  12051. * @param name Define the name of the uniform as defined in the shader
  12052. * @param value Define the value to give to the uniform
  12053. * @return the texture itself allowing "fluent" like uniform updates
  12054. */
  12055. setColor3(name: string, value: Color3): ProceduralTexture;
  12056. /**
  12057. * Set a vec4 in the shader from a Color4.
  12058. * @param name Define the name of the uniform as defined in the shader
  12059. * @param value Define the value to give to the uniform
  12060. * @return the texture itself allowing "fluent" like uniform updates
  12061. */
  12062. setColor4(name: string, value: Color4): ProceduralTexture;
  12063. /**
  12064. * Set a vec2 in the shader from a Vector2.
  12065. * @param name Define the name of the uniform as defined in the shader
  12066. * @param value Define the value to give to the uniform
  12067. * @return the texture itself allowing "fluent" like uniform updates
  12068. */
  12069. setVector2(name: string, value: Vector2): ProceduralTexture;
  12070. /**
  12071. * Set a vec3 in the shader from a Vector3.
  12072. * @param name Define the name of the uniform as defined in the shader
  12073. * @param value Define the value to give to the uniform
  12074. * @return the texture itself allowing "fluent" like uniform updates
  12075. */
  12076. setVector3(name: string, value: Vector3): ProceduralTexture;
  12077. /**
  12078. * Set a mat4 in the shader from a MAtrix.
  12079. * @param name Define the name of the uniform as defined in the shader
  12080. * @param value Define the value to give to the uniform
  12081. * @return the texture itself allowing "fluent" like uniform updates
  12082. */
  12083. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12084. /**
  12085. * Render the texture to its associated render target.
  12086. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12087. */
  12088. render(useCameraPostProcess?: boolean): void;
  12089. /**
  12090. * Clone the texture.
  12091. * @returns the cloned texture
  12092. */
  12093. clone(): ProceduralTexture;
  12094. /**
  12095. * Dispose the texture and release its asoociated resources.
  12096. */
  12097. dispose(): void;
  12098. }
  12099. }
  12100. declare module "babylonjs/Particles/baseParticleSystem" {
  12101. import { Nullable } from "babylonjs/types";
  12102. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12104. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12105. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12106. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12107. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12108. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12109. import { Texture } from "babylonjs/Materials/Textures/texture";
  12110. import { Color4 } from "babylonjs/Maths/math.color";
  12111. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12112. import { Animation } from "babylonjs/Animations/animation";
  12113. import { Scene } from "babylonjs/scene";
  12114. /**
  12115. * This represents the base class for particle system in Babylon.
  12116. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12117. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12118. * @example https://doc.babylonjs.com/babylon101/particles
  12119. */
  12120. export class BaseParticleSystem {
  12121. /**
  12122. * Source color is added to the destination color without alpha affecting the result
  12123. */
  12124. static BLENDMODE_ONEONE: number;
  12125. /**
  12126. * Blend current color and particle color using particle’s alpha
  12127. */
  12128. static BLENDMODE_STANDARD: number;
  12129. /**
  12130. * Add current color and particle color multiplied by particle’s alpha
  12131. */
  12132. static BLENDMODE_ADD: number;
  12133. /**
  12134. * Multiply current color with particle color
  12135. */
  12136. static BLENDMODE_MULTIPLY: number;
  12137. /**
  12138. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12139. */
  12140. static BLENDMODE_MULTIPLYADD: number;
  12141. /**
  12142. * List of animations used by the particle system.
  12143. */
  12144. animations: Animation[];
  12145. /**
  12146. * Gets or sets the unique id of the particle system
  12147. */
  12148. uniqueId: number;
  12149. /**
  12150. * The id of the Particle system.
  12151. */
  12152. id: string;
  12153. /**
  12154. * The friendly name of the Particle system.
  12155. */
  12156. name: string;
  12157. /**
  12158. * Snippet ID if the particle system was created from the snippet server
  12159. */
  12160. snippetId: string;
  12161. /**
  12162. * The rendering group used by the Particle system to chose when to render.
  12163. */
  12164. renderingGroupId: number;
  12165. /**
  12166. * The emitter represents the Mesh or position we are attaching the particle system to.
  12167. */
  12168. emitter: Nullable<AbstractMesh | Vector3>;
  12169. /**
  12170. * The maximum number of particles to emit per frame
  12171. */
  12172. emitRate: number;
  12173. /**
  12174. * If you want to launch only a few particles at once, that can be done, as well.
  12175. */
  12176. manualEmitCount: number;
  12177. /**
  12178. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12179. */
  12180. updateSpeed: number;
  12181. /**
  12182. * The amount of time the particle system is running (depends of the overall update speed).
  12183. */
  12184. targetStopDuration: number;
  12185. /**
  12186. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12187. */
  12188. disposeOnStop: boolean;
  12189. /**
  12190. * Minimum power of emitting particles.
  12191. */
  12192. minEmitPower: number;
  12193. /**
  12194. * Maximum power of emitting particles.
  12195. */
  12196. maxEmitPower: number;
  12197. /**
  12198. * Minimum life time of emitting particles.
  12199. */
  12200. minLifeTime: number;
  12201. /**
  12202. * Maximum life time of emitting particles.
  12203. */
  12204. maxLifeTime: number;
  12205. /**
  12206. * Minimum Size of emitting particles.
  12207. */
  12208. minSize: number;
  12209. /**
  12210. * Maximum Size of emitting particles.
  12211. */
  12212. maxSize: number;
  12213. /**
  12214. * Minimum scale of emitting particles on X axis.
  12215. */
  12216. minScaleX: number;
  12217. /**
  12218. * Maximum scale of emitting particles on X axis.
  12219. */
  12220. maxScaleX: number;
  12221. /**
  12222. * Minimum scale of emitting particles on Y axis.
  12223. */
  12224. minScaleY: number;
  12225. /**
  12226. * Maximum scale of emitting particles on Y axis.
  12227. */
  12228. maxScaleY: number;
  12229. /**
  12230. * Gets or sets the minimal initial rotation in radians.
  12231. */
  12232. minInitialRotation: number;
  12233. /**
  12234. * Gets or sets the maximal initial rotation in radians.
  12235. */
  12236. maxInitialRotation: number;
  12237. /**
  12238. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12239. */
  12240. minAngularSpeed: number;
  12241. /**
  12242. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12243. */
  12244. maxAngularSpeed: number;
  12245. /**
  12246. * The texture used to render each particle. (this can be a spritesheet)
  12247. */
  12248. particleTexture: Nullable<Texture>;
  12249. /**
  12250. * The layer mask we are rendering the particles through.
  12251. */
  12252. layerMask: number;
  12253. /**
  12254. * This can help using your own shader to render the particle system.
  12255. * The according effect will be created
  12256. */
  12257. customShader: any;
  12258. /**
  12259. * By default particle system starts as soon as they are created. This prevents the
  12260. * automatic start to happen and let you decide when to start emitting particles.
  12261. */
  12262. preventAutoStart: boolean;
  12263. private _noiseTexture;
  12264. /**
  12265. * Gets or sets a texture used to add random noise to particle positions
  12266. */
  12267. get noiseTexture(): Nullable<ProceduralTexture>;
  12268. set noiseTexture(value: Nullable<ProceduralTexture>);
  12269. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12270. noiseStrength: Vector3;
  12271. /**
  12272. * Callback triggered when the particle animation is ending.
  12273. */
  12274. onAnimationEnd: Nullable<() => void>;
  12275. /**
  12276. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12277. */
  12278. blendMode: number;
  12279. /**
  12280. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12281. * to override the particles.
  12282. */
  12283. forceDepthWrite: boolean;
  12284. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12285. preWarmCycles: number;
  12286. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12287. preWarmStepOffset: number;
  12288. /**
  12289. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12290. */
  12291. spriteCellChangeSpeed: number;
  12292. /**
  12293. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12294. */
  12295. startSpriteCellID: number;
  12296. /**
  12297. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12298. */
  12299. endSpriteCellID: number;
  12300. /**
  12301. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12302. */
  12303. spriteCellWidth: number;
  12304. /**
  12305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12306. */
  12307. spriteCellHeight: number;
  12308. /**
  12309. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12310. */
  12311. spriteRandomStartCell: boolean;
  12312. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12313. translationPivot: Vector2;
  12314. /** @hidden */
  12315. protected _isAnimationSheetEnabled: boolean;
  12316. /**
  12317. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12318. */
  12319. beginAnimationOnStart: boolean;
  12320. /**
  12321. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12322. */
  12323. beginAnimationFrom: number;
  12324. /**
  12325. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12326. */
  12327. beginAnimationTo: number;
  12328. /**
  12329. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12330. */
  12331. beginAnimationLoop: boolean;
  12332. /**
  12333. * Gets or sets a world offset applied to all particles
  12334. */
  12335. worldOffset: Vector3;
  12336. /**
  12337. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12338. */
  12339. get isAnimationSheetEnabled(): boolean;
  12340. set isAnimationSheetEnabled(value: boolean);
  12341. /**
  12342. * Get hosting scene
  12343. * @returns the scene
  12344. */
  12345. getScene(): Nullable<Scene>;
  12346. /**
  12347. * You can use gravity if you want to give an orientation to your particles.
  12348. */
  12349. gravity: Vector3;
  12350. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12351. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12352. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12353. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12354. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12355. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12356. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12357. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12358. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12359. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12360. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12361. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12362. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12363. /**
  12364. * Defines the delay in milliseconds before starting the system (0 by default)
  12365. */
  12366. startDelay: number;
  12367. /**
  12368. * Gets the current list of drag gradients.
  12369. * You must use addDragGradient and removeDragGradient to udpate this list
  12370. * @returns the list of drag gradients
  12371. */
  12372. getDragGradients(): Nullable<Array<FactorGradient>>;
  12373. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12374. limitVelocityDamping: number;
  12375. /**
  12376. * Gets the current list of limit velocity gradients.
  12377. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12378. * @returns the list of limit velocity gradients
  12379. */
  12380. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12381. /**
  12382. * Gets the current list of color gradients.
  12383. * You must use addColorGradient and removeColorGradient to udpate this list
  12384. * @returns the list of color gradients
  12385. */
  12386. getColorGradients(): Nullable<Array<ColorGradient>>;
  12387. /**
  12388. * Gets the current list of size gradients.
  12389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12390. * @returns the list of size gradients
  12391. */
  12392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12393. /**
  12394. * Gets the current list of color remap gradients.
  12395. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12396. * @returns the list of color remap gradients
  12397. */
  12398. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12399. /**
  12400. * Gets the current list of alpha remap gradients.
  12401. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12402. * @returns the list of alpha remap gradients
  12403. */
  12404. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of life time gradients.
  12407. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12408. * @returns the list of life time gradients
  12409. */
  12410. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12411. /**
  12412. * Gets the current list of angular speed gradients.
  12413. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12414. * @returns the list of angular speed gradients
  12415. */
  12416. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of velocity gradients.
  12419. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12420. * @returns the list of velocity gradients
  12421. */
  12422. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of start size gradients.
  12425. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12426. * @returns the list of start size gradients
  12427. */
  12428. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of emit rate gradients.
  12431. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12432. * @returns the list of emit rate gradients
  12433. */
  12434. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12438. */
  12439. get direction1(): Vector3;
  12440. set direction1(value: Vector3);
  12441. /**
  12442. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12443. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12444. */
  12445. get direction2(): Vector3;
  12446. set direction2(value: Vector3);
  12447. /**
  12448. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12450. */
  12451. get minEmitBox(): Vector3;
  12452. set minEmitBox(value: Vector3);
  12453. /**
  12454. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12456. */
  12457. get maxEmitBox(): Vector3;
  12458. set maxEmitBox(value: Vector3);
  12459. /**
  12460. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12461. */
  12462. color1: Color4;
  12463. /**
  12464. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12465. */
  12466. color2: Color4;
  12467. /**
  12468. * Color the particle will have at the end of its lifetime
  12469. */
  12470. colorDead: Color4;
  12471. /**
  12472. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12473. */
  12474. textureMask: Color4;
  12475. /**
  12476. * The particle emitter type defines the emitter used by the particle system.
  12477. * It can be for example box, sphere, or cone...
  12478. */
  12479. particleEmitterType: IParticleEmitterType;
  12480. /** @hidden */
  12481. _isSubEmitter: boolean;
  12482. /**
  12483. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12484. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12485. */
  12486. billboardMode: number;
  12487. protected _isBillboardBased: boolean;
  12488. /**
  12489. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12490. */
  12491. get isBillboardBased(): boolean;
  12492. set isBillboardBased(value: boolean);
  12493. /**
  12494. * The scene the particle system belongs to.
  12495. */
  12496. protected _scene: Nullable<Scene>;
  12497. /**
  12498. * The engine the particle system belongs to.
  12499. */
  12500. protected _engine: ThinEngine;
  12501. /**
  12502. * Local cache of defines for image processing.
  12503. */
  12504. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12505. /**
  12506. * Default configuration related to image processing available in the standard Material.
  12507. */
  12508. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12509. /**
  12510. * Gets the image processing configuration used either in this material.
  12511. */
  12512. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12513. /**
  12514. * Sets the Default image processing configuration used either in the this material.
  12515. *
  12516. * If sets to null, the scene one is in use.
  12517. */
  12518. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12519. /**
  12520. * Attaches a new image processing configuration to the Standard Material.
  12521. * @param configuration
  12522. */
  12523. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12524. /** @hidden */
  12525. protected _reset(): void;
  12526. /** @hidden */
  12527. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12528. /**
  12529. * Instantiates a particle system.
  12530. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12531. * @param name The name of the particle system
  12532. */
  12533. constructor(name: string);
  12534. /**
  12535. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12538. * @returns the emitter
  12539. */
  12540. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12541. /**
  12542. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12543. * @param radius The radius of the hemisphere to emit from
  12544. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12545. * @returns the emitter
  12546. */
  12547. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12548. /**
  12549. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12550. * @param radius The radius of the sphere to emit from
  12551. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12552. * @returns the emitter
  12553. */
  12554. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12555. /**
  12556. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12557. * @param radius The radius of the sphere to emit from
  12558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12560. * @returns the emitter
  12561. */
  12562. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12563. /**
  12564. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12565. * @param radius The radius of the emission cylinder
  12566. * @param height The height of the emission cylinder
  12567. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12568. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12569. * @returns the emitter
  12570. */
  12571. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12572. /**
  12573. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12574. * @param radius The radius of the cylinder to emit from
  12575. * @param height The height of the emission cylinder
  12576. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12577. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12578. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12579. * @returns the emitter
  12580. */
  12581. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12582. /**
  12583. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12584. * @param radius The radius of the cone to emit from
  12585. * @param angle The base angle of the cone
  12586. * @returns the emitter
  12587. */
  12588. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12589. /**
  12590. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12593. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12594. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12595. * @returns the emitter
  12596. */
  12597. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12598. }
  12599. }
  12600. declare module "babylonjs/Particles/subEmitter" {
  12601. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12602. import { Scene } from "babylonjs/scene";
  12603. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12604. /**
  12605. * Type of sub emitter
  12606. */
  12607. export enum SubEmitterType {
  12608. /**
  12609. * Attached to the particle over it's lifetime
  12610. */
  12611. ATTACHED = 0,
  12612. /**
  12613. * Created when the particle dies
  12614. */
  12615. END = 1
  12616. }
  12617. /**
  12618. * Sub emitter class used to emit particles from an existing particle
  12619. */
  12620. export class SubEmitter {
  12621. /**
  12622. * the particle system to be used by the sub emitter
  12623. */
  12624. particleSystem: ParticleSystem;
  12625. /**
  12626. * Type of the submitter (Default: END)
  12627. */
  12628. type: SubEmitterType;
  12629. /**
  12630. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12631. * Note: This only is supported when using an emitter of type Mesh
  12632. */
  12633. inheritDirection: boolean;
  12634. /**
  12635. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12636. */
  12637. inheritedVelocityAmount: number;
  12638. /**
  12639. * Creates a sub emitter
  12640. * @param particleSystem the particle system to be used by the sub emitter
  12641. */
  12642. constructor(
  12643. /**
  12644. * the particle system to be used by the sub emitter
  12645. */
  12646. particleSystem: ParticleSystem);
  12647. /**
  12648. * Clones the sub emitter
  12649. * @returns the cloned sub emitter
  12650. */
  12651. clone(): SubEmitter;
  12652. /**
  12653. * Serialize current object to a JSON object
  12654. * @returns the serialized object
  12655. */
  12656. serialize(): any;
  12657. /** @hidden */
  12658. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12659. /**
  12660. * Creates a new SubEmitter from a serialized JSON version
  12661. * @param serializationObject defines the JSON object to read from
  12662. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12663. * @param rootUrl defines the rootUrl for data loading
  12664. * @returns a new SubEmitter
  12665. */
  12666. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12667. /** Release associated resources */
  12668. dispose(): void;
  12669. }
  12670. }
  12671. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12672. /** @hidden */
  12673. export var imageProcessingDeclaration: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12679. /** @hidden */
  12680. export var imageProcessingFunctions: {
  12681. name: string;
  12682. shader: string;
  12683. };
  12684. }
  12685. declare module "babylonjs/Shaders/particles.fragment" {
  12686. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12689. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12691. /** @hidden */
  12692. export var particlesPixelShader: {
  12693. name: string;
  12694. shader: string;
  12695. };
  12696. }
  12697. declare module "babylonjs/Shaders/particles.vertex" {
  12698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12699. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12700. /** @hidden */
  12701. export var particlesVertexShader: {
  12702. name: string;
  12703. shader: string;
  12704. };
  12705. }
  12706. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12707. import { Nullable } from "babylonjs/types";
  12708. import { Plane } from "babylonjs/Maths/math";
  12709. /**
  12710. * Interface used to define entities containing multiple clip planes
  12711. */
  12712. export interface IClipPlanesHolder {
  12713. /**
  12714. * Gets or sets the active clipplane 1
  12715. */
  12716. clipPlane: Nullable<Plane>;
  12717. /**
  12718. * Gets or sets the active clipplane 2
  12719. */
  12720. clipPlane2: Nullable<Plane>;
  12721. /**
  12722. * Gets or sets the active clipplane 3
  12723. */
  12724. clipPlane3: Nullable<Plane>;
  12725. /**
  12726. * Gets or sets the active clipplane 4
  12727. */
  12728. clipPlane4: Nullable<Plane>;
  12729. /**
  12730. * Gets or sets the active clipplane 5
  12731. */
  12732. clipPlane5: Nullable<Plane>;
  12733. /**
  12734. * Gets or sets the active clipplane 6
  12735. */
  12736. clipPlane6: Nullable<Plane>;
  12737. }
  12738. }
  12739. declare module "babylonjs/Materials/thinMaterialHelper" {
  12740. import { Effect } from "babylonjs/Materials/effect";
  12741. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12742. /**
  12743. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12744. *
  12745. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12746. *
  12747. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12748. */
  12749. export class ThinMaterialHelper {
  12750. /**
  12751. * Binds the clip plane information from the holder to the effect.
  12752. * @param effect The effect we are binding the data to
  12753. * @param holder The entity containing the clip plane information
  12754. */
  12755. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12756. }
  12757. }
  12758. declare module "babylonjs/Particles/particleSystem" {
  12759. import { Nullable } from "babylonjs/types";
  12760. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12761. import { Observable } from "babylonjs/Misc/observable";
  12762. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12763. import { Effect } from "babylonjs/Materials/effect";
  12764. import { IDisposable } from "babylonjs/scene";
  12765. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12766. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12767. import { Particle } from "babylonjs/Particles/particle";
  12768. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12769. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12770. import "babylonjs/Shaders/particles.fragment";
  12771. import "babylonjs/Shaders/particles.vertex";
  12772. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12773. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12774. import { Scene } from "babylonjs/scene";
  12775. /**
  12776. * This represents a particle system in Babylon.
  12777. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12778. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12779. * @example https://doc.babylonjs.com/babylon101/particles
  12780. */
  12781. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12782. /**
  12783. * Billboard mode will only apply to Y axis
  12784. */
  12785. static readonly BILLBOARDMODE_Y: number;
  12786. /**
  12787. * Billboard mode will apply to all axes
  12788. */
  12789. static readonly BILLBOARDMODE_ALL: number;
  12790. /**
  12791. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12792. */
  12793. static readonly BILLBOARDMODE_STRETCHED: number;
  12794. /**
  12795. * This function can be defined to provide custom update for active particles.
  12796. * This function will be called instead of regular update (age, position, color, etc.).
  12797. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12798. */
  12799. updateFunction: (particles: Particle[]) => void;
  12800. private _emitterWorldMatrix;
  12801. /**
  12802. * This function can be defined to specify initial direction for every new particle.
  12803. * It by default use the emitterType defined function
  12804. */
  12805. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12806. /**
  12807. * This function can be defined to specify initial position for every new particle.
  12808. * It by default use the emitterType defined function
  12809. */
  12810. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12811. /**
  12812. * @hidden
  12813. */
  12814. _inheritedVelocityOffset: Vector3;
  12815. /**
  12816. * An event triggered when the system is disposed
  12817. */
  12818. onDisposeObservable: Observable<IParticleSystem>;
  12819. private _onDisposeObserver;
  12820. /**
  12821. * Sets a callback that will be triggered when the system is disposed
  12822. */
  12823. set onDispose(callback: () => void);
  12824. private _particles;
  12825. private _epsilon;
  12826. private _capacity;
  12827. private _stockParticles;
  12828. private _newPartsExcess;
  12829. private _vertexData;
  12830. private _vertexBuffer;
  12831. private _vertexBuffers;
  12832. private _spriteBuffer;
  12833. private _indexBuffer;
  12834. private _effect;
  12835. private _customEffect;
  12836. private _cachedDefines;
  12837. private _scaledColorStep;
  12838. private _colorDiff;
  12839. private _scaledDirection;
  12840. private _scaledGravity;
  12841. private _currentRenderId;
  12842. private _alive;
  12843. private _useInstancing;
  12844. private _started;
  12845. private _stopped;
  12846. private _actualFrame;
  12847. private _scaledUpdateSpeed;
  12848. private _vertexBufferSize;
  12849. /** @hidden */
  12850. _currentEmitRateGradient: Nullable<FactorGradient>;
  12851. /** @hidden */
  12852. _currentEmitRate1: number;
  12853. /** @hidden */
  12854. _currentEmitRate2: number;
  12855. /** @hidden */
  12856. _currentStartSizeGradient: Nullable<FactorGradient>;
  12857. /** @hidden */
  12858. _currentStartSize1: number;
  12859. /** @hidden */
  12860. _currentStartSize2: number;
  12861. private readonly _rawTextureWidth;
  12862. private _rampGradientsTexture;
  12863. private _useRampGradients;
  12864. /** Gets or sets a matrix to use to compute projection */
  12865. defaultProjectionMatrix: Matrix;
  12866. /** Gets or sets a boolean indicating that ramp gradients must be used
  12867. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12868. */
  12869. get useRampGradients(): boolean;
  12870. set useRampGradients(value: boolean);
  12871. /**
  12872. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12873. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12874. */
  12875. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12876. private _subEmitters;
  12877. /**
  12878. * @hidden
  12879. * If the particle systems emitter should be disposed when the particle system is disposed
  12880. */
  12881. _disposeEmitterOnDispose: boolean;
  12882. /**
  12883. * The current active Sub-systems, this property is used by the root particle system only.
  12884. */
  12885. activeSubSystems: Array<ParticleSystem>;
  12886. /**
  12887. * Specifies if the particles are updated in emitter local space or world space
  12888. */
  12889. isLocal: boolean;
  12890. private _rootParticleSystem;
  12891. /**
  12892. * Gets the current list of active particles
  12893. */
  12894. get particles(): Particle[];
  12895. /**
  12896. * Gets the number of particles active at the same time.
  12897. * @returns The number of active particles.
  12898. */
  12899. getActiveCount(): number;
  12900. /**
  12901. * Returns the string "ParticleSystem"
  12902. * @returns a string containing the class name
  12903. */
  12904. getClassName(): string;
  12905. /**
  12906. * Gets a boolean indicating that the system is stopping
  12907. * @returns true if the system is currently stopping
  12908. */
  12909. isStopping(): boolean;
  12910. /**
  12911. * Gets the custom effect used to render the particles
  12912. * @param blendMode Blend mode for which the effect should be retrieved
  12913. * @returns The effect
  12914. */
  12915. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12916. /**
  12917. * Sets the custom effect used to render the particles
  12918. * @param effect The effect to set
  12919. * @param blendMode Blend mode for which the effect should be set
  12920. */
  12921. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12922. /** @hidden */
  12923. private _onBeforeDrawParticlesObservable;
  12924. /**
  12925. * Observable that will be called just before the particles are drawn
  12926. */
  12927. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12928. /**
  12929. * Gets the name of the particle vertex shader
  12930. */
  12931. get vertexShaderName(): string;
  12932. /**
  12933. * Instantiates a particle system.
  12934. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12935. * @param name The name of the particle system
  12936. * @param capacity The max number of particles alive at the same time
  12937. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12938. * @param customEffect a custom effect used to change the way particles are rendered by default
  12939. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12940. * @param epsilon Offset used to render the particles
  12941. */
  12942. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12943. private _addFactorGradient;
  12944. private _removeFactorGradient;
  12945. /**
  12946. * Adds a new life time gradient
  12947. * @param gradient defines the gradient to use (between 0 and 1)
  12948. * @param factor defines the life time factor to affect to the specified gradient
  12949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12950. * @returns the current particle system
  12951. */
  12952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12953. /**
  12954. * Remove a specific life time gradient
  12955. * @param gradient defines the gradient to remove
  12956. * @returns the current particle system
  12957. */
  12958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12959. /**
  12960. * Adds a new size gradient
  12961. * @param gradient defines the gradient to use (between 0 and 1)
  12962. * @param factor defines the size factor to affect to the specified gradient
  12963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12964. * @returns the current particle system
  12965. */
  12966. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12967. /**
  12968. * Remove a specific size gradient
  12969. * @param gradient defines the gradient to remove
  12970. * @returns the current particle system
  12971. */
  12972. removeSizeGradient(gradient: number): IParticleSystem;
  12973. /**
  12974. * Adds a new color remap gradient
  12975. * @param gradient defines the gradient to use (between 0 and 1)
  12976. * @param min defines the color remap minimal range
  12977. * @param max defines the color remap maximal range
  12978. * @returns the current particle system
  12979. */
  12980. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12981. /**
  12982. * Remove a specific color remap gradient
  12983. * @param gradient defines the gradient to remove
  12984. * @returns the current particle system
  12985. */
  12986. removeColorRemapGradient(gradient: number): IParticleSystem;
  12987. /**
  12988. * Adds a new alpha remap gradient
  12989. * @param gradient defines the gradient to use (between 0 and 1)
  12990. * @param min defines the alpha remap minimal range
  12991. * @param max defines the alpha remap maximal range
  12992. * @returns the current particle system
  12993. */
  12994. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12995. /**
  12996. * Remove a specific alpha remap gradient
  12997. * @param gradient defines the gradient to remove
  12998. * @returns the current particle system
  12999. */
  13000. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13001. /**
  13002. * Adds a new angular speed gradient
  13003. * @param gradient defines the gradient to use (between 0 and 1)
  13004. * @param factor defines the angular speed to affect to the specified gradient
  13005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13006. * @returns the current particle system
  13007. */
  13008. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13009. /**
  13010. * Remove a specific angular speed gradient
  13011. * @param gradient defines the gradient to remove
  13012. * @returns the current particle system
  13013. */
  13014. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13015. /**
  13016. * Adds a new velocity gradient
  13017. * @param gradient defines the gradient to use (between 0 and 1)
  13018. * @param factor defines the velocity to affect to the specified gradient
  13019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13020. * @returns the current particle system
  13021. */
  13022. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13023. /**
  13024. * Remove a specific velocity gradient
  13025. * @param gradient defines the gradient to remove
  13026. * @returns the current particle system
  13027. */
  13028. removeVelocityGradient(gradient: number): IParticleSystem;
  13029. /**
  13030. * Adds a new limit velocity gradient
  13031. * @param gradient defines the gradient to use (between 0 and 1)
  13032. * @param factor defines the limit velocity value to affect to the specified gradient
  13033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13034. * @returns the current particle system
  13035. */
  13036. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13037. /**
  13038. * Remove a specific limit velocity gradient
  13039. * @param gradient defines the gradient to remove
  13040. * @returns the current particle system
  13041. */
  13042. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13043. /**
  13044. * Adds a new drag gradient
  13045. * @param gradient defines the gradient to use (between 0 and 1)
  13046. * @param factor defines the drag value to affect to the specified gradient
  13047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13048. * @returns the current particle system
  13049. */
  13050. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13051. /**
  13052. * Remove a specific drag gradient
  13053. * @param gradient defines the gradient to remove
  13054. * @returns the current particle system
  13055. */
  13056. removeDragGradient(gradient: number): IParticleSystem;
  13057. /**
  13058. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13059. * @param gradient defines the gradient to use (between 0 and 1)
  13060. * @param factor defines the emit rate value to affect to the specified gradient
  13061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13062. * @returns the current particle system
  13063. */
  13064. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13065. /**
  13066. * Remove a specific emit rate gradient
  13067. * @param gradient defines the gradient to remove
  13068. * @returns the current particle system
  13069. */
  13070. removeEmitRateGradient(gradient: number): IParticleSystem;
  13071. /**
  13072. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13073. * @param gradient defines the gradient to use (between 0 and 1)
  13074. * @param factor defines the start size value to affect to the specified gradient
  13075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13076. * @returns the current particle system
  13077. */
  13078. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13079. /**
  13080. * Remove a specific start size gradient
  13081. * @param gradient defines the gradient to remove
  13082. * @returns the current particle system
  13083. */
  13084. removeStartSizeGradient(gradient: number): IParticleSystem;
  13085. private _createRampGradientTexture;
  13086. /**
  13087. * Gets the current list of ramp gradients.
  13088. * You must use addRampGradient and removeRampGradient to udpate this list
  13089. * @returns the list of ramp gradients
  13090. */
  13091. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13092. /** Force the system to rebuild all gradients that need to be resync */
  13093. forceRefreshGradients(): void;
  13094. private _syncRampGradientTexture;
  13095. /**
  13096. * Adds a new ramp gradient used to remap particle colors
  13097. * @param gradient defines the gradient to use (between 0 and 1)
  13098. * @param color defines the color to affect to the specified gradient
  13099. * @returns the current particle system
  13100. */
  13101. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13102. /**
  13103. * Remove a specific ramp gradient
  13104. * @param gradient defines the gradient to remove
  13105. * @returns the current particle system
  13106. */
  13107. removeRampGradient(gradient: number): ParticleSystem;
  13108. /**
  13109. * Adds a new color gradient
  13110. * @param gradient defines the gradient to use (between 0 and 1)
  13111. * @param color1 defines the color to affect to the specified gradient
  13112. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13113. * @returns this particle system
  13114. */
  13115. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13116. /**
  13117. * Remove a specific color gradient
  13118. * @param gradient defines the gradient to remove
  13119. * @returns this particle system
  13120. */
  13121. removeColorGradient(gradient: number): IParticleSystem;
  13122. private _fetchR;
  13123. protected _reset(): void;
  13124. private _resetEffect;
  13125. private _createVertexBuffers;
  13126. private _createIndexBuffer;
  13127. /**
  13128. * Gets the maximum number of particles active at the same time.
  13129. * @returns The max number of active particles.
  13130. */
  13131. getCapacity(): number;
  13132. /**
  13133. * Gets whether there are still active particles in the system.
  13134. * @returns True if it is alive, otherwise false.
  13135. */
  13136. isAlive(): boolean;
  13137. /**
  13138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13139. * @returns True if it has been started, otherwise false.
  13140. */
  13141. isStarted(): boolean;
  13142. private _prepareSubEmitterInternalArray;
  13143. /**
  13144. * Starts the particle system and begins to emit
  13145. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13146. */
  13147. start(delay?: number): void;
  13148. /**
  13149. * Stops the particle system.
  13150. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13151. */
  13152. stop(stopSubEmitters?: boolean): void;
  13153. /**
  13154. * Remove all active particles
  13155. */
  13156. reset(): void;
  13157. /**
  13158. * @hidden (for internal use only)
  13159. */
  13160. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13161. /**
  13162. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13163. * Its lifetime will start back at 0.
  13164. */
  13165. recycleParticle: (particle: Particle) => void;
  13166. private _stopSubEmitters;
  13167. private _createParticle;
  13168. private _removeFromRoot;
  13169. private _emitFromParticle;
  13170. private _update;
  13171. /** @hidden */
  13172. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13173. /** @hidden */
  13174. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13175. /**
  13176. * Fill the defines array according to the current settings of the particle system
  13177. * @param defines Array to be updated
  13178. * @param blendMode blend mode to take into account when updating the array
  13179. */
  13180. fillDefines(defines: Array<string>, blendMode: number): void;
  13181. /**
  13182. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13183. * @param uniforms Uniforms array to fill
  13184. * @param attributes Attributes array to fill
  13185. * @param samplers Samplers array to fill
  13186. */
  13187. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13188. /** @hidden */
  13189. private _getEffect;
  13190. /**
  13191. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13192. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13193. */
  13194. animate(preWarmOnly?: boolean): void;
  13195. private _appendParticleVertices;
  13196. /**
  13197. * Rebuilds the particle system.
  13198. */
  13199. rebuild(): void;
  13200. /**
  13201. * Is this system ready to be used/rendered
  13202. * @return true if the system is ready
  13203. */
  13204. isReady(): boolean;
  13205. private _render;
  13206. /**
  13207. * Renders the particle system in its current state.
  13208. * @returns the current number of particles
  13209. */
  13210. render(): number;
  13211. /**
  13212. * Disposes the particle system and free the associated resources
  13213. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13214. */
  13215. dispose(disposeTexture?: boolean): void;
  13216. /**
  13217. * Clones the particle system.
  13218. * @param name The name of the cloned object
  13219. * @param newEmitter The new emitter to use
  13220. * @returns the cloned particle system
  13221. */
  13222. clone(name: string, newEmitter: any): ParticleSystem;
  13223. /**
  13224. * Serializes the particle system to a JSON object
  13225. * @param serializeTexture defines if the texture must be serialized as well
  13226. * @returns the JSON object
  13227. */
  13228. serialize(serializeTexture?: boolean): any;
  13229. /** @hidden */
  13230. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13231. /** @hidden */
  13232. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13233. /**
  13234. * Parses a JSON object to create a particle system.
  13235. * @param parsedParticleSystem The JSON object to parse
  13236. * @param sceneOrEngine The scene or the engine to create the particle system in
  13237. * @param rootUrl The root url to use to load external dependencies like texture
  13238. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13239. * @returns the Parsed particle system
  13240. */
  13241. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13242. }
  13243. }
  13244. declare module "babylonjs/Particles/particle" {
  13245. import { Nullable } from "babylonjs/types";
  13246. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13247. import { Color4 } from "babylonjs/Maths/math.color";
  13248. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13249. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13250. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13251. /**
  13252. * A particle represents one of the element emitted by a particle system.
  13253. * This is mainly define by its coordinates, direction, velocity and age.
  13254. */
  13255. export class Particle {
  13256. /**
  13257. * The particle system the particle belongs to.
  13258. */
  13259. particleSystem: ParticleSystem;
  13260. private static _Count;
  13261. /**
  13262. * Unique ID of the particle
  13263. */
  13264. id: number;
  13265. /**
  13266. * The world position of the particle in the scene.
  13267. */
  13268. position: Vector3;
  13269. /**
  13270. * The world direction of the particle in the scene.
  13271. */
  13272. direction: Vector3;
  13273. /**
  13274. * The color of the particle.
  13275. */
  13276. color: Color4;
  13277. /**
  13278. * The color change of the particle per step.
  13279. */
  13280. colorStep: Color4;
  13281. /**
  13282. * Defines how long will the life of the particle be.
  13283. */
  13284. lifeTime: number;
  13285. /**
  13286. * The current age of the particle.
  13287. */
  13288. age: number;
  13289. /**
  13290. * The current size of the particle.
  13291. */
  13292. size: number;
  13293. /**
  13294. * The current scale of the particle.
  13295. */
  13296. scale: Vector2;
  13297. /**
  13298. * The current angle of the particle.
  13299. */
  13300. angle: number;
  13301. /**
  13302. * Defines how fast is the angle changing.
  13303. */
  13304. angularSpeed: number;
  13305. /**
  13306. * Defines the cell index used by the particle to be rendered from a sprite.
  13307. */
  13308. cellIndex: number;
  13309. /**
  13310. * The information required to support color remapping
  13311. */
  13312. remapData: Vector4;
  13313. /** @hidden */
  13314. _randomCellOffset?: number;
  13315. /** @hidden */
  13316. _initialDirection: Nullable<Vector3>;
  13317. /** @hidden */
  13318. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13319. /** @hidden */
  13320. _initialStartSpriteCellID: number;
  13321. /** @hidden */
  13322. _initialEndSpriteCellID: number;
  13323. /** @hidden */
  13324. _currentColorGradient: Nullable<ColorGradient>;
  13325. /** @hidden */
  13326. _currentColor1: Color4;
  13327. /** @hidden */
  13328. _currentColor2: Color4;
  13329. /** @hidden */
  13330. _currentSizeGradient: Nullable<FactorGradient>;
  13331. /** @hidden */
  13332. _currentSize1: number;
  13333. /** @hidden */
  13334. _currentSize2: number;
  13335. /** @hidden */
  13336. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13337. /** @hidden */
  13338. _currentAngularSpeed1: number;
  13339. /** @hidden */
  13340. _currentAngularSpeed2: number;
  13341. /** @hidden */
  13342. _currentVelocityGradient: Nullable<FactorGradient>;
  13343. /** @hidden */
  13344. _currentVelocity1: number;
  13345. /** @hidden */
  13346. _currentVelocity2: number;
  13347. /** @hidden */
  13348. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13349. /** @hidden */
  13350. _currentLimitVelocity1: number;
  13351. /** @hidden */
  13352. _currentLimitVelocity2: number;
  13353. /** @hidden */
  13354. _currentDragGradient: Nullable<FactorGradient>;
  13355. /** @hidden */
  13356. _currentDrag1: number;
  13357. /** @hidden */
  13358. _currentDrag2: number;
  13359. /** @hidden */
  13360. _randomNoiseCoordinates1: Vector3;
  13361. /** @hidden */
  13362. _randomNoiseCoordinates2: Vector3;
  13363. /** @hidden */
  13364. _localPosition?: Vector3;
  13365. /**
  13366. * Creates a new instance Particle
  13367. * @param particleSystem the particle system the particle belongs to
  13368. */
  13369. constructor(
  13370. /**
  13371. * The particle system the particle belongs to.
  13372. */
  13373. particleSystem: ParticleSystem);
  13374. private updateCellInfoFromSystem;
  13375. /**
  13376. * Defines how the sprite cell index is updated for the particle
  13377. */
  13378. updateCellIndex(): void;
  13379. /** @hidden */
  13380. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13381. /** @hidden */
  13382. _inheritParticleInfoToSubEmitters(): void;
  13383. /** @hidden */
  13384. _reset(): void;
  13385. /**
  13386. * Copy the properties of particle to another one.
  13387. * @param other the particle to copy the information to.
  13388. */
  13389. copyTo(other: Particle): void;
  13390. }
  13391. }
  13392. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13393. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13394. import { Effect } from "babylonjs/Materials/effect";
  13395. import { Particle } from "babylonjs/Particles/particle";
  13396. import { Nullable } from "babylonjs/types";
  13397. import { Scene } from "babylonjs/scene";
  13398. /**
  13399. * Particle emitter represents a volume emitting particles.
  13400. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13401. */
  13402. export interface IParticleEmitterType {
  13403. /**
  13404. * Called by the particle System when the direction is computed for the created particle.
  13405. * @param worldMatrix is the world matrix of the particle system
  13406. * @param directionToUpdate is the direction vector to update with the result
  13407. * @param particle is the particle we are computed the direction for
  13408. * @param isLocal defines if the direction should be set in local space
  13409. */
  13410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13411. /**
  13412. * Called by the particle System when the position is computed for the created particle.
  13413. * @param worldMatrix is the world matrix of the particle system
  13414. * @param positionToUpdate is the position vector to update with the result
  13415. * @param particle is the particle we are computed the position for
  13416. * @param isLocal defines if the position should be set in local space
  13417. */
  13418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13419. /**
  13420. * Clones the current emitter and returns a copy of it
  13421. * @returns the new emitter
  13422. */
  13423. clone(): IParticleEmitterType;
  13424. /**
  13425. * Called by the GPUParticleSystem to setup the update shader
  13426. * @param effect defines the update shader
  13427. */
  13428. applyToShader(effect: Effect): void;
  13429. /**
  13430. * Returns a string to use to update the GPU particles update shader
  13431. * @returns the effect defines string
  13432. */
  13433. getEffectDefines(): string;
  13434. /**
  13435. * Returns a string representing the class name
  13436. * @returns a string containing the class name
  13437. */
  13438. getClassName(): string;
  13439. /**
  13440. * Serializes the particle system to a JSON object.
  13441. * @returns the JSON object
  13442. */
  13443. serialize(): any;
  13444. /**
  13445. * Parse properties from a JSON object
  13446. * @param serializationObject defines the JSON object
  13447. * @param scene defines the hosting scene
  13448. */
  13449. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13450. }
  13451. }
  13452. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13453. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13454. import { Effect } from "babylonjs/Materials/effect";
  13455. import { Particle } from "babylonjs/Particles/particle";
  13456. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13457. /**
  13458. * Particle emitter emitting particles from the inside of a box.
  13459. * It emits the particles randomly between 2 given directions.
  13460. */
  13461. export class BoxParticleEmitter implements IParticleEmitterType {
  13462. /**
  13463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13464. */
  13465. direction1: Vector3;
  13466. /**
  13467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13468. */
  13469. direction2: Vector3;
  13470. /**
  13471. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13472. */
  13473. minEmitBox: Vector3;
  13474. /**
  13475. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13476. */
  13477. maxEmitBox: Vector3;
  13478. /**
  13479. * Creates a new instance BoxParticleEmitter
  13480. */
  13481. constructor();
  13482. /**
  13483. * Called by the particle System when the direction is computed for the created particle.
  13484. * @param worldMatrix is the world matrix of the particle system
  13485. * @param directionToUpdate is the direction vector to update with the result
  13486. * @param particle is the particle we are computed the direction for
  13487. * @param isLocal defines if the direction should be set in local space
  13488. */
  13489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13490. /**
  13491. * Called by the particle System when the position is computed for the created particle.
  13492. * @param worldMatrix is the world matrix of the particle system
  13493. * @param positionToUpdate is the position vector to update with the result
  13494. * @param particle is the particle we are computed the position for
  13495. * @param isLocal defines if the position should be set in local space
  13496. */
  13497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13498. /**
  13499. * Clones the current emitter and returns a copy of it
  13500. * @returns the new emitter
  13501. */
  13502. clone(): BoxParticleEmitter;
  13503. /**
  13504. * Called by the GPUParticleSystem to setup the update shader
  13505. * @param effect defines the update shader
  13506. */
  13507. applyToShader(effect: Effect): void;
  13508. /**
  13509. * Returns a string to use to update the GPU particles update shader
  13510. * @returns a string containng the defines string
  13511. */
  13512. getEffectDefines(): string;
  13513. /**
  13514. * Returns the string "BoxParticleEmitter"
  13515. * @returns a string containing the class name
  13516. */
  13517. getClassName(): string;
  13518. /**
  13519. * Serializes the particle system to a JSON object.
  13520. * @returns the JSON object
  13521. */
  13522. serialize(): any;
  13523. /**
  13524. * Parse properties from a JSON object
  13525. * @param serializationObject defines the JSON object
  13526. */
  13527. parse(serializationObject: any): void;
  13528. }
  13529. }
  13530. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13531. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13532. import { Effect } from "babylonjs/Materials/effect";
  13533. import { Particle } from "babylonjs/Particles/particle";
  13534. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13535. /**
  13536. * Particle emitter emitting particles from the inside of a cone.
  13537. * It emits the particles alongside the cone volume from the base to the particle.
  13538. * The emission direction might be randomized.
  13539. */
  13540. export class ConeParticleEmitter implements IParticleEmitterType {
  13541. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13542. directionRandomizer: number;
  13543. private _radius;
  13544. private _angle;
  13545. private _height;
  13546. /**
  13547. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13548. */
  13549. radiusRange: number;
  13550. /**
  13551. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13552. */
  13553. heightRange: number;
  13554. /**
  13555. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13556. */
  13557. emitFromSpawnPointOnly: boolean;
  13558. /**
  13559. * Gets or sets the radius of the emission cone
  13560. */
  13561. get radius(): number;
  13562. set radius(value: number);
  13563. /**
  13564. * Gets or sets the angle of the emission cone
  13565. */
  13566. get angle(): number;
  13567. set angle(value: number);
  13568. private _buildHeight;
  13569. /**
  13570. * Creates a new instance ConeParticleEmitter
  13571. * @param radius the radius of the emission cone (1 by default)
  13572. * @param angle the cone base angle (PI by default)
  13573. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13574. */
  13575. constructor(radius?: number, angle?: number,
  13576. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13577. directionRandomizer?: number);
  13578. /**
  13579. * Called by the particle System when the direction is computed for the created particle.
  13580. * @param worldMatrix is the world matrix of the particle system
  13581. * @param directionToUpdate is the direction vector to update with the result
  13582. * @param particle is the particle we are computed the direction for
  13583. * @param isLocal defines if the direction should be set in local space
  13584. */
  13585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13586. /**
  13587. * Called by the particle System when the position is computed for the created particle.
  13588. * @param worldMatrix is the world matrix of the particle system
  13589. * @param positionToUpdate is the position vector to update with the result
  13590. * @param particle is the particle we are computed the position for
  13591. * @param isLocal defines if the position should be set in local space
  13592. */
  13593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13594. /**
  13595. * Clones the current emitter and returns a copy of it
  13596. * @returns the new emitter
  13597. */
  13598. clone(): ConeParticleEmitter;
  13599. /**
  13600. * Called by the GPUParticleSystem to setup the update shader
  13601. * @param effect defines the update shader
  13602. */
  13603. applyToShader(effect: Effect): void;
  13604. /**
  13605. * Returns a string to use to update the GPU particles update shader
  13606. * @returns a string containng the defines string
  13607. */
  13608. getEffectDefines(): string;
  13609. /**
  13610. * Returns the string "ConeParticleEmitter"
  13611. * @returns a string containing the class name
  13612. */
  13613. getClassName(): string;
  13614. /**
  13615. * Serializes the particle system to a JSON object.
  13616. * @returns the JSON object
  13617. */
  13618. serialize(): any;
  13619. /**
  13620. * Parse properties from a JSON object
  13621. * @param serializationObject defines the JSON object
  13622. */
  13623. parse(serializationObject: any): void;
  13624. }
  13625. }
  13626. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13627. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13628. import { Effect } from "babylonjs/Materials/effect";
  13629. import { Particle } from "babylonjs/Particles/particle";
  13630. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13631. /**
  13632. * Particle emitter emitting particles from the inside of a cylinder.
  13633. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13634. */
  13635. export class CylinderParticleEmitter implements IParticleEmitterType {
  13636. /**
  13637. * The radius of the emission cylinder.
  13638. */
  13639. radius: number;
  13640. /**
  13641. * The height of the emission cylinder.
  13642. */
  13643. height: number;
  13644. /**
  13645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13646. */
  13647. radiusRange: number;
  13648. /**
  13649. * How much to randomize the particle direction [0-1].
  13650. */
  13651. directionRandomizer: number;
  13652. /**
  13653. * Creates a new instance CylinderParticleEmitter
  13654. * @param radius the radius of the emission cylinder (1 by default)
  13655. * @param height the height of the emission cylinder (1 by default)
  13656. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13657. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13658. */
  13659. constructor(
  13660. /**
  13661. * The radius of the emission cylinder.
  13662. */
  13663. radius?: number,
  13664. /**
  13665. * The height of the emission cylinder.
  13666. */
  13667. height?: number,
  13668. /**
  13669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13670. */
  13671. radiusRange?: number,
  13672. /**
  13673. * How much to randomize the particle direction [0-1].
  13674. */
  13675. directionRandomizer?: number);
  13676. /**
  13677. * Called by the particle System when the direction is computed for the created particle.
  13678. * @param worldMatrix is the world matrix of the particle system
  13679. * @param directionToUpdate is the direction vector to update with the result
  13680. * @param particle is the particle we are computed the direction for
  13681. * @param isLocal defines if the direction should be set in local space
  13682. */
  13683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13684. /**
  13685. * Called by the particle System when the position is computed for the created particle.
  13686. * @param worldMatrix is the world matrix of the particle system
  13687. * @param positionToUpdate is the position vector to update with the result
  13688. * @param particle is the particle we are computed the position for
  13689. * @param isLocal defines if the position should be set in local space
  13690. */
  13691. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13692. /**
  13693. * Clones the current emitter and returns a copy of it
  13694. * @returns the new emitter
  13695. */
  13696. clone(): CylinderParticleEmitter;
  13697. /**
  13698. * Called by the GPUParticleSystem to setup the update shader
  13699. * @param effect defines the update shader
  13700. */
  13701. applyToShader(effect: Effect): void;
  13702. /**
  13703. * Returns a string to use to update the GPU particles update shader
  13704. * @returns a string containng the defines string
  13705. */
  13706. getEffectDefines(): string;
  13707. /**
  13708. * Returns the string "CylinderParticleEmitter"
  13709. * @returns a string containing the class name
  13710. */
  13711. getClassName(): string;
  13712. /**
  13713. * Serializes the particle system to a JSON object.
  13714. * @returns the JSON object
  13715. */
  13716. serialize(): any;
  13717. /**
  13718. * Parse properties from a JSON object
  13719. * @param serializationObject defines the JSON object
  13720. */
  13721. parse(serializationObject: any): void;
  13722. }
  13723. /**
  13724. * Particle emitter emitting particles from the inside of a cylinder.
  13725. * It emits the particles randomly between two vectors.
  13726. */
  13727. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13728. /**
  13729. * The min limit of the emission direction.
  13730. */
  13731. direction1: Vector3;
  13732. /**
  13733. * The max limit of the emission direction.
  13734. */
  13735. direction2: Vector3;
  13736. /**
  13737. * Creates a new instance CylinderDirectedParticleEmitter
  13738. * @param radius the radius of the emission cylinder (1 by default)
  13739. * @param height the height of the emission cylinder (1 by default)
  13740. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13741. * @param direction1 the min limit of the emission direction (up vector by default)
  13742. * @param direction2 the max limit of the emission direction (up vector by default)
  13743. */
  13744. constructor(radius?: number, height?: number, radiusRange?: number,
  13745. /**
  13746. * The min limit of the emission direction.
  13747. */
  13748. direction1?: Vector3,
  13749. /**
  13750. * The max limit of the emission direction.
  13751. */
  13752. direction2?: Vector3);
  13753. /**
  13754. * Called by the particle System when the direction is computed for the created particle.
  13755. * @param worldMatrix is the world matrix of the particle system
  13756. * @param directionToUpdate is the direction vector to update with the result
  13757. * @param particle is the particle we are computed the direction for
  13758. */
  13759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13760. /**
  13761. * Clones the current emitter and returns a copy of it
  13762. * @returns the new emitter
  13763. */
  13764. clone(): CylinderDirectedParticleEmitter;
  13765. /**
  13766. * Called by the GPUParticleSystem to setup the update shader
  13767. * @param effect defines the update shader
  13768. */
  13769. applyToShader(effect: Effect): void;
  13770. /**
  13771. * Returns a string to use to update the GPU particles update shader
  13772. * @returns a string containng the defines string
  13773. */
  13774. getEffectDefines(): string;
  13775. /**
  13776. * Returns the string "CylinderDirectedParticleEmitter"
  13777. * @returns a string containing the class name
  13778. */
  13779. getClassName(): string;
  13780. /**
  13781. * Serializes the particle system to a JSON object.
  13782. * @returns the JSON object
  13783. */
  13784. serialize(): any;
  13785. /**
  13786. * Parse properties from a JSON object
  13787. * @param serializationObject defines the JSON object
  13788. */
  13789. parse(serializationObject: any): void;
  13790. }
  13791. }
  13792. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13793. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13794. import { Effect } from "babylonjs/Materials/effect";
  13795. import { Particle } from "babylonjs/Particles/particle";
  13796. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13797. /**
  13798. * Particle emitter emitting particles from the inside of a hemisphere.
  13799. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13800. */
  13801. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13802. /**
  13803. * The radius of the emission hemisphere.
  13804. */
  13805. radius: number;
  13806. /**
  13807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13808. */
  13809. radiusRange: number;
  13810. /**
  13811. * How much to randomize the particle direction [0-1].
  13812. */
  13813. directionRandomizer: number;
  13814. /**
  13815. * Creates a new instance HemisphericParticleEmitter
  13816. * @param radius the radius of the emission hemisphere (1 by default)
  13817. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13819. */
  13820. constructor(
  13821. /**
  13822. * The radius of the emission hemisphere.
  13823. */
  13824. radius?: number,
  13825. /**
  13826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13827. */
  13828. radiusRange?: number,
  13829. /**
  13830. * How much to randomize the particle direction [0-1].
  13831. */
  13832. directionRandomizer?: number);
  13833. /**
  13834. * Called by the particle System when the direction is computed for the created particle.
  13835. * @param worldMatrix is the world matrix of the particle system
  13836. * @param directionToUpdate is the direction vector to update with the result
  13837. * @param particle is the particle we are computed the direction for
  13838. * @param isLocal defines if the direction should be set in local space
  13839. */
  13840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13841. /**
  13842. * Called by the particle System when the position is computed for the created particle.
  13843. * @param worldMatrix is the world matrix of the particle system
  13844. * @param positionToUpdate is the position vector to update with the result
  13845. * @param particle is the particle we are computed the position for
  13846. * @param isLocal defines if the position should be set in local space
  13847. */
  13848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13849. /**
  13850. * Clones the current emitter and returns a copy of it
  13851. * @returns the new emitter
  13852. */
  13853. clone(): HemisphericParticleEmitter;
  13854. /**
  13855. * Called by the GPUParticleSystem to setup the update shader
  13856. * @param effect defines the update shader
  13857. */
  13858. applyToShader(effect: Effect): void;
  13859. /**
  13860. * Returns a string to use to update the GPU particles update shader
  13861. * @returns a string containng the defines string
  13862. */
  13863. getEffectDefines(): string;
  13864. /**
  13865. * Returns the string "HemisphericParticleEmitter"
  13866. * @returns a string containing the class name
  13867. */
  13868. getClassName(): string;
  13869. /**
  13870. * Serializes the particle system to a JSON object.
  13871. * @returns the JSON object
  13872. */
  13873. serialize(): any;
  13874. /**
  13875. * Parse properties from a JSON object
  13876. * @param serializationObject defines the JSON object
  13877. */
  13878. parse(serializationObject: any): void;
  13879. }
  13880. }
  13881. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13882. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13883. import { Effect } from "babylonjs/Materials/effect";
  13884. import { Particle } from "babylonjs/Particles/particle";
  13885. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13886. /**
  13887. * Particle emitter emitting particles from a point.
  13888. * It emits the particles randomly between 2 given directions.
  13889. */
  13890. export class PointParticleEmitter implements IParticleEmitterType {
  13891. /**
  13892. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13893. */
  13894. direction1: Vector3;
  13895. /**
  13896. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13897. */
  13898. direction2: Vector3;
  13899. /**
  13900. * Creates a new instance PointParticleEmitter
  13901. */
  13902. constructor();
  13903. /**
  13904. * Called by the particle System when the direction is computed for the created particle.
  13905. * @param worldMatrix is the world matrix of the particle system
  13906. * @param directionToUpdate is the direction vector to update with the result
  13907. * @param particle is the particle we are computed the direction for
  13908. * @param isLocal defines if the direction should be set in local space
  13909. */
  13910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13911. /**
  13912. * Called by the particle System when the position is computed for the created particle.
  13913. * @param worldMatrix is the world matrix of the particle system
  13914. * @param positionToUpdate is the position vector to update with the result
  13915. * @param particle is the particle we are computed the position for
  13916. * @param isLocal defines if the position should be set in local space
  13917. */
  13918. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13919. /**
  13920. * Clones the current emitter and returns a copy of it
  13921. * @returns the new emitter
  13922. */
  13923. clone(): PointParticleEmitter;
  13924. /**
  13925. * Called by the GPUParticleSystem to setup the update shader
  13926. * @param effect defines the update shader
  13927. */
  13928. applyToShader(effect: Effect): void;
  13929. /**
  13930. * Returns a string to use to update the GPU particles update shader
  13931. * @returns a string containng the defines string
  13932. */
  13933. getEffectDefines(): string;
  13934. /**
  13935. * Returns the string "PointParticleEmitter"
  13936. * @returns a string containing the class name
  13937. */
  13938. getClassName(): string;
  13939. /**
  13940. * Serializes the particle system to a JSON object.
  13941. * @returns the JSON object
  13942. */
  13943. serialize(): any;
  13944. /**
  13945. * Parse properties from a JSON object
  13946. * @param serializationObject defines the JSON object
  13947. */
  13948. parse(serializationObject: any): void;
  13949. }
  13950. }
  13951. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13952. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13953. import { Effect } from "babylonjs/Materials/effect";
  13954. import { Particle } from "babylonjs/Particles/particle";
  13955. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13956. /**
  13957. * Particle emitter emitting particles from the inside of a sphere.
  13958. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13959. */
  13960. export class SphereParticleEmitter implements IParticleEmitterType {
  13961. /**
  13962. * The radius of the emission sphere.
  13963. */
  13964. radius: number;
  13965. /**
  13966. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13967. */
  13968. radiusRange: number;
  13969. /**
  13970. * How much to randomize the particle direction [0-1].
  13971. */
  13972. directionRandomizer: number;
  13973. /**
  13974. * Creates a new instance SphereParticleEmitter
  13975. * @param radius the radius of the emission sphere (1 by default)
  13976. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13977. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13978. */
  13979. constructor(
  13980. /**
  13981. * The radius of the emission sphere.
  13982. */
  13983. radius?: number,
  13984. /**
  13985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13986. */
  13987. radiusRange?: number,
  13988. /**
  13989. * How much to randomize the particle direction [0-1].
  13990. */
  13991. directionRandomizer?: number);
  13992. /**
  13993. * Called by the particle System when the direction is computed for the created particle.
  13994. * @param worldMatrix is the world matrix of the particle system
  13995. * @param directionToUpdate is the direction vector to update with the result
  13996. * @param particle is the particle we are computed the direction for
  13997. * @param isLocal defines if the direction should be set in local space
  13998. */
  13999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14000. /**
  14001. * Called by the particle System when the position is computed for the created particle.
  14002. * @param worldMatrix is the world matrix of the particle system
  14003. * @param positionToUpdate is the position vector to update with the result
  14004. * @param particle is the particle we are computed the position for
  14005. * @param isLocal defines if the position should be set in local space
  14006. */
  14007. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14008. /**
  14009. * Clones the current emitter and returns a copy of it
  14010. * @returns the new emitter
  14011. */
  14012. clone(): SphereParticleEmitter;
  14013. /**
  14014. * Called by the GPUParticleSystem to setup the update shader
  14015. * @param effect defines the update shader
  14016. */
  14017. applyToShader(effect: Effect): void;
  14018. /**
  14019. * Returns a string to use to update the GPU particles update shader
  14020. * @returns a string containng the defines string
  14021. */
  14022. getEffectDefines(): string;
  14023. /**
  14024. * Returns the string "SphereParticleEmitter"
  14025. * @returns a string containing the class name
  14026. */
  14027. getClassName(): string;
  14028. /**
  14029. * Serializes the particle system to a JSON object.
  14030. * @returns the JSON object
  14031. */
  14032. serialize(): any;
  14033. /**
  14034. * Parse properties from a JSON object
  14035. * @param serializationObject defines the JSON object
  14036. */
  14037. parse(serializationObject: any): void;
  14038. }
  14039. /**
  14040. * Particle emitter emitting particles from the inside of a sphere.
  14041. * It emits the particles randomly between two vectors.
  14042. */
  14043. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14044. /**
  14045. * The min limit of the emission direction.
  14046. */
  14047. direction1: Vector3;
  14048. /**
  14049. * The max limit of the emission direction.
  14050. */
  14051. direction2: Vector3;
  14052. /**
  14053. * Creates a new instance SphereDirectedParticleEmitter
  14054. * @param radius the radius of the emission sphere (1 by default)
  14055. * @param direction1 the min limit of the emission direction (up vector by default)
  14056. * @param direction2 the max limit of the emission direction (up vector by default)
  14057. */
  14058. constructor(radius?: number,
  14059. /**
  14060. * The min limit of the emission direction.
  14061. */
  14062. direction1?: Vector3,
  14063. /**
  14064. * The max limit of the emission direction.
  14065. */
  14066. direction2?: Vector3);
  14067. /**
  14068. * Called by the particle System when the direction is computed for the created particle.
  14069. * @param worldMatrix is the world matrix of the particle system
  14070. * @param directionToUpdate is the direction vector to update with the result
  14071. * @param particle is the particle we are computed the direction for
  14072. */
  14073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14074. /**
  14075. * Clones the current emitter and returns a copy of it
  14076. * @returns the new emitter
  14077. */
  14078. clone(): SphereDirectedParticleEmitter;
  14079. /**
  14080. * Called by the GPUParticleSystem to setup the update shader
  14081. * @param effect defines the update shader
  14082. */
  14083. applyToShader(effect: Effect): void;
  14084. /**
  14085. * Returns a string to use to update the GPU particles update shader
  14086. * @returns a string containng the defines string
  14087. */
  14088. getEffectDefines(): string;
  14089. /**
  14090. * Returns the string "SphereDirectedParticleEmitter"
  14091. * @returns a string containing the class name
  14092. */
  14093. getClassName(): string;
  14094. /**
  14095. * Serializes the particle system to a JSON object.
  14096. * @returns the JSON object
  14097. */
  14098. serialize(): any;
  14099. /**
  14100. * Parse properties from a JSON object
  14101. * @param serializationObject defines the JSON object
  14102. */
  14103. parse(serializationObject: any): void;
  14104. }
  14105. }
  14106. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14108. import { Effect } from "babylonjs/Materials/effect";
  14109. import { Particle } from "babylonjs/Particles/particle";
  14110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14111. import { Nullable } from "babylonjs/types";
  14112. /**
  14113. * Particle emitter emitting particles from a custom list of positions.
  14114. */
  14115. export class CustomParticleEmitter implements IParticleEmitterType {
  14116. /**
  14117. * Gets or sets the position generator that will create the inital position of each particle.
  14118. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14119. */
  14120. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14121. /**
  14122. * Gets or sets the destination generator that will create the final destination of each particle.
  14123. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14124. */
  14125. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14126. /**
  14127. * Creates a new instance CustomParticleEmitter
  14128. */
  14129. constructor();
  14130. /**
  14131. * Called by the particle System when the direction is computed for the created particle.
  14132. * @param worldMatrix is the world matrix of the particle system
  14133. * @param directionToUpdate is the direction vector to update with the result
  14134. * @param particle is the particle we are computed the direction for
  14135. * @param isLocal defines if the direction should be set in local space
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14138. /**
  14139. * Called by the particle System when the position is computed for the created particle.
  14140. * @param worldMatrix is the world matrix of the particle system
  14141. * @param positionToUpdate is the position vector to update with the result
  14142. * @param particle is the particle we are computed the position for
  14143. * @param isLocal defines if the position should be set in local space
  14144. */
  14145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14146. /**
  14147. * Clones the current emitter and returns a copy of it
  14148. * @returns the new emitter
  14149. */
  14150. clone(): CustomParticleEmitter;
  14151. /**
  14152. * Called by the GPUParticleSystem to setup the update shader
  14153. * @param effect defines the update shader
  14154. */
  14155. applyToShader(effect: Effect): void;
  14156. /**
  14157. * Returns a string to use to update the GPU particles update shader
  14158. * @returns a string containng the defines string
  14159. */
  14160. getEffectDefines(): string;
  14161. /**
  14162. * Returns the string "PointParticleEmitter"
  14163. * @returns a string containing the class name
  14164. */
  14165. getClassName(): string;
  14166. /**
  14167. * Serializes the particle system to a JSON object.
  14168. * @returns the JSON object
  14169. */
  14170. serialize(): any;
  14171. /**
  14172. * Parse properties from a JSON object
  14173. * @param serializationObject defines the JSON object
  14174. */
  14175. parse(serializationObject: any): void;
  14176. }
  14177. }
  14178. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14179. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Particle } from "babylonjs/Particles/particle";
  14182. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14183. import { Nullable } from "babylonjs/types";
  14184. import { Scene } from "babylonjs/scene";
  14185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14186. /**
  14187. * Particle emitter emitting particles from the inside of a box.
  14188. * It emits the particles randomly between 2 given directions.
  14189. */
  14190. export class MeshParticleEmitter implements IParticleEmitterType {
  14191. private _indices;
  14192. private _positions;
  14193. private _normals;
  14194. private _storedNormal;
  14195. private _mesh;
  14196. /**
  14197. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14198. */
  14199. direction1: Vector3;
  14200. /**
  14201. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14202. */
  14203. direction2: Vector3;
  14204. /**
  14205. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14206. */
  14207. useMeshNormalsForDirection: boolean;
  14208. /** Defines the mesh to use as source */
  14209. get mesh(): Nullable<AbstractMesh>;
  14210. set mesh(value: Nullable<AbstractMesh>);
  14211. /**
  14212. * Creates a new instance MeshParticleEmitter
  14213. * @param mesh defines the mesh to use as source
  14214. */
  14215. constructor(mesh?: Nullable<AbstractMesh>);
  14216. /**
  14217. * Called by the particle System when the direction is computed for the created particle.
  14218. * @param worldMatrix is the world matrix of the particle system
  14219. * @param directionToUpdate is the direction vector to update with the result
  14220. * @param particle is the particle we are computed the direction for
  14221. * @param isLocal defines if the direction should be set in local space
  14222. */
  14223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14224. /**
  14225. * Called by the particle System when the position is computed for the created particle.
  14226. * @param worldMatrix is the world matrix of the particle system
  14227. * @param positionToUpdate is the position vector to update with the result
  14228. * @param particle is the particle we are computed the position for
  14229. * @param isLocal defines if the position should be set in local space
  14230. */
  14231. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14232. /**
  14233. * Clones the current emitter and returns a copy of it
  14234. * @returns the new emitter
  14235. */
  14236. clone(): MeshParticleEmitter;
  14237. /**
  14238. * Called by the GPUParticleSystem to setup the update shader
  14239. * @param effect defines the update shader
  14240. */
  14241. applyToShader(effect: Effect): void;
  14242. /**
  14243. * Returns a string to use to update the GPU particles update shader
  14244. * @returns a string containng the defines string
  14245. */
  14246. getEffectDefines(): string;
  14247. /**
  14248. * Returns the string "BoxParticleEmitter"
  14249. * @returns a string containing the class name
  14250. */
  14251. getClassName(): string;
  14252. /**
  14253. * Serializes the particle system to a JSON object.
  14254. * @returns the JSON object
  14255. */
  14256. serialize(): any;
  14257. /**
  14258. * Parse properties from a JSON object
  14259. * @param serializationObject defines the JSON object
  14260. * @param scene defines the hosting scene
  14261. */
  14262. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14263. }
  14264. }
  14265. declare module "babylonjs/Particles/EmitterTypes/index" {
  14266. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14267. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14268. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14269. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14270. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14271. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14272. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14273. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14274. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14275. }
  14276. declare module "babylonjs/Particles/IParticleSystem" {
  14277. import { Nullable } from "babylonjs/types";
  14278. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14279. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14281. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14282. import { Scene } from "babylonjs/scene";
  14283. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14284. import { Effect } from "babylonjs/Materials/effect";
  14285. import { Observable } from "babylonjs/Misc/observable";
  14286. import { Animation } from "babylonjs/Animations/animation";
  14287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14288. /**
  14289. * Interface representing a particle system in Babylon.js.
  14290. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14291. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14292. */
  14293. export interface IParticleSystem {
  14294. /**
  14295. * List of animations used by the particle system.
  14296. */
  14297. animations: Animation[];
  14298. /**
  14299. * The id of the Particle system.
  14300. */
  14301. id: string;
  14302. /**
  14303. * The name of the Particle system.
  14304. */
  14305. name: string;
  14306. /**
  14307. * The emitter represents the Mesh or position we are attaching the particle system to.
  14308. */
  14309. emitter: Nullable<AbstractMesh | Vector3>;
  14310. /**
  14311. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14312. */
  14313. isBillboardBased: boolean;
  14314. /**
  14315. * The rendering group used by the Particle system to chose when to render.
  14316. */
  14317. renderingGroupId: number;
  14318. /**
  14319. * The layer mask we are rendering the particles through.
  14320. */
  14321. layerMask: number;
  14322. /**
  14323. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14324. */
  14325. updateSpeed: number;
  14326. /**
  14327. * The amount of time the particle system is running (depends of the overall update speed).
  14328. */
  14329. targetStopDuration: number;
  14330. /**
  14331. * The texture used to render each particle. (this can be a spritesheet)
  14332. */
  14333. particleTexture: Nullable<BaseTexture>;
  14334. /**
  14335. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14336. */
  14337. blendMode: number;
  14338. /**
  14339. * Minimum life time of emitting particles.
  14340. */
  14341. minLifeTime: number;
  14342. /**
  14343. * Maximum life time of emitting particles.
  14344. */
  14345. maxLifeTime: number;
  14346. /**
  14347. * Minimum Size of emitting particles.
  14348. */
  14349. minSize: number;
  14350. /**
  14351. * Maximum Size of emitting particles.
  14352. */
  14353. maxSize: number;
  14354. /**
  14355. * Minimum scale of emitting particles on X axis.
  14356. */
  14357. minScaleX: number;
  14358. /**
  14359. * Maximum scale of emitting particles on X axis.
  14360. */
  14361. maxScaleX: number;
  14362. /**
  14363. * Minimum scale of emitting particles on Y axis.
  14364. */
  14365. minScaleY: number;
  14366. /**
  14367. * Maximum scale of emitting particles on Y axis.
  14368. */
  14369. maxScaleY: number;
  14370. /**
  14371. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14372. */
  14373. color1: Color4;
  14374. /**
  14375. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14376. */
  14377. color2: Color4;
  14378. /**
  14379. * Color the particle will have at the end of its lifetime.
  14380. */
  14381. colorDead: Color4;
  14382. /**
  14383. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14384. */
  14385. emitRate: number;
  14386. /**
  14387. * You can use gravity if you want to give an orientation to your particles.
  14388. */
  14389. gravity: Vector3;
  14390. /**
  14391. * Minimum power of emitting particles.
  14392. */
  14393. minEmitPower: number;
  14394. /**
  14395. * Maximum power of emitting particles.
  14396. */
  14397. maxEmitPower: number;
  14398. /**
  14399. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14400. */
  14401. minAngularSpeed: number;
  14402. /**
  14403. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14404. */
  14405. maxAngularSpeed: number;
  14406. /**
  14407. * Gets or sets the minimal initial rotation in radians.
  14408. */
  14409. minInitialRotation: number;
  14410. /**
  14411. * Gets or sets the maximal initial rotation in radians.
  14412. */
  14413. maxInitialRotation: number;
  14414. /**
  14415. * The particle emitter type defines the emitter used by the particle system.
  14416. * It can be for example box, sphere, or cone...
  14417. */
  14418. particleEmitterType: Nullable<IParticleEmitterType>;
  14419. /**
  14420. * Defines the delay in milliseconds before starting the system (0 by default)
  14421. */
  14422. startDelay: number;
  14423. /**
  14424. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14425. */
  14426. preWarmCycles: number;
  14427. /**
  14428. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14429. */
  14430. preWarmStepOffset: number;
  14431. /**
  14432. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14433. */
  14434. spriteCellChangeSpeed: number;
  14435. /**
  14436. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14437. */
  14438. startSpriteCellID: number;
  14439. /**
  14440. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14441. */
  14442. endSpriteCellID: number;
  14443. /**
  14444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14445. */
  14446. spriteCellWidth: number;
  14447. /**
  14448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14449. */
  14450. spriteCellHeight: number;
  14451. /**
  14452. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14453. */
  14454. spriteRandomStartCell: boolean;
  14455. /**
  14456. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14457. */
  14458. isAnimationSheetEnabled: boolean;
  14459. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14460. translationPivot: Vector2;
  14461. /**
  14462. * Gets or sets a texture used to add random noise to particle positions
  14463. */
  14464. noiseTexture: Nullable<BaseTexture>;
  14465. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14466. noiseStrength: Vector3;
  14467. /**
  14468. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14469. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14470. */
  14471. billboardMode: number;
  14472. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14473. limitVelocityDamping: number;
  14474. /**
  14475. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14476. */
  14477. beginAnimationOnStart: boolean;
  14478. /**
  14479. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14480. */
  14481. beginAnimationFrom: number;
  14482. /**
  14483. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14484. */
  14485. beginAnimationTo: number;
  14486. /**
  14487. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14488. */
  14489. beginAnimationLoop: boolean;
  14490. /**
  14491. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14492. */
  14493. disposeOnStop: boolean;
  14494. /**
  14495. * Specifies if the particles are updated in emitter local space or world space
  14496. */
  14497. isLocal: boolean;
  14498. /** Snippet ID if the particle system was created from the snippet server */
  14499. snippetId: string;
  14500. /** Gets or sets a matrix to use to compute projection */
  14501. defaultProjectionMatrix: Matrix;
  14502. /**
  14503. * Gets the maximum number of particles active at the same time.
  14504. * @returns The max number of active particles.
  14505. */
  14506. getCapacity(): number;
  14507. /**
  14508. * Gets the number of particles active at the same time.
  14509. * @returns The number of active particles.
  14510. */
  14511. getActiveCount(): number;
  14512. /**
  14513. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14514. * @returns True if it has been started, otherwise false.
  14515. */
  14516. isStarted(): boolean;
  14517. /**
  14518. * Animates the particle system for this frame.
  14519. */
  14520. animate(): void;
  14521. /**
  14522. * Renders the particle system in its current state.
  14523. * @returns the current number of particles
  14524. */
  14525. render(): number;
  14526. /**
  14527. * Dispose the particle system and frees its associated resources.
  14528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14529. */
  14530. dispose(disposeTexture?: boolean): void;
  14531. /**
  14532. * An event triggered when the system is disposed
  14533. */
  14534. onDisposeObservable: Observable<IParticleSystem>;
  14535. /**
  14536. * Clones the particle system.
  14537. * @param name The name of the cloned object
  14538. * @param newEmitter The new emitter to use
  14539. * @returns the cloned particle system
  14540. */
  14541. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14542. /**
  14543. * Serializes the particle system to a JSON object
  14544. * @param serializeTexture defines if the texture must be serialized as well
  14545. * @returns the JSON object
  14546. */
  14547. serialize(serializeTexture: boolean): any;
  14548. /**
  14549. * Rebuild the particle system
  14550. */
  14551. rebuild(): void;
  14552. /** Force the system to rebuild all gradients that need to be resync */
  14553. forceRefreshGradients(): void;
  14554. /**
  14555. * Starts the particle system and begins to emit
  14556. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14557. */
  14558. start(delay?: number): void;
  14559. /**
  14560. * Stops the particle system.
  14561. */
  14562. stop(): void;
  14563. /**
  14564. * Remove all active particles
  14565. */
  14566. reset(): void;
  14567. /**
  14568. * Gets a boolean indicating that the system is stopping
  14569. * @returns true if the system is currently stopping
  14570. */
  14571. isStopping(): boolean;
  14572. /**
  14573. * Is this system ready to be used/rendered
  14574. * @return true if the system is ready
  14575. */
  14576. isReady(): boolean;
  14577. /**
  14578. * Returns the string "ParticleSystem"
  14579. * @returns a string containing the class name
  14580. */
  14581. getClassName(): string;
  14582. /**
  14583. * Gets the custom effect used to render the particles
  14584. * @param blendMode Blend mode for which the effect should be retrieved
  14585. * @returns The effect
  14586. */
  14587. getCustomEffect(blendMode: number): Nullable<Effect>;
  14588. /**
  14589. * Sets the custom effect used to render the particles
  14590. * @param effect The effect to set
  14591. * @param blendMode Blend mode for which the effect should be set
  14592. */
  14593. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14594. /**
  14595. * Fill the defines array according to the current settings of the particle system
  14596. * @param defines Array to be updated
  14597. * @param blendMode blend mode to take into account when updating the array
  14598. */
  14599. fillDefines(defines: Array<string>, blendMode: number): void;
  14600. /**
  14601. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14602. * @param uniforms Uniforms array to fill
  14603. * @param attributes Attributes array to fill
  14604. * @param samplers Samplers array to fill
  14605. */
  14606. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14607. /**
  14608. * Observable that will be called just before the particles are drawn
  14609. */
  14610. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14611. /**
  14612. * Gets the name of the particle vertex shader
  14613. */
  14614. vertexShaderName: string;
  14615. /**
  14616. * Adds a new color gradient
  14617. * @param gradient defines the gradient to use (between 0 and 1)
  14618. * @param color1 defines the color to affect to the specified gradient
  14619. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14620. * @returns the current particle system
  14621. */
  14622. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14623. /**
  14624. * Remove a specific color gradient
  14625. * @param gradient defines the gradient to remove
  14626. * @returns the current particle system
  14627. */
  14628. removeColorGradient(gradient: number): IParticleSystem;
  14629. /**
  14630. * Adds a new size gradient
  14631. * @param gradient defines the gradient to use (between 0 and 1)
  14632. * @param factor defines the size factor to affect to the specified gradient
  14633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14634. * @returns the current particle system
  14635. */
  14636. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14637. /**
  14638. * Remove a specific size gradient
  14639. * @param gradient defines the gradient to remove
  14640. * @returns the current particle system
  14641. */
  14642. removeSizeGradient(gradient: number): IParticleSystem;
  14643. /**
  14644. * Gets the current list of color gradients.
  14645. * You must use addColorGradient and removeColorGradient to udpate this list
  14646. * @returns the list of color gradients
  14647. */
  14648. getColorGradients(): Nullable<Array<ColorGradient>>;
  14649. /**
  14650. * Gets the current list of size gradients.
  14651. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14652. * @returns the list of size gradients
  14653. */
  14654. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14655. /**
  14656. * Gets the current list of angular speed gradients.
  14657. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14658. * @returns the list of angular speed gradients
  14659. */
  14660. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Adds a new angular speed gradient
  14663. * @param gradient defines the gradient to use (between 0 and 1)
  14664. * @param factor defines the angular speed to affect to the specified gradient
  14665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14666. * @returns the current particle system
  14667. */
  14668. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14669. /**
  14670. * Remove a specific angular speed gradient
  14671. * @param gradient defines the gradient to remove
  14672. * @returns the current particle system
  14673. */
  14674. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14675. /**
  14676. * Gets the current list of velocity gradients.
  14677. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14678. * @returns the list of velocity gradients
  14679. */
  14680. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14681. /**
  14682. * Adds a new velocity gradient
  14683. * @param gradient defines the gradient to use (between 0 and 1)
  14684. * @param factor defines the velocity to affect to the specified gradient
  14685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14686. * @returns the current particle system
  14687. */
  14688. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14689. /**
  14690. * Remove a specific velocity gradient
  14691. * @param gradient defines the gradient to remove
  14692. * @returns the current particle system
  14693. */
  14694. removeVelocityGradient(gradient: number): IParticleSystem;
  14695. /**
  14696. * Gets the current list of limit velocity gradients.
  14697. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14698. * @returns the list of limit velocity gradients
  14699. */
  14700. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14701. /**
  14702. * Adds a new limit velocity gradient
  14703. * @param gradient defines the gradient to use (between 0 and 1)
  14704. * @param factor defines the limit velocity to affect to the specified gradient
  14705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14706. * @returns the current particle system
  14707. */
  14708. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14709. /**
  14710. * Remove a specific limit velocity gradient
  14711. * @param gradient defines the gradient to remove
  14712. * @returns the current particle system
  14713. */
  14714. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14715. /**
  14716. * Adds a new drag gradient
  14717. * @param gradient defines the gradient to use (between 0 and 1)
  14718. * @param factor defines the drag to affect to the specified gradient
  14719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14720. * @returns the current particle system
  14721. */
  14722. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14723. /**
  14724. * Remove a specific drag gradient
  14725. * @param gradient defines the gradient to remove
  14726. * @returns the current particle system
  14727. */
  14728. removeDragGradient(gradient: number): IParticleSystem;
  14729. /**
  14730. * Gets the current list of drag gradients.
  14731. * You must use addDragGradient and removeDragGradient to udpate this list
  14732. * @returns the list of drag gradients
  14733. */
  14734. getDragGradients(): Nullable<Array<FactorGradient>>;
  14735. /**
  14736. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14737. * @param gradient defines the gradient to use (between 0 and 1)
  14738. * @param factor defines the emit rate to affect to the specified gradient
  14739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14740. * @returns the current particle system
  14741. */
  14742. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14743. /**
  14744. * Remove a specific emit rate gradient
  14745. * @param gradient defines the gradient to remove
  14746. * @returns the current particle system
  14747. */
  14748. removeEmitRateGradient(gradient: number): IParticleSystem;
  14749. /**
  14750. * Gets the current list of emit rate gradients.
  14751. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14752. * @returns the list of emit rate gradients
  14753. */
  14754. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14755. /**
  14756. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14757. * @param gradient defines the gradient to use (between 0 and 1)
  14758. * @param factor defines the start size to affect to the specified gradient
  14759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14760. * @returns the current particle system
  14761. */
  14762. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14763. /**
  14764. * Remove a specific start size gradient
  14765. * @param gradient defines the gradient to remove
  14766. * @returns the current particle system
  14767. */
  14768. removeStartSizeGradient(gradient: number): IParticleSystem;
  14769. /**
  14770. * Gets the current list of start size gradients.
  14771. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14772. * @returns the list of start size gradients
  14773. */
  14774. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14775. /**
  14776. * Adds a new life time gradient
  14777. * @param gradient defines the gradient to use (between 0 and 1)
  14778. * @param factor defines the life time factor to affect to the specified gradient
  14779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14780. * @returns the current particle system
  14781. */
  14782. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14783. /**
  14784. * Remove a specific life time gradient
  14785. * @param gradient defines the gradient to remove
  14786. * @returns the current particle system
  14787. */
  14788. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14789. /**
  14790. * Gets the current list of life time gradients.
  14791. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14792. * @returns the list of life time gradients
  14793. */
  14794. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14795. /**
  14796. * Gets the current list of color gradients.
  14797. * You must use addColorGradient and removeColorGradient to udpate this list
  14798. * @returns the list of color gradients
  14799. */
  14800. getColorGradients(): Nullable<Array<ColorGradient>>;
  14801. /**
  14802. * Adds a new ramp gradient used to remap particle colors
  14803. * @param gradient defines the gradient to use (between 0 and 1)
  14804. * @param color defines the color to affect to the specified gradient
  14805. * @returns the current particle system
  14806. */
  14807. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14808. /**
  14809. * Gets the current list of ramp gradients.
  14810. * You must use addRampGradient and removeRampGradient to udpate this list
  14811. * @returns the list of ramp gradients
  14812. */
  14813. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14814. /** Gets or sets a boolean indicating that ramp gradients must be used
  14815. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14816. */
  14817. useRampGradients: boolean;
  14818. /**
  14819. * Adds a new color remap gradient
  14820. * @param gradient defines the gradient to use (between 0 and 1)
  14821. * @param min defines the color remap minimal range
  14822. * @param max defines the color remap maximal range
  14823. * @returns the current particle system
  14824. */
  14825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14826. /**
  14827. * Gets the current list of color remap gradients.
  14828. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14829. * @returns the list of color remap gradients
  14830. */
  14831. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14832. /**
  14833. * Adds a new alpha remap gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param min defines the alpha remap minimal range
  14836. * @param max defines the alpha remap maximal range
  14837. * @returns the current particle system
  14838. */
  14839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14840. /**
  14841. * Gets the current list of alpha remap gradients.
  14842. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14843. * @returns the list of alpha remap gradients
  14844. */
  14845. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14846. /**
  14847. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14850. * @returns the emitter
  14851. */
  14852. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14853. /**
  14854. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14855. * @param radius The radius of the hemisphere to emit from
  14856. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14857. * @returns the emitter
  14858. */
  14859. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14860. /**
  14861. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14862. * @param radius The radius of the sphere to emit from
  14863. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14864. * @returns the emitter
  14865. */
  14866. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14867. /**
  14868. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14869. * @param radius The radius of the sphere to emit from
  14870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14872. * @returns the emitter
  14873. */
  14874. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14875. /**
  14876. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14877. * @param radius The radius of the emission cylinder
  14878. * @param height The height of the emission cylinder
  14879. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14880. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14881. * @returns the emitter
  14882. */
  14883. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14884. /**
  14885. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14886. * @param radius The radius of the cylinder to emit from
  14887. * @param height The height of the emission cylinder
  14888. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14889. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14890. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14891. * @returns the emitter
  14892. */
  14893. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14894. /**
  14895. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14896. * @param radius The radius of the cone to emit from
  14897. * @param angle The base angle of the cone
  14898. * @returns the emitter
  14899. */
  14900. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14901. /**
  14902. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14905. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14906. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14907. * @returns the emitter
  14908. */
  14909. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14910. /**
  14911. * Get hosting scene
  14912. * @returns the scene
  14913. */
  14914. getScene(): Nullable<Scene>;
  14915. }
  14916. }
  14917. declare module "babylonjs/Meshes/transformNode" {
  14918. import { DeepImmutable } from "babylonjs/types";
  14919. import { Observable } from "babylonjs/Misc/observable";
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Camera } from "babylonjs/Cameras/camera";
  14922. import { Scene } from "babylonjs/scene";
  14923. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14924. import { Node } from "babylonjs/node";
  14925. import { Bone } from "babylonjs/Bones/bone";
  14926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14927. import { Space } from "babylonjs/Maths/math.axis";
  14928. /**
  14929. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14930. * @see https://doc.babylonjs.com/how_to/transformnode
  14931. */
  14932. export class TransformNode extends Node {
  14933. /**
  14934. * Object will not rotate to face the camera
  14935. */
  14936. static BILLBOARDMODE_NONE: number;
  14937. /**
  14938. * Object will rotate to face the camera but only on the x axis
  14939. */
  14940. static BILLBOARDMODE_X: number;
  14941. /**
  14942. * Object will rotate to face the camera but only on the y axis
  14943. */
  14944. static BILLBOARDMODE_Y: number;
  14945. /**
  14946. * Object will rotate to face the camera but only on the z axis
  14947. */
  14948. static BILLBOARDMODE_Z: number;
  14949. /**
  14950. * Object will rotate to face the camera
  14951. */
  14952. static BILLBOARDMODE_ALL: number;
  14953. /**
  14954. * Object will rotate to face the camera's position instead of orientation
  14955. */
  14956. static BILLBOARDMODE_USE_POSITION: number;
  14957. private static _TmpRotation;
  14958. private static _TmpScaling;
  14959. private static _TmpTranslation;
  14960. private _forward;
  14961. private _forwardInverted;
  14962. private _up;
  14963. private _right;
  14964. private _rightInverted;
  14965. private _position;
  14966. private _rotation;
  14967. private _rotationQuaternion;
  14968. protected _scaling: Vector3;
  14969. protected _isDirty: boolean;
  14970. private _transformToBoneReferal;
  14971. private _isAbsoluteSynced;
  14972. private _billboardMode;
  14973. /**
  14974. * Gets or sets the billboard mode. Default is 0.
  14975. *
  14976. * | Value | Type | Description |
  14977. * | --- | --- | --- |
  14978. * | 0 | BILLBOARDMODE_NONE | |
  14979. * | 1 | BILLBOARDMODE_X | |
  14980. * | 2 | BILLBOARDMODE_Y | |
  14981. * | 4 | BILLBOARDMODE_Z | |
  14982. * | 7 | BILLBOARDMODE_ALL | |
  14983. *
  14984. */
  14985. get billboardMode(): number;
  14986. set billboardMode(value: number);
  14987. private _preserveParentRotationForBillboard;
  14988. /**
  14989. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14990. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14991. */
  14992. get preserveParentRotationForBillboard(): boolean;
  14993. set preserveParentRotationForBillboard(value: boolean);
  14994. /**
  14995. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14996. */
  14997. scalingDeterminant: number;
  14998. private _infiniteDistance;
  14999. /**
  15000. * Gets or sets the distance of the object to max, often used by skybox
  15001. */
  15002. get infiniteDistance(): boolean;
  15003. set infiniteDistance(value: boolean);
  15004. /**
  15005. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15006. * By default the system will update normals to compensate
  15007. */
  15008. ignoreNonUniformScaling: boolean;
  15009. /**
  15010. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  15011. */
  15012. reIntegrateRotationIntoRotationQuaternion: boolean;
  15013. /** @hidden */
  15014. _poseMatrix: Nullable<Matrix>;
  15015. /** @hidden */
  15016. _localMatrix: Matrix;
  15017. private _usePivotMatrix;
  15018. private _absolutePosition;
  15019. private _absoluteScaling;
  15020. private _absoluteRotationQuaternion;
  15021. private _pivotMatrix;
  15022. private _pivotMatrixInverse;
  15023. protected _postMultiplyPivotMatrix: boolean;
  15024. protected _isWorldMatrixFrozen: boolean;
  15025. /** @hidden */
  15026. _indexInSceneTransformNodesArray: number;
  15027. /**
  15028. * An event triggered after the world matrix is updated
  15029. */
  15030. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15031. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15032. /**
  15033. * Gets a string identifying the name of the class
  15034. * @returns "TransformNode" string
  15035. */
  15036. getClassName(): string;
  15037. /**
  15038. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15039. */
  15040. get position(): Vector3;
  15041. set position(newPosition: Vector3);
  15042. /**
  15043. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15044. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15045. */
  15046. get rotation(): Vector3;
  15047. set rotation(newRotation: Vector3);
  15048. /**
  15049. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  15050. */
  15051. get scaling(): Vector3;
  15052. set scaling(newScaling: Vector3);
  15053. /**
  15054. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  15055. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15056. */
  15057. get rotationQuaternion(): Nullable<Quaternion>;
  15058. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15059. /**
  15060. * The forward direction of that transform in world space.
  15061. */
  15062. get forward(): Vector3;
  15063. /**
  15064. * The up direction of that transform in world space.
  15065. */
  15066. get up(): Vector3;
  15067. /**
  15068. * The right direction of that transform in world space.
  15069. */
  15070. get right(): Vector3;
  15071. /**
  15072. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15073. * @param matrix the matrix to copy the pose from
  15074. * @returns this TransformNode.
  15075. */
  15076. updatePoseMatrix(matrix: Matrix): TransformNode;
  15077. /**
  15078. * Returns the mesh Pose matrix.
  15079. * @returns the pose matrix
  15080. */
  15081. getPoseMatrix(): Matrix;
  15082. /** @hidden */
  15083. _isSynchronized(): boolean;
  15084. /** @hidden */
  15085. _initCache(): void;
  15086. /**
  15087. * Flag the transform node as dirty (Forcing it to update everything)
  15088. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15089. * @returns this transform node
  15090. */
  15091. markAsDirty(property: string): TransformNode;
  15092. /**
  15093. * Returns the current mesh absolute position.
  15094. * Returns a Vector3.
  15095. */
  15096. get absolutePosition(): Vector3;
  15097. /**
  15098. * Returns the current mesh absolute scaling.
  15099. * Returns a Vector3.
  15100. */
  15101. get absoluteScaling(): Vector3;
  15102. /**
  15103. * Returns the current mesh absolute rotation.
  15104. * Returns a Quaternion.
  15105. */
  15106. get absoluteRotationQuaternion(): Quaternion;
  15107. /**
  15108. * Sets a new matrix to apply before all other transformation
  15109. * @param matrix defines the transform matrix
  15110. * @returns the current TransformNode
  15111. */
  15112. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15113. /**
  15114. * Sets a new pivot matrix to the current node
  15115. * @param matrix defines the new pivot matrix to use
  15116. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  15117. * @returns the current TransformNode
  15118. */
  15119. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15120. /**
  15121. * Returns the mesh pivot matrix.
  15122. * Default : Identity.
  15123. * @returns the matrix
  15124. */
  15125. getPivotMatrix(): Matrix;
  15126. /**
  15127. * Instantiate (when possible) or clone that node with its hierarchy
  15128. * @param newParent defines the new parent to use for the instance (or clone)
  15129. * @param options defines options to configure how copy is done
  15130. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15131. * @returns an instance (or a clone) of the current node with its hiearchy
  15132. */
  15133. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15134. doNotInstantiate: boolean;
  15135. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15136. /**
  15137. * Prevents the World matrix to be computed any longer
  15138. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15139. * @returns the TransformNode.
  15140. */
  15141. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15142. /**
  15143. * Allows back the World matrix computation.
  15144. * @returns the TransformNode.
  15145. */
  15146. unfreezeWorldMatrix(): this;
  15147. /**
  15148. * True if the World matrix has been frozen.
  15149. */
  15150. get isWorldMatrixFrozen(): boolean;
  15151. /**
  15152. * Retuns the mesh absolute position in the World.
  15153. * @returns a Vector3.
  15154. */
  15155. getAbsolutePosition(): Vector3;
  15156. /**
  15157. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15158. * @param absolutePosition the absolute position to set
  15159. * @returns the TransformNode.
  15160. */
  15161. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15162. /**
  15163. * Sets the mesh position in its local space.
  15164. * @param vector3 the position to set in localspace
  15165. * @returns the TransformNode.
  15166. */
  15167. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15168. /**
  15169. * Returns the mesh position in the local space from the current World matrix values.
  15170. * @returns a new Vector3.
  15171. */
  15172. getPositionExpressedInLocalSpace(): Vector3;
  15173. /**
  15174. * Translates the mesh along the passed Vector3 in its local space.
  15175. * @param vector3 the distance to translate in localspace
  15176. * @returns the TransformNode.
  15177. */
  15178. locallyTranslate(vector3: Vector3): TransformNode;
  15179. private static _lookAtVectorCache;
  15180. /**
  15181. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15182. * @param targetPoint the position (must be in same space as current mesh) to look at
  15183. * @param yawCor optional yaw (y-axis) correction in radians
  15184. * @param pitchCor optional pitch (x-axis) correction in radians
  15185. * @param rollCor optional roll (z-axis) correction in radians
  15186. * @param space the choosen space of the target
  15187. * @returns the TransformNode.
  15188. */
  15189. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15190. /**
  15191. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15192. * This Vector3 is expressed in the World space.
  15193. * @param localAxis axis to rotate
  15194. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15195. */
  15196. getDirection(localAxis: Vector3): Vector3;
  15197. /**
  15198. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15199. * localAxis is expressed in the mesh local space.
  15200. * result is computed in the Wordl space from the mesh World matrix.
  15201. * @param localAxis axis to rotate
  15202. * @param result the resulting transformnode
  15203. * @returns this TransformNode.
  15204. */
  15205. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15206. /**
  15207. * Sets this transform node rotation to the given local axis.
  15208. * @param localAxis the axis in local space
  15209. * @param yawCor optional yaw (y-axis) correction in radians
  15210. * @param pitchCor optional pitch (x-axis) correction in radians
  15211. * @param rollCor optional roll (z-axis) correction in radians
  15212. * @returns this TransformNode
  15213. */
  15214. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15215. /**
  15216. * Sets a new pivot point to the current node
  15217. * @param point defines the new pivot point to use
  15218. * @param space defines if the point is in world or local space (local by default)
  15219. * @returns the current TransformNode
  15220. */
  15221. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15222. /**
  15223. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15224. * @returns the pivot point
  15225. */
  15226. getPivotPoint(): Vector3;
  15227. /**
  15228. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15229. * @param result the vector3 to store the result
  15230. * @returns this TransformNode.
  15231. */
  15232. getPivotPointToRef(result: Vector3): TransformNode;
  15233. /**
  15234. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15235. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15236. */
  15237. getAbsolutePivotPoint(): Vector3;
  15238. /**
  15239. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15240. * @param result vector3 to store the result
  15241. * @returns this TransformNode.
  15242. */
  15243. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15244. /**
  15245. * Defines the passed node as the parent of the current node.
  15246. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15247. * @see https://doc.babylonjs.com/how_to/parenting
  15248. * @param node the node ot set as the parent
  15249. * @returns this TransformNode.
  15250. */
  15251. setParent(node: Nullable<Node>): TransformNode;
  15252. private _nonUniformScaling;
  15253. /**
  15254. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15255. */
  15256. get nonUniformScaling(): boolean;
  15257. /** @hidden */
  15258. _updateNonUniformScalingState(value: boolean): boolean;
  15259. /**
  15260. * Attach the current TransformNode to another TransformNode associated with a bone
  15261. * @param bone Bone affecting the TransformNode
  15262. * @param affectedTransformNode TransformNode associated with the bone
  15263. * @returns this object
  15264. */
  15265. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15266. /**
  15267. * Detach the transform node if its associated with a bone
  15268. * @returns this object
  15269. */
  15270. detachFromBone(): TransformNode;
  15271. private static _rotationAxisCache;
  15272. /**
  15273. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15274. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15275. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15276. * The passed axis is also normalized.
  15277. * @param axis the axis to rotate around
  15278. * @param amount the amount to rotate in radians
  15279. * @param space Space to rotate in (Default: local)
  15280. * @returns the TransformNode.
  15281. */
  15282. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15283. /**
  15284. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15285. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15286. * The passed axis is also normalized. .
  15287. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15288. * @param point the point to rotate around
  15289. * @param axis the axis to rotate around
  15290. * @param amount the amount to rotate in radians
  15291. * @returns the TransformNode
  15292. */
  15293. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15294. /**
  15295. * Translates the mesh along the axis vector for the passed distance in the given space.
  15296. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15297. * @param axis the axis to translate in
  15298. * @param distance the distance to translate
  15299. * @param space Space to rotate in (Default: local)
  15300. * @returns the TransformNode.
  15301. */
  15302. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15303. /**
  15304. * Adds a rotation step to the mesh current rotation.
  15305. * x, y, z are Euler angles expressed in radians.
  15306. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15307. * This means this rotation is made in the mesh local space only.
  15308. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15309. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15310. * ```javascript
  15311. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15312. * ```
  15313. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15314. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  15315. * @param x Rotation to add
  15316. * @param y Rotation to add
  15317. * @param z Rotation to add
  15318. * @returns the TransformNode.
  15319. */
  15320. addRotation(x: number, y: number, z: number): TransformNode;
  15321. /**
  15322. * @hidden
  15323. */
  15324. protected _getEffectiveParent(): Nullable<Node>;
  15325. /**
  15326. * Computes the world matrix of the node
  15327. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15328. * @returns the world matrix
  15329. */
  15330. computeWorldMatrix(force?: boolean): Matrix;
  15331. /**
  15332. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15333. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15334. */
  15335. resetLocalMatrix(independentOfChildren?: boolean): void;
  15336. protected _afterComputeWorldMatrix(): void;
  15337. /**
  15338. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15339. * @param func callback function to add
  15340. *
  15341. * @returns the TransformNode.
  15342. */
  15343. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15344. /**
  15345. * Removes a registered callback function.
  15346. * @param func callback function to remove
  15347. * @returns the TransformNode.
  15348. */
  15349. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15350. /**
  15351. * Gets the position of the current mesh in camera space
  15352. * @param camera defines the camera to use
  15353. * @returns a position
  15354. */
  15355. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15356. /**
  15357. * Returns the distance from the mesh to the active camera
  15358. * @param camera defines the camera to use
  15359. * @returns the distance
  15360. */
  15361. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15362. /**
  15363. * Clone the current transform node
  15364. * @param name Name of the new clone
  15365. * @param newParent New parent for the clone
  15366. * @param doNotCloneChildren Do not clone children hierarchy
  15367. * @returns the new transform node
  15368. */
  15369. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15370. /**
  15371. * Serializes the objects information.
  15372. * @param currentSerializationObject defines the object to serialize in
  15373. * @returns the serialized object
  15374. */
  15375. serialize(currentSerializationObject?: any): any;
  15376. /**
  15377. * Returns a new TransformNode object parsed from the source provided.
  15378. * @param parsedTransformNode is the source.
  15379. * @param scene the scne the object belongs to
  15380. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15381. * @returns a new TransformNode object parsed from the source provided.
  15382. */
  15383. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15384. /**
  15385. * Get all child-transformNodes of this node
  15386. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15387. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15388. * @returns an array of TransformNode
  15389. */
  15390. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15391. /**
  15392. * Releases resources associated with this transform node.
  15393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15395. */
  15396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15397. /**
  15398. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15399. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15400. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15401. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15402. * @returns the current mesh
  15403. */
  15404. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15405. private _syncAbsoluteScalingAndRotation;
  15406. }
  15407. }
  15408. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15409. /**
  15410. * Class used to override all child animations of a given target
  15411. */
  15412. export class AnimationPropertiesOverride {
  15413. /**
  15414. * Gets or sets a value indicating if animation blending must be used
  15415. */
  15416. enableBlending: boolean;
  15417. /**
  15418. * Gets or sets the blending speed to use when enableBlending is true
  15419. */
  15420. blendingSpeed: number;
  15421. /**
  15422. * Gets or sets the default loop mode to use
  15423. */
  15424. loopMode: number;
  15425. }
  15426. }
  15427. declare module "babylonjs/Bones/bone" {
  15428. import { Skeleton } from "babylonjs/Bones/skeleton";
  15429. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15430. import { Nullable } from "babylonjs/types";
  15431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15433. import { Node } from "babylonjs/node";
  15434. import { Space } from "babylonjs/Maths/math.axis";
  15435. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15436. /**
  15437. * Class used to store bone information
  15438. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15439. */
  15440. export class Bone extends Node {
  15441. /**
  15442. * defines the bone name
  15443. */
  15444. name: string;
  15445. private static _tmpVecs;
  15446. private static _tmpQuat;
  15447. private static _tmpMats;
  15448. /**
  15449. * Gets the list of child bones
  15450. */
  15451. children: Bone[];
  15452. /** Gets the animations associated with this bone */
  15453. animations: import("babylonjs/Animations/animation").Animation[];
  15454. /**
  15455. * Gets or sets bone length
  15456. */
  15457. length: number;
  15458. /**
  15459. * @hidden Internal only
  15460. * Set this value to map this bone to a different index in the transform matrices
  15461. * Set this value to -1 to exclude the bone from the transform matrices
  15462. */
  15463. _index: Nullable<number>;
  15464. private _skeleton;
  15465. private _localMatrix;
  15466. private _restPose;
  15467. private _bindPose;
  15468. private _baseMatrix;
  15469. private _absoluteTransform;
  15470. private _invertedAbsoluteTransform;
  15471. private _parent;
  15472. private _scalingDeterminant;
  15473. private _worldTransform;
  15474. private _localScaling;
  15475. private _localRotation;
  15476. private _localPosition;
  15477. private _needToDecompose;
  15478. private _needToCompose;
  15479. /** @hidden */
  15480. _linkedTransformNode: Nullable<TransformNode>;
  15481. /** @hidden */
  15482. _waitingTransformNodeId: Nullable<string>;
  15483. /** @hidden */
  15484. get _matrix(): Matrix;
  15485. /** @hidden */
  15486. set _matrix(value: Matrix);
  15487. /**
  15488. * Create a new bone
  15489. * @param name defines the bone name
  15490. * @param skeleton defines the parent skeleton
  15491. * @param parentBone defines the parent (can be null if the bone is the root)
  15492. * @param localMatrix defines the local matrix
  15493. * @param restPose defines the rest pose matrix
  15494. * @param baseMatrix defines the base matrix
  15495. * @param index defines index of the bone in the hiearchy
  15496. */
  15497. constructor(
  15498. /**
  15499. * defines the bone name
  15500. */
  15501. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15502. /**
  15503. * Gets the current object class name.
  15504. * @return the class name
  15505. */
  15506. getClassName(): string;
  15507. /**
  15508. * Gets the parent skeleton
  15509. * @returns a skeleton
  15510. */
  15511. getSkeleton(): Skeleton;
  15512. /**
  15513. * Gets parent bone
  15514. * @returns a bone or null if the bone is the root of the bone hierarchy
  15515. */
  15516. getParent(): Nullable<Bone>;
  15517. /**
  15518. * Returns an array containing the root bones
  15519. * @returns an array containing the root bones
  15520. */
  15521. getChildren(): Array<Bone>;
  15522. /**
  15523. * Gets the node index in matrix array generated for rendering
  15524. * @returns the node index
  15525. */
  15526. getIndex(): number;
  15527. /**
  15528. * Sets the parent bone
  15529. * @param parent defines the parent (can be null if the bone is the root)
  15530. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15531. */
  15532. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15533. /**
  15534. * Gets the local matrix
  15535. * @returns a matrix
  15536. */
  15537. getLocalMatrix(): Matrix;
  15538. /**
  15539. * Gets the base matrix (initial matrix which remains unchanged)
  15540. * @returns a matrix
  15541. */
  15542. getBaseMatrix(): Matrix;
  15543. /**
  15544. * Gets the rest pose matrix
  15545. * @returns a matrix
  15546. */
  15547. getRestPose(): Matrix;
  15548. /**
  15549. * Sets the rest pose matrix
  15550. * @param matrix the local-space rest pose to set for this bone
  15551. */
  15552. setRestPose(matrix: Matrix): void;
  15553. /**
  15554. * Gets the bind pose matrix
  15555. * @returns the bind pose matrix
  15556. */
  15557. getBindPose(): Matrix;
  15558. /**
  15559. * Sets the bind pose matrix
  15560. * @param matrix the local-space bind pose to set for this bone
  15561. */
  15562. setBindPose(matrix: Matrix): void;
  15563. /**
  15564. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15565. */
  15566. getWorldMatrix(): Matrix;
  15567. /**
  15568. * Sets the local matrix to rest pose matrix
  15569. */
  15570. returnToRest(): void;
  15571. /**
  15572. * Gets the inverse of the absolute transform matrix.
  15573. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15574. * @returns a matrix
  15575. */
  15576. getInvertedAbsoluteTransform(): Matrix;
  15577. /**
  15578. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15579. * @returns a matrix
  15580. */
  15581. getAbsoluteTransform(): Matrix;
  15582. /**
  15583. * Links with the given transform node.
  15584. * The local matrix of this bone is copied from the transform node every frame.
  15585. * @param transformNode defines the transform node to link to
  15586. */
  15587. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15588. /**
  15589. * Gets the node used to drive the bone's transformation
  15590. * @returns a transform node or null
  15591. */
  15592. getTransformNode(): Nullable<TransformNode>;
  15593. /** Gets or sets current position (in local space) */
  15594. get position(): Vector3;
  15595. set position(newPosition: Vector3);
  15596. /** Gets or sets current rotation (in local space) */
  15597. get rotation(): Vector3;
  15598. set rotation(newRotation: Vector3);
  15599. /** Gets or sets current rotation quaternion (in local space) */
  15600. get rotationQuaternion(): Quaternion;
  15601. set rotationQuaternion(newRotation: Quaternion);
  15602. /** Gets or sets current scaling (in local space) */
  15603. get scaling(): Vector3;
  15604. set scaling(newScaling: Vector3);
  15605. /**
  15606. * Gets the animation properties override
  15607. */
  15608. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15609. private _decompose;
  15610. private _compose;
  15611. /**
  15612. * Update the base and local matrices
  15613. * @param matrix defines the new base or local matrix
  15614. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15615. * @param updateLocalMatrix defines if the local matrix should be updated
  15616. */
  15617. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15618. /** @hidden */
  15619. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15620. /**
  15621. * Flag the bone as dirty (Forcing it to update everything)
  15622. */
  15623. markAsDirty(): void;
  15624. /** @hidden */
  15625. _markAsDirtyAndCompose(): void;
  15626. private _markAsDirtyAndDecompose;
  15627. /**
  15628. * Translate the bone in local or world space
  15629. * @param vec The amount to translate the bone
  15630. * @param space The space that the translation is in
  15631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15632. */
  15633. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15634. /**
  15635. * Set the postion of the bone in local or world space
  15636. * @param position The position to set the bone
  15637. * @param space The space that the position is in
  15638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15639. */
  15640. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15641. /**
  15642. * Set the absolute position of the bone (world space)
  15643. * @param position The position to set the bone
  15644. * @param mesh The mesh that this bone is attached to
  15645. */
  15646. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15647. /**
  15648. * Scale the bone on the x, y and z axes (in local space)
  15649. * @param x The amount to scale the bone on the x axis
  15650. * @param y The amount to scale the bone on the y axis
  15651. * @param z The amount to scale the bone on the z axis
  15652. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15653. */
  15654. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15655. /**
  15656. * Set the bone scaling in local space
  15657. * @param scale defines the scaling vector
  15658. */
  15659. setScale(scale: Vector3): void;
  15660. /**
  15661. * Gets the current scaling in local space
  15662. * @returns the current scaling vector
  15663. */
  15664. getScale(): Vector3;
  15665. /**
  15666. * Gets the current scaling in local space and stores it in a target vector
  15667. * @param result defines the target vector
  15668. */
  15669. getScaleToRef(result: Vector3): void;
  15670. /**
  15671. * Set the yaw, pitch, and roll of the bone in local or world space
  15672. * @param yaw The rotation of the bone on the y axis
  15673. * @param pitch The rotation of the bone on the x axis
  15674. * @param roll The rotation of the bone on the z axis
  15675. * @param space The space that the axes of rotation are in
  15676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15677. */
  15678. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15679. /**
  15680. * Add a rotation to the bone on an axis in local or world space
  15681. * @param axis The axis to rotate the bone on
  15682. * @param amount The amount to rotate the bone
  15683. * @param space The space that the axis is in
  15684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15685. */
  15686. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15687. /**
  15688. * Set the rotation of the bone to a particular axis angle in local or world space
  15689. * @param axis The axis to rotate the bone on
  15690. * @param angle The angle that the bone should be rotated to
  15691. * @param space The space that the axis is in
  15692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15693. */
  15694. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15695. /**
  15696. * Set the euler rotation of the bone in local of world space
  15697. * @param rotation The euler rotation that the bone should be set to
  15698. * @param space The space that the rotation is in
  15699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15700. */
  15701. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15702. /**
  15703. * Set the quaternion rotation of the bone in local of world space
  15704. * @param quat The quaternion rotation that the bone should be set to
  15705. * @param space The space that the rotation is in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. */
  15708. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15709. /**
  15710. * Set the rotation matrix of the bone in local of world space
  15711. * @param rotMat The rotation matrix that the bone should be set to
  15712. * @param space The space that the rotation is in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. */
  15715. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15716. private _rotateWithMatrix;
  15717. private _getNegativeRotationToRef;
  15718. /**
  15719. * Get the position of the bone in local or world space
  15720. * @param space The space that the returned position is in
  15721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15722. * @returns The position of the bone
  15723. */
  15724. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15725. /**
  15726. * Copy the position of the bone to a vector3 in local or world space
  15727. * @param space The space that the returned position is in
  15728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15729. * @param result The vector3 to copy the position to
  15730. */
  15731. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15732. /**
  15733. * Get the absolute position of the bone (world space)
  15734. * @param mesh The mesh that this bone is attached to
  15735. * @returns The absolute position of the bone
  15736. */
  15737. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15738. /**
  15739. * Copy the absolute position of the bone (world space) to the result param
  15740. * @param mesh The mesh that this bone is attached to
  15741. * @param result The vector3 to copy the absolute position to
  15742. */
  15743. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15744. /**
  15745. * Compute the absolute transforms of this bone and its children
  15746. */
  15747. computeAbsoluteTransforms(): void;
  15748. /**
  15749. * Get the world direction from an axis that is in the local space of the bone
  15750. * @param localAxis The local direction that is used to compute the world direction
  15751. * @param mesh The mesh that this bone is attached to
  15752. * @returns The world direction
  15753. */
  15754. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15755. /**
  15756. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15757. * @param localAxis The local direction that is used to compute the world direction
  15758. * @param mesh The mesh that this bone is attached to
  15759. * @param result The vector3 that the world direction will be copied to
  15760. */
  15761. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15762. /**
  15763. * Get the euler rotation of the bone in local or world space
  15764. * @param space The space that the rotation should be in
  15765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15766. * @returns The euler rotation
  15767. */
  15768. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15769. /**
  15770. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15771. * @param space The space that the rotation should be in
  15772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15773. * @param result The vector3 that the rotation should be copied to
  15774. */
  15775. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15776. /**
  15777. * Get the quaternion rotation of the bone in either local or world space
  15778. * @param space The space that the rotation should be in
  15779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15780. * @returns The quaternion rotation
  15781. */
  15782. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15783. /**
  15784. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15785. * @param space The space that the rotation should be in
  15786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15787. * @param result The quaternion that the rotation should be copied to
  15788. */
  15789. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15790. /**
  15791. * Get the rotation matrix of the bone in local or world space
  15792. * @param space The space that the rotation should be in
  15793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15794. * @returns The rotation matrix
  15795. */
  15796. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15797. /**
  15798. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15799. * @param space The space that the rotation should be in
  15800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15801. * @param result The quaternion that the rotation should be copied to
  15802. */
  15803. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15804. /**
  15805. * Get the world position of a point that is in the local space of the bone
  15806. * @param position The local position
  15807. * @param mesh The mesh that this bone is attached to
  15808. * @returns The world position
  15809. */
  15810. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15811. /**
  15812. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15813. * @param position The local position
  15814. * @param mesh The mesh that this bone is attached to
  15815. * @param result The vector3 that the world position should be copied to
  15816. */
  15817. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15818. /**
  15819. * Get the local position of a point that is in world space
  15820. * @param position The world position
  15821. * @param mesh The mesh that this bone is attached to
  15822. * @returns The local position
  15823. */
  15824. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15825. /**
  15826. * Get the local position of a point that is in world space and copy it to the result param
  15827. * @param position The world position
  15828. * @param mesh The mesh that this bone is attached to
  15829. * @param result The vector3 that the local position should be copied to
  15830. */
  15831. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15832. }
  15833. }
  15834. declare module "babylonjs/Animations/runtimeAnimation" {
  15835. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15836. import { Animatable } from "babylonjs/Animations/animatable";
  15837. import { Scene } from "babylonjs/scene";
  15838. /**
  15839. * Defines a runtime animation
  15840. */
  15841. export class RuntimeAnimation {
  15842. private _events;
  15843. /**
  15844. * The current frame of the runtime animation
  15845. */
  15846. private _currentFrame;
  15847. /**
  15848. * The animation used by the runtime animation
  15849. */
  15850. private _animation;
  15851. /**
  15852. * The target of the runtime animation
  15853. */
  15854. private _target;
  15855. /**
  15856. * The initiating animatable
  15857. */
  15858. private _host;
  15859. /**
  15860. * The original value of the runtime animation
  15861. */
  15862. private _originalValue;
  15863. /**
  15864. * The original blend value of the runtime animation
  15865. */
  15866. private _originalBlendValue;
  15867. /**
  15868. * The offsets cache of the runtime animation
  15869. */
  15870. private _offsetsCache;
  15871. /**
  15872. * The high limits cache of the runtime animation
  15873. */
  15874. private _highLimitsCache;
  15875. /**
  15876. * Specifies if the runtime animation has been stopped
  15877. */
  15878. private _stopped;
  15879. /**
  15880. * The blending factor of the runtime animation
  15881. */
  15882. private _blendingFactor;
  15883. /**
  15884. * The BabylonJS scene
  15885. */
  15886. private _scene;
  15887. /**
  15888. * The current value of the runtime animation
  15889. */
  15890. private _currentValue;
  15891. /** @hidden */
  15892. _animationState: _IAnimationState;
  15893. /**
  15894. * The active target of the runtime animation
  15895. */
  15896. private _activeTargets;
  15897. private _currentActiveTarget;
  15898. private _directTarget;
  15899. /**
  15900. * The target path of the runtime animation
  15901. */
  15902. private _targetPath;
  15903. /**
  15904. * The weight of the runtime animation
  15905. */
  15906. private _weight;
  15907. /**
  15908. * The ratio offset of the runtime animation
  15909. */
  15910. private _ratioOffset;
  15911. /**
  15912. * The previous delay of the runtime animation
  15913. */
  15914. private _previousDelay;
  15915. /**
  15916. * The previous ratio of the runtime animation
  15917. */
  15918. private _previousRatio;
  15919. private _enableBlending;
  15920. private _keys;
  15921. private _minFrame;
  15922. private _maxFrame;
  15923. private _minValue;
  15924. private _maxValue;
  15925. private _targetIsArray;
  15926. /**
  15927. * Gets the current frame of the runtime animation
  15928. */
  15929. get currentFrame(): number;
  15930. /**
  15931. * Gets the weight of the runtime animation
  15932. */
  15933. get weight(): number;
  15934. /**
  15935. * Gets the current value of the runtime animation
  15936. */
  15937. get currentValue(): any;
  15938. /**
  15939. * Gets the target path of the runtime animation
  15940. */
  15941. get targetPath(): string;
  15942. /**
  15943. * Gets the actual target of the runtime animation
  15944. */
  15945. get target(): any;
  15946. /**
  15947. * Gets the additive state of the runtime animation
  15948. */
  15949. get isAdditive(): boolean;
  15950. /** @hidden */
  15951. _onLoop: () => void;
  15952. /**
  15953. * Create a new RuntimeAnimation object
  15954. * @param target defines the target of the animation
  15955. * @param animation defines the source animation object
  15956. * @param scene defines the hosting scene
  15957. * @param host defines the initiating Animatable
  15958. */
  15959. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15960. private _preparePath;
  15961. /**
  15962. * Gets the animation from the runtime animation
  15963. */
  15964. get animation(): Animation;
  15965. /**
  15966. * Resets the runtime animation to the beginning
  15967. * @param restoreOriginal defines whether to restore the target property to the original value
  15968. */
  15969. reset(restoreOriginal?: boolean): void;
  15970. /**
  15971. * Specifies if the runtime animation is stopped
  15972. * @returns Boolean specifying if the runtime animation is stopped
  15973. */
  15974. isStopped(): boolean;
  15975. /**
  15976. * Disposes of the runtime animation
  15977. */
  15978. dispose(): void;
  15979. /**
  15980. * Apply the interpolated value to the target
  15981. * @param currentValue defines the value computed by the animation
  15982. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15983. */
  15984. setValue(currentValue: any, weight: number): void;
  15985. private _getOriginalValues;
  15986. private _setValue;
  15987. /**
  15988. * Gets the loop pmode of the runtime animation
  15989. * @returns Loop Mode
  15990. */
  15991. private _getCorrectLoopMode;
  15992. /**
  15993. * Move the current animation to a given frame
  15994. * @param frame defines the frame to move to
  15995. */
  15996. goToFrame(frame: number): void;
  15997. /**
  15998. * @hidden Internal use only
  15999. */
  16000. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16001. /**
  16002. * Execute the current animation
  16003. * @param delay defines the delay to add to the current frame
  16004. * @param from defines the lower bound of the animation range
  16005. * @param to defines the upper bound of the animation range
  16006. * @param loop defines if the current animation must loop
  16007. * @param speedRatio defines the current speed ratio
  16008. * @param weight defines the weight of the animation (default is -1 so no weight)
  16009. * @param onLoop optional callback called when animation loops
  16010. * @returns a boolean indicating if the animation is running
  16011. */
  16012. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16013. }
  16014. }
  16015. declare module "babylonjs/Animations/animatable" {
  16016. import { Animation } from "babylonjs/Animations/animation";
  16017. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16018. import { Nullable } from "babylonjs/types";
  16019. import { Observable } from "babylonjs/Misc/observable";
  16020. import { Scene } from "babylonjs/scene";
  16021. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16022. import { Node } from "babylonjs/node";
  16023. /**
  16024. * Class used to store an actual running animation
  16025. */
  16026. export class Animatable {
  16027. /** defines the target object */
  16028. target: any;
  16029. /** defines the starting frame number (default is 0) */
  16030. fromFrame: number;
  16031. /** defines the ending frame number (default is 100) */
  16032. toFrame: number;
  16033. /** defines if the animation must loop (default is false) */
  16034. loopAnimation: boolean;
  16035. /** defines a callback to call when animation ends if it is not looping */
  16036. onAnimationEnd?: (() => void) | null | undefined;
  16037. /** defines a callback to call when animation loops */
  16038. onAnimationLoop?: (() => void) | null | undefined;
  16039. /** defines whether the animation should be evaluated additively */
  16040. isAdditive: boolean;
  16041. private _localDelayOffset;
  16042. private _pausedDelay;
  16043. private _runtimeAnimations;
  16044. private _paused;
  16045. private _scene;
  16046. private _speedRatio;
  16047. private _weight;
  16048. private _syncRoot;
  16049. /**
  16050. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16051. * This will only apply for non looping animation (default is true)
  16052. */
  16053. disposeOnEnd: boolean;
  16054. /**
  16055. * Gets a boolean indicating if the animation has started
  16056. */
  16057. animationStarted: boolean;
  16058. /**
  16059. * Observer raised when the animation ends
  16060. */
  16061. onAnimationEndObservable: Observable<Animatable>;
  16062. /**
  16063. * Observer raised when the animation loops
  16064. */
  16065. onAnimationLoopObservable: Observable<Animatable>;
  16066. /**
  16067. * Gets the root Animatable used to synchronize and normalize animations
  16068. */
  16069. get syncRoot(): Nullable<Animatable>;
  16070. /**
  16071. * Gets the current frame of the first RuntimeAnimation
  16072. * Used to synchronize Animatables
  16073. */
  16074. get masterFrame(): number;
  16075. /**
  16076. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16077. */
  16078. get weight(): number;
  16079. set weight(value: number);
  16080. /**
  16081. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16082. */
  16083. get speedRatio(): number;
  16084. set speedRatio(value: number);
  16085. /**
  16086. * Creates a new Animatable
  16087. * @param scene defines the hosting scene
  16088. * @param target defines the target object
  16089. * @param fromFrame defines the starting frame number (default is 0)
  16090. * @param toFrame defines the ending frame number (default is 100)
  16091. * @param loopAnimation defines if the animation must loop (default is false)
  16092. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16093. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16094. * @param animations defines a group of animation to add to the new Animatable
  16095. * @param onAnimationLoop defines a callback to call when animation loops
  16096. * @param isAdditive defines whether the animation should be evaluated additively
  16097. */
  16098. constructor(scene: Scene,
  16099. /** defines the target object */
  16100. target: any,
  16101. /** defines the starting frame number (default is 0) */
  16102. fromFrame?: number,
  16103. /** defines the ending frame number (default is 100) */
  16104. toFrame?: number,
  16105. /** defines if the animation must loop (default is false) */
  16106. loopAnimation?: boolean, speedRatio?: number,
  16107. /** defines a callback to call when animation ends if it is not looping */
  16108. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16109. /** defines a callback to call when animation loops */
  16110. onAnimationLoop?: (() => void) | null | undefined,
  16111. /** defines whether the animation should be evaluated additively */
  16112. isAdditive?: boolean);
  16113. /**
  16114. * Synchronize and normalize current Animatable with a source Animatable
  16115. * This is useful when using animation weights and when animations are not of the same length
  16116. * @param root defines the root Animatable to synchronize with
  16117. * @returns the current Animatable
  16118. */
  16119. syncWith(root: Animatable): Animatable;
  16120. /**
  16121. * Gets the list of runtime animations
  16122. * @returns an array of RuntimeAnimation
  16123. */
  16124. getAnimations(): RuntimeAnimation[];
  16125. /**
  16126. * Adds more animations to the current animatable
  16127. * @param target defines the target of the animations
  16128. * @param animations defines the new animations to add
  16129. */
  16130. appendAnimations(target: any, animations: Animation[]): void;
  16131. /**
  16132. * Gets the source animation for a specific property
  16133. * @param property defines the propertyu to look for
  16134. * @returns null or the source animation for the given property
  16135. */
  16136. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16137. /**
  16138. * Gets the runtime animation for a specific property
  16139. * @param property defines the propertyu to look for
  16140. * @returns null or the runtime animation for the given property
  16141. */
  16142. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16143. /**
  16144. * Resets the animatable to its original state
  16145. */
  16146. reset(): void;
  16147. /**
  16148. * Allows the animatable to blend with current running animations
  16149. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16150. * @param blendingSpeed defines the blending speed to use
  16151. */
  16152. enableBlending(blendingSpeed: number): void;
  16153. /**
  16154. * Disable animation blending
  16155. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16156. */
  16157. disableBlending(): void;
  16158. /**
  16159. * Jump directly to a given frame
  16160. * @param frame defines the frame to jump to
  16161. */
  16162. goToFrame(frame: number): void;
  16163. /**
  16164. * Pause the animation
  16165. */
  16166. pause(): void;
  16167. /**
  16168. * Restart the animation
  16169. */
  16170. restart(): void;
  16171. private _raiseOnAnimationEnd;
  16172. /**
  16173. * Stop and delete the current animation
  16174. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16175. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  16176. */
  16177. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16178. /**
  16179. * Wait asynchronously for the animation to end
  16180. * @returns a promise which will be fullfilled when the animation ends
  16181. */
  16182. waitAsync(): Promise<Animatable>;
  16183. /** @hidden */
  16184. _animate(delay: number): boolean;
  16185. }
  16186. module "babylonjs/scene" {
  16187. interface Scene {
  16188. /** @hidden */
  16189. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16190. /** @hidden */
  16191. _processLateAnimationBindingsForMatrices(holder: {
  16192. totalWeight: number;
  16193. totalAdditiveWeight: number;
  16194. animations: RuntimeAnimation[];
  16195. additiveAnimations: RuntimeAnimation[];
  16196. originalValue: Matrix;
  16197. }): any;
  16198. /** @hidden */
  16199. _processLateAnimationBindingsForQuaternions(holder: {
  16200. totalWeight: number;
  16201. totalAdditiveWeight: number;
  16202. animations: RuntimeAnimation[];
  16203. additiveAnimations: RuntimeAnimation[];
  16204. originalValue: Quaternion;
  16205. }, refQuaternion: Quaternion): Quaternion;
  16206. /** @hidden */
  16207. _processLateAnimationBindings(): void;
  16208. /**
  16209. * Will start the animation sequence of a given target
  16210. * @param target defines the target
  16211. * @param from defines from which frame should animation start
  16212. * @param to defines until which frame should animation run.
  16213. * @param weight defines the weight to apply to the animation (1.0 by default)
  16214. * @param loop defines if the animation loops
  16215. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16216. * @param onAnimationEnd defines the function to be executed when the animation ends
  16217. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16218. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16219. * @param onAnimationLoop defines the callback to call when an animation loops
  16220. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16221. * @returns the animatable object created for this animation
  16222. */
  16223. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16224. /**
  16225. * Will start the animation sequence of a given target
  16226. * @param target defines the target
  16227. * @param from defines from which frame should animation start
  16228. * @param to defines until which frame should animation run.
  16229. * @param loop defines if the animation loops
  16230. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16231. * @param onAnimationEnd defines the function to be executed when the animation ends
  16232. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16233. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16234. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16235. * @param onAnimationLoop defines the callback to call when an animation loops
  16236. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16237. * @returns the animatable object created for this animation
  16238. */
  16239. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16240. /**
  16241. * Will start the animation sequence of a given target and its hierarchy
  16242. * @param target defines the target
  16243. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16244. * @param from defines from which frame should animation start
  16245. * @param to defines until which frame should animation run.
  16246. * @param loop defines if the animation loops
  16247. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16248. * @param onAnimationEnd defines the function to be executed when the animation ends
  16249. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16250. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16251. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16252. * @param onAnimationLoop defines the callback to call when an animation loops
  16253. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16254. * @returns the list of created animatables
  16255. */
  16256. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16257. /**
  16258. * Begin a new animation on a given node
  16259. * @param target defines the target where the animation will take place
  16260. * @param animations defines the list of animations to start
  16261. * @param from defines the initial value
  16262. * @param to defines the final value
  16263. * @param loop defines if you want animation to loop (off by default)
  16264. * @param speedRatio defines the speed ratio to apply to all animations
  16265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16266. * @param onAnimationLoop defines the callback to call when an animation loops
  16267. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16268. * @returns the list of created animatables
  16269. */
  16270. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16271. /**
  16272. * Begin a new animation on a given node and its hierarchy
  16273. * @param target defines the root node where the animation will take place
  16274. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  16275. * @param animations defines the list of animations to start
  16276. * @param from defines the initial value
  16277. * @param to defines the final value
  16278. * @param loop defines if you want animation to loop (off by default)
  16279. * @param speedRatio defines the speed ratio to apply to all animations
  16280. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16281. * @param onAnimationLoop defines the callback to call when an animation loops
  16282. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16283. * @returns the list of animatables created for all nodes
  16284. */
  16285. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16286. /**
  16287. * Gets the animatable associated with a specific target
  16288. * @param target defines the target of the animatable
  16289. * @returns the required animatable if found
  16290. */
  16291. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16292. /**
  16293. * Gets all animatables associated with a given target
  16294. * @param target defines the target to look animatables for
  16295. * @returns an array of Animatables
  16296. */
  16297. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16298. /**
  16299. * Stops and removes all animations that have been applied to the scene
  16300. */
  16301. stopAllAnimations(): void;
  16302. /**
  16303. * Gets the current delta time used by animation engine
  16304. */
  16305. deltaTime: number;
  16306. }
  16307. }
  16308. module "babylonjs/Bones/bone" {
  16309. interface Bone {
  16310. /**
  16311. * Copy an animation range from another bone
  16312. * @param source defines the source bone
  16313. * @param rangeName defines the range name to copy
  16314. * @param frameOffset defines the frame offset
  16315. * @param rescaleAsRequired defines if rescaling must be applied if required
  16316. * @param skelDimensionsRatio defines the scaling ratio
  16317. * @returns true if operation was successful
  16318. */
  16319. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16320. }
  16321. }
  16322. }
  16323. declare module "babylonjs/Bones/skeleton" {
  16324. import { Bone } from "babylonjs/Bones/bone";
  16325. import { Observable } from "babylonjs/Misc/observable";
  16326. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16327. import { Scene } from "babylonjs/scene";
  16328. import { Nullable } from "babylonjs/types";
  16329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16330. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16331. import { Animatable } from "babylonjs/Animations/animatable";
  16332. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16333. import { Animation } from "babylonjs/Animations/animation";
  16334. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16335. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16337. /**
  16338. * Class used to handle skinning animations
  16339. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16340. */
  16341. export class Skeleton implements IAnimatable {
  16342. /** defines the skeleton name */
  16343. name: string;
  16344. /** defines the skeleton Id */
  16345. id: string;
  16346. /**
  16347. * Defines the list of child bones
  16348. */
  16349. bones: Bone[];
  16350. /**
  16351. * Defines an estimate of the dimension of the skeleton at rest
  16352. */
  16353. dimensionsAtRest: Vector3;
  16354. /**
  16355. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16356. */
  16357. needInitialSkinMatrix: boolean;
  16358. /**
  16359. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16360. */
  16361. overrideMesh: Nullable<AbstractMesh>;
  16362. /**
  16363. * Gets the list of animations attached to this skeleton
  16364. */
  16365. animations: Array<Animation>;
  16366. private _scene;
  16367. private _isDirty;
  16368. private _transformMatrices;
  16369. private _transformMatrixTexture;
  16370. private _meshesWithPoseMatrix;
  16371. private _animatables;
  16372. private _identity;
  16373. private _synchronizedWithMesh;
  16374. private _ranges;
  16375. private _lastAbsoluteTransformsUpdateId;
  16376. private _canUseTextureForBones;
  16377. private _uniqueId;
  16378. /** @hidden */
  16379. _numBonesWithLinkedTransformNode: number;
  16380. /** @hidden */
  16381. _hasWaitingData: Nullable<boolean>;
  16382. /**
  16383. * Specifies if the skeleton should be serialized
  16384. */
  16385. doNotSerialize: boolean;
  16386. private _useTextureToStoreBoneMatrices;
  16387. /**
  16388. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16389. * Please note that this option is not available if the hardware does not support it
  16390. */
  16391. get useTextureToStoreBoneMatrices(): boolean;
  16392. set useTextureToStoreBoneMatrices(value: boolean);
  16393. private _animationPropertiesOverride;
  16394. /**
  16395. * Gets or sets the animation properties override
  16396. */
  16397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16398. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16399. /**
  16400. * List of inspectable custom properties (used by the Inspector)
  16401. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16402. */
  16403. inspectableCustomProperties: IInspectable[];
  16404. /**
  16405. * An observable triggered before computing the skeleton's matrices
  16406. */
  16407. onBeforeComputeObservable: Observable<Skeleton>;
  16408. /**
  16409. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16410. */
  16411. get isUsingTextureForMatrices(): boolean;
  16412. /**
  16413. * Gets the unique ID of this skeleton
  16414. */
  16415. get uniqueId(): number;
  16416. /**
  16417. * Creates a new skeleton
  16418. * @param name defines the skeleton name
  16419. * @param id defines the skeleton Id
  16420. * @param scene defines the hosting scene
  16421. */
  16422. constructor(
  16423. /** defines the skeleton name */
  16424. name: string,
  16425. /** defines the skeleton Id */
  16426. id: string, scene: Scene);
  16427. /**
  16428. * Gets the current object class name.
  16429. * @return the class name
  16430. */
  16431. getClassName(): string;
  16432. /**
  16433. * Returns an array containing the root bones
  16434. * @returns an array containing the root bones
  16435. */
  16436. getChildren(): Array<Bone>;
  16437. /**
  16438. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16439. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16440. * @returns a Float32Array containing matrices data
  16441. */
  16442. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16443. /**
  16444. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16445. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16446. * @returns a raw texture containing the data
  16447. */
  16448. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16449. /**
  16450. * Gets the current hosting scene
  16451. * @returns a scene object
  16452. */
  16453. getScene(): Scene;
  16454. /**
  16455. * Gets a string representing the current skeleton data
  16456. * @param fullDetails defines a boolean indicating if we want a verbose version
  16457. * @returns a string representing the current skeleton data
  16458. */
  16459. toString(fullDetails?: boolean): string;
  16460. /**
  16461. * Get bone's index searching by name
  16462. * @param name defines bone's name to search for
  16463. * @return the indice of the bone. Returns -1 if not found
  16464. */
  16465. getBoneIndexByName(name: string): number;
  16466. /**
  16467. * Creater a new animation range
  16468. * @param name defines the name of the range
  16469. * @param from defines the start key
  16470. * @param to defines the end key
  16471. */
  16472. createAnimationRange(name: string, from: number, to: number): void;
  16473. /**
  16474. * Delete a specific animation range
  16475. * @param name defines the name of the range
  16476. * @param deleteFrames defines if frames must be removed as well
  16477. */
  16478. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16479. /**
  16480. * Gets a specific animation range
  16481. * @param name defines the name of the range to look for
  16482. * @returns the requested animation range or null if not found
  16483. */
  16484. getAnimationRange(name: string): Nullable<AnimationRange>;
  16485. /**
  16486. * Gets the list of all animation ranges defined on this skeleton
  16487. * @returns an array
  16488. */
  16489. getAnimationRanges(): Nullable<AnimationRange>[];
  16490. /**
  16491. * Copy animation range from a source skeleton.
  16492. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16493. * @param source defines the source skeleton
  16494. * @param name defines the name of the range to copy
  16495. * @param rescaleAsRequired defines if rescaling must be applied if required
  16496. * @returns true if operation was successful
  16497. */
  16498. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16499. /**
  16500. * Forces the skeleton to go to rest pose
  16501. */
  16502. returnToRest(): void;
  16503. private _getHighestAnimationFrame;
  16504. /**
  16505. * Begin a specific animation range
  16506. * @param name defines the name of the range to start
  16507. * @param loop defines if looping must be turned on (false by default)
  16508. * @param speedRatio defines the speed ratio to apply (1 by default)
  16509. * @param onAnimationEnd defines a callback which will be called when animation will end
  16510. * @returns a new animatable
  16511. */
  16512. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16513. /**
  16514. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16515. * @param skeleton defines the Skeleton containing the animation range to convert
  16516. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16517. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16518. * @returns the original skeleton
  16519. */
  16520. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16521. /** @hidden */
  16522. _markAsDirty(): void;
  16523. /** @hidden */
  16524. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16525. /** @hidden */
  16526. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16527. private _computeTransformMatrices;
  16528. /**
  16529. * Build all resources required to render a skeleton
  16530. */
  16531. prepare(): void;
  16532. /**
  16533. * Gets the list of animatables currently running for this skeleton
  16534. * @returns an array of animatables
  16535. */
  16536. getAnimatables(): IAnimatable[];
  16537. /**
  16538. * Clone the current skeleton
  16539. * @param name defines the name of the new skeleton
  16540. * @param id defines the id of the new skeleton
  16541. * @returns the new skeleton
  16542. */
  16543. clone(name: string, id?: string): Skeleton;
  16544. /**
  16545. * Enable animation blending for this skeleton
  16546. * @param blendingSpeed defines the blending speed to apply
  16547. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16548. */
  16549. enableBlending(blendingSpeed?: number): void;
  16550. /**
  16551. * Releases all resources associated with the current skeleton
  16552. */
  16553. dispose(): void;
  16554. /**
  16555. * Serialize the skeleton in a JSON object
  16556. * @returns a JSON object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Creates a new skeleton from serialized data
  16561. * @param parsedSkeleton defines the serialized data
  16562. * @param scene defines the hosting scene
  16563. * @returns a new skeleton
  16564. */
  16565. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16566. /**
  16567. * Compute all node absolute transforms
  16568. * @param forceUpdate defines if computation must be done even if cache is up to date
  16569. */
  16570. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16571. /**
  16572. * Gets the root pose matrix
  16573. * @returns a matrix
  16574. */
  16575. getPoseMatrix(): Nullable<Matrix>;
  16576. /**
  16577. * Sorts bones per internal index
  16578. */
  16579. sortBones(): void;
  16580. private _sortBones;
  16581. }
  16582. }
  16583. declare module "babylonjs/Meshes/instancedMesh" {
  16584. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16585. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16586. import { Camera } from "babylonjs/Cameras/camera";
  16587. import { Node } from "babylonjs/node";
  16588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16589. import { Mesh } from "babylonjs/Meshes/mesh";
  16590. import { Material } from "babylonjs/Materials/material";
  16591. import { Skeleton } from "babylonjs/Bones/skeleton";
  16592. import { Light } from "babylonjs/Lights/light";
  16593. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16594. /**
  16595. * Creates an instance based on a source mesh.
  16596. */
  16597. export class InstancedMesh extends AbstractMesh {
  16598. private _sourceMesh;
  16599. private _currentLOD;
  16600. /** @hidden */
  16601. _indexInSourceMeshInstanceArray: number;
  16602. constructor(name: string, source: Mesh);
  16603. /**
  16604. * Returns the string "InstancedMesh".
  16605. */
  16606. getClassName(): string;
  16607. /** Gets the list of lights affecting that mesh */
  16608. get lightSources(): Light[];
  16609. _resyncLightSources(): void;
  16610. _resyncLightSource(light: Light): void;
  16611. _removeLightSource(light: Light, dispose: boolean): void;
  16612. /**
  16613. * If the source mesh receives shadows
  16614. */
  16615. get receiveShadows(): boolean;
  16616. /**
  16617. * The material of the source mesh
  16618. */
  16619. get material(): Nullable<Material>;
  16620. /**
  16621. * Visibility of the source mesh
  16622. */
  16623. get visibility(): number;
  16624. /**
  16625. * Skeleton of the source mesh
  16626. */
  16627. get skeleton(): Nullable<Skeleton>;
  16628. /**
  16629. * Rendering ground id of the source mesh
  16630. */
  16631. get renderingGroupId(): number;
  16632. set renderingGroupId(value: number);
  16633. /**
  16634. * Returns the total number of vertices (integer).
  16635. */
  16636. getTotalVertices(): number;
  16637. /**
  16638. * Returns a positive integer : the total number of indices in this mesh geometry.
  16639. * @returns the numner of indices or zero if the mesh has no geometry.
  16640. */
  16641. getTotalIndices(): number;
  16642. /**
  16643. * The source mesh of the instance
  16644. */
  16645. get sourceMesh(): Mesh;
  16646. /**
  16647. * Creates a new InstancedMesh object from the mesh model.
  16648. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16649. * @param name defines the name of the new instance
  16650. * @returns a new InstancedMesh
  16651. */
  16652. createInstance(name: string): InstancedMesh;
  16653. /**
  16654. * Is this node ready to be used/rendered
  16655. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16656. * @return {boolean} is it ready
  16657. */
  16658. isReady(completeCheck?: boolean): boolean;
  16659. /**
  16660. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16661. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16662. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16663. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16664. */
  16665. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16666. /**
  16667. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16668. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16669. * The `data` are either a numeric array either a Float32Array.
  16670. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16671. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16672. * Note that a new underlying VertexBuffer object is created each call.
  16673. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16674. *
  16675. * Possible `kind` values :
  16676. * - VertexBuffer.PositionKind
  16677. * - VertexBuffer.UVKind
  16678. * - VertexBuffer.UV2Kind
  16679. * - VertexBuffer.UV3Kind
  16680. * - VertexBuffer.UV4Kind
  16681. * - VertexBuffer.UV5Kind
  16682. * - VertexBuffer.UV6Kind
  16683. * - VertexBuffer.ColorKind
  16684. * - VertexBuffer.MatricesIndicesKind
  16685. * - VertexBuffer.MatricesIndicesExtraKind
  16686. * - VertexBuffer.MatricesWeightsKind
  16687. * - VertexBuffer.MatricesWeightsExtraKind
  16688. *
  16689. * Returns the Mesh.
  16690. */
  16691. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16692. /**
  16693. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16694. * If the mesh has no geometry, it is simply returned as it is.
  16695. * The `data` are either a numeric array either a Float32Array.
  16696. * No new underlying VertexBuffer object is created.
  16697. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16698. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16699. *
  16700. * Possible `kind` values :
  16701. * - VertexBuffer.PositionKind
  16702. * - VertexBuffer.UVKind
  16703. * - VertexBuffer.UV2Kind
  16704. * - VertexBuffer.UV3Kind
  16705. * - VertexBuffer.UV4Kind
  16706. * - VertexBuffer.UV5Kind
  16707. * - VertexBuffer.UV6Kind
  16708. * - VertexBuffer.ColorKind
  16709. * - VertexBuffer.MatricesIndicesKind
  16710. * - VertexBuffer.MatricesIndicesExtraKind
  16711. * - VertexBuffer.MatricesWeightsKind
  16712. * - VertexBuffer.MatricesWeightsExtraKind
  16713. *
  16714. * Returns the Mesh.
  16715. */
  16716. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16717. /**
  16718. * Sets the mesh indices.
  16719. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16720. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16721. * This method creates a new index buffer each call.
  16722. * Returns the Mesh.
  16723. */
  16724. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16725. /**
  16726. * Boolean : True if the mesh owns the requested kind of data.
  16727. */
  16728. isVerticesDataPresent(kind: string): boolean;
  16729. /**
  16730. * Returns an array of indices (IndicesArray).
  16731. */
  16732. getIndices(): Nullable<IndicesArray>;
  16733. get _positions(): Nullable<Vector3[]>;
  16734. /**
  16735. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16736. * This means the mesh underlying bounding box and sphere are recomputed.
  16737. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16738. * @returns the current mesh
  16739. */
  16740. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16741. /** @hidden */
  16742. _preActivate(): InstancedMesh;
  16743. /** @hidden */
  16744. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16745. /** @hidden */
  16746. _postActivate(): void;
  16747. getWorldMatrix(): Matrix;
  16748. get isAnInstance(): boolean;
  16749. /**
  16750. * Returns the current associated LOD AbstractMesh.
  16751. */
  16752. getLOD(camera: Camera): AbstractMesh;
  16753. /** @hidden */
  16754. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16755. /** @hidden */
  16756. _syncSubMeshes(): InstancedMesh;
  16757. /** @hidden */
  16758. _generatePointsArray(): boolean;
  16759. /** @hidden */
  16760. _updateBoundingInfo(): AbstractMesh;
  16761. /**
  16762. * Creates a new InstancedMesh from the current mesh.
  16763. * - name (string) : the cloned mesh name
  16764. * - newParent (optional Node) : the optional Node to parent the clone to.
  16765. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16766. *
  16767. * Returns the clone.
  16768. */
  16769. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16770. /**
  16771. * Disposes the InstancedMesh.
  16772. * Returns nothing.
  16773. */
  16774. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16775. }
  16776. module "babylonjs/Meshes/mesh" {
  16777. interface Mesh {
  16778. /**
  16779. * Register a custom buffer that will be instanced
  16780. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16781. * @param kind defines the buffer kind
  16782. * @param stride defines the stride in floats
  16783. */
  16784. registerInstancedBuffer(kind: string, stride: number): void;
  16785. /**
  16786. * true to use the edge renderer for all instances of this mesh
  16787. */
  16788. edgesShareWithInstances: boolean;
  16789. /** @hidden */
  16790. _userInstancedBuffersStorage: {
  16791. data: {
  16792. [key: string]: Float32Array;
  16793. };
  16794. sizes: {
  16795. [key: string]: number;
  16796. };
  16797. vertexBuffers: {
  16798. [key: string]: Nullable<VertexBuffer>;
  16799. };
  16800. strides: {
  16801. [key: string]: number;
  16802. };
  16803. };
  16804. }
  16805. }
  16806. module "babylonjs/Meshes/abstractMesh" {
  16807. interface AbstractMesh {
  16808. /**
  16809. * Object used to store instanced buffers defined by user
  16810. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16811. */
  16812. instancedBuffers: {
  16813. [key: string]: any;
  16814. };
  16815. }
  16816. }
  16817. }
  16818. declare module "babylonjs/Materials/shaderMaterial" {
  16819. import { Nullable } from "babylonjs/types";
  16820. import { Scene } from "babylonjs/scene";
  16821. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16823. import { Mesh } from "babylonjs/Meshes/mesh";
  16824. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16826. import { Effect } from "babylonjs/Materials/effect";
  16827. import { Material } from "babylonjs/Materials/material";
  16828. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16829. /**
  16830. * Defines the options associated with the creation of a shader material.
  16831. */
  16832. export interface IShaderMaterialOptions {
  16833. /**
  16834. * Does the material work in alpha blend mode
  16835. */
  16836. needAlphaBlending: boolean;
  16837. /**
  16838. * Does the material work in alpha test mode
  16839. */
  16840. needAlphaTesting: boolean;
  16841. /**
  16842. * The list of attribute names used in the shader
  16843. */
  16844. attributes: string[];
  16845. /**
  16846. * The list of unifrom names used in the shader
  16847. */
  16848. uniforms: string[];
  16849. /**
  16850. * The list of UBO names used in the shader
  16851. */
  16852. uniformBuffers: string[];
  16853. /**
  16854. * The list of sampler names used in the shader
  16855. */
  16856. samplers: string[];
  16857. /**
  16858. * The list of defines used in the shader
  16859. */
  16860. defines: string[];
  16861. }
  16862. /**
  16863. * 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.
  16864. *
  16865. * This returned material effects how the mesh will look based on the code in the shaders.
  16866. *
  16867. * @see https://doc.babylonjs.com/how_to/shader_material
  16868. */
  16869. export class ShaderMaterial extends Material {
  16870. private _shaderPath;
  16871. private _options;
  16872. private _textures;
  16873. private _textureArrays;
  16874. private _floats;
  16875. private _ints;
  16876. private _floatsArrays;
  16877. private _colors3;
  16878. private _colors3Arrays;
  16879. private _colors4;
  16880. private _colors4Arrays;
  16881. private _vectors2;
  16882. private _vectors3;
  16883. private _vectors4;
  16884. private _matrices;
  16885. private _matrixArrays;
  16886. private _matrices3x3;
  16887. private _matrices2x2;
  16888. private _vectors2Arrays;
  16889. private _vectors3Arrays;
  16890. private _vectors4Arrays;
  16891. private _cachedWorldViewMatrix;
  16892. private _cachedWorldViewProjectionMatrix;
  16893. private _renderId;
  16894. private _multiview;
  16895. private _cachedDefines;
  16896. /** Define the Url to load snippets */
  16897. static SnippetUrl: string;
  16898. /** Snippet ID if the material was created from the snippet server */
  16899. snippetId: string;
  16900. /**
  16901. * Instantiate a new shader material.
  16902. * 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.
  16903. * This returned material effects how the mesh will look based on the code in the shaders.
  16904. * @see https://doc.babylonjs.com/how_to/shader_material
  16905. * @param name Define the name of the material in the scene
  16906. * @param scene Define the scene the material belongs to
  16907. * @param shaderPath Defines the route to the shader code in one of three ways:
  16908. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16909. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16910. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16911. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16912. * @param options Define the options used to create the shader
  16913. */
  16914. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16915. /**
  16916. * Gets the shader path used to define the shader code
  16917. * It can be modified to trigger a new compilation
  16918. */
  16919. get shaderPath(): any;
  16920. /**
  16921. * Sets the shader path used to define the shader code
  16922. * It can be modified to trigger a new compilation
  16923. */
  16924. set shaderPath(shaderPath: any);
  16925. /**
  16926. * Gets the options used to compile the shader.
  16927. * They can be modified to trigger a new compilation
  16928. */
  16929. get options(): IShaderMaterialOptions;
  16930. /**
  16931. * Gets the current class name of the material e.g. "ShaderMaterial"
  16932. * Mainly use in serialization.
  16933. * @returns the class name
  16934. */
  16935. getClassName(): string;
  16936. /**
  16937. * Specifies if the material will require alpha blending
  16938. * @returns a boolean specifying if alpha blending is needed
  16939. */
  16940. needAlphaBlending(): boolean;
  16941. /**
  16942. * Specifies if this material should be rendered in alpha test mode
  16943. * @returns a boolean specifying if an alpha test is needed.
  16944. */
  16945. needAlphaTesting(): boolean;
  16946. private _checkUniform;
  16947. /**
  16948. * Set a texture in the shader.
  16949. * @param name Define the name of the uniform samplers as defined in the shader
  16950. * @param texture Define the texture to bind to this sampler
  16951. * @return the material itself allowing "fluent" like uniform updates
  16952. */
  16953. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16954. /**
  16955. * Set a texture array in the shader.
  16956. * @param name Define the name of the uniform sampler array as defined in the shader
  16957. * @param textures Define the list of textures to bind to this sampler
  16958. * @return the material itself allowing "fluent" like uniform updates
  16959. */
  16960. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16961. /**
  16962. * Set a float in the shader.
  16963. * @param name Define the name of the uniform as defined in the shader
  16964. * @param value Define the value to give to the uniform
  16965. * @return the material itself allowing "fluent" like uniform updates
  16966. */
  16967. setFloat(name: string, value: number): ShaderMaterial;
  16968. /**
  16969. * Set a int in the shader.
  16970. * @param name Define the name of the uniform as defined in the shader
  16971. * @param value Define the value to give to the uniform
  16972. * @return the material itself allowing "fluent" like uniform updates
  16973. */
  16974. setInt(name: string, value: number): ShaderMaterial;
  16975. /**
  16976. * Set an array of floats in the shader.
  16977. * @param name Define the name of the uniform as defined in the shader
  16978. * @param value Define the value to give to the uniform
  16979. * @return the material itself allowing "fluent" like uniform updates
  16980. */
  16981. setFloats(name: string, value: number[]): ShaderMaterial;
  16982. /**
  16983. * Set a vec3 in the shader from a Color3.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the material itself allowing "fluent" like uniform updates
  16987. */
  16988. setColor3(name: string, value: Color3): ShaderMaterial;
  16989. /**
  16990. * Set a vec3 array in the shader from a Color3 array.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the material itself allowing "fluent" like uniform updates
  16994. */
  16995. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16996. /**
  16997. * Set a vec4 in the shader from a Color4.
  16998. * @param name Define the name of the uniform as defined in the shader
  16999. * @param value Define the value to give to the uniform
  17000. * @return the material itself allowing "fluent" like uniform updates
  17001. */
  17002. setColor4(name: string, value: Color4): ShaderMaterial;
  17003. /**
  17004. * Set a vec4 array in the shader from a Color4 array.
  17005. * @param name Define the name of the uniform as defined in the shader
  17006. * @param value Define the value to give to the uniform
  17007. * @return the material itself allowing "fluent" like uniform updates
  17008. */
  17009. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17010. /**
  17011. * Set a vec2 in the shader from a Vector2.
  17012. * @param name Define the name of the uniform as defined in the shader
  17013. * @param value Define the value to give to the uniform
  17014. * @return the material itself allowing "fluent" like uniform updates
  17015. */
  17016. setVector2(name: string, value: Vector2): ShaderMaterial;
  17017. /**
  17018. * Set a vec3 in the shader from a Vector3.
  17019. * @param name Define the name of the uniform as defined in the shader
  17020. * @param value Define the value to give to the uniform
  17021. * @return the material itself allowing "fluent" like uniform updates
  17022. */
  17023. setVector3(name: string, value: Vector3): ShaderMaterial;
  17024. /**
  17025. * Set a vec4 in the shader from a Vector4.
  17026. * @param name Define the name of the uniform as defined in the shader
  17027. * @param value Define the value to give to the uniform
  17028. * @return the material itself allowing "fluent" like uniform updates
  17029. */
  17030. setVector4(name: string, value: Vector4): ShaderMaterial;
  17031. /**
  17032. * Set a mat4 in the shader from a Matrix.
  17033. * @param name Define the name of the uniform as defined in the shader
  17034. * @param value Define the value to give to the uniform
  17035. * @return the material itself allowing "fluent" like uniform updates
  17036. */
  17037. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17038. /**
  17039. * Set a float32Array in the shader from a matrix array.
  17040. * @param name Define the name of the uniform as defined in the shader
  17041. * @param value Define the value to give to the uniform
  17042. * @return the material itself allowing "fluent" like uniform updates
  17043. */
  17044. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17045. /**
  17046. * Set a mat3 in the shader from a Float32Array.
  17047. * @param name Define the name of the uniform as defined in the shader
  17048. * @param value Define the value to give to the uniform
  17049. * @return the material itself allowing "fluent" like uniform updates
  17050. */
  17051. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17052. /**
  17053. * Set a mat2 in the shader from a Float32Array.
  17054. * @param name Define the name of the uniform as defined in the shader
  17055. * @param value Define the value to give to the uniform
  17056. * @return the material itself allowing "fluent" like uniform updates
  17057. */
  17058. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17059. /**
  17060. * Set a vec2 array in the shader from a number array.
  17061. * @param name Define the name of the uniform as defined in the shader
  17062. * @param value Define the value to give to the uniform
  17063. * @return the material itself allowing "fluent" like uniform updates
  17064. */
  17065. setArray2(name: string, value: number[]): ShaderMaterial;
  17066. /**
  17067. * Set a vec3 array in the shader from a number array.
  17068. * @param name Define the name of the uniform as defined in the shader
  17069. * @param value Define the value to give to the uniform
  17070. * @return the material itself allowing "fluent" like uniform updates
  17071. */
  17072. setArray3(name: string, value: number[]): ShaderMaterial;
  17073. /**
  17074. * Set a vec4 array in the shader from a number array.
  17075. * @param name Define the name of the uniform as defined in the shader
  17076. * @param value Define the value to give to the uniform
  17077. * @return the material itself allowing "fluent" like uniform updates
  17078. */
  17079. setArray4(name: string, value: number[]): ShaderMaterial;
  17080. private _checkCache;
  17081. /**
  17082. * Specifies that the submesh is ready to be used
  17083. * @param mesh defines the mesh to check
  17084. * @param subMesh defines which submesh to check
  17085. * @param useInstances specifies that instances should be used
  17086. * @returns a boolean indicating that the submesh is ready or not
  17087. */
  17088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17089. /**
  17090. * Checks if the material is ready to render the requested mesh
  17091. * @param mesh Define the mesh to render
  17092. * @param useInstances Define whether or not the material is used with instances
  17093. * @returns true if ready, otherwise false
  17094. */
  17095. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17096. /**
  17097. * Binds the world matrix to the material
  17098. * @param world defines the world transformation matrix
  17099. * @param effectOverride - If provided, use this effect instead of internal effect
  17100. */
  17101. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17102. /**
  17103. * Binds the submesh to this material by preparing the effect and shader to draw
  17104. * @param world defines the world transformation matrix
  17105. * @param mesh defines the mesh containing the submesh
  17106. * @param subMesh defines the submesh to bind the material to
  17107. */
  17108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17109. /**
  17110. * Binds the material to the mesh
  17111. * @param world defines the world transformation matrix
  17112. * @param mesh defines the mesh to bind the material to
  17113. * @param effectOverride - If provided, use this effect instead of internal effect
  17114. */
  17115. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17116. protected _afterBind(mesh?: Mesh): void;
  17117. /**
  17118. * Gets the active textures from the material
  17119. * @returns an array of textures
  17120. */
  17121. getActiveTextures(): BaseTexture[];
  17122. /**
  17123. * Specifies if the material uses a texture
  17124. * @param texture defines the texture to check against the material
  17125. * @returns a boolean specifying if the material uses the texture
  17126. */
  17127. hasTexture(texture: BaseTexture): boolean;
  17128. /**
  17129. * Makes a duplicate of the material, and gives it a new name
  17130. * @param name defines the new name for the duplicated material
  17131. * @returns the cloned material
  17132. */
  17133. clone(name: string): ShaderMaterial;
  17134. /**
  17135. * Disposes the material
  17136. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17137. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17138. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17139. */
  17140. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17141. /**
  17142. * Serializes this material in a JSON representation
  17143. * @returns the serialized material object
  17144. */
  17145. serialize(): any;
  17146. /**
  17147. * Creates a shader material from parsed shader material data
  17148. * @param source defines the JSON represnetation of the material
  17149. * @param scene defines the hosting scene
  17150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17151. * @returns a new material
  17152. */
  17153. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17154. /**
  17155. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17156. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17157. * @param url defines the url to load from
  17158. * @param scene defines the hosting scene
  17159. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17160. * @returns a promise that will resolve to the new ShaderMaterial
  17161. */
  17162. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17163. /**
  17164. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17165. * @param snippetId defines the snippet to load
  17166. * @param scene defines the hosting scene
  17167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17168. * @returns a promise that will resolve to the new ShaderMaterial
  17169. */
  17170. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17171. }
  17172. }
  17173. declare module "babylonjs/Shaders/color.fragment" {
  17174. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17175. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17176. /** @hidden */
  17177. export var colorPixelShader: {
  17178. name: string;
  17179. shader: string;
  17180. };
  17181. }
  17182. declare module "babylonjs/Shaders/color.vertex" {
  17183. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17184. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17186. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17187. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17188. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17189. /** @hidden */
  17190. export var colorVertexShader: {
  17191. name: string;
  17192. shader: string;
  17193. };
  17194. }
  17195. declare module "babylonjs/Meshes/linesMesh" {
  17196. import { Nullable } from "babylonjs/types";
  17197. import { Scene } from "babylonjs/scene";
  17198. import { Color3 } from "babylonjs/Maths/math.color";
  17199. import { Node } from "babylonjs/node";
  17200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17201. import { Mesh } from "babylonjs/Meshes/mesh";
  17202. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17203. import { Effect } from "babylonjs/Materials/effect";
  17204. import { Material } from "babylonjs/Materials/material";
  17205. import "babylonjs/Shaders/color.fragment";
  17206. import "babylonjs/Shaders/color.vertex";
  17207. /**
  17208. * Line mesh
  17209. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17210. */
  17211. export class LinesMesh extends Mesh {
  17212. /**
  17213. * If vertex color should be applied to the mesh
  17214. */
  17215. readonly useVertexColor?: boolean | undefined;
  17216. /**
  17217. * If vertex alpha should be applied to the mesh
  17218. */
  17219. readonly useVertexAlpha?: boolean | undefined;
  17220. /**
  17221. * Color of the line (Default: White)
  17222. */
  17223. color: Color3;
  17224. /**
  17225. * Alpha of the line (Default: 1)
  17226. */
  17227. alpha: number;
  17228. /**
  17229. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17230. * This margin is expressed in world space coordinates, so its value may vary.
  17231. * Default value is 0.1
  17232. */
  17233. intersectionThreshold: number;
  17234. private _colorShader;
  17235. private color4;
  17236. /**
  17237. * Creates a new LinesMesh
  17238. * @param name defines the name
  17239. * @param scene defines the hosting scene
  17240. * @param parent defines the parent mesh if any
  17241. * @param source defines the optional source LinesMesh used to clone data from
  17242. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17243. * When false, achieved by calling a clone(), also passing False.
  17244. * This will make creation of children, recursive.
  17245. * @param useVertexColor defines if this LinesMesh supports vertex color
  17246. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17247. */
  17248. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17249. /**
  17250. * If vertex color should be applied to the mesh
  17251. */
  17252. useVertexColor?: boolean | undefined,
  17253. /**
  17254. * If vertex alpha should be applied to the mesh
  17255. */
  17256. useVertexAlpha?: boolean | undefined);
  17257. private _addClipPlaneDefine;
  17258. private _removeClipPlaneDefine;
  17259. isReady(): boolean;
  17260. /**
  17261. * Returns the string "LineMesh"
  17262. */
  17263. getClassName(): string;
  17264. /**
  17265. * @hidden
  17266. */
  17267. get material(): Material;
  17268. /**
  17269. * @hidden
  17270. */
  17271. set material(value: Material);
  17272. /**
  17273. * @hidden
  17274. */
  17275. get checkCollisions(): boolean;
  17276. /** @hidden */
  17277. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17278. /** @hidden */
  17279. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17280. /**
  17281. * Disposes of the line mesh
  17282. * @param doNotRecurse If children should be disposed
  17283. */
  17284. dispose(doNotRecurse?: boolean): void;
  17285. /**
  17286. * Returns a new LineMesh object cloned from the current one.
  17287. */
  17288. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17289. /**
  17290. * Creates a new InstancedLinesMesh object from the mesh model.
  17291. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17292. * @param name defines the name of the new instance
  17293. * @returns a new InstancedLinesMesh
  17294. */
  17295. createInstance(name: string): InstancedLinesMesh;
  17296. }
  17297. /**
  17298. * Creates an instance based on a source LinesMesh
  17299. */
  17300. export class InstancedLinesMesh extends InstancedMesh {
  17301. /**
  17302. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17303. * This margin is expressed in world space coordinates, so its value may vary.
  17304. * Initilized with the intersectionThreshold value of the source LinesMesh
  17305. */
  17306. intersectionThreshold: number;
  17307. constructor(name: string, source: LinesMesh);
  17308. /**
  17309. * Returns the string "InstancedLinesMesh".
  17310. */
  17311. getClassName(): string;
  17312. }
  17313. }
  17314. declare module "babylonjs/Shaders/line.fragment" {
  17315. /** @hidden */
  17316. export var linePixelShader: {
  17317. name: string;
  17318. shader: string;
  17319. };
  17320. }
  17321. declare module "babylonjs/Shaders/line.vertex" {
  17322. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17324. /** @hidden */
  17325. export var lineVertexShader: {
  17326. name: string;
  17327. shader: string;
  17328. };
  17329. }
  17330. declare module "babylonjs/Rendering/edgesRenderer" {
  17331. import { Nullable } from "babylonjs/types";
  17332. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17334. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17335. import { IDisposable } from "babylonjs/scene";
  17336. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17337. import "babylonjs/Shaders/line.fragment";
  17338. import "babylonjs/Shaders/line.vertex";
  17339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17340. import { SmartArray } from "babylonjs/Misc/smartArray";
  17341. module "babylonjs/scene" {
  17342. interface Scene {
  17343. /** @hidden */
  17344. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17345. }
  17346. }
  17347. module "babylonjs/Meshes/abstractMesh" {
  17348. interface AbstractMesh {
  17349. /**
  17350. * Gets the edgesRenderer associated with the mesh
  17351. */
  17352. edgesRenderer: Nullable<EdgesRenderer>;
  17353. }
  17354. }
  17355. module "babylonjs/Meshes/linesMesh" {
  17356. interface LinesMesh {
  17357. /**
  17358. * Enables the edge rendering mode on the mesh.
  17359. * This mode makes the mesh edges visible
  17360. * @param epsilon defines the maximal distance between two angles to detect a face
  17361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17362. * @returns the currentAbstractMesh
  17363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17364. */
  17365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17366. }
  17367. }
  17368. module "babylonjs/Meshes/linesMesh" {
  17369. interface InstancedLinesMesh {
  17370. /**
  17371. * Enables the edge rendering mode on the mesh.
  17372. * This mode makes the mesh edges visible
  17373. * @param epsilon defines the maximal distance between two angles to detect a face
  17374. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17375. * @returns the current InstancedLinesMesh
  17376. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17377. */
  17378. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17379. }
  17380. }
  17381. /**
  17382. * Defines the minimum contract an Edges renderer should follow.
  17383. */
  17384. export interface IEdgesRenderer extends IDisposable {
  17385. /**
  17386. * Gets or sets a boolean indicating if the edgesRenderer is active
  17387. */
  17388. isEnabled: boolean;
  17389. /**
  17390. * Renders the edges of the attached mesh,
  17391. */
  17392. render(): void;
  17393. /**
  17394. * Checks wether or not the edges renderer is ready to render.
  17395. * @return true if ready, otherwise false.
  17396. */
  17397. isReady(): boolean;
  17398. /**
  17399. * List of instances to render in case the source mesh has instances
  17400. */
  17401. customInstances: SmartArray<Matrix>;
  17402. }
  17403. /**
  17404. * Defines the additional options of the edges renderer
  17405. */
  17406. export interface IEdgesRendererOptions {
  17407. /**
  17408. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17409. * If not defined, the default value is true
  17410. */
  17411. useAlternateEdgeFinder?: boolean;
  17412. /**
  17413. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17414. * If not defined, the default value is true.
  17415. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17416. * This option is used only if useAlternateEdgeFinder = true
  17417. */
  17418. useFastVertexMerger?: boolean;
  17419. /**
  17420. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17421. * The default value is 1e-6
  17422. * This option is used only if useAlternateEdgeFinder = true
  17423. */
  17424. epsilonVertexMerge?: number;
  17425. /**
  17426. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17427. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17428. * This option is used only if useAlternateEdgeFinder = true
  17429. */
  17430. applyTessellation?: boolean;
  17431. /**
  17432. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17433. * The default value is 1e-6
  17434. * This option is used only if useAlternateEdgeFinder = true
  17435. */
  17436. epsilonVertexAligned?: number;
  17437. }
  17438. /**
  17439. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17440. */
  17441. export class EdgesRenderer implements IEdgesRenderer {
  17442. /**
  17443. * Define the size of the edges with an orthographic camera
  17444. */
  17445. edgesWidthScalerForOrthographic: number;
  17446. /**
  17447. * Define the size of the edges with a perspective camera
  17448. */
  17449. edgesWidthScalerForPerspective: number;
  17450. protected _source: AbstractMesh;
  17451. protected _linesPositions: number[];
  17452. protected _linesNormals: number[];
  17453. protected _linesIndices: number[];
  17454. protected _epsilon: number;
  17455. protected _indicesCount: number;
  17456. protected _lineShader: ShaderMaterial;
  17457. protected _ib: DataBuffer;
  17458. protected _buffers: {
  17459. [key: string]: Nullable<VertexBuffer>;
  17460. };
  17461. protected _buffersForInstances: {
  17462. [key: string]: Nullable<VertexBuffer>;
  17463. };
  17464. protected _checkVerticesInsteadOfIndices: boolean;
  17465. protected _options: Nullable<IEdgesRendererOptions>;
  17466. private _meshRebuildObserver;
  17467. private _meshDisposeObserver;
  17468. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17469. isEnabled: boolean;
  17470. /**
  17471. * List of instances to render in case the source mesh has instances
  17472. */
  17473. customInstances: SmartArray<Matrix>;
  17474. private static GetShader;
  17475. /**
  17476. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17477. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17478. * @param source Mesh used to create edges
  17479. * @param epsilon sum of angles in adjacency to check for edge
  17480. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17481. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17482. * @param options The options to apply when generating the edges
  17483. */
  17484. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17485. protected _prepareRessources(): void;
  17486. /** @hidden */
  17487. _rebuild(): void;
  17488. /**
  17489. * Releases the required resources for the edges renderer
  17490. */
  17491. dispose(): void;
  17492. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17493. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17494. /**
  17495. * Checks if the pair of p0 and p1 is en edge
  17496. * @param faceIndex
  17497. * @param edge
  17498. * @param faceNormals
  17499. * @param p0
  17500. * @param p1
  17501. * @private
  17502. */
  17503. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17504. /**
  17505. * push line into the position, normal and index buffer
  17506. * @protected
  17507. */
  17508. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17509. /**
  17510. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17511. */
  17512. private _tessellateTriangle;
  17513. private _generateEdgesLinesAlternate;
  17514. /**
  17515. * Generates lines edges from adjacencjes
  17516. * @private
  17517. */
  17518. _generateEdgesLines(): void;
  17519. /**
  17520. * Checks wether or not the edges renderer is ready to render.
  17521. * @return true if ready, otherwise false.
  17522. */
  17523. isReady(): boolean;
  17524. /**
  17525. * Renders the edges of the attached mesh,
  17526. */
  17527. render(): void;
  17528. }
  17529. /**
  17530. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17531. */
  17532. export class LineEdgesRenderer extends EdgesRenderer {
  17533. /**
  17534. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17535. * @param source LineMesh used to generate edges
  17536. * @param epsilon not important (specified angle for edge detection)
  17537. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17538. */
  17539. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17540. /**
  17541. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17542. */
  17543. _generateEdgesLines(): void;
  17544. }
  17545. }
  17546. declare module "babylonjs/Rendering/renderingGroup" {
  17547. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17548. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17550. import { Nullable } from "babylonjs/types";
  17551. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17552. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17553. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17554. import { Material } from "babylonjs/Materials/material";
  17555. import { Scene } from "babylonjs/scene";
  17556. /**
  17557. * This represents the object necessary to create a rendering group.
  17558. * This is exclusively used and created by the rendering manager.
  17559. * To modify the behavior, you use the available helpers in your scene or meshes.
  17560. * @hidden
  17561. */
  17562. export class RenderingGroup {
  17563. index: number;
  17564. private static _zeroVector;
  17565. private _scene;
  17566. private _opaqueSubMeshes;
  17567. private _transparentSubMeshes;
  17568. private _alphaTestSubMeshes;
  17569. private _depthOnlySubMeshes;
  17570. private _particleSystems;
  17571. private _spriteManagers;
  17572. private _opaqueSortCompareFn;
  17573. private _alphaTestSortCompareFn;
  17574. private _transparentSortCompareFn;
  17575. private _renderOpaque;
  17576. private _renderAlphaTest;
  17577. private _renderTransparent;
  17578. /** @hidden */
  17579. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17580. onBeforeTransparentRendering: () => void;
  17581. /**
  17582. * Set the opaque sort comparison function.
  17583. * If null the sub meshes will be render in the order they were created
  17584. */
  17585. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17586. /**
  17587. * Set the alpha test sort comparison function.
  17588. * If null the sub meshes will be render in the order they were created
  17589. */
  17590. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17591. /**
  17592. * Set the transparent sort comparison function.
  17593. * If null the sub meshes will be render in the order they were created
  17594. */
  17595. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17596. /**
  17597. * Creates a new rendering group.
  17598. * @param index The rendering group index
  17599. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17600. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17601. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17602. */
  17603. 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>);
  17604. /**
  17605. * Render all the sub meshes contained in the group.
  17606. * @param customRenderFunction Used to override the default render behaviour of the group.
  17607. * @returns true if rendered some submeshes.
  17608. */
  17609. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17610. /**
  17611. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17612. * @param subMeshes The submeshes to render
  17613. */
  17614. private renderOpaqueSorted;
  17615. /**
  17616. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17617. * @param subMeshes The submeshes to render
  17618. */
  17619. private renderAlphaTestSorted;
  17620. /**
  17621. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17622. * @param subMeshes The submeshes to render
  17623. */
  17624. private renderTransparentSorted;
  17625. /**
  17626. * Renders the submeshes in a specified order.
  17627. * @param subMeshes The submeshes to sort before render
  17628. * @param sortCompareFn The comparison function use to sort
  17629. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17630. * @param transparent Specifies to activate blending if true
  17631. */
  17632. private static renderSorted;
  17633. /**
  17634. * Renders the submeshes in the order they were dispatched (no sort applied).
  17635. * @param subMeshes The submeshes to render
  17636. */
  17637. private static renderUnsorted;
  17638. /**
  17639. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17640. * are rendered back to front if in the same alpha index.
  17641. *
  17642. * @param a The first submesh
  17643. * @param b The second submesh
  17644. * @returns The result of the comparison
  17645. */
  17646. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17647. /**
  17648. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17649. * are rendered back to front.
  17650. *
  17651. * @param a The first submesh
  17652. * @param b The second submesh
  17653. * @returns The result of the comparison
  17654. */
  17655. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17656. /**
  17657. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17658. * are rendered front to back (prevent overdraw).
  17659. *
  17660. * @param a The first submesh
  17661. * @param b The second submesh
  17662. * @returns The result of the comparison
  17663. */
  17664. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17665. /**
  17666. * Resets the different lists of submeshes to prepare a new frame.
  17667. */
  17668. prepare(): void;
  17669. dispose(): void;
  17670. /**
  17671. * Inserts the submesh in its correct queue depending on its material.
  17672. * @param subMesh The submesh to dispatch
  17673. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17674. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17675. */
  17676. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17677. dispatchSprites(spriteManager: ISpriteManager): void;
  17678. dispatchParticles(particleSystem: IParticleSystem): void;
  17679. private _renderParticles;
  17680. private _renderSprites;
  17681. }
  17682. }
  17683. declare module "babylonjs/Rendering/renderingManager" {
  17684. import { Nullable } from "babylonjs/types";
  17685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17687. import { SmartArray } from "babylonjs/Misc/smartArray";
  17688. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17689. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17690. import { Material } from "babylonjs/Materials/material";
  17691. import { Scene } from "babylonjs/scene";
  17692. import { Camera } from "babylonjs/Cameras/camera";
  17693. /**
  17694. * Interface describing the different options available in the rendering manager
  17695. * regarding Auto Clear between groups.
  17696. */
  17697. export interface IRenderingManagerAutoClearSetup {
  17698. /**
  17699. * Defines whether or not autoclear is enable.
  17700. */
  17701. autoClear: boolean;
  17702. /**
  17703. * Defines whether or not to autoclear the depth buffer.
  17704. */
  17705. depth: boolean;
  17706. /**
  17707. * Defines whether or not to autoclear the stencil buffer.
  17708. */
  17709. stencil: boolean;
  17710. }
  17711. /**
  17712. * This class is used by the onRenderingGroupObservable
  17713. */
  17714. export class RenderingGroupInfo {
  17715. /**
  17716. * The Scene that being rendered
  17717. */
  17718. scene: Scene;
  17719. /**
  17720. * The camera currently used for the rendering pass
  17721. */
  17722. camera: Nullable<Camera>;
  17723. /**
  17724. * The ID of the renderingGroup being processed
  17725. */
  17726. renderingGroupId: number;
  17727. }
  17728. /**
  17729. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17730. * It is enable to manage the different groups as well as the different necessary sort functions.
  17731. * This should not be used directly aside of the few static configurations
  17732. */
  17733. export class RenderingManager {
  17734. /**
  17735. * The max id used for rendering groups (not included)
  17736. */
  17737. static MAX_RENDERINGGROUPS: number;
  17738. /**
  17739. * The min id used for rendering groups (included)
  17740. */
  17741. static MIN_RENDERINGGROUPS: number;
  17742. /**
  17743. * Used to globally prevent autoclearing scenes.
  17744. */
  17745. static AUTOCLEAR: boolean;
  17746. /**
  17747. * @hidden
  17748. */
  17749. _useSceneAutoClearSetup: boolean;
  17750. private _scene;
  17751. private _renderingGroups;
  17752. private _depthStencilBufferAlreadyCleaned;
  17753. private _autoClearDepthStencil;
  17754. private _customOpaqueSortCompareFn;
  17755. private _customAlphaTestSortCompareFn;
  17756. private _customTransparentSortCompareFn;
  17757. private _renderingGroupInfo;
  17758. /**
  17759. * Instantiates a new rendering group for a particular scene
  17760. * @param scene Defines the scene the groups belongs to
  17761. */
  17762. constructor(scene: Scene);
  17763. private _clearDepthStencilBuffer;
  17764. /**
  17765. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17766. * @hidden
  17767. */
  17768. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17769. /**
  17770. * Resets the different information of the group to prepare a new frame
  17771. * @hidden
  17772. */
  17773. reset(): void;
  17774. /**
  17775. * Dispose and release the group and its associated resources.
  17776. * @hidden
  17777. */
  17778. dispose(): void;
  17779. /**
  17780. * Clear the info related to rendering groups preventing retention points during dispose.
  17781. */
  17782. freeRenderingGroups(): void;
  17783. private _prepareRenderingGroup;
  17784. /**
  17785. * Add a sprite manager to the rendering manager in order to render it this frame.
  17786. * @param spriteManager Define the sprite manager to render
  17787. */
  17788. dispatchSprites(spriteManager: ISpriteManager): void;
  17789. /**
  17790. * Add a particle system to the rendering manager in order to render it this frame.
  17791. * @param particleSystem Define the particle system to render
  17792. */
  17793. dispatchParticles(particleSystem: IParticleSystem): void;
  17794. /**
  17795. * Add a submesh to the manager in order to render it this frame
  17796. * @param subMesh The submesh to dispatch
  17797. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17798. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17799. */
  17800. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17801. /**
  17802. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17803. * This allowed control for front to back rendering or reversly depending of the special needs.
  17804. *
  17805. * @param renderingGroupId The rendering group id corresponding to its index
  17806. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17807. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17808. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17809. */
  17810. 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;
  17811. /**
  17812. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17813. *
  17814. * @param renderingGroupId The rendering group id corresponding to its index
  17815. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17816. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17817. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17818. */
  17819. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17820. /**
  17821. * Gets the current auto clear configuration for one rendering group of the rendering
  17822. * manager.
  17823. * @param index the rendering group index to get the information for
  17824. * @returns The auto clear setup for the requested rendering group
  17825. */
  17826. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17827. }
  17828. }
  17829. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17830. import { SmartArray } from "babylonjs/Misc/smartArray";
  17831. import { Nullable } from "babylonjs/types";
  17832. import { Scene } from "babylonjs/scene";
  17833. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17836. import { Mesh } from "babylonjs/Meshes/mesh";
  17837. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17838. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17839. import { Effect } from "babylonjs/Materials/effect";
  17840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17842. import "babylonjs/Shaders/shadowMap.fragment";
  17843. import "babylonjs/Shaders/shadowMap.vertex";
  17844. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17845. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17846. import { Observable } from "babylonjs/Misc/observable";
  17847. /**
  17848. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17849. */
  17850. export interface ICustomShaderOptions {
  17851. /**
  17852. * Gets or sets the custom shader name to use
  17853. */
  17854. shaderName: string;
  17855. /**
  17856. * The list of attribute names used in the shader
  17857. */
  17858. attributes?: string[];
  17859. /**
  17860. * The list of unifrom names used in the shader
  17861. */
  17862. uniforms?: string[];
  17863. /**
  17864. * The list of sampler names used in the shader
  17865. */
  17866. samplers?: string[];
  17867. /**
  17868. * The list of defines used in the shader
  17869. */
  17870. defines?: string[];
  17871. }
  17872. /**
  17873. * Interface to implement to create a shadow generator compatible with BJS.
  17874. */
  17875. export interface IShadowGenerator {
  17876. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17877. id: string;
  17878. /**
  17879. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17880. * @returns The render target texture if present otherwise, null
  17881. */
  17882. getShadowMap(): Nullable<RenderTargetTexture>;
  17883. /**
  17884. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17885. * @param subMesh The submesh we want to render in the shadow map
  17886. * @param useInstances Defines wether will draw in the map using instances
  17887. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17888. * @returns true if ready otherwise, false
  17889. */
  17890. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17891. /**
  17892. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17893. * @param defines Defines of the material we want to update
  17894. * @param lightIndex Index of the light in the enabled light list of the material
  17895. */
  17896. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17897. /**
  17898. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17899. * defined in the generator but impacting the effect).
  17900. * It implies the unifroms available on the materials are the standard BJS ones.
  17901. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17902. * @param effect The effect we are binfing the information for
  17903. */
  17904. bindShadowLight(lightIndex: string, effect: Effect): void;
  17905. /**
  17906. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17907. * (eq to shadow prjection matrix * light transform matrix)
  17908. * @returns The transform matrix used to create the shadow map
  17909. */
  17910. getTransformMatrix(): Matrix;
  17911. /**
  17912. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17913. * Cube and 2D textures for instance.
  17914. */
  17915. recreateShadowMap(): void;
  17916. /**
  17917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17918. * @param onCompiled Callback triggered at the and of the effects compilation
  17919. * @param options Sets of optional options forcing the compilation with different modes
  17920. */
  17921. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17922. useInstances: boolean;
  17923. }>): void;
  17924. /**
  17925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17926. * @param options Sets of optional options forcing the compilation with different modes
  17927. * @returns A promise that resolves when the compilation completes
  17928. */
  17929. forceCompilationAsync(options?: Partial<{
  17930. useInstances: boolean;
  17931. }>): Promise<void>;
  17932. /**
  17933. * Serializes the shadow generator setup to a json object.
  17934. * @returns The serialized JSON object
  17935. */
  17936. serialize(): any;
  17937. /**
  17938. * Disposes the Shadow map and related Textures and effects.
  17939. */
  17940. dispose(): void;
  17941. }
  17942. /**
  17943. * Default implementation IShadowGenerator.
  17944. * This is the main object responsible of generating shadows in the framework.
  17945. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17946. */
  17947. export class ShadowGenerator implements IShadowGenerator {
  17948. /**
  17949. * Name of the shadow generator class
  17950. */
  17951. static CLASSNAME: string;
  17952. /**
  17953. * Shadow generator mode None: no filtering applied.
  17954. */
  17955. static readonly FILTER_NONE: number;
  17956. /**
  17957. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17958. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17959. */
  17960. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17961. /**
  17962. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17963. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17964. */
  17965. static readonly FILTER_POISSONSAMPLING: number;
  17966. /**
  17967. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17968. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17969. */
  17970. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17971. /**
  17972. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17973. * edge artifacts on steep falloff.
  17974. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17975. */
  17976. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17977. /**
  17978. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17979. * edge artifacts on steep falloff.
  17980. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17981. */
  17982. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17983. /**
  17984. * Shadow generator mode PCF: Percentage Closer Filtering
  17985. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17986. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17987. */
  17988. static readonly FILTER_PCF: number;
  17989. /**
  17990. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17991. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17992. * Contact Hardening
  17993. */
  17994. static readonly FILTER_PCSS: number;
  17995. /**
  17996. * Reserved for PCF and PCSS
  17997. * Highest Quality.
  17998. *
  17999. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18000. *
  18001. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18002. */
  18003. static readonly QUALITY_HIGH: number;
  18004. /**
  18005. * Reserved for PCF and PCSS
  18006. * Good tradeoff for quality/perf cross devices
  18007. *
  18008. * Execute PCF on a 3*3 kernel.
  18009. *
  18010. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18011. */
  18012. static readonly QUALITY_MEDIUM: number;
  18013. /**
  18014. * Reserved for PCF and PCSS
  18015. * The lowest quality but the fastest.
  18016. *
  18017. * Execute PCF on a 1*1 kernel.
  18018. *
  18019. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18020. */
  18021. static readonly QUALITY_LOW: number;
  18022. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18023. id: string;
  18024. /** Gets or sets the custom shader name to use */
  18025. customShaderOptions: ICustomShaderOptions;
  18026. /**
  18027. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18028. */
  18029. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18030. /**
  18031. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18032. */
  18033. onAfterShadowMapRenderObservable: Observable<Effect>;
  18034. /**
  18035. * Observable triggered before a mesh is rendered in the shadow map.
  18036. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18037. */
  18038. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18039. /**
  18040. * Observable triggered after a mesh is rendered in the shadow map.
  18041. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18042. */
  18043. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18044. protected _bias: number;
  18045. /**
  18046. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18047. */
  18048. get bias(): number;
  18049. /**
  18050. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18051. */
  18052. set bias(bias: number);
  18053. protected _normalBias: number;
  18054. /**
  18055. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18056. */
  18057. get normalBias(): number;
  18058. /**
  18059. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18060. */
  18061. set normalBias(normalBias: number);
  18062. protected _blurBoxOffset: number;
  18063. /**
  18064. * Gets the blur box offset: offset applied during the blur pass.
  18065. * Only useful if useKernelBlur = false
  18066. */
  18067. get blurBoxOffset(): number;
  18068. /**
  18069. * Sets the blur box offset: offset applied during the blur pass.
  18070. * Only useful if useKernelBlur = false
  18071. */
  18072. set blurBoxOffset(value: number);
  18073. protected _blurScale: number;
  18074. /**
  18075. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18076. * 2 means half of the size.
  18077. */
  18078. get blurScale(): number;
  18079. /**
  18080. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18081. * 2 means half of the size.
  18082. */
  18083. set blurScale(value: number);
  18084. protected _blurKernel: number;
  18085. /**
  18086. * Gets the blur kernel: kernel size of the blur pass.
  18087. * Only useful if useKernelBlur = true
  18088. */
  18089. get blurKernel(): number;
  18090. /**
  18091. * Sets the blur kernel: kernel size of the blur pass.
  18092. * Only useful if useKernelBlur = true
  18093. */
  18094. set blurKernel(value: number);
  18095. protected _useKernelBlur: boolean;
  18096. /**
  18097. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18098. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18099. */
  18100. get useKernelBlur(): boolean;
  18101. /**
  18102. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18103. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18104. */
  18105. set useKernelBlur(value: boolean);
  18106. protected _depthScale: number;
  18107. /**
  18108. * Gets the depth scale used in ESM mode.
  18109. */
  18110. get depthScale(): number;
  18111. /**
  18112. * Sets the depth scale used in ESM mode.
  18113. * This can override the scale stored on the light.
  18114. */
  18115. set depthScale(value: number);
  18116. protected _validateFilter(filter: number): number;
  18117. protected _filter: number;
  18118. /**
  18119. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18120. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18121. */
  18122. get filter(): number;
  18123. /**
  18124. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18125. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18126. */
  18127. set filter(value: number);
  18128. /**
  18129. * Gets if the current filter is set to Poisson Sampling.
  18130. */
  18131. get usePoissonSampling(): boolean;
  18132. /**
  18133. * Sets the current filter to Poisson Sampling.
  18134. */
  18135. set usePoissonSampling(value: boolean);
  18136. /**
  18137. * Gets if the current filter is set to ESM.
  18138. */
  18139. get useExponentialShadowMap(): boolean;
  18140. /**
  18141. * Sets the current filter is to ESM.
  18142. */
  18143. set useExponentialShadowMap(value: boolean);
  18144. /**
  18145. * Gets if the current filter is set to filtered ESM.
  18146. */
  18147. get useBlurExponentialShadowMap(): boolean;
  18148. /**
  18149. * Gets if the current filter is set to filtered ESM.
  18150. */
  18151. set useBlurExponentialShadowMap(value: boolean);
  18152. /**
  18153. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18154. * exponential to prevent steep falloff artifacts).
  18155. */
  18156. get useCloseExponentialShadowMap(): boolean;
  18157. /**
  18158. * Sets the current filter to "close ESM" (using the inverse of the
  18159. * exponential to prevent steep falloff artifacts).
  18160. */
  18161. set useCloseExponentialShadowMap(value: boolean);
  18162. /**
  18163. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18164. * exponential to prevent steep falloff artifacts).
  18165. */
  18166. get useBlurCloseExponentialShadowMap(): boolean;
  18167. /**
  18168. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18169. * exponential to prevent steep falloff artifacts).
  18170. */
  18171. set useBlurCloseExponentialShadowMap(value: boolean);
  18172. /**
  18173. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18174. */
  18175. get usePercentageCloserFiltering(): boolean;
  18176. /**
  18177. * Sets the current filter to "PCF" (percentage closer filtering).
  18178. */
  18179. set usePercentageCloserFiltering(value: boolean);
  18180. protected _filteringQuality: number;
  18181. /**
  18182. * Gets the PCF or PCSS Quality.
  18183. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18184. */
  18185. get filteringQuality(): number;
  18186. /**
  18187. * Sets the PCF or PCSS Quality.
  18188. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18189. */
  18190. set filteringQuality(filteringQuality: number);
  18191. /**
  18192. * Gets if the current filter is set to "PCSS" (contact hardening).
  18193. */
  18194. get useContactHardeningShadow(): boolean;
  18195. /**
  18196. * Sets the current filter to "PCSS" (contact hardening).
  18197. */
  18198. set useContactHardeningShadow(value: boolean);
  18199. protected _contactHardeningLightSizeUVRatio: number;
  18200. /**
  18201. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18202. * Using a ratio helps keeping shape stability independently of the map size.
  18203. *
  18204. * It does not account for the light projection as it was having too much
  18205. * instability during the light setup or during light position changes.
  18206. *
  18207. * Only valid if useContactHardeningShadow is true.
  18208. */
  18209. get contactHardeningLightSizeUVRatio(): number;
  18210. /**
  18211. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18212. * Using a ratio helps keeping shape stability independently of the map size.
  18213. *
  18214. * It does not account for the light projection as it was having too much
  18215. * instability during the light setup or during light position changes.
  18216. *
  18217. * Only valid if useContactHardeningShadow is true.
  18218. */
  18219. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18220. protected _darkness: number;
  18221. /** Gets or sets the actual darkness of a shadow */
  18222. get darkness(): number;
  18223. set darkness(value: number);
  18224. /**
  18225. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18226. * 0 means strongest and 1 would means no shadow.
  18227. * @returns the darkness.
  18228. */
  18229. getDarkness(): number;
  18230. /**
  18231. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18232. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18233. * @returns the shadow generator allowing fluent coding.
  18234. */
  18235. setDarkness(darkness: number): ShadowGenerator;
  18236. protected _transparencyShadow: boolean;
  18237. /** Gets or sets the ability to have transparent shadow */
  18238. get transparencyShadow(): boolean;
  18239. set transparencyShadow(value: boolean);
  18240. /**
  18241. * Sets the ability to have transparent shadow (boolean).
  18242. * @param transparent True if transparent else False
  18243. * @returns the shadow generator allowing fluent coding
  18244. */
  18245. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18246. /**
  18247. * Enables or disables shadows with varying strength based on the transparency
  18248. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18249. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18250. * mesh.visibility * alphaTexture.a
  18251. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18252. */
  18253. enableSoftTransparentShadow: boolean;
  18254. protected _shadowMap: Nullable<RenderTargetTexture>;
  18255. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18256. /**
  18257. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18258. * @returns The render target texture if present otherwise, null
  18259. */
  18260. getShadowMap(): Nullable<RenderTargetTexture>;
  18261. /**
  18262. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18263. * @returns The render target texture if the shadow map is present otherwise, null
  18264. */
  18265. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18266. /**
  18267. * Gets the class name of that object
  18268. * @returns "ShadowGenerator"
  18269. */
  18270. getClassName(): string;
  18271. /**
  18272. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18273. * @param mesh Mesh to add
  18274. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18275. * @returns the Shadow Generator itself
  18276. */
  18277. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18278. /**
  18279. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18280. * @param mesh Mesh to remove
  18281. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18282. * @returns the Shadow Generator itself
  18283. */
  18284. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18285. /**
  18286. * Controls the extent to which the shadows fade out at the edge of the frustum
  18287. */
  18288. frustumEdgeFalloff: number;
  18289. protected _light: IShadowLight;
  18290. /**
  18291. * Returns the associated light object.
  18292. * @returns the light generating the shadow
  18293. */
  18294. getLight(): IShadowLight;
  18295. /**
  18296. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18297. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18298. * It might on the other hand introduce peter panning.
  18299. */
  18300. forceBackFacesOnly: boolean;
  18301. protected _scene: Scene;
  18302. protected _lightDirection: Vector3;
  18303. protected _effect: Effect;
  18304. protected _viewMatrix: Matrix;
  18305. protected _projectionMatrix: Matrix;
  18306. protected _transformMatrix: Matrix;
  18307. protected _cachedPosition: Vector3;
  18308. protected _cachedDirection: Vector3;
  18309. protected _cachedDefines: string;
  18310. protected _currentRenderID: number;
  18311. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18312. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18313. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18314. protected _blurPostProcesses: PostProcess[];
  18315. protected _mapSize: number;
  18316. protected _currentFaceIndex: number;
  18317. protected _currentFaceIndexCache: number;
  18318. protected _textureType: number;
  18319. protected _defaultTextureMatrix: Matrix;
  18320. protected _storedUniqueId: Nullable<number>;
  18321. /** @hidden */
  18322. static _SceneComponentInitialization: (scene: Scene) => void;
  18323. /**
  18324. * Creates a ShadowGenerator object.
  18325. * A ShadowGenerator is the required tool to use the shadows.
  18326. * Each light casting shadows needs to use its own ShadowGenerator.
  18327. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18328. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18329. * @param light The light object generating the shadows.
  18330. * @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.
  18331. */
  18332. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18333. protected _initializeGenerator(): void;
  18334. protected _createTargetRenderTexture(): void;
  18335. protected _initializeShadowMap(): void;
  18336. protected _initializeBlurRTTAndPostProcesses(): void;
  18337. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18338. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18339. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18340. protected _applyFilterValues(): void;
  18341. /**
  18342. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18343. * @param onCompiled Callback triggered at the and of the effects compilation
  18344. * @param options Sets of optional options forcing the compilation with different modes
  18345. */
  18346. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18347. useInstances: boolean;
  18348. }>): void;
  18349. /**
  18350. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18351. * @param options Sets of optional options forcing the compilation with different modes
  18352. * @returns A promise that resolves when the compilation completes
  18353. */
  18354. forceCompilationAsync(options?: Partial<{
  18355. useInstances: boolean;
  18356. }>): Promise<void>;
  18357. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18358. private _prepareShadowDefines;
  18359. /**
  18360. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18361. * @param subMesh The submesh we want to render in the shadow map
  18362. * @param useInstances Defines wether will draw in the map using instances
  18363. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18364. * @returns true if ready otherwise, false
  18365. */
  18366. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18367. /**
  18368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18369. * @param defines Defines of the material we want to update
  18370. * @param lightIndex Index of the light in the enabled light list of the material
  18371. */
  18372. prepareDefines(defines: any, lightIndex: number): void;
  18373. /**
  18374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18375. * defined in the generator but impacting the effect).
  18376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18377. * @param effect The effect we are binfing the information for
  18378. */
  18379. bindShadowLight(lightIndex: string, effect: Effect): void;
  18380. /**
  18381. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18382. * (eq to shadow prjection matrix * light transform matrix)
  18383. * @returns The transform matrix used to create the shadow map
  18384. */
  18385. getTransformMatrix(): Matrix;
  18386. /**
  18387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18388. * Cube and 2D textures for instance.
  18389. */
  18390. recreateShadowMap(): void;
  18391. protected _disposeBlurPostProcesses(): void;
  18392. protected _disposeRTTandPostProcesses(): void;
  18393. /**
  18394. * Disposes the ShadowGenerator.
  18395. * Returns nothing.
  18396. */
  18397. dispose(): void;
  18398. /**
  18399. * Serializes the shadow generator setup to a json object.
  18400. * @returns The serialized JSON object
  18401. */
  18402. serialize(): any;
  18403. /**
  18404. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18405. * @param parsedShadowGenerator The JSON object to parse
  18406. * @param scene The scene to create the shadow map for
  18407. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18408. * @returns The parsed shadow generator
  18409. */
  18410. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18411. }
  18412. }
  18413. declare module "babylonjs/Lights/light" {
  18414. import { Nullable } from "babylonjs/types";
  18415. import { Scene } from "babylonjs/scene";
  18416. import { Vector3 } from "babylonjs/Maths/math.vector";
  18417. import { Color3 } from "babylonjs/Maths/math.color";
  18418. import { Node } from "babylonjs/node";
  18419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18420. import { Effect } from "babylonjs/Materials/effect";
  18421. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18422. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18423. /**
  18424. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18425. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18426. * 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.
  18427. */
  18428. export abstract class Light extends Node {
  18429. /**
  18430. * Falloff Default: light is falling off following the material specification:
  18431. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18432. */
  18433. static readonly FALLOFF_DEFAULT: number;
  18434. /**
  18435. * Falloff Physical: light is falling off following the inverse squared distance law.
  18436. */
  18437. static readonly FALLOFF_PHYSICAL: number;
  18438. /**
  18439. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18440. * to enhance interoperability with other engines.
  18441. */
  18442. static readonly FALLOFF_GLTF: number;
  18443. /**
  18444. * Falloff Standard: light is falling off like in the standard material
  18445. * to enhance interoperability with other materials.
  18446. */
  18447. static readonly FALLOFF_STANDARD: number;
  18448. /**
  18449. * If every light affecting the material is in this lightmapMode,
  18450. * material.lightmapTexture adds or multiplies
  18451. * (depends on material.useLightmapAsShadowmap)
  18452. * after every other light calculations.
  18453. */
  18454. static readonly LIGHTMAP_DEFAULT: number;
  18455. /**
  18456. * material.lightmapTexture as only diffuse lighting from this light
  18457. * adds only specular lighting from this light
  18458. * adds dynamic shadows
  18459. */
  18460. static readonly LIGHTMAP_SPECULAR: number;
  18461. /**
  18462. * material.lightmapTexture as only lighting
  18463. * no light calculation from this light
  18464. * only adds dynamic shadows from this light
  18465. */
  18466. static readonly LIGHTMAP_SHADOWSONLY: number;
  18467. /**
  18468. * Each light type uses the default quantity according to its type:
  18469. * point/spot lights use luminous intensity
  18470. * directional lights use illuminance
  18471. */
  18472. static readonly INTENSITYMODE_AUTOMATIC: number;
  18473. /**
  18474. * lumen (lm)
  18475. */
  18476. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18477. /**
  18478. * candela (lm/sr)
  18479. */
  18480. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18481. /**
  18482. * lux (lm/m^2)
  18483. */
  18484. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18485. /**
  18486. * nit (cd/m^2)
  18487. */
  18488. static readonly INTENSITYMODE_LUMINANCE: number;
  18489. /**
  18490. * Light type const id of the point light.
  18491. */
  18492. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18493. /**
  18494. * Light type const id of the directional light.
  18495. */
  18496. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18497. /**
  18498. * Light type const id of the spot light.
  18499. */
  18500. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18501. /**
  18502. * Light type const id of the hemispheric light.
  18503. */
  18504. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18505. /**
  18506. * Diffuse gives the basic color to an object.
  18507. */
  18508. diffuse: Color3;
  18509. /**
  18510. * Specular produces a highlight color on an object.
  18511. * Note: This is note affecting PBR materials.
  18512. */
  18513. specular: Color3;
  18514. /**
  18515. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18516. * falling off base on range or angle.
  18517. * This can be set to any values in Light.FALLOFF_x.
  18518. *
  18519. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18520. * other types of materials.
  18521. */
  18522. falloffType: number;
  18523. /**
  18524. * Strength of the light.
  18525. * Note: By default it is define in the framework own unit.
  18526. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18527. */
  18528. intensity: number;
  18529. private _range;
  18530. protected _inverseSquaredRange: number;
  18531. /**
  18532. * Defines how far from the source the light is impacting in scene units.
  18533. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18534. */
  18535. get range(): number;
  18536. /**
  18537. * Defines how far from the source the light is impacting in scene units.
  18538. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18539. */
  18540. set range(value: number);
  18541. /**
  18542. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18543. * of light.
  18544. */
  18545. private _photometricScale;
  18546. private _intensityMode;
  18547. /**
  18548. * Gets the photometric scale used to interpret the intensity.
  18549. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18550. */
  18551. get intensityMode(): number;
  18552. /**
  18553. * Sets the photometric scale used to interpret the intensity.
  18554. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18555. */
  18556. set intensityMode(value: number);
  18557. private _radius;
  18558. /**
  18559. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18560. */
  18561. get radius(): number;
  18562. /**
  18563. * sets the light radius used by PBR Materials to simulate soft area lights.
  18564. */
  18565. set radius(value: number);
  18566. private _renderPriority;
  18567. /**
  18568. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18569. * exceeding the number allowed of the materials.
  18570. */
  18571. renderPriority: number;
  18572. private _shadowEnabled;
  18573. /**
  18574. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18575. * the current shadow generator.
  18576. */
  18577. get shadowEnabled(): boolean;
  18578. /**
  18579. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18580. * the current shadow generator.
  18581. */
  18582. set shadowEnabled(value: boolean);
  18583. private _includedOnlyMeshes;
  18584. /**
  18585. * Gets the only meshes impacted by this light.
  18586. */
  18587. get includedOnlyMeshes(): AbstractMesh[];
  18588. /**
  18589. * Sets the only meshes impacted by this light.
  18590. */
  18591. set includedOnlyMeshes(value: AbstractMesh[]);
  18592. private _excludedMeshes;
  18593. /**
  18594. * Gets the meshes not impacted by this light.
  18595. */
  18596. get excludedMeshes(): AbstractMesh[];
  18597. /**
  18598. * Sets the meshes not impacted by this light.
  18599. */
  18600. set excludedMeshes(value: AbstractMesh[]);
  18601. private _excludeWithLayerMask;
  18602. /**
  18603. * Gets the layer id use to find what meshes are not impacted by the light.
  18604. * Inactive if 0
  18605. */
  18606. get excludeWithLayerMask(): number;
  18607. /**
  18608. * Sets the layer id use to find what meshes are not impacted by the light.
  18609. * Inactive if 0
  18610. */
  18611. set excludeWithLayerMask(value: number);
  18612. private _includeOnlyWithLayerMask;
  18613. /**
  18614. * Gets the layer id use to find what meshes are impacted by the light.
  18615. * Inactive if 0
  18616. */
  18617. get includeOnlyWithLayerMask(): number;
  18618. /**
  18619. * Sets the layer id use to find what meshes are impacted by the light.
  18620. * Inactive if 0
  18621. */
  18622. set includeOnlyWithLayerMask(value: number);
  18623. private _lightmapMode;
  18624. /**
  18625. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18626. */
  18627. get lightmapMode(): number;
  18628. /**
  18629. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18630. */
  18631. set lightmapMode(value: number);
  18632. /**
  18633. * Shadow generator associted to the light.
  18634. * @hidden Internal use only.
  18635. */
  18636. _shadowGenerator: Nullable<IShadowGenerator>;
  18637. /**
  18638. * @hidden Internal use only.
  18639. */
  18640. _excludedMeshesIds: string[];
  18641. /**
  18642. * @hidden Internal use only.
  18643. */
  18644. _includedOnlyMeshesIds: string[];
  18645. /**
  18646. * The current light unifom buffer.
  18647. * @hidden Internal use only.
  18648. */
  18649. _uniformBuffer: UniformBuffer;
  18650. /** @hidden */
  18651. _renderId: number;
  18652. /**
  18653. * Creates a Light object in the scene.
  18654. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18655. * @param name The firendly name of the light
  18656. * @param scene The scene the light belongs too
  18657. */
  18658. constructor(name: string, scene: Scene);
  18659. protected abstract _buildUniformLayout(): void;
  18660. /**
  18661. * Sets the passed Effect "effect" with the Light information.
  18662. * @param effect The effect to update
  18663. * @param lightIndex The index of the light in the effect to update
  18664. * @returns The light
  18665. */
  18666. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18667. /**
  18668. * Sets the passed Effect "effect" with the Light textures.
  18669. * @param effect The effect to update
  18670. * @param lightIndex The index of the light in the effect to update
  18671. * @returns The light
  18672. */
  18673. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18674. /**
  18675. * Binds the lights information from the scene to the effect for the given mesh.
  18676. * @param lightIndex Light index
  18677. * @param scene The scene where the light belongs to
  18678. * @param effect The effect we are binding the data to
  18679. * @param useSpecular Defines if specular is supported
  18680. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18681. */
  18682. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18683. /**
  18684. * Sets the passed Effect "effect" with the Light information.
  18685. * @param effect The effect to update
  18686. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18687. * @returns The light
  18688. */
  18689. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18690. /**
  18691. * Returns the string "Light".
  18692. * @returns the class name
  18693. */
  18694. getClassName(): string;
  18695. /** @hidden */
  18696. readonly _isLight: boolean;
  18697. /**
  18698. * Converts the light information to a readable string for debug purpose.
  18699. * @param fullDetails Supports for multiple levels of logging within scene loading
  18700. * @returns the human readable light info
  18701. */
  18702. toString(fullDetails?: boolean): string;
  18703. /** @hidden */
  18704. protected _syncParentEnabledState(): void;
  18705. /**
  18706. * Set the enabled state of this node.
  18707. * @param value - the new enabled state
  18708. */
  18709. setEnabled(value: boolean): void;
  18710. /**
  18711. * Returns the Light associated shadow generator if any.
  18712. * @return the associated shadow generator.
  18713. */
  18714. getShadowGenerator(): Nullable<IShadowGenerator>;
  18715. /**
  18716. * Returns a Vector3, the absolute light position in the World.
  18717. * @returns the world space position of the light
  18718. */
  18719. getAbsolutePosition(): Vector3;
  18720. /**
  18721. * Specifies if the light will affect the passed mesh.
  18722. * @param mesh The mesh to test against the light
  18723. * @return true the mesh is affected otherwise, false.
  18724. */
  18725. canAffectMesh(mesh: AbstractMesh): boolean;
  18726. /**
  18727. * Sort function to order lights for rendering.
  18728. * @param a First Light object to compare to second.
  18729. * @param b Second Light object to compare first.
  18730. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18731. */
  18732. static CompareLightsPriority(a: Light, b: Light): number;
  18733. /**
  18734. * Releases resources associated with this node.
  18735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18737. */
  18738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18739. /**
  18740. * Returns the light type ID (integer).
  18741. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18742. */
  18743. getTypeID(): number;
  18744. /**
  18745. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18746. * @returns the scaled intensity in intensity mode unit
  18747. */
  18748. getScaledIntensity(): number;
  18749. /**
  18750. * Returns a new Light object, named "name", from the current one.
  18751. * @param name The name of the cloned light
  18752. * @param newParent The parent of this light, if it has one
  18753. * @returns the new created light
  18754. */
  18755. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18756. /**
  18757. * Serializes the current light into a Serialization object.
  18758. * @returns the serialized object.
  18759. */
  18760. serialize(): any;
  18761. /**
  18762. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18763. * This new light is named "name" and added to the passed scene.
  18764. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18765. * @param name The friendly name of the light
  18766. * @param scene The scene the new light will belong to
  18767. * @returns the constructor function
  18768. */
  18769. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18770. /**
  18771. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18772. * @param parsedLight The JSON representation of the light
  18773. * @param scene The scene to create the parsed light in
  18774. * @returns the created light after parsing
  18775. */
  18776. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18777. private _hookArrayForExcluded;
  18778. private _hookArrayForIncludedOnly;
  18779. private _resyncMeshes;
  18780. /**
  18781. * Forces the meshes to update their light related information in their rendering used effects
  18782. * @hidden Internal Use Only
  18783. */
  18784. _markMeshesAsLightDirty(): void;
  18785. /**
  18786. * Recomputes the cached photometric scale if needed.
  18787. */
  18788. private _computePhotometricScale;
  18789. /**
  18790. * Returns the Photometric Scale according to the light type and intensity mode.
  18791. */
  18792. private _getPhotometricScale;
  18793. /**
  18794. * Reorder the light in the scene according to their defined priority.
  18795. * @hidden Internal Use Only
  18796. */
  18797. _reorderLightsInScene(): void;
  18798. /**
  18799. * Prepares the list of defines specific to the light type.
  18800. * @param defines the list of defines
  18801. * @param lightIndex defines the index of the light for the effect
  18802. */
  18803. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18804. }
  18805. }
  18806. declare module "babylonjs/Cameras/targetCamera" {
  18807. import { Nullable } from "babylonjs/types";
  18808. import { Camera } from "babylonjs/Cameras/camera";
  18809. import { Scene } from "babylonjs/scene";
  18810. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18811. /**
  18812. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18813. * This is the base of the follow, arc rotate cameras and Free camera
  18814. * @see https://doc.babylonjs.com/features/cameras
  18815. */
  18816. export class TargetCamera extends Camera {
  18817. private static _RigCamTransformMatrix;
  18818. private static _TargetTransformMatrix;
  18819. private static _TargetFocalPoint;
  18820. private _tmpUpVector;
  18821. private _tmpTargetVector;
  18822. /**
  18823. * Define the current direction the camera is moving to
  18824. */
  18825. cameraDirection: Vector3;
  18826. /**
  18827. * Define the current rotation the camera is rotating to
  18828. */
  18829. cameraRotation: Vector2;
  18830. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18831. ignoreParentScaling: boolean;
  18832. /**
  18833. * When set, the up vector of the camera will be updated by the rotation of the camera
  18834. */
  18835. updateUpVectorFromRotation: boolean;
  18836. private _tmpQuaternion;
  18837. /**
  18838. * Define the current rotation of the camera
  18839. */
  18840. rotation: Vector3;
  18841. /**
  18842. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18843. */
  18844. rotationQuaternion: Quaternion;
  18845. /**
  18846. * Define the current speed of the camera
  18847. */
  18848. speed: number;
  18849. /**
  18850. * Add constraint to the camera to prevent it to move freely in all directions and
  18851. * around all axis.
  18852. */
  18853. noRotationConstraint: boolean;
  18854. /**
  18855. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18856. * panning
  18857. */
  18858. invertRotation: boolean;
  18859. /**
  18860. * Speed multiplier for inverse camera panning
  18861. */
  18862. inverseRotationSpeed: number;
  18863. /**
  18864. * Define the current target of the camera as an object or a position.
  18865. */
  18866. lockedTarget: any;
  18867. /** @hidden */
  18868. _currentTarget: Vector3;
  18869. /** @hidden */
  18870. _initialFocalDistance: number;
  18871. /** @hidden */
  18872. _viewMatrix: Matrix;
  18873. /** @hidden */
  18874. _camMatrix: Matrix;
  18875. /** @hidden */
  18876. _cameraTransformMatrix: Matrix;
  18877. /** @hidden */
  18878. _cameraRotationMatrix: Matrix;
  18879. /** @hidden */
  18880. _referencePoint: Vector3;
  18881. /** @hidden */
  18882. _transformedReferencePoint: Vector3;
  18883. /** @hidden */
  18884. _reset: () => void;
  18885. private _defaultUp;
  18886. /**
  18887. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18888. * This is the base of the follow, arc rotate cameras and Free camera
  18889. * @see https://doc.babylonjs.com/features/cameras
  18890. * @param name Defines the name of the camera in the scene
  18891. * @param position Defines the start position of the camera in the scene
  18892. * @param scene Defines the scene the camera belongs to
  18893. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18894. */
  18895. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18896. /**
  18897. * Gets the position in front of the camera at a given distance.
  18898. * @param distance The distance from the camera we want the position to be
  18899. * @returns the position
  18900. */
  18901. getFrontPosition(distance: number): Vector3;
  18902. /** @hidden */
  18903. _getLockedTargetPosition(): Nullable<Vector3>;
  18904. private _storedPosition;
  18905. private _storedRotation;
  18906. private _storedRotationQuaternion;
  18907. /**
  18908. * Store current camera state of the camera (fov, position, rotation, etc..)
  18909. * @returns the camera
  18910. */
  18911. storeState(): Camera;
  18912. /**
  18913. * Restored camera state. You must call storeState() first
  18914. * @returns whether it was successful or not
  18915. * @hidden
  18916. */
  18917. _restoreStateValues(): boolean;
  18918. /** @hidden */
  18919. _initCache(): void;
  18920. /** @hidden */
  18921. _updateCache(ignoreParentClass?: boolean): void;
  18922. /** @hidden */
  18923. _isSynchronizedViewMatrix(): boolean;
  18924. /** @hidden */
  18925. _computeLocalCameraSpeed(): number;
  18926. /**
  18927. * Defines the target the camera should look at.
  18928. * @param target Defines the new target as a Vector or a mesh
  18929. */
  18930. setTarget(target: Vector3): void;
  18931. /**
  18932. * Defines the target point of the camera.
  18933. * The camera looks towards it form the radius distance.
  18934. */
  18935. get target(): Vector3;
  18936. set target(value: Vector3);
  18937. /**
  18938. * Return the current target position of the camera. This value is expressed in local space.
  18939. * @returns the target position
  18940. */
  18941. getTarget(): Vector3;
  18942. /** @hidden */
  18943. _decideIfNeedsToMove(): boolean;
  18944. /** @hidden */
  18945. _updatePosition(): void;
  18946. /** @hidden */
  18947. _checkInputs(): void;
  18948. protected _updateCameraRotationMatrix(): void;
  18949. /**
  18950. * 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)
  18951. * @returns the current camera
  18952. */
  18953. private _rotateUpVectorWithCameraRotationMatrix;
  18954. private _cachedRotationZ;
  18955. private _cachedQuaternionRotationZ;
  18956. /** @hidden */
  18957. _getViewMatrix(): Matrix;
  18958. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18959. /**
  18960. * @hidden
  18961. */
  18962. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18963. /**
  18964. * @hidden
  18965. */
  18966. _updateRigCameras(): void;
  18967. private _getRigCamPositionAndTarget;
  18968. /**
  18969. * Gets the current object class name.
  18970. * @return the class name
  18971. */
  18972. getClassName(): string;
  18973. }
  18974. }
  18975. declare module "babylonjs/Events/keyboardEvents" {
  18976. /**
  18977. * Gather the list of keyboard event types as constants.
  18978. */
  18979. export class KeyboardEventTypes {
  18980. /**
  18981. * The keydown event is fired when a key becomes active (pressed).
  18982. */
  18983. static readonly KEYDOWN: number;
  18984. /**
  18985. * The keyup event is fired when a key has been released.
  18986. */
  18987. static readonly KEYUP: number;
  18988. }
  18989. /**
  18990. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18991. */
  18992. export class KeyboardInfo {
  18993. /**
  18994. * Defines the type of event (KeyboardEventTypes)
  18995. */
  18996. type: number;
  18997. /**
  18998. * Defines the related dom event
  18999. */
  19000. event: KeyboardEvent;
  19001. /**
  19002. * Instantiates a new keyboard info.
  19003. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19004. * @param type Defines the type of event (KeyboardEventTypes)
  19005. * @param event Defines the related dom event
  19006. */
  19007. constructor(
  19008. /**
  19009. * Defines the type of event (KeyboardEventTypes)
  19010. */
  19011. type: number,
  19012. /**
  19013. * Defines the related dom event
  19014. */
  19015. event: KeyboardEvent);
  19016. }
  19017. /**
  19018. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19019. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19020. */
  19021. export class KeyboardInfoPre extends KeyboardInfo {
  19022. /**
  19023. * Defines the type of event (KeyboardEventTypes)
  19024. */
  19025. type: number;
  19026. /**
  19027. * Defines the related dom event
  19028. */
  19029. event: KeyboardEvent;
  19030. /**
  19031. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19032. */
  19033. skipOnPointerObservable: boolean;
  19034. /**
  19035. * Instantiates a new keyboard pre info.
  19036. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19037. * @param type Defines the type of event (KeyboardEventTypes)
  19038. * @param event Defines the related dom event
  19039. */
  19040. constructor(
  19041. /**
  19042. * Defines the type of event (KeyboardEventTypes)
  19043. */
  19044. type: number,
  19045. /**
  19046. * Defines the related dom event
  19047. */
  19048. event: KeyboardEvent);
  19049. }
  19050. }
  19051. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19052. import { Nullable } from "babylonjs/types";
  19053. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19054. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19055. /**
  19056. * Manage the keyboard inputs to control the movement of a free camera.
  19057. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19058. */
  19059. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19060. /**
  19061. * Defines the camera the input is attached to.
  19062. */
  19063. camera: FreeCamera;
  19064. /**
  19065. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19066. */
  19067. keysUp: number[];
  19068. /**
  19069. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19070. */
  19071. keysUpward: number[];
  19072. /**
  19073. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19074. */
  19075. keysDown: number[];
  19076. /**
  19077. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19078. */
  19079. keysDownward: number[];
  19080. /**
  19081. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19082. */
  19083. keysLeft: number[];
  19084. /**
  19085. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19086. */
  19087. keysRight: number[];
  19088. private _keys;
  19089. private _onCanvasBlurObserver;
  19090. private _onKeyboardObserver;
  19091. private _engine;
  19092. private _scene;
  19093. /**
  19094. * Attach the input controls to a specific dom element to get the input from.
  19095. * @param element Defines the element the controls should be listened from
  19096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19097. */
  19098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19099. /**
  19100. * Detach the current controls from the specified dom element.
  19101. * @param element Defines the element to stop listening the inputs from
  19102. */
  19103. detachControl(element: Nullable<HTMLElement>): void;
  19104. /**
  19105. * Update the current camera state depending on the inputs that have been used this frame.
  19106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19107. */
  19108. checkInputs(): void;
  19109. /**
  19110. * Gets the class name of the current intput.
  19111. * @returns the class name
  19112. */
  19113. getClassName(): string;
  19114. /** @hidden */
  19115. _onLostFocus(): void;
  19116. /**
  19117. * Get the friendly name associated with the input class.
  19118. * @returns the input friendly name
  19119. */
  19120. getSimpleName(): string;
  19121. }
  19122. }
  19123. declare module "babylonjs/Events/pointerEvents" {
  19124. import { Nullable } from "babylonjs/types";
  19125. import { Vector2 } from "babylonjs/Maths/math.vector";
  19126. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19127. import { Ray } from "babylonjs/Culling/ray";
  19128. /**
  19129. * Gather the list of pointer event types as constants.
  19130. */
  19131. export class PointerEventTypes {
  19132. /**
  19133. * 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.
  19134. */
  19135. static readonly POINTERDOWN: number;
  19136. /**
  19137. * The pointerup event is fired when a pointer is no longer active.
  19138. */
  19139. static readonly POINTERUP: number;
  19140. /**
  19141. * The pointermove event is fired when a pointer changes coordinates.
  19142. */
  19143. static readonly POINTERMOVE: number;
  19144. /**
  19145. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19146. */
  19147. static readonly POINTERWHEEL: number;
  19148. /**
  19149. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19150. */
  19151. static readonly POINTERPICK: number;
  19152. /**
  19153. * The pointertap event is fired when a the object has been touched and released without drag.
  19154. */
  19155. static readonly POINTERTAP: number;
  19156. /**
  19157. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19158. */
  19159. static readonly POINTERDOUBLETAP: number;
  19160. }
  19161. /**
  19162. * Base class of pointer info types.
  19163. */
  19164. export class PointerInfoBase {
  19165. /**
  19166. * Defines the type of event (PointerEventTypes)
  19167. */
  19168. type: number;
  19169. /**
  19170. * Defines the related dom event
  19171. */
  19172. event: PointerEvent | MouseWheelEvent;
  19173. /**
  19174. * Instantiates the base class of pointers info.
  19175. * @param type Defines the type of event (PointerEventTypes)
  19176. * @param event Defines the related dom event
  19177. */
  19178. constructor(
  19179. /**
  19180. * Defines the type of event (PointerEventTypes)
  19181. */
  19182. type: number,
  19183. /**
  19184. * Defines the related dom event
  19185. */
  19186. event: PointerEvent | MouseWheelEvent);
  19187. }
  19188. /**
  19189. * This class is used to store pointer related info for the onPrePointerObservable event.
  19190. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19191. */
  19192. export class PointerInfoPre extends PointerInfoBase {
  19193. /**
  19194. * Ray from a pointer if availible (eg. 6dof controller)
  19195. */
  19196. ray: Nullable<Ray>;
  19197. /**
  19198. * Defines the local position of the pointer on the canvas.
  19199. */
  19200. localPosition: Vector2;
  19201. /**
  19202. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19203. */
  19204. skipOnPointerObservable: boolean;
  19205. /**
  19206. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19207. * @param type Defines the type of event (PointerEventTypes)
  19208. * @param event Defines the related dom event
  19209. * @param localX Defines the local x coordinates of the pointer when the event occured
  19210. * @param localY Defines the local y coordinates of the pointer when the event occured
  19211. */
  19212. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19213. }
  19214. /**
  19215. * This type contains all the data related to a pointer event in Babylon.js.
  19216. * 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.
  19217. */
  19218. export class PointerInfo extends PointerInfoBase {
  19219. /**
  19220. * Defines the picking info associated to the info (if any)\
  19221. */
  19222. pickInfo: Nullable<PickingInfo>;
  19223. /**
  19224. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19225. * @param type Defines the type of event (PointerEventTypes)
  19226. * @param event Defines the related dom event
  19227. * @param pickInfo Defines the picking info associated to the info (if any)\
  19228. */
  19229. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19230. /**
  19231. * Defines the picking info associated to the info (if any)\
  19232. */
  19233. pickInfo: Nullable<PickingInfo>);
  19234. }
  19235. /**
  19236. * Data relating to a touch event on the screen.
  19237. */
  19238. export interface PointerTouch {
  19239. /**
  19240. * X coordinate of touch.
  19241. */
  19242. x: number;
  19243. /**
  19244. * Y coordinate of touch.
  19245. */
  19246. y: number;
  19247. /**
  19248. * Id of touch. Unique for each finger.
  19249. */
  19250. pointerId: number;
  19251. /**
  19252. * Event type passed from DOM.
  19253. */
  19254. type: any;
  19255. }
  19256. }
  19257. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19258. import { Observable } from "babylonjs/Misc/observable";
  19259. import { Nullable } from "babylonjs/types";
  19260. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19261. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19262. /**
  19263. * Manage the mouse inputs to control the movement of a free camera.
  19264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19265. */
  19266. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19267. /**
  19268. * Define if touch is enabled in the mouse input
  19269. */
  19270. touchEnabled: boolean;
  19271. /**
  19272. * Defines the camera the input is attached to.
  19273. */
  19274. camera: FreeCamera;
  19275. /**
  19276. * Defines the buttons associated with the input to handle camera move.
  19277. */
  19278. buttons: number[];
  19279. /**
  19280. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19281. */
  19282. angularSensibility: number;
  19283. private _pointerInput;
  19284. private _onMouseMove;
  19285. private _observer;
  19286. private previousPosition;
  19287. /**
  19288. * Observable for when a pointer move event occurs containing the move offset
  19289. */
  19290. onPointerMovedObservable: Observable<{
  19291. offsetX: number;
  19292. offsetY: number;
  19293. }>;
  19294. /**
  19295. * @hidden
  19296. * If the camera should be rotated automatically based on pointer movement
  19297. */
  19298. _allowCameraRotation: boolean;
  19299. /**
  19300. * Manage the mouse inputs to control the movement of a free camera.
  19301. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19302. * @param touchEnabled Defines if touch is enabled or not
  19303. */
  19304. constructor(
  19305. /**
  19306. * Define if touch is enabled in the mouse input
  19307. */
  19308. touchEnabled?: boolean);
  19309. /**
  19310. * Attach the input controls to a specific dom element to get the input from.
  19311. * @param element Defines the element the controls should be listened from
  19312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19313. */
  19314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19315. /**
  19316. * Called on JS contextmenu event.
  19317. * Override this method to provide functionality.
  19318. */
  19319. protected onContextMenu(evt: PointerEvent): void;
  19320. /**
  19321. * Detach the current controls from the specified dom element.
  19322. * @param element Defines the element to stop listening the inputs from
  19323. */
  19324. detachControl(element: Nullable<HTMLElement>): void;
  19325. /**
  19326. * Gets the class name of the current intput.
  19327. * @returns the class name
  19328. */
  19329. getClassName(): string;
  19330. /**
  19331. * Get the friendly name associated with the input class.
  19332. * @returns the input friendly name
  19333. */
  19334. getSimpleName(): string;
  19335. }
  19336. }
  19337. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19338. import { Nullable } from "babylonjs/types";
  19339. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19340. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19341. /**
  19342. * Manage the touch inputs to control the movement of a free camera.
  19343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19344. */
  19345. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19346. /**
  19347. * Defines the camera the input is attached to.
  19348. */
  19349. camera: FreeCamera;
  19350. /**
  19351. * Defines the touch sensibility for rotation.
  19352. * The higher the faster.
  19353. */
  19354. touchAngularSensibility: number;
  19355. /**
  19356. * Defines the touch sensibility for move.
  19357. * The higher the faster.
  19358. */
  19359. touchMoveSensibility: number;
  19360. private _offsetX;
  19361. private _offsetY;
  19362. private _pointerPressed;
  19363. private _pointerInput;
  19364. private _observer;
  19365. private _onLostFocus;
  19366. /**
  19367. * Attach the input controls to a specific dom element to get the input from.
  19368. * @param element Defines the element the controls should be listened from
  19369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19370. */
  19371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19372. /**
  19373. * Detach the current controls from the specified dom element.
  19374. * @param element Defines the element to stop listening the inputs from
  19375. */
  19376. detachControl(element: Nullable<HTMLElement>): void;
  19377. /**
  19378. * Update the current camera state depending on the inputs that have been used this frame.
  19379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19380. */
  19381. checkInputs(): void;
  19382. /**
  19383. * Gets the class name of the current intput.
  19384. * @returns the class name
  19385. */
  19386. getClassName(): string;
  19387. /**
  19388. * Get the friendly name associated with the input class.
  19389. * @returns the input friendly name
  19390. */
  19391. getSimpleName(): string;
  19392. }
  19393. }
  19394. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19395. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19396. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19397. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19398. import { Nullable } from "babylonjs/types";
  19399. /**
  19400. * Default Inputs manager for the FreeCamera.
  19401. * It groups all the default supported inputs for ease of use.
  19402. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19403. */
  19404. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19405. /**
  19406. * @hidden
  19407. */
  19408. _mouseInput: Nullable<FreeCameraMouseInput>;
  19409. /**
  19410. * Instantiates a new FreeCameraInputsManager.
  19411. * @param camera Defines the camera the inputs belong to
  19412. */
  19413. constructor(camera: FreeCamera);
  19414. /**
  19415. * Add keyboard input support to the input manager.
  19416. * @returns the current input manager
  19417. */
  19418. addKeyboard(): FreeCameraInputsManager;
  19419. /**
  19420. * Add mouse input support to the input manager.
  19421. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19422. * @returns the current input manager
  19423. */
  19424. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19425. /**
  19426. * Removes the mouse input support from the manager
  19427. * @returns the current input manager
  19428. */
  19429. removeMouse(): FreeCameraInputsManager;
  19430. /**
  19431. * Add touch input support to the input manager.
  19432. * @returns the current input manager
  19433. */
  19434. addTouch(): FreeCameraInputsManager;
  19435. /**
  19436. * Remove all attached input methods from a camera
  19437. */
  19438. clear(): void;
  19439. }
  19440. }
  19441. declare module "babylonjs/Cameras/freeCamera" {
  19442. import { Vector3 } from "babylonjs/Maths/math.vector";
  19443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19444. import { Scene } from "babylonjs/scene";
  19445. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19446. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19447. /**
  19448. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19449. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19450. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19451. */
  19452. export class FreeCamera extends TargetCamera {
  19453. /**
  19454. * Define the collision ellipsoid of the camera.
  19455. * This is helpful to simulate a camera body like the player body around the camera
  19456. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19457. */
  19458. ellipsoid: Vector3;
  19459. /**
  19460. * Define an offset for the position of the ellipsoid around the camera.
  19461. * This can be helpful to determine the center of the body near the gravity center of the body
  19462. * instead of its head.
  19463. */
  19464. ellipsoidOffset: Vector3;
  19465. /**
  19466. * Enable or disable collisions of the camera with the rest of the scene objects.
  19467. */
  19468. checkCollisions: boolean;
  19469. /**
  19470. * Enable or disable gravity on the camera.
  19471. */
  19472. applyGravity: boolean;
  19473. /**
  19474. * Define the input manager associated to the camera.
  19475. */
  19476. inputs: FreeCameraInputsManager;
  19477. /**
  19478. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19479. * Higher values reduce sensitivity.
  19480. */
  19481. get angularSensibility(): number;
  19482. /**
  19483. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19484. * Higher values reduce sensitivity.
  19485. */
  19486. set angularSensibility(value: number);
  19487. /**
  19488. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19489. */
  19490. get keysUp(): number[];
  19491. set keysUp(value: number[]);
  19492. /**
  19493. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19494. */
  19495. get keysUpward(): number[];
  19496. set keysUpward(value: number[]);
  19497. /**
  19498. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19499. */
  19500. get keysDown(): number[];
  19501. set keysDown(value: number[]);
  19502. /**
  19503. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19504. */
  19505. get keysDownward(): number[];
  19506. set keysDownward(value: number[]);
  19507. /**
  19508. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19509. */
  19510. get keysLeft(): number[];
  19511. set keysLeft(value: number[]);
  19512. /**
  19513. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19514. */
  19515. get keysRight(): number[];
  19516. set keysRight(value: number[]);
  19517. /**
  19518. * Event raised when the camera collide with a mesh in the scene.
  19519. */
  19520. onCollide: (collidedMesh: AbstractMesh) => void;
  19521. private _collider;
  19522. private _needMoveForGravity;
  19523. private _oldPosition;
  19524. private _diffPosition;
  19525. private _newPosition;
  19526. /** @hidden */
  19527. _localDirection: Vector3;
  19528. /** @hidden */
  19529. _transformedDirection: Vector3;
  19530. /**
  19531. * Instantiates a Free Camera.
  19532. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19533. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19534. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19535. * @param name Define the name of the camera in the scene
  19536. * @param position Define the start position of the camera in the scene
  19537. * @param scene Define the scene the camera belongs to
  19538. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19539. */
  19540. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19541. /**
  19542. * Attached controls to the current camera.
  19543. * @param element Defines the element the controls should be listened from
  19544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19545. */
  19546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19547. /**
  19548. * Detach the current controls from the camera.
  19549. * The camera will stop reacting to inputs.
  19550. * @param element Defines the element to stop listening the inputs from
  19551. */
  19552. detachControl(element: HTMLElement): void;
  19553. private _collisionMask;
  19554. /**
  19555. * Define a collision mask to limit the list of object the camera can collide with
  19556. */
  19557. get collisionMask(): number;
  19558. set collisionMask(mask: number);
  19559. /** @hidden */
  19560. _collideWithWorld(displacement: Vector3): void;
  19561. private _onCollisionPositionChange;
  19562. /** @hidden */
  19563. _checkInputs(): void;
  19564. /** @hidden */
  19565. _decideIfNeedsToMove(): boolean;
  19566. /** @hidden */
  19567. _updatePosition(): void;
  19568. /**
  19569. * Destroy the camera and release the current resources hold by it.
  19570. */
  19571. dispose(): void;
  19572. /**
  19573. * Gets the current object class name.
  19574. * @return the class name
  19575. */
  19576. getClassName(): string;
  19577. }
  19578. }
  19579. declare module "babylonjs/Gamepads/gamepad" {
  19580. import { Observable } from "babylonjs/Misc/observable";
  19581. /**
  19582. * Represents a gamepad control stick position
  19583. */
  19584. export class StickValues {
  19585. /**
  19586. * The x component of the control stick
  19587. */
  19588. x: number;
  19589. /**
  19590. * The y component of the control stick
  19591. */
  19592. y: number;
  19593. /**
  19594. * Initializes the gamepad x and y control stick values
  19595. * @param x The x component of the gamepad control stick value
  19596. * @param y The y component of the gamepad control stick value
  19597. */
  19598. constructor(
  19599. /**
  19600. * The x component of the control stick
  19601. */
  19602. x: number,
  19603. /**
  19604. * The y component of the control stick
  19605. */
  19606. y: number);
  19607. }
  19608. /**
  19609. * An interface which manages callbacks for gamepad button changes
  19610. */
  19611. export interface GamepadButtonChanges {
  19612. /**
  19613. * Called when a gamepad has been changed
  19614. */
  19615. changed: boolean;
  19616. /**
  19617. * Called when a gamepad press event has been triggered
  19618. */
  19619. pressChanged: boolean;
  19620. /**
  19621. * Called when a touch event has been triggered
  19622. */
  19623. touchChanged: boolean;
  19624. /**
  19625. * Called when a value has changed
  19626. */
  19627. valueChanged: boolean;
  19628. }
  19629. /**
  19630. * Represents a gamepad
  19631. */
  19632. export class Gamepad {
  19633. /**
  19634. * The id of the gamepad
  19635. */
  19636. id: string;
  19637. /**
  19638. * The index of the gamepad
  19639. */
  19640. index: number;
  19641. /**
  19642. * The browser gamepad
  19643. */
  19644. browserGamepad: any;
  19645. /**
  19646. * Specifies what type of gamepad this represents
  19647. */
  19648. type: number;
  19649. private _leftStick;
  19650. private _rightStick;
  19651. /** @hidden */
  19652. _isConnected: boolean;
  19653. private _leftStickAxisX;
  19654. private _leftStickAxisY;
  19655. private _rightStickAxisX;
  19656. private _rightStickAxisY;
  19657. /**
  19658. * Triggered when the left control stick has been changed
  19659. */
  19660. private _onleftstickchanged;
  19661. /**
  19662. * Triggered when the right control stick has been changed
  19663. */
  19664. private _onrightstickchanged;
  19665. /**
  19666. * Represents a gamepad controller
  19667. */
  19668. static GAMEPAD: number;
  19669. /**
  19670. * Represents a generic controller
  19671. */
  19672. static GENERIC: number;
  19673. /**
  19674. * Represents an XBox controller
  19675. */
  19676. static XBOX: number;
  19677. /**
  19678. * Represents a pose-enabled controller
  19679. */
  19680. static POSE_ENABLED: number;
  19681. /**
  19682. * Represents an Dual Shock controller
  19683. */
  19684. static DUALSHOCK: number;
  19685. /**
  19686. * Specifies whether the left control stick should be Y-inverted
  19687. */
  19688. protected _invertLeftStickY: boolean;
  19689. /**
  19690. * Specifies if the gamepad has been connected
  19691. */
  19692. get isConnected(): boolean;
  19693. /**
  19694. * Initializes the gamepad
  19695. * @param id The id of the gamepad
  19696. * @param index The index of the gamepad
  19697. * @param browserGamepad The browser gamepad
  19698. * @param leftStickX The x component of the left joystick
  19699. * @param leftStickY The y component of the left joystick
  19700. * @param rightStickX The x component of the right joystick
  19701. * @param rightStickY The y component of the right joystick
  19702. */
  19703. constructor(
  19704. /**
  19705. * The id of the gamepad
  19706. */
  19707. id: string,
  19708. /**
  19709. * The index of the gamepad
  19710. */
  19711. index: number,
  19712. /**
  19713. * The browser gamepad
  19714. */
  19715. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19716. /**
  19717. * Callback triggered when the left joystick has changed
  19718. * @param callback
  19719. */
  19720. onleftstickchanged(callback: (values: StickValues) => void): void;
  19721. /**
  19722. * Callback triggered when the right joystick has changed
  19723. * @param callback
  19724. */
  19725. onrightstickchanged(callback: (values: StickValues) => void): void;
  19726. /**
  19727. * Gets the left joystick
  19728. */
  19729. get leftStick(): StickValues;
  19730. /**
  19731. * Sets the left joystick values
  19732. */
  19733. set leftStick(newValues: StickValues);
  19734. /**
  19735. * Gets the right joystick
  19736. */
  19737. get rightStick(): StickValues;
  19738. /**
  19739. * Sets the right joystick value
  19740. */
  19741. set rightStick(newValues: StickValues);
  19742. /**
  19743. * Updates the gamepad joystick positions
  19744. */
  19745. update(): void;
  19746. /**
  19747. * Disposes the gamepad
  19748. */
  19749. dispose(): void;
  19750. }
  19751. /**
  19752. * Represents a generic gamepad
  19753. */
  19754. export class GenericPad extends Gamepad {
  19755. private _buttons;
  19756. private _onbuttondown;
  19757. private _onbuttonup;
  19758. /**
  19759. * Observable triggered when a button has been pressed
  19760. */
  19761. onButtonDownObservable: Observable<number>;
  19762. /**
  19763. * Observable triggered when a button has been released
  19764. */
  19765. onButtonUpObservable: Observable<number>;
  19766. /**
  19767. * Callback triggered when a button has been pressed
  19768. * @param callback Called when a button has been pressed
  19769. */
  19770. onbuttondown(callback: (buttonPressed: number) => void): void;
  19771. /**
  19772. * Callback triggered when a button has been released
  19773. * @param callback Called when a button has been released
  19774. */
  19775. onbuttonup(callback: (buttonReleased: number) => void): void;
  19776. /**
  19777. * Initializes the generic gamepad
  19778. * @param id The id of the generic gamepad
  19779. * @param index The index of the generic gamepad
  19780. * @param browserGamepad The browser gamepad
  19781. */
  19782. constructor(id: string, index: number, browserGamepad: any);
  19783. private _setButtonValue;
  19784. /**
  19785. * Updates the generic gamepad
  19786. */
  19787. update(): void;
  19788. /**
  19789. * Disposes the generic gamepad
  19790. */
  19791. dispose(): void;
  19792. }
  19793. }
  19794. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19795. import { Observable } from "babylonjs/Misc/observable";
  19796. import { Nullable } from "babylonjs/types";
  19797. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19798. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19800. import { Ray } from "babylonjs/Culling/ray";
  19801. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19802. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19803. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19804. /**
  19805. * Defines the types of pose enabled controllers that are supported
  19806. */
  19807. export enum PoseEnabledControllerType {
  19808. /**
  19809. * HTC Vive
  19810. */
  19811. VIVE = 0,
  19812. /**
  19813. * Oculus Rift
  19814. */
  19815. OCULUS = 1,
  19816. /**
  19817. * Windows mixed reality
  19818. */
  19819. WINDOWS = 2,
  19820. /**
  19821. * Samsung gear VR
  19822. */
  19823. GEAR_VR = 3,
  19824. /**
  19825. * Google Daydream
  19826. */
  19827. DAYDREAM = 4,
  19828. /**
  19829. * Generic
  19830. */
  19831. GENERIC = 5
  19832. }
  19833. /**
  19834. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19835. */
  19836. export interface MutableGamepadButton {
  19837. /**
  19838. * Value of the button/trigger
  19839. */
  19840. value: number;
  19841. /**
  19842. * If the button/trigger is currently touched
  19843. */
  19844. touched: boolean;
  19845. /**
  19846. * If the button/trigger is currently pressed
  19847. */
  19848. pressed: boolean;
  19849. }
  19850. /**
  19851. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19852. * @hidden
  19853. */
  19854. export interface ExtendedGamepadButton extends GamepadButton {
  19855. /**
  19856. * If the button/trigger is currently pressed
  19857. */
  19858. readonly pressed: boolean;
  19859. /**
  19860. * If the button/trigger is currently touched
  19861. */
  19862. readonly touched: boolean;
  19863. /**
  19864. * Value of the button/trigger
  19865. */
  19866. readonly value: number;
  19867. }
  19868. /** @hidden */
  19869. export interface _GamePadFactory {
  19870. /**
  19871. * Returns whether or not the current gamepad can be created for this type of controller.
  19872. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19873. * @returns true if it can be created, otherwise false
  19874. */
  19875. canCreate(gamepadInfo: any): boolean;
  19876. /**
  19877. * Creates a new instance of the Gamepad.
  19878. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19879. * @returns the new gamepad instance
  19880. */
  19881. create(gamepadInfo: any): Gamepad;
  19882. }
  19883. /**
  19884. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19885. */
  19886. export class PoseEnabledControllerHelper {
  19887. /** @hidden */
  19888. static _ControllerFactories: _GamePadFactory[];
  19889. /** @hidden */
  19890. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19891. /**
  19892. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19893. * @param vrGamepad the gamepad to initialized
  19894. * @returns a vr controller of the type the gamepad identified as
  19895. */
  19896. static InitiateController(vrGamepad: any): Gamepad;
  19897. }
  19898. /**
  19899. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19900. */
  19901. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19902. /**
  19903. * If the controller is used in a webXR session
  19904. */
  19905. isXR: boolean;
  19906. private _deviceRoomPosition;
  19907. private _deviceRoomRotationQuaternion;
  19908. /**
  19909. * The device position in babylon space
  19910. */
  19911. devicePosition: Vector3;
  19912. /**
  19913. * The device rotation in babylon space
  19914. */
  19915. deviceRotationQuaternion: Quaternion;
  19916. /**
  19917. * The scale factor of the device in babylon space
  19918. */
  19919. deviceScaleFactor: number;
  19920. /**
  19921. * (Likely devicePosition should be used instead) The device position in its room space
  19922. */
  19923. position: Vector3;
  19924. /**
  19925. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19926. */
  19927. rotationQuaternion: Quaternion;
  19928. /**
  19929. * The type of controller (Eg. Windows mixed reality)
  19930. */
  19931. controllerType: PoseEnabledControllerType;
  19932. protected _calculatedPosition: Vector3;
  19933. private _calculatedRotation;
  19934. /**
  19935. * The raw pose from the device
  19936. */
  19937. rawPose: DevicePose;
  19938. private _trackPosition;
  19939. private _maxRotationDistFromHeadset;
  19940. private _draggedRoomRotation;
  19941. /**
  19942. * @hidden
  19943. */
  19944. _disableTrackPosition(fixedPosition: Vector3): void;
  19945. /**
  19946. * Internal, the mesh attached to the controller
  19947. * @hidden
  19948. */
  19949. _mesh: Nullable<AbstractMesh>;
  19950. private _poseControlledCamera;
  19951. private _leftHandSystemQuaternion;
  19952. /**
  19953. * Internal, matrix used to convert room space to babylon space
  19954. * @hidden
  19955. */
  19956. _deviceToWorld: Matrix;
  19957. /**
  19958. * Node to be used when casting a ray from the controller
  19959. * @hidden
  19960. */
  19961. _pointingPoseNode: Nullable<TransformNode>;
  19962. /**
  19963. * Name of the child mesh that can be used to cast a ray from the controller
  19964. */
  19965. static readonly POINTING_POSE: string;
  19966. /**
  19967. * Creates a new PoseEnabledController from a gamepad
  19968. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19969. */
  19970. constructor(browserGamepad: any);
  19971. private _workingMatrix;
  19972. /**
  19973. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19974. */
  19975. update(): void;
  19976. /**
  19977. * Updates only the pose device and mesh without doing any button event checking
  19978. */
  19979. protected _updatePoseAndMesh(): void;
  19980. /**
  19981. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19982. * @param poseData raw pose fromthe device
  19983. */
  19984. updateFromDevice(poseData: DevicePose): void;
  19985. /**
  19986. * @hidden
  19987. */
  19988. _meshAttachedObservable: Observable<AbstractMesh>;
  19989. /**
  19990. * Attaches a mesh to the controller
  19991. * @param mesh the mesh to be attached
  19992. */
  19993. attachToMesh(mesh: AbstractMesh): void;
  19994. /**
  19995. * Attaches the controllers mesh to a camera
  19996. * @param camera the camera the mesh should be attached to
  19997. */
  19998. attachToPoseControlledCamera(camera: TargetCamera): void;
  19999. /**
  20000. * Disposes of the controller
  20001. */
  20002. dispose(): void;
  20003. /**
  20004. * The mesh that is attached to the controller
  20005. */
  20006. get mesh(): Nullable<AbstractMesh>;
  20007. /**
  20008. * Gets the ray of the controller in the direction the controller is pointing
  20009. * @param length the length the resulting ray should be
  20010. * @returns a ray in the direction the controller is pointing
  20011. */
  20012. getForwardRay(length?: number): Ray;
  20013. }
  20014. }
  20015. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20016. import { Observable } from "babylonjs/Misc/observable";
  20017. import { Scene } from "babylonjs/scene";
  20018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20019. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20020. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20021. import { Nullable } from "babylonjs/types";
  20022. /**
  20023. * Defines the WebVRController object that represents controllers tracked in 3D space
  20024. */
  20025. export abstract class WebVRController extends PoseEnabledController {
  20026. /**
  20027. * Internal, the default controller model for the controller
  20028. */
  20029. protected _defaultModel: Nullable<AbstractMesh>;
  20030. /**
  20031. * Fired when the trigger state has changed
  20032. */
  20033. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20034. /**
  20035. * Fired when the main button state has changed
  20036. */
  20037. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20038. /**
  20039. * Fired when the secondary button state has changed
  20040. */
  20041. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20042. /**
  20043. * Fired when the pad state has changed
  20044. */
  20045. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20046. /**
  20047. * Fired when controllers stick values have changed
  20048. */
  20049. onPadValuesChangedObservable: Observable<StickValues>;
  20050. /**
  20051. * Array of button availible on the controller
  20052. */
  20053. protected _buttons: Array<MutableGamepadButton>;
  20054. private _onButtonStateChange;
  20055. /**
  20056. * Fired when a controller button's state has changed
  20057. * @param callback the callback containing the button that was modified
  20058. */
  20059. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20060. /**
  20061. * X and Y axis corresponding to the controllers joystick
  20062. */
  20063. pad: StickValues;
  20064. /**
  20065. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20066. */
  20067. hand: string;
  20068. /**
  20069. * The default controller model for the controller
  20070. */
  20071. get defaultModel(): Nullable<AbstractMesh>;
  20072. /**
  20073. * Creates a new WebVRController from a gamepad
  20074. * @param vrGamepad the gamepad that the WebVRController should be created from
  20075. */
  20076. constructor(vrGamepad: any);
  20077. /**
  20078. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20079. */
  20080. update(): void;
  20081. /**
  20082. * Function to be called when a button is modified
  20083. */
  20084. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20085. /**
  20086. * Loads a mesh and attaches it to the controller
  20087. * @param scene the scene the mesh should be added to
  20088. * @param meshLoaded callback for when the mesh has been loaded
  20089. */
  20090. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20091. private _setButtonValue;
  20092. private _changes;
  20093. private _checkChanges;
  20094. /**
  20095. * Disposes of th webVRCOntroller
  20096. */
  20097. dispose(): void;
  20098. }
  20099. }
  20100. declare module "babylonjs/Lights/hemisphericLight" {
  20101. import { Nullable } from "babylonjs/types";
  20102. import { Scene } from "babylonjs/scene";
  20103. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20104. import { Color3 } from "babylonjs/Maths/math.color";
  20105. import { Effect } from "babylonjs/Materials/effect";
  20106. import { Light } from "babylonjs/Lights/light";
  20107. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20108. /**
  20109. * The HemisphericLight simulates the ambient environment light,
  20110. * so the passed direction is the light reflection direction, not the incoming direction.
  20111. */
  20112. export class HemisphericLight extends Light {
  20113. /**
  20114. * The groundColor is the light in the opposite direction to the one specified during creation.
  20115. * 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.
  20116. */
  20117. groundColor: Color3;
  20118. /**
  20119. * The light reflection direction, not the incoming direction.
  20120. */
  20121. direction: Vector3;
  20122. /**
  20123. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20124. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20125. * The HemisphericLight can't cast shadows.
  20126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20127. * @param name The friendly name of the light
  20128. * @param direction The direction of the light reflection
  20129. * @param scene The scene the light belongs to
  20130. */
  20131. constructor(name: string, direction: Vector3, scene: Scene);
  20132. protected _buildUniformLayout(): void;
  20133. /**
  20134. * Returns the string "HemisphericLight".
  20135. * @return The class name
  20136. */
  20137. getClassName(): string;
  20138. /**
  20139. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20140. * Returns the updated direction.
  20141. * @param target The target the direction should point to
  20142. * @return The computed direction
  20143. */
  20144. setDirectionToTarget(target: Vector3): Vector3;
  20145. /**
  20146. * Returns the shadow generator associated to the light.
  20147. * @returns Always null for hemispheric lights because it does not support shadows.
  20148. */
  20149. getShadowGenerator(): Nullable<IShadowGenerator>;
  20150. /**
  20151. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20152. * @param effect The effect to update
  20153. * @param lightIndex The index of the light in the effect to update
  20154. * @returns The hemispheric light
  20155. */
  20156. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20157. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20158. /**
  20159. * Computes the world matrix of the node
  20160. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20161. * @param useWasUpdatedFlag defines a reserved property
  20162. * @returns the world matrix
  20163. */
  20164. computeWorldMatrix(): Matrix;
  20165. /**
  20166. * Returns the integer 3.
  20167. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20168. */
  20169. getTypeID(): number;
  20170. /**
  20171. * Prepares the list of defines specific to the light type.
  20172. * @param defines the list of defines
  20173. * @param lightIndex defines the index of the light for the effect
  20174. */
  20175. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20176. }
  20177. }
  20178. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20179. /** @hidden */
  20180. export var vrMultiviewToSingleviewPixelShader: {
  20181. name: string;
  20182. shader: string;
  20183. };
  20184. }
  20185. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20187. import { Scene } from "babylonjs/scene";
  20188. /**
  20189. * Renders to multiple views with a single draw call
  20190. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20191. */
  20192. export class MultiviewRenderTarget extends RenderTargetTexture {
  20193. /**
  20194. * Creates a multiview render target
  20195. * @param scene scene used with the render target
  20196. * @param size the size of the render target (used for each view)
  20197. */
  20198. constructor(scene: Scene, size?: number | {
  20199. width: number;
  20200. height: number;
  20201. } | {
  20202. ratio: number;
  20203. });
  20204. /**
  20205. * @hidden
  20206. * @param faceIndex the face index, if its a cube texture
  20207. */
  20208. _bindFrameBuffer(faceIndex?: number): void;
  20209. /**
  20210. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20211. * @returns the view count
  20212. */
  20213. getViewCount(): number;
  20214. }
  20215. }
  20216. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20217. import { Camera } from "babylonjs/Cameras/camera";
  20218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20219. import { Nullable } from "babylonjs/types";
  20220. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20221. import { Matrix } from "babylonjs/Maths/math.vector";
  20222. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20223. module "babylonjs/Engines/engine" {
  20224. interface Engine {
  20225. /**
  20226. * Creates a new multiview render target
  20227. * @param width defines the width of the texture
  20228. * @param height defines the height of the texture
  20229. * @returns the created multiview texture
  20230. */
  20231. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20232. /**
  20233. * Binds a multiview framebuffer to be drawn to
  20234. * @param multiviewTexture texture to bind
  20235. */
  20236. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20237. }
  20238. }
  20239. module "babylonjs/Cameras/camera" {
  20240. interface Camera {
  20241. /**
  20242. * @hidden
  20243. * 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)
  20244. */
  20245. _useMultiviewToSingleView: boolean;
  20246. /**
  20247. * @hidden
  20248. * 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)
  20249. */
  20250. _multiviewTexture: Nullable<RenderTargetTexture>;
  20251. /**
  20252. * @hidden
  20253. * ensures the multiview texture of the camera exists and has the specified width/height
  20254. * @param width height to set on the multiview texture
  20255. * @param height width to set on the multiview texture
  20256. */
  20257. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20258. }
  20259. }
  20260. module "babylonjs/scene" {
  20261. interface Scene {
  20262. /** @hidden */
  20263. _transformMatrixR: Matrix;
  20264. /** @hidden */
  20265. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20266. /** @hidden */
  20267. _createMultiviewUbo(): void;
  20268. /** @hidden */
  20269. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20270. /** @hidden */
  20271. _renderMultiviewToSingleView(camera: Camera): void;
  20272. }
  20273. }
  20274. }
  20275. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20276. import { Camera } from "babylonjs/Cameras/camera";
  20277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20278. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20279. import "babylonjs/Engines/Extensions/engine.multiview";
  20280. /**
  20281. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20282. * This will not be used for webXR as it supports displaying texture arrays directly
  20283. */
  20284. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20285. /**
  20286. * Initializes a VRMultiviewToSingleview
  20287. * @param name name of the post process
  20288. * @param camera camera to be applied to
  20289. * @param scaleFactor scaling factor to the size of the output texture
  20290. */
  20291. constructor(name: string, camera: Camera, scaleFactor: number);
  20292. }
  20293. }
  20294. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20295. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20296. import { Nullable } from "babylonjs/types";
  20297. import { Size } from "babylonjs/Maths/math.size";
  20298. import { Observable } from "babylonjs/Misc/observable";
  20299. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20300. /**
  20301. * Interface used to define additional presentation attributes
  20302. */
  20303. export interface IVRPresentationAttributes {
  20304. /**
  20305. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20306. */
  20307. highRefreshRate: boolean;
  20308. /**
  20309. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20310. */
  20311. foveationLevel: number;
  20312. }
  20313. module "babylonjs/Engines/engine" {
  20314. interface Engine {
  20315. /** @hidden */
  20316. _vrDisplay: any;
  20317. /** @hidden */
  20318. _vrSupported: boolean;
  20319. /** @hidden */
  20320. _oldSize: Size;
  20321. /** @hidden */
  20322. _oldHardwareScaleFactor: number;
  20323. /** @hidden */
  20324. _vrExclusivePointerMode: boolean;
  20325. /** @hidden */
  20326. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20327. /** @hidden */
  20328. _onVRDisplayPointerRestricted: () => void;
  20329. /** @hidden */
  20330. _onVRDisplayPointerUnrestricted: () => void;
  20331. /** @hidden */
  20332. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20333. /** @hidden */
  20334. _onVrDisplayDisconnect: Nullable<() => void>;
  20335. /** @hidden */
  20336. _onVrDisplayPresentChange: Nullable<() => void>;
  20337. /**
  20338. * Observable signaled when VR display mode changes
  20339. */
  20340. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20341. /**
  20342. * Observable signaled when VR request present is complete
  20343. */
  20344. onVRRequestPresentComplete: Observable<boolean>;
  20345. /**
  20346. * Observable signaled when VR request present starts
  20347. */
  20348. onVRRequestPresentStart: Observable<Engine>;
  20349. /**
  20350. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20351. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20352. */
  20353. isInVRExclusivePointerMode: boolean;
  20354. /**
  20355. * Gets a boolean indicating if a webVR device was detected
  20356. * @returns true if a webVR device was detected
  20357. */
  20358. isVRDevicePresent(): boolean;
  20359. /**
  20360. * Gets the current webVR device
  20361. * @returns the current webVR device (or null)
  20362. */
  20363. getVRDevice(): any;
  20364. /**
  20365. * Initializes a webVR display and starts listening to display change events
  20366. * The onVRDisplayChangedObservable will be notified upon these changes
  20367. * @returns A promise containing a VRDisplay and if vr is supported
  20368. */
  20369. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20370. /** @hidden */
  20371. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20372. /**
  20373. * Gets or sets the presentation attributes used to configure VR rendering
  20374. */
  20375. vrPresentationAttributes?: IVRPresentationAttributes;
  20376. /**
  20377. * Call this function to switch to webVR mode
  20378. * Will do nothing if webVR is not supported or if there is no webVR device
  20379. * @param options the webvr options provided to the camera. mainly used for multiview
  20380. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20381. */
  20382. enableVR(options: WebVROptions): void;
  20383. /** @hidden */
  20384. _onVRFullScreenTriggered(): void;
  20385. }
  20386. }
  20387. }
  20388. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20389. import { Nullable } from "babylonjs/types";
  20390. import { Observable } from "babylonjs/Misc/observable";
  20391. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20392. import { Scene } from "babylonjs/scene";
  20393. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20394. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20395. import { Node } from "babylonjs/node";
  20396. import { Ray } from "babylonjs/Culling/ray";
  20397. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20398. import "babylonjs/Engines/Extensions/engine.webVR";
  20399. /**
  20400. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20401. * IMPORTANT!! The data is right-hand data.
  20402. * @export
  20403. * @interface DevicePose
  20404. */
  20405. export interface DevicePose {
  20406. /**
  20407. * The position of the device, values in array are [x,y,z].
  20408. */
  20409. readonly position: Nullable<Float32Array>;
  20410. /**
  20411. * The linearVelocity of the device, values in array are [x,y,z].
  20412. */
  20413. readonly linearVelocity: Nullable<Float32Array>;
  20414. /**
  20415. * The linearAcceleration of the device, values in array are [x,y,z].
  20416. */
  20417. readonly linearAcceleration: Nullable<Float32Array>;
  20418. /**
  20419. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20420. */
  20421. readonly orientation: Nullable<Float32Array>;
  20422. /**
  20423. * The angularVelocity of the device, values in array are [x,y,z].
  20424. */
  20425. readonly angularVelocity: Nullable<Float32Array>;
  20426. /**
  20427. * The angularAcceleration of the device, values in array are [x,y,z].
  20428. */
  20429. readonly angularAcceleration: Nullable<Float32Array>;
  20430. }
  20431. /**
  20432. * Interface representing a pose controlled object in Babylon.
  20433. * A pose controlled object has both regular pose values as well as pose values
  20434. * from an external device such as a VR head mounted display
  20435. */
  20436. export interface PoseControlled {
  20437. /**
  20438. * The position of the object in babylon space.
  20439. */
  20440. position: Vector3;
  20441. /**
  20442. * The rotation quaternion of the object in babylon space.
  20443. */
  20444. rotationQuaternion: Quaternion;
  20445. /**
  20446. * The position of the device in babylon space.
  20447. */
  20448. devicePosition?: Vector3;
  20449. /**
  20450. * The rotation quaternion of the device in babylon space.
  20451. */
  20452. deviceRotationQuaternion: Quaternion;
  20453. /**
  20454. * The raw pose coming from the device.
  20455. */
  20456. rawPose: Nullable<DevicePose>;
  20457. /**
  20458. * The scale of the device to be used when translating from device space to babylon space.
  20459. */
  20460. deviceScaleFactor: number;
  20461. /**
  20462. * Updates the poseControlled values based on the input device pose.
  20463. * @param poseData the pose data to update the object with
  20464. */
  20465. updateFromDevice(poseData: DevicePose): void;
  20466. }
  20467. /**
  20468. * Set of options to customize the webVRCamera
  20469. */
  20470. export interface WebVROptions {
  20471. /**
  20472. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20473. */
  20474. trackPosition?: boolean;
  20475. /**
  20476. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20477. */
  20478. positionScale?: number;
  20479. /**
  20480. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20481. */
  20482. displayName?: string;
  20483. /**
  20484. * Should the native controller meshes be initialized. (default: true)
  20485. */
  20486. controllerMeshes?: boolean;
  20487. /**
  20488. * Creating a default HemiLight only on controllers. (default: true)
  20489. */
  20490. defaultLightingOnControllers?: boolean;
  20491. /**
  20492. * If you don't want to use the default VR button of the helper. (default: false)
  20493. */
  20494. useCustomVRButton?: boolean;
  20495. /**
  20496. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20497. */
  20498. customVRButton?: HTMLButtonElement;
  20499. /**
  20500. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20501. */
  20502. rayLength?: number;
  20503. /**
  20504. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20505. */
  20506. defaultHeight?: number;
  20507. /**
  20508. * If multiview should be used if availible (default: false)
  20509. */
  20510. useMultiview?: boolean;
  20511. }
  20512. /**
  20513. * This represents a WebVR camera.
  20514. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20515. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20516. */
  20517. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20518. private webVROptions;
  20519. /**
  20520. * @hidden
  20521. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20522. */
  20523. _vrDevice: any;
  20524. /**
  20525. * The rawPose of the vrDevice.
  20526. */
  20527. rawPose: Nullable<DevicePose>;
  20528. private _onVREnabled;
  20529. private _specsVersion;
  20530. private _attached;
  20531. private _frameData;
  20532. protected _descendants: Array<Node>;
  20533. private _deviceRoomPosition;
  20534. /** @hidden */
  20535. _deviceRoomRotationQuaternion: Quaternion;
  20536. private _standingMatrix;
  20537. /**
  20538. * Represents device position in babylon space.
  20539. */
  20540. devicePosition: Vector3;
  20541. /**
  20542. * Represents device rotation in babylon space.
  20543. */
  20544. deviceRotationQuaternion: Quaternion;
  20545. /**
  20546. * The scale of the device to be used when translating from device space to babylon space.
  20547. */
  20548. deviceScaleFactor: number;
  20549. private _deviceToWorld;
  20550. private _worldToDevice;
  20551. /**
  20552. * References to the webVR controllers for the vrDevice.
  20553. */
  20554. controllers: Array<WebVRController>;
  20555. /**
  20556. * Emits an event when a controller is attached.
  20557. */
  20558. onControllersAttachedObservable: Observable<WebVRController[]>;
  20559. /**
  20560. * Emits an event when a controller's mesh has been loaded;
  20561. */
  20562. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20563. /**
  20564. * Emits an event when the HMD's pose has been updated.
  20565. */
  20566. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20567. private _poseSet;
  20568. /**
  20569. * If the rig cameras be used as parent instead of this camera.
  20570. */
  20571. rigParenting: boolean;
  20572. private _lightOnControllers;
  20573. private _defaultHeight?;
  20574. /**
  20575. * Instantiates a WebVRFreeCamera.
  20576. * @param name The name of the WebVRFreeCamera
  20577. * @param position The starting anchor position for the camera
  20578. * @param scene The scene the camera belongs to
  20579. * @param webVROptions a set of customizable options for the webVRCamera
  20580. */
  20581. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20582. /**
  20583. * Gets the device distance from the ground in meters.
  20584. * @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.
  20585. */
  20586. deviceDistanceToRoomGround(): number;
  20587. /**
  20588. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20589. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20590. */
  20591. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20592. /**
  20593. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20594. * @returns A promise with a boolean set to if the standing matrix is supported.
  20595. */
  20596. useStandingMatrixAsync(): Promise<boolean>;
  20597. /**
  20598. * Disposes the camera
  20599. */
  20600. dispose(): void;
  20601. /**
  20602. * Gets a vrController by name.
  20603. * @param name The name of the controller to retreive
  20604. * @returns the controller matching the name specified or null if not found
  20605. */
  20606. getControllerByName(name: string): Nullable<WebVRController>;
  20607. private _leftController;
  20608. /**
  20609. * The controller corresponding to the users left hand.
  20610. */
  20611. get leftController(): Nullable<WebVRController>;
  20612. private _rightController;
  20613. /**
  20614. * The controller corresponding to the users right hand.
  20615. */
  20616. get rightController(): Nullable<WebVRController>;
  20617. /**
  20618. * Casts a ray forward from the vrCamera's gaze.
  20619. * @param length Length of the ray (default: 100)
  20620. * @returns the ray corresponding to the gaze
  20621. */
  20622. getForwardRay(length?: number): Ray;
  20623. /**
  20624. * @hidden
  20625. * Updates the camera based on device's frame data
  20626. */
  20627. _checkInputs(): void;
  20628. /**
  20629. * Updates the poseControlled values based on the input device pose.
  20630. * @param poseData Pose coming from the device
  20631. */
  20632. updateFromDevice(poseData: DevicePose): void;
  20633. private _htmlElementAttached;
  20634. private _detachIfAttached;
  20635. /**
  20636. * WebVR's attach control will start broadcasting frames to the device.
  20637. * Note that in certain browsers (chrome for example) this function must be called
  20638. * within a user-interaction callback. Example:
  20639. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20640. *
  20641. * @param element html element to attach the vrDevice to
  20642. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20643. */
  20644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20645. /**
  20646. * Detaches the camera from the html element and disables VR
  20647. *
  20648. * @param element html element to detach from
  20649. */
  20650. detachControl(element: HTMLElement): void;
  20651. /**
  20652. * @returns the name of this class
  20653. */
  20654. getClassName(): string;
  20655. /**
  20656. * Calls resetPose on the vrDisplay
  20657. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20658. */
  20659. resetToCurrentRotation(): void;
  20660. /**
  20661. * @hidden
  20662. * Updates the rig cameras (left and right eye)
  20663. */
  20664. _updateRigCameras(): void;
  20665. private _workingVector;
  20666. private _oneVector;
  20667. private _workingMatrix;
  20668. private updateCacheCalled;
  20669. private _correctPositionIfNotTrackPosition;
  20670. /**
  20671. * @hidden
  20672. * Updates the cached values of the camera
  20673. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20674. */
  20675. _updateCache(ignoreParentClass?: boolean): void;
  20676. /**
  20677. * @hidden
  20678. * Get current device position in babylon world
  20679. */
  20680. _computeDevicePosition(): void;
  20681. /**
  20682. * Updates the current device position and rotation in the babylon world
  20683. */
  20684. update(): void;
  20685. /**
  20686. * @hidden
  20687. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20688. * @returns an identity matrix
  20689. */
  20690. _getViewMatrix(): Matrix;
  20691. private _tmpMatrix;
  20692. /**
  20693. * This function is called by the two RIG cameras.
  20694. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20695. * @hidden
  20696. */
  20697. _getWebVRViewMatrix(): Matrix;
  20698. /** @hidden */
  20699. _getWebVRProjectionMatrix(): Matrix;
  20700. private _onGamepadConnectedObserver;
  20701. private _onGamepadDisconnectedObserver;
  20702. private _updateCacheWhenTrackingDisabledObserver;
  20703. /**
  20704. * Initializes the controllers and their meshes
  20705. */
  20706. initControllers(): void;
  20707. }
  20708. }
  20709. declare module "babylonjs/Materials/materialHelper" {
  20710. import { Nullable } from "babylonjs/types";
  20711. import { Scene } from "babylonjs/scene";
  20712. import { Engine } from "babylonjs/Engines/engine";
  20713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20714. import { Light } from "babylonjs/Lights/light";
  20715. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20716. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20718. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20719. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20720. /**
  20721. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20722. *
  20723. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20724. *
  20725. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20726. */
  20727. export class MaterialHelper {
  20728. /**
  20729. * Bind the current view position to an effect.
  20730. * @param effect The effect to be bound
  20731. * @param scene The scene the eyes position is used from
  20732. * @param variableName name of the shader variable that will hold the eye position
  20733. */
  20734. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20735. /**
  20736. * Helps preparing the defines values about the UVs in used in the effect.
  20737. * UVs are shared as much as we can accross channels in the shaders.
  20738. * @param texture The texture we are preparing the UVs for
  20739. * @param defines The defines to update
  20740. * @param key The channel key "diffuse", "specular"... used in the shader
  20741. */
  20742. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20743. /**
  20744. * Binds a texture matrix value to its corrsponding uniform
  20745. * @param texture The texture to bind the matrix for
  20746. * @param uniformBuffer The uniform buffer receivin the data
  20747. * @param key The channel key "diffuse", "specular"... used in the shader
  20748. */
  20749. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20750. /**
  20751. * Gets the current status of the fog (should it be enabled?)
  20752. * @param mesh defines the mesh to evaluate for fog support
  20753. * @param scene defines the hosting scene
  20754. * @returns true if fog must be enabled
  20755. */
  20756. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20757. /**
  20758. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20759. * @param mesh defines the current mesh
  20760. * @param scene defines the current scene
  20761. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20762. * @param pointsCloud defines if point cloud rendering has to be turned on
  20763. * @param fogEnabled defines if fog has to be turned on
  20764. * @param alphaTest defines if alpha testing has to be turned on
  20765. * @param defines defines the current list of defines
  20766. */
  20767. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20768. /**
  20769. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20770. * @param scene defines the current scene
  20771. * @param engine defines the current engine
  20772. * @param defines specifies the list of active defines
  20773. * @param useInstances defines if instances have to be turned on
  20774. * @param useClipPlane defines if clip plane have to be turned on
  20775. * @param useInstances defines if instances have to be turned on
  20776. * @param useThinInstances defines if thin instances have to be turned on
  20777. */
  20778. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20779. /**
  20780. * Prepares the defines for bones
  20781. * @param mesh The mesh containing the geometry data we will draw
  20782. * @param defines The defines to update
  20783. */
  20784. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20785. /**
  20786. * Prepares the defines for morph targets
  20787. * @param mesh The mesh containing the geometry data we will draw
  20788. * @param defines The defines to update
  20789. */
  20790. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20791. /**
  20792. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20793. * @param mesh The mesh containing the geometry data we will draw
  20794. * @param defines The defines to update
  20795. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20796. * @param useBones Precise whether bones should be used or not (override mesh info)
  20797. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20798. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20799. * @returns false if defines are considered not dirty and have not been checked
  20800. */
  20801. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20802. /**
  20803. * Prepares the defines related to multiview
  20804. * @param scene The scene we are intending to draw
  20805. * @param defines The defines to update
  20806. */
  20807. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20808. /**
  20809. * Prepares the defines related to the prepass
  20810. * @param scene The scene we are intending to draw
  20811. * @param defines The defines to update
  20812. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20813. */
  20814. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20815. /**
  20816. * Prepares the defines related to the light information passed in parameter
  20817. * @param scene The scene we are intending to draw
  20818. * @param mesh The mesh the effect is compiling for
  20819. * @param light The light the effect is compiling for
  20820. * @param lightIndex The index of the light
  20821. * @param defines The defines to update
  20822. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20823. * @param state Defines the current state regarding what is needed (normals, etc...)
  20824. */
  20825. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20826. needNormals: boolean;
  20827. needRebuild: boolean;
  20828. shadowEnabled: boolean;
  20829. specularEnabled: boolean;
  20830. lightmapMode: boolean;
  20831. }): void;
  20832. /**
  20833. * Prepares the defines related to the light information passed in parameter
  20834. * @param scene The scene we are intending to draw
  20835. * @param mesh The mesh the effect is compiling for
  20836. * @param defines The defines to update
  20837. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20838. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20839. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20840. * @returns true if normals will be required for the rest of the effect
  20841. */
  20842. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20843. /**
  20844. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20845. * @param lightIndex defines the light index
  20846. * @param uniformsList The uniform list
  20847. * @param samplersList The sampler list
  20848. * @param projectedLightTexture defines if projected texture must be used
  20849. * @param uniformBuffersList defines an optional list of uniform buffers
  20850. */
  20851. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20852. /**
  20853. * Prepares the uniforms and samplers list to be used in the effect
  20854. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20855. * @param samplersList The sampler list
  20856. * @param defines The defines helping in the list generation
  20857. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20858. */
  20859. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20860. /**
  20861. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20862. * @param defines The defines to update while falling back
  20863. * @param fallbacks The authorized effect fallbacks
  20864. * @param maxSimultaneousLights The maximum number of lights allowed
  20865. * @param rank the current rank of the Effect
  20866. * @returns The newly affected rank
  20867. */
  20868. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20869. private static _TmpMorphInfluencers;
  20870. /**
  20871. * Prepares the list of attributes required for morph targets according to the effect defines.
  20872. * @param attribs The current list of supported attribs
  20873. * @param mesh The mesh to prepare the morph targets attributes for
  20874. * @param influencers The number of influencers
  20875. */
  20876. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20877. /**
  20878. * Prepares the list of attributes required for morph targets according to the effect defines.
  20879. * @param attribs The current list of supported attribs
  20880. * @param mesh The mesh to prepare the morph targets attributes for
  20881. * @param defines The current Defines of the effect
  20882. */
  20883. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20884. /**
  20885. * Prepares the list of attributes required for bones according to the effect defines.
  20886. * @param attribs The current list of supported attribs
  20887. * @param mesh The mesh to prepare the bones attributes for
  20888. * @param defines The current Defines of the effect
  20889. * @param fallbacks The current efffect fallback strategy
  20890. */
  20891. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20892. /**
  20893. * Check and prepare the list of attributes required for instances according to the effect defines.
  20894. * @param attribs The current list of supported attribs
  20895. * @param defines The current MaterialDefines of the effect
  20896. */
  20897. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20898. /**
  20899. * Add the list of attributes required for instances to the attribs array.
  20900. * @param attribs The current list of supported attribs
  20901. */
  20902. static PushAttributesForInstances(attribs: string[]): void;
  20903. /**
  20904. * Binds the light information to the effect.
  20905. * @param light The light containing the generator
  20906. * @param effect The effect we are binding the data to
  20907. * @param lightIndex The light index in the effect used to render
  20908. */
  20909. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20910. /**
  20911. * Binds the lights information from the scene to the effect for the given mesh.
  20912. * @param light Light to bind
  20913. * @param lightIndex Light index
  20914. * @param scene The scene where the light belongs to
  20915. * @param effect The effect we are binding the data to
  20916. * @param useSpecular Defines if specular is supported
  20917. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20918. */
  20919. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20920. /**
  20921. * Binds the lights information from the scene to the effect for the given mesh.
  20922. * @param scene The scene the lights belongs to
  20923. * @param mesh The mesh we are binding the information to render
  20924. * @param effect The effect we are binding the data to
  20925. * @param defines The generated defines for the effect
  20926. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20927. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20928. */
  20929. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20930. private static _tempFogColor;
  20931. /**
  20932. * Binds the fog information from the scene to the effect for the given mesh.
  20933. * @param scene The scene the lights belongs to
  20934. * @param mesh The mesh we are binding the information to render
  20935. * @param effect The effect we are binding the data to
  20936. * @param linearSpace Defines if the fog effect is applied in linear space
  20937. */
  20938. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20939. /**
  20940. * Binds the bones information from the mesh to the effect.
  20941. * @param mesh The mesh we are binding the information to render
  20942. * @param effect The effect we are binding the data to
  20943. */
  20944. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20945. /**
  20946. * Binds the morph targets information from the mesh to the effect.
  20947. * @param abstractMesh The mesh we are binding the information to render
  20948. * @param effect The effect we are binding the data to
  20949. */
  20950. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20951. /**
  20952. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20953. * @param defines The generated defines used in the effect
  20954. * @param effect The effect we are binding the data to
  20955. * @param scene The scene we are willing to render with logarithmic scale for
  20956. */
  20957. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20958. /**
  20959. * Binds the clip plane information from the scene to the effect.
  20960. * @param scene The scene the clip plane information are extracted from
  20961. * @param effect The effect we are binding the data to
  20962. */
  20963. static BindClipPlane(effect: Effect, scene: Scene): void;
  20964. }
  20965. }
  20966. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20968. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20969. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20970. import { Nullable } from "babylonjs/types";
  20971. import { Effect } from "babylonjs/Materials/effect";
  20972. import { Matrix } from "babylonjs/Maths/math.vector";
  20973. import { Scene } from "babylonjs/scene";
  20974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20976. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20977. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20978. import { Observable } from "babylonjs/Misc/observable";
  20979. /**
  20980. * Block used to expose an input value
  20981. */
  20982. export class InputBlock extends NodeMaterialBlock {
  20983. private _mode;
  20984. private _associatedVariableName;
  20985. private _storedValue;
  20986. private _valueCallback;
  20987. private _type;
  20988. private _animationType;
  20989. /** Gets or set a value used to limit the range of float values */
  20990. min: number;
  20991. /** Gets or set a value used to limit the range of float values */
  20992. max: number;
  20993. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20994. isBoolean: boolean;
  20995. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20996. matrixMode: number;
  20997. /** @hidden */
  20998. _systemValue: Nullable<NodeMaterialSystemValues>;
  20999. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21000. visibleInInspector: boolean;
  21001. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21002. isConstant: boolean;
  21003. /** Gets or sets the group to use to display this block in the Inspector */
  21004. groupInInspector: string;
  21005. /** Gets an observable raised when the value is changed */
  21006. onValueChangedObservable: Observable<InputBlock>;
  21007. /**
  21008. * Gets or sets the connection point type (default is float)
  21009. */
  21010. get type(): NodeMaterialBlockConnectionPointTypes;
  21011. /**
  21012. * Creates a new InputBlock
  21013. * @param name defines the block name
  21014. * @param target defines the target of that block (Vertex by default)
  21015. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21016. */
  21017. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21018. /**
  21019. * Validates if a name is a reserve word.
  21020. * @param newName the new name to be given to the node.
  21021. * @returns false if the name is a reserve word, else true.
  21022. */
  21023. validateBlockName(newName: string): boolean;
  21024. /**
  21025. * Gets the output component
  21026. */
  21027. get output(): NodeMaterialConnectionPoint;
  21028. /**
  21029. * Set the source of this connection point to a vertex attribute
  21030. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21031. * @returns the current connection point
  21032. */
  21033. setAsAttribute(attributeName?: string): InputBlock;
  21034. /**
  21035. * Set the source of this connection point to a system value
  21036. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21037. * @returns the current connection point
  21038. */
  21039. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21040. /**
  21041. * Gets or sets the value of that point.
  21042. * Please note that this value will be ignored if valueCallback is defined
  21043. */
  21044. get value(): any;
  21045. set value(value: any);
  21046. /**
  21047. * Gets or sets a callback used to get the value of that point.
  21048. * Please note that setting this value will force the connection point to ignore the value property
  21049. */
  21050. get valueCallback(): () => any;
  21051. set valueCallback(value: () => any);
  21052. /**
  21053. * Gets or sets the associated variable name in the shader
  21054. */
  21055. get associatedVariableName(): string;
  21056. set associatedVariableName(value: string);
  21057. /** Gets or sets the type of animation applied to the input */
  21058. get animationType(): AnimatedInputBlockTypes;
  21059. set animationType(value: AnimatedInputBlockTypes);
  21060. /**
  21061. * Gets a boolean indicating that this connection point not defined yet
  21062. */
  21063. get isUndefined(): boolean;
  21064. /**
  21065. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21066. * In this case the connection point name must be the name of the uniform to use.
  21067. * Can only be set on inputs
  21068. */
  21069. get isUniform(): boolean;
  21070. set isUniform(value: boolean);
  21071. /**
  21072. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21073. * In this case the connection point name must be the name of the attribute to use
  21074. * Can only be set on inputs
  21075. */
  21076. get isAttribute(): boolean;
  21077. set isAttribute(value: boolean);
  21078. /**
  21079. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21080. * Can only be set on exit points
  21081. */
  21082. get isVarying(): boolean;
  21083. set isVarying(value: boolean);
  21084. /**
  21085. * Gets a boolean indicating that the current connection point is a system value
  21086. */
  21087. get isSystemValue(): boolean;
  21088. /**
  21089. * Gets or sets the current well known value or null if not defined as a system value
  21090. */
  21091. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21092. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21093. /**
  21094. * Gets the current class name
  21095. * @returns the class name
  21096. */
  21097. getClassName(): string;
  21098. /**
  21099. * Animate the input if animationType !== None
  21100. * @param scene defines the rendering scene
  21101. */
  21102. animate(scene: Scene): void;
  21103. private _emitDefine;
  21104. initialize(state: NodeMaterialBuildState): void;
  21105. /**
  21106. * Set the input block to its default value (based on its type)
  21107. */
  21108. setDefaultValue(): void;
  21109. private _emitConstant;
  21110. /** @hidden */
  21111. get _noContextSwitch(): boolean;
  21112. private _emit;
  21113. /** @hidden */
  21114. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21115. /** @hidden */
  21116. _transmit(effect: Effect, scene: Scene): void;
  21117. protected _buildBlock(state: NodeMaterialBuildState): void;
  21118. protected _dumpPropertiesCode(): string;
  21119. dispose(): void;
  21120. serialize(): any;
  21121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21122. }
  21123. }
  21124. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21125. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21126. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21127. import { Nullable } from "babylonjs/types";
  21128. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21129. import { Observable } from "babylonjs/Misc/observable";
  21130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21131. /**
  21132. * Enum used to define the compatibility state between two connection points
  21133. */
  21134. export enum NodeMaterialConnectionPointCompatibilityStates {
  21135. /** Points are compatibles */
  21136. Compatible = 0,
  21137. /** Points are incompatible because of their types */
  21138. TypeIncompatible = 1,
  21139. /** Points are incompatible because of their targets (vertex vs fragment) */
  21140. TargetIncompatible = 2
  21141. }
  21142. /**
  21143. * Defines the direction of a connection point
  21144. */
  21145. export enum NodeMaterialConnectionPointDirection {
  21146. /** Input */
  21147. Input = 0,
  21148. /** Output */
  21149. Output = 1
  21150. }
  21151. /**
  21152. * Defines a connection point for a block
  21153. */
  21154. export class NodeMaterialConnectionPoint {
  21155. /** @hidden */
  21156. _ownerBlock: NodeMaterialBlock;
  21157. /** @hidden */
  21158. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21159. private _endpoints;
  21160. private _associatedVariableName;
  21161. private _direction;
  21162. /** @hidden */
  21163. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21164. /** @hidden */
  21165. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21166. private _type;
  21167. /** @hidden */
  21168. _enforceAssociatedVariableName: boolean;
  21169. /** Gets the direction of the point */
  21170. get direction(): NodeMaterialConnectionPointDirection;
  21171. /** Indicates that this connection point needs dual validation before being connected to another point */
  21172. needDualDirectionValidation: boolean;
  21173. /**
  21174. * Gets or sets the additional types supported by this connection point
  21175. */
  21176. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21177. /**
  21178. * Gets or sets the additional types excluded by this connection point
  21179. */
  21180. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21181. /**
  21182. * Observable triggered when this point is connected
  21183. */
  21184. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21185. /**
  21186. * Gets or sets the associated variable name in the shader
  21187. */
  21188. get associatedVariableName(): string;
  21189. set associatedVariableName(value: string);
  21190. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21191. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21192. /**
  21193. * Gets or sets the connection point type (default is float)
  21194. */
  21195. get type(): NodeMaterialBlockConnectionPointTypes;
  21196. set type(value: NodeMaterialBlockConnectionPointTypes);
  21197. /**
  21198. * Gets or sets the connection point name
  21199. */
  21200. name: string;
  21201. /**
  21202. * Gets or sets the connection point name
  21203. */
  21204. displayName: string;
  21205. /**
  21206. * Gets or sets a boolean indicating that this connection point can be omitted
  21207. */
  21208. isOptional: boolean;
  21209. /**
  21210. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21211. */
  21212. isExposedOnFrame: boolean;
  21213. /**
  21214. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21215. */
  21216. define: string;
  21217. /** @hidden */
  21218. _prioritizeVertex: boolean;
  21219. private _target;
  21220. /** Gets or sets the target of that connection point */
  21221. get target(): NodeMaterialBlockTargets;
  21222. set target(value: NodeMaterialBlockTargets);
  21223. /**
  21224. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21225. */
  21226. get isConnected(): boolean;
  21227. /**
  21228. * Gets a boolean indicating that the current point is connected to an input block
  21229. */
  21230. get isConnectedToInputBlock(): boolean;
  21231. /**
  21232. * Gets a the connected input block (if any)
  21233. */
  21234. get connectInputBlock(): Nullable<InputBlock>;
  21235. /** Get the other side of the connection (if any) */
  21236. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21237. /** Get the block that owns this connection point */
  21238. get ownerBlock(): NodeMaterialBlock;
  21239. /** Get the block connected on the other side of this connection (if any) */
  21240. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21241. /** Get the block connected on the endpoints of this connection (if any) */
  21242. get connectedBlocks(): Array<NodeMaterialBlock>;
  21243. /** Gets the list of connected endpoints */
  21244. get endpoints(): NodeMaterialConnectionPoint[];
  21245. /** Gets a boolean indicating if that output point is connected to at least one input */
  21246. get hasEndpoints(): boolean;
  21247. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21248. get isConnectedInVertexShader(): boolean;
  21249. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21250. get isConnectedInFragmentShader(): boolean;
  21251. /**
  21252. * Creates a block suitable to be used as an input for this input point.
  21253. * If null is returned, a block based on the point type will be created.
  21254. * @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
  21255. */
  21256. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21257. /**
  21258. * Creates a new connection point
  21259. * @param name defines the connection point name
  21260. * @param ownerBlock defines the block hosting this connection point
  21261. * @param direction defines the direction of the connection point
  21262. */
  21263. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21264. /**
  21265. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21266. * @returns the class name
  21267. */
  21268. getClassName(): string;
  21269. /**
  21270. * Gets a boolean indicating if the current point can be connected to another point
  21271. * @param connectionPoint defines the other connection point
  21272. * @returns a boolean
  21273. */
  21274. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21275. /**
  21276. * Gets a number indicating if the current point can be connected to another point
  21277. * @param connectionPoint defines the other connection point
  21278. * @returns a number defining the compatibility state
  21279. */
  21280. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21281. /**
  21282. * Connect this point to another connection point
  21283. * @param connectionPoint defines the other connection point
  21284. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21285. * @returns the current connection point
  21286. */
  21287. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21288. /**
  21289. * Disconnect this point from one of his endpoint
  21290. * @param endpoint defines the other connection point
  21291. * @returns the current connection point
  21292. */
  21293. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Serializes this point in a JSON representation
  21296. * @param isInput defines if the connection point is an input (default is true)
  21297. * @returns the serialized point object
  21298. */
  21299. serialize(isInput?: boolean): any;
  21300. /**
  21301. * Release resources
  21302. */
  21303. dispose(): void;
  21304. }
  21305. }
  21306. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21307. /**
  21308. * Enum used to define the material modes
  21309. */
  21310. export enum NodeMaterialModes {
  21311. /** Regular material */
  21312. Material = 0,
  21313. /** For post process */
  21314. PostProcess = 1,
  21315. /** For particle system */
  21316. Particle = 2
  21317. }
  21318. }
  21319. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21322. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21325. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21326. import { Effect } from "babylonjs/Materials/effect";
  21327. import { Mesh } from "babylonjs/Meshes/mesh";
  21328. import { Nullable } from "babylonjs/types";
  21329. import { Texture } from "babylonjs/Materials/Textures/texture";
  21330. import { Scene } from "babylonjs/scene";
  21331. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21332. /**
  21333. * Block used to read a texture from a sampler
  21334. */
  21335. export class TextureBlock extends NodeMaterialBlock {
  21336. private _defineName;
  21337. private _linearDefineName;
  21338. private _gammaDefineName;
  21339. private _tempTextureRead;
  21340. private _samplerName;
  21341. private _transformedUVName;
  21342. private _textureTransformName;
  21343. private _textureInfoName;
  21344. private _mainUVName;
  21345. private _mainUVDefineName;
  21346. private _fragmentOnly;
  21347. /**
  21348. * Gets or sets the texture associated with the node
  21349. */
  21350. texture: Nullable<Texture>;
  21351. /**
  21352. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21353. */
  21354. convertToGammaSpace: boolean;
  21355. /**
  21356. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21357. */
  21358. convertToLinearSpace: boolean;
  21359. /**
  21360. * Create a new TextureBlock
  21361. * @param name defines the block name
  21362. */
  21363. constructor(name: string, fragmentOnly?: boolean);
  21364. /**
  21365. * Gets the current class name
  21366. * @returns the class name
  21367. */
  21368. getClassName(): string;
  21369. /**
  21370. * Gets the uv input component
  21371. */
  21372. get uv(): NodeMaterialConnectionPoint;
  21373. /**
  21374. * Gets the rgba output component
  21375. */
  21376. get rgba(): NodeMaterialConnectionPoint;
  21377. /**
  21378. * Gets the rgb output component
  21379. */
  21380. get rgb(): NodeMaterialConnectionPoint;
  21381. /**
  21382. * Gets the r output component
  21383. */
  21384. get r(): NodeMaterialConnectionPoint;
  21385. /**
  21386. * Gets the g output component
  21387. */
  21388. get g(): NodeMaterialConnectionPoint;
  21389. /**
  21390. * Gets the b output component
  21391. */
  21392. get b(): NodeMaterialConnectionPoint;
  21393. /**
  21394. * Gets the a output component
  21395. */
  21396. get a(): NodeMaterialConnectionPoint;
  21397. get target(): NodeMaterialBlockTargets;
  21398. autoConfigure(material: NodeMaterial): void;
  21399. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21401. isReady(): boolean;
  21402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21403. private get _isMixed();
  21404. private _injectVertexCode;
  21405. private _writeTextureRead;
  21406. private _writeOutput;
  21407. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21408. protected _dumpPropertiesCode(): string;
  21409. serialize(): any;
  21410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21411. }
  21412. }
  21413. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21414. /** @hidden */
  21415. export var reflectionFunction: {
  21416. name: string;
  21417. shader: string;
  21418. };
  21419. }
  21420. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21427. import { Effect } from "babylonjs/Materials/effect";
  21428. import { Mesh } from "babylonjs/Meshes/mesh";
  21429. import { Nullable } from "babylonjs/types";
  21430. import { Scene } from "babylonjs/scene";
  21431. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21432. /**
  21433. * Base block used to read a reflection texture from a sampler
  21434. */
  21435. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21436. /** @hidden */
  21437. _define3DName: string;
  21438. /** @hidden */
  21439. _defineCubicName: string;
  21440. /** @hidden */
  21441. _defineExplicitName: string;
  21442. /** @hidden */
  21443. _defineProjectionName: string;
  21444. /** @hidden */
  21445. _defineLocalCubicName: string;
  21446. /** @hidden */
  21447. _defineSphericalName: string;
  21448. /** @hidden */
  21449. _definePlanarName: string;
  21450. /** @hidden */
  21451. _defineEquirectangularName: string;
  21452. /** @hidden */
  21453. _defineMirroredEquirectangularFixedName: string;
  21454. /** @hidden */
  21455. _defineEquirectangularFixedName: string;
  21456. /** @hidden */
  21457. _defineSkyboxName: string;
  21458. /** @hidden */
  21459. _defineOppositeZ: string;
  21460. /** @hidden */
  21461. _cubeSamplerName: string;
  21462. /** @hidden */
  21463. _2DSamplerName: string;
  21464. protected _positionUVWName: string;
  21465. protected _directionWName: string;
  21466. protected _reflectionVectorName: string;
  21467. /** @hidden */
  21468. _reflectionCoordsName: string;
  21469. /** @hidden */
  21470. _reflectionMatrixName: string;
  21471. protected _reflectionColorName: string;
  21472. /**
  21473. * Gets or sets the texture associated with the node
  21474. */
  21475. texture: Nullable<BaseTexture>;
  21476. /**
  21477. * Create a new ReflectionTextureBaseBlock
  21478. * @param name defines the block name
  21479. */
  21480. constructor(name: string);
  21481. /**
  21482. * Gets the current class name
  21483. * @returns the class name
  21484. */
  21485. getClassName(): string;
  21486. /**
  21487. * Gets the world position input component
  21488. */
  21489. abstract get position(): NodeMaterialConnectionPoint;
  21490. /**
  21491. * Gets the world position input component
  21492. */
  21493. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21494. /**
  21495. * Gets the world normal input component
  21496. */
  21497. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21498. /**
  21499. * Gets the world input component
  21500. */
  21501. abstract get world(): NodeMaterialConnectionPoint;
  21502. /**
  21503. * Gets the camera (or eye) position component
  21504. */
  21505. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21506. /**
  21507. * Gets the view input component
  21508. */
  21509. abstract get view(): NodeMaterialConnectionPoint;
  21510. protected _getTexture(): Nullable<BaseTexture>;
  21511. autoConfigure(material: NodeMaterial): void;
  21512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21513. isReady(): boolean;
  21514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21515. /**
  21516. * Gets the code to inject in the vertex shader
  21517. * @param state current state of the node material building
  21518. * @returns the shader code
  21519. */
  21520. handleVertexSide(state: NodeMaterialBuildState): string;
  21521. /**
  21522. * Handles the inits for the fragment code path
  21523. * @param state node material build state
  21524. */
  21525. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21526. /**
  21527. * Generates the reflection coords code for the fragment code path
  21528. * @param worldNormalVarName name of the world normal variable
  21529. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21530. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21531. * @returns the shader code
  21532. */
  21533. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21534. /**
  21535. * Generates the reflection color code for the fragment code path
  21536. * @param lodVarName name of the lod variable
  21537. * @param swizzleLookupTexture swizzle to use for the final color variable
  21538. * @returns the shader code
  21539. */
  21540. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21541. /**
  21542. * Generates the code corresponding to the connected output points
  21543. * @param state node material build state
  21544. * @param varName name of the variable to output
  21545. * @returns the shader code
  21546. */
  21547. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21548. protected _buildBlock(state: NodeMaterialBuildState): this;
  21549. protected _dumpPropertiesCode(): string;
  21550. serialize(): any;
  21551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21552. }
  21553. }
  21554. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21556. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21557. import { Nullable } from "babylonjs/types";
  21558. /**
  21559. * Defines a connection point to be used for points with a custom object type
  21560. */
  21561. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21562. private _blockType;
  21563. private _blockName;
  21564. private _nameForCheking?;
  21565. /**
  21566. * Creates a new connection point
  21567. * @param name defines the connection point name
  21568. * @param ownerBlock defines the block hosting this connection point
  21569. * @param direction defines the direction of the connection point
  21570. */
  21571. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21572. /**
  21573. * Gets a number indicating if the current point can be connected to another point
  21574. * @param connectionPoint defines the other connection point
  21575. * @returns a number defining the compatibility state
  21576. */
  21577. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21578. /**
  21579. * Creates a block suitable to be used as an input for this input point.
  21580. * If null is returned, a block based on the point type will be created.
  21581. * @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
  21582. */
  21583. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21584. }
  21585. }
  21586. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21587. /**
  21588. * Enum defining the type of properties that can be edited in the property pages in the NME
  21589. */
  21590. export enum PropertyTypeForEdition {
  21591. /** property is a boolean */
  21592. Boolean = 0,
  21593. /** property is a float */
  21594. Float = 1,
  21595. /** property is a Vector2 */
  21596. Vector2 = 2,
  21597. /** property is a list of values */
  21598. List = 3
  21599. }
  21600. /**
  21601. * Interface that defines an option in a variable of type list
  21602. */
  21603. export interface IEditablePropertyListOption {
  21604. /** label of the option */
  21605. "label": string;
  21606. /** value of the option */
  21607. "value": number;
  21608. }
  21609. /**
  21610. * Interface that defines the options available for an editable property
  21611. */
  21612. export interface IEditablePropertyOption {
  21613. /** min value */
  21614. "min"?: number;
  21615. /** max value */
  21616. "max"?: number;
  21617. /** notifiers: indicates which actions to take when the property is changed */
  21618. "notifiers"?: {
  21619. /** the material should be rebuilt */
  21620. "rebuild"?: boolean;
  21621. /** the preview should be updated */
  21622. "update"?: boolean;
  21623. };
  21624. /** list of the options for a variable of type list */
  21625. "options"?: IEditablePropertyListOption[];
  21626. }
  21627. /**
  21628. * Interface that describes an editable property
  21629. */
  21630. export interface IPropertyDescriptionForEdition {
  21631. /** name of the property */
  21632. "propertyName": string;
  21633. /** display name of the property */
  21634. "displayName": string;
  21635. /** type of the property */
  21636. "type": PropertyTypeForEdition;
  21637. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21638. "groupName": string;
  21639. /** options for the property */
  21640. "options": IEditablePropertyOption;
  21641. }
  21642. /**
  21643. * Decorator that flags a property in a node material block as being editable
  21644. */
  21645. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21646. }
  21647. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21650. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21652. import { Nullable } from "babylonjs/types";
  21653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21654. import { Mesh } from "babylonjs/Meshes/mesh";
  21655. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21656. import { Effect } from "babylonjs/Materials/effect";
  21657. import { Scene } from "babylonjs/scene";
  21658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21659. /**
  21660. * Block used to implement the refraction part of the sub surface module of the PBR material
  21661. */
  21662. export class RefractionBlock extends NodeMaterialBlock {
  21663. /** @hidden */
  21664. _define3DName: string;
  21665. /** @hidden */
  21666. _refractionMatrixName: string;
  21667. /** @hidden */
  21668. _defineLODRefractionAlpha: string;
  21669. /** @hidden */
  21670. _defineLinearSpecularRefraction: string;
  21671. /** @hidden */
  21672. _defineOppositeZ: string;
  21673. /** @hidden */
  21674. _cubeSamplerName: string;
  21675. /** @hidden */
  21676. _2DSamplerName: string;
  21677. /** @hidden */
  21678. _vRefractionMicrosurfaceInfosName: string;
  21679. /** @hidden */
  21680. _vRefractionInfosName: string;
  21681. private _scene;
  21682. /**
  21683. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21684. * Materials half opaque for instance using refraction could benefit from this control.
  21685. */
  21686. linkRefractionWithTransparency: boolean;
  21687. /**
  21688. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21689. */
  21690. invertRefractionY: boolean;
  21691. /**
  21692. * Gets or sets the texture associated with the node
  21693. */
  21694. texture: Nullable<BaseTexture>;
  21695. /**
  21696. * Create a new RefractionBlock
  21697. * @param name defines the block name
  21698. */
  21699. constructor(name: string);
  21700. /**
  21701. * Gets the current class name
  21702. * @returns the class name
  21703. */
  21704. getClassName(): string;
  21705. /**
  21706. * Gets the intensity input component
  21707. */
  21708. get intensity(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the index of refraction input component
  21711. */
  21712. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the tint at distance input component
  21715. */
  21716. get tintAtDistance(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the view input component
  21719. */
  21720. get view(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the refraction object output component
  21723. */
  21724. get refraction(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Returns true if the block has a texture
  21727. */
  21728. get hasTexture(): boolean;
  21729. protected _getTexture(): Nullable<BaseTexture>;
  21730. autoConfigure(material: NodeMaterial): void;
  21731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21732. isReady(): boolean;
  21733. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21734. /**
  21735. * Gets the main code of the block (fragment side)
  21736. * @param state current state of the node material building
  21737. * @returns the shader code
  21738. */
  21739. getCode(state: NodeMaterialBuildState): string;
  21740. protected _buildBlock(state: NodeMaterialBuildState): this;
  21741. protected _dumpPropertiesCode(): string;
  21742. serialize(): any;
  21743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21744. }
  21745. }
  21746. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21749. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21752. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21754. import { Nullable } from "babylonjs/types";
  21755. import { Scene } from "babylonjs/scene";
  21756. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21757. /**
  21758. * Base block used as input for post process
  21759. */
  21760. export class CurrentScreenBlock extends NodeMaterialBlock {
  21761. private _samplerName;
  21762. private _linearDefineName;
  21763. private _gammaDefineName;
  21764. private _mainUVName;
  21765. private _tempTextureRead;
  21766. /**
  21767. * Gets or sets the texture associated with the node
  21768. */
  21769. texture: Nullable<BaseTexture>;
  21770. /**
  21771. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21772. */
  21773. convertToGammaSpace: boolean;
  21774. /**
  21775. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21776. */
  21777. convertToLinearSpace: boolean;
  21778. /**
  21779. * Create a new CurrentScreenBlock
  21780. * @param name defines the block name
  21781. */
  21782. constructor(name: string);
  21783. /**
  21784. * Gets the current class name
  21785. * @returns the class name
  21786. */
  21787. getClassName(): string;
  21788. /**
  21789. * Gets the uv input component
  21790. */
  21791. get uv(): NodeMaterialConnectionPoint;
  21792. /**
  21793. * Gets the rgba output component
  21794. */
  21795. get rgba(): NodeMaterialConnectionPoint;
  21796. /**
  21797. * Gets the rgb output component
  21798. */
  21799. get rgb(): NodeMaterialConnectionPoint;
  21800. /**
  21801. * Gets the r output component
  21802. */
  21803. get r(): NodeMaterialConnectionPoint;
  21804. /**
  21805. * Gets the g output component
  21806. */
  21807. get g(): NodeMaterialConnectionPoint;
  21808. /**
  21809. * Gets the b output component
  21810. */
  21811. get b(): NodeMaterialConnectionPoint;
  21812. /**
  21813. * Gets the a output component
  21814. */
  21815. get a(): NodeMaterialConnectionPoint;
  21816. /**
  21817. * Initialize the block and prepare the context for build
  21818. * @param state defines the state that will be used for the build
  21819. */
  21820. initialize(state: NodeMaterialBuildState): void;
  21821. get target(): NodeMaterialBlockTargets;
  21822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21823. isReady(): boolean;
  21824. private _injectVertexCode;
  21825. private _writeTextureRead;
  21826. private _writeOutput;
  21827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21828. serialize(): any;
  21829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21830. }
  21831. }
  21832. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21837. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21839. import { Nullable } from "babylonjs/types";
  21840. import { Scene } from "babylonjs/scene";
  21841. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21842. /**
  21843. * Base block used for the particle texture
  21844. */
  21845. export class ParticleTextureBlock extends NodeMaterialBlock {
  21846. private _samplerName;
  21847. private _linearDefineName;
  21848. private _gammaDefineName;
  21849. private _tempTextureRead;
  21850. /**
  21851. * Gets or sets the texture associated with the node
  21852. */
  21853. texture: Nullable<BaseTexture>;
  21854. /**
  21855. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21856. */
  21857. convertToGammaSpace: boolean;
  21858. /**
  21859. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21860. */
  21861. convertToLinearSpace: boolean;
  21862. /**
  21863. * Create a new ParticleTextureBlock
  21864. * @param name defines the block name
  21865. */
  21866. constructor(name: string);
  21867. /**
  21868. * Gets the current class name
  21869. * @returns the class name
  21870. */
  21871. getClassName(): string;
  21872. /**
  21873. * Gets the uv input component
  21874. */
  21875. get uv(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the rgba output component
  21878. */
  21879. get rgba(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Gets the rgb output component
  21882. */
  21883. get rgb(): NodeMaterialConnectionPoint;
  21884. /**
  21885. * Gets the r output component
  21886. */
  21887. get r(): NodeMaterialConnectionPoint;
  21888. /**
  21889. * Gets the g output component
  21890. */
  21891. get g(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the b output component
  21894. */
  21895. get b(): NodeMaterialConnectionPoint;
  21896. /**
  21897. * Gets the a output component
  21898. */
  21899. get a(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Initialize the block and prepare the context for build
  21902. * @param state defines the state that will be used for the build
  21903. */
  21904. initialize(state: NodeMaterialBuildState): void;
  21905. autoConfigure(material: NodeMaterial): void;
  21906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21907. isReady(): boolean;
  21908. private _writeOutput;
  21909. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21910. serialize(): any;
  21911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21912. }
  21913. }
  21914. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21917. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21918. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21919. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21920. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21921. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21922. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21923. import { Scene } from "babylonjs/scene";
  21924. /**
  21925. * Class used to store shared data between 2 NodeMaterialBuildState
  21926. */
  21927. export class NodeMaterialBuildStateSharedData {
  21928. /**
  21929. * Gets the list of emitted varyings
  21930. */
  21931. temps: string[];
  21932. /**
  21933. * Gets the list of emitted varyings
  21934. */
  21935. varyings: string[];
  21936. /**
  21937. * Gets the varying declaration string
  21938. */
  21939. varyingDeclaration: string;
  21940. /**
  21941. * Input blocks
  21942. */
  21943. inputBlocks: InputBlock[];
  21944. /**
  21945. * Input blocks
  21946. */
  21947. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21948. /**
  21949. * Bindable blocks (Blocks that need to set data to the effect)
  21950. */
  21951. bindableBlocks: NodeMaterialBlock[];
  21952. /**
  21953. * List of blocks that can provide a compilation fallback
  21954. */
  21955. blocksWithFallbacks: NodeMaterialBlock[];
  21956. /**
  21957. * List of blocks that can provide a define update
  21958. */
  21959. blocksWithDefines: NodeMaterialBlock[];
  21960. /**
  21961. * List of blocks that can provide a repeatable content
  21962. */
  21963. repeatableContentBlocks: NodeMaterialBlock[];
  21964. /**
  21965. * List of blocks that can provide a dynamic list of uniforms
  21966. */
  21967. dynamicUniformBlocks: NodeMaterialBlock[];
  21968. /**
  21969. * List of blocks that can block the isReady function for the material
  21970. */
  21971. blockingBlocks: NodeMaterialBlock[];
  21972. /**
  21973. * Gets the list of animated inputs
  21974. */
  21975. animatedInputs: InputBlock[];
  21976. /**
  21977. * Build Id used to avoid multiple recompilations
  21978. */
  21979. buildId: number;
  21980. /** List of emitted variables */
  21981. variableNames: {
  21982. [key: string]: number;
  21983. };
  21984. /** List of emitted defines */
  21985. defineNames: {
  21986. [key: string]: number;
  21987. };
  21988. /** Should emit comments? */
  21989. emitComments: boolean;
  21990. /** Emit build activity */
  21991. verbose: boolean;
  21992. /** Gets or sets the hosting scene */
  21993. scene: Scene;
  21994. /**
  21995. * Gets the compilation hints emitted at compilation time
  21996. */
  21997. hints: {
  21998. needWorldViewMatrix: boolean;
  21999. needWorldViewProjectionMatrix: boolean;
  22000. needAlphaBlending: boolean;
  22001. needAlphaTesting: boolean;
  22002. };
  22003. /**
  22004. * List of compilation checks
  22005. */
  22006. checks: {
  22007. emitVertex: boolean;
  22008. emitFragment: boolean;
  22009. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22010. };
  22011. /**
  22012. * Is vertex program allowed to be empty?
  22013. */
  22014. allowEmptyVertexProgram: boolean;
  22015. /** Creates a new shared data */
  22016. constructor();
  22017. /**
  22018. * Emits console errors and exceptions if there is a failing check
  22019. */
  22020. emitErrors(): void;
  22021. }
  22022. }
  22023. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22024. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22025. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22026. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22027. /**
  22028. * Class used to store node based material build state
  22029. */
  22030. export class NodeMaterialBuildState {
  22031. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22032. supportUniformBuffers: boolean;
  22033. /**
  22034. * Gets the list of emitted attributes
  22035. */
  22036. attributes: string[];
  22037. /**
  22038. * Gets the list of emitted uniforms
  22039. */
  22040. uniforms: string[];
  22041. /**
  22042. * Gets the list of emitted constants
  22043. */
  22044. constants: string[];
  22045. /**
  22046. * Gets the list of emitted samplers
  22047. */
  22048. samplers: string[];
  22049. /**
  22050. * Gets the list of emitted functions
  22051. */
  22052. functions: {
  22053. [key: string]: string;
  22054. };
  22055. /**
  22056. * Gets the list of emitted extensions
  22057. */
  22058. extensions: {
  22059. [key: string]: string;
  22060. };
  22061. /**
  22062. * Gets the target of the compilation state
  22063. */
  22064. target: NodeMaterialBlockTargets;
  22065. /**
  22066. * Gets the list of emitted counters
  22067. */
  22068. counters: {
  22069. [key: string]: number;
  22070. };
  22071. /**
  22072. * Shared data between multiple NodeMaterialBuildState instances
  22073. */
  22074. sharedData: NodeMaterialBuildStateSharedData;
  22075. /** @hidden */
  22076. _vertexState: NodeMaterialBuildState;
  22077. /** @hidden */
  22078. _attributeDeclaration: string;
  22079. /** @hidden */
  22080. _uniformDeclaration: string;
  22081. /** @hidden */
  22082. _constantDeclaration: string;
  22083. /** @hidden */
  22084. _samplerDeclaration: string;
  22085. /** @hidden */
  22086. _varyingTransfer: string;
  22087. /** @hidden */
  22088. _injectAtEnd: string;
  22089. private _repeatableContentAnchorIndex;
  22090. /** @hidden */
  22091. _builtCompilationString: string;
  22092. /**
  22093. * Gets the emitted compilation strings
  22094. */
  22095. compilationString: string;
  22096. /**
  22097. * Finalize the compilation strings
  22098. * @param state defines the current compilation state
  22099. */
  22100. finalize(state: NodeMaterialBuildState): void;
  22101. /** @hidden */
  22102. get _repeatableContentAnchor(): string;
  22103. /** @hidden */
  22104. _getFreeVariableName(prefix: string): string;
  22105. /** @hidden */
  22106. _getFreeDefineName(prefix: string): string;
  22107. /** @hidden */
  22108. _excludeVariableName(name: string): void;
  22109. /** @hidden */
  22110. _emit2DSampler(name: string): void;
  22111. /** @hidden */
  22112. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22113. /** @hidden */
  22114. _emitExtension(name: string, extension: string, define?: string): void;
  22115. /** @hidden */
  22116. _emitFunction(name: string, code: string, comments: string): void;
  22117. /** @hidden */
  22118. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22119. replaceStrings?: {
  22120. search: RegExp;
  22121. replace: string;
  22122. }[];
  22123. repeatKey?: string;
  22124. }): string;
  22125. /** @hidden */
  22126. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22127. repeatKey?: string;
  22128. removeAttributes?: boolean;
  22129. removeUniforms?: boolean;
  22130. removeVaryings?: boolean;
  22131. removeIfDef?: boolean;
  22132. replaceStrings?: {
  22133. search: RegExp;
  22134. replace: string;
  22135. }[];
  22136. }, storeKey?: string): void;
  22137. /** @hidden */
  22138. _registerTempVariable(name: string): boolean;
  22139. /** @hidden */
  22140. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22141. /** @hidden */
  22142. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22143. /** @hidden */
  22144. _emitFloat(value: number): string;
  22145. }
  22146. }
  22147. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22148. /**
  22149. * Helper class used to generate session unique ID
  22150. */
  22151. export class UniqueIdGenerator {
  22152. private static _UniqueIdCounter;
  22153. /**
  22154. * Gets an unique (relatively to the current scene) Id
  22155. */
  22156. static get UniqueId(): number;
  22157. }
  22158. }
  22159. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22160. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22162. import { Nullable } from "babylonjs/types";
  22163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22164. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22165. import { Effect } from "babylonjs/Materials/effect";
  22166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22167. import { Mesh } from "babylonjs/Meshes/mesh";
  22168. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22169. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22170. import { Scene } from "babylonjs/scene";
  22171. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22172. /**
  22173. * Defines a block that can be used inside a node based material
  22174. */
  22175. export class NodeMaterialBlock {
  22176. private _buildId;
  22177. private _buildTarget;
  22178. private _target;
  22179. private _isFinalMerger;
  22180. private _isInput;
  22181. private _name;
  22182. protected _isUnique: boolean;
  22183. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22184. inputsAreExclusive: boolean;
  22185. /** @hidden */
  22186. _codeVariableName: string;
  22187. /** @hidden */
  22188. _inputs: NodeMaterialConnectionPoint[];
  22189. /** @hidden */
  22190. _outputs: NodeMaterialConnectionPoint[];
  22191. /** @hidden */
  22192. _preparationId: number;
  22193. /**
  22194. * Gets the name of the block
  22195. */
  22196. get name(): string;
  22197. /**
  22198. * Sets the name of the block. Will check if the name is valid.
  22199. */
  22200. set name(newName: string);
  22201. /**
  22202. * Gets or sets the unique id of the node
  22203. */
  22204. uniqueId: number;
  22205. /**
  22206. * Gets or sets the comments associated with this block
  22207. */
  22208. comments: string;
  22209. /**
  22210. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22211. */
  22212. get isUnique(): boolean;
  22213. /**
  22214. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22215. */
  22216. get isFinalMerger(): boolean;
  22217. /**
  22218. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22219. */
  22220. get isInput(): boolean;
  22221. /**
  22222. * Gets or sets the build Id
  22223. */
  22224. get buildId(): number;
  22225. set buildId(value: number);
  22226. /**
  22227. * Gets or sets the target of the block
  22228. */
  22229. get target(): NodeMaterialBlockTargets;
  22230. set target(value: NodeMaterialBlockTargets);
  22231. /**
  22232. * Gets the list of input points
  22233. */
  22234. get inputs(): NodeMaterialConnectionPoint[];
  22235. /** Gets the list of output points */
  22236. get outputs(): NodeMaterialConnectionPoint[];
  22237. /**
  22238. * Find an input by its name
  22239. * @param name defines the name of the input to look for
  22240. * @returns the input or null if not found
  22241. */
  22242. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22243. /**
  22244. * Find an output by its name
  22245. * @param name defines the name of the outputto look for
  22246. * @returns the output or null if not found
  22247. */
  22248. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22249. /**
  22250. * Creates a new NodeMaterialBlock
  22251. * @param name defines the block name
  22252. * @param target defines the target of that block (Vertex by default)
  22253. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22254. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22255. */
  22256. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22257. /**
  22258. * Initialize the block and prepare the context for build
  22259. * @param state defines the state that will be used for the build
  22260. */
  22261. initialize(state: NodeMaterialBuildState): void;
  22262. /**
  22263. * Bind data to effect. Will only be called for blocks with isBindable === true
  22264. * @param effect defines the effect to bind data to
  22265. * @param nodeMaterial defines the hosting NodeMaterial
  22266. * @param mesh defines the mesh that will be rendered
  22267. * @param subMesh defines the submesh that will be rendered
  22268. */
  22269. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22270. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22271. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22272. protected _writeFloat(value: number): string;
  22273. /**
  22274. * Gets the current class name e.g. "NodeMaterialBlock"
  22275. * @returns the class name
  22276. */
  22277. getClassName(): string;
  22278. /**
  22279. * Register a new input. Must be called inside a block constructor
  22280. * @param name defines the connection point name
  22281. * @param type defines the connection point type
  22282. * @param isOptional defines a boolean indicating that this input can be omitted
  22283. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22284. * @param point an already created connection point. If not provided, create a new one
  22285. * @returns the current block
  22286. */
  22287. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22288. /**
  22289. * Register a new output. Must be called inside a block constructor
  22290. * @param name defines the connection point name
  22291. * @param type defines the connection point type
  22292. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22293. * @param point an already created connection point. If not provided, create a new one
  22294. * @returns the current block
  22295. */
  22296. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22297. /**
  22298. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22299. * @param forOutput defines an optional connection point to check compatibility with
  22300. * @returns the first available input or null
  22301. */
  22302. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22303. /**
  22304. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22305. * @param forBlock defines an optional block to check compatibility with
  22306. * @returns the first available input or null
  22307. */
  22308. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22309. /**
  22310. * Gets the sibling of the given output
  22311. * @param current defines the current output
  22312. * @returns the next output in the list or null
  22313. */
  22314. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22315. /**
  22316. * Connect current block with another block
  22317. * @param other defines the block to connect with
  22318. * @param options define the various options to help pick the right connections
  22319. * @returns the current block
  22320. */
  22321. connectTo(other: NodeMaterialBlock, options?: {
  22322. input?: string;
  22323. output?: string;
  22324. outputSwizzle?: string;
  22325. }): this | undefined;
  22326. protected _buildBlock(state: NodeMaterialBuildState): void;
  22327. /**
  22328. * Add uniforms, samplers and uniform buffers at compilation time
  22329. * @param state defines the state to update
  22330. * @param nodeMaterial defines the node material requesting the update
  22331. * @param defines defines the material defines to update
  22332. * @param uniformBuffers defines the list of uniform buffer names
  22333. */
  22334. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22335. /**
  22336. * Add potential fallbacks if shader compilation fails
  22337. * @param mesh defines the mesh to be rendered
  22338. * @param fallbacks defines the current prioritized list of fallbacks
  22339. */
  22340. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22341. /**
  22342. * Initialize defines for shader compilation
  22343. * @param mesh defines the mesh to be rendered
  22344. * @param nodeMaterial defines the node material requesting the update
  22345. * @param defines defines the material defines to update
  22346. * @param useInstances specifies that instances should be used
  22347. */
  22348. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22349. /**
  22350. * Update defines for shader compilation
  22351. * @param mesh defines the mesh to be rendered
  22352. * @param nodeMaterial defines the node material requesting the update
  22353. * @param defines defines the material defines to update
  22354. * @param useInstances specifies that instances should be used
  22355. * @param subMesh defines which submesh to render
  22356. */
  22357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22358. /**
  22359. * Lets the block try to connect some inputs automatically
  22360. * @param material defines the hosting NodeMaterial
  22361. */
  22362. autoConfigure(material: NodeMaterial): void;
  22363. /**
  22364. * Function called when a block is declared as repeatable content generator
  22365. * @param vertexShaderState defines the current compilation state for the vertex shader
  22366. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22367. * @param mesh defines the mesh to be rendered
  22368. * @param defines defines the material defines to update
  22369. */
  22370. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22371. /**
  22372. * Checks if the block is ready
  22373. * @param mesh defines the mesh to be rendered
  22374. * @param nodeMaterial defines the node material requesting the update
  22375. * @param defines defines the material defines to update
  22376. * @param useInstances specifies that instances should be used
  22377. * @returns true if the block is ready
  22378. */
  22379. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22380. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22381. private _processBuild;
  22382. /**
  22383. * Validates the new name for the block node.
  22384. * @param newName the new name to be given to the node.
  22385. * @returns false if the name is a reserve word, else true.
  22386. */
  22387. validateBlockName(newName: string): boolean;
  22388. /**
  22389. * Compile the current node and generate the shader code
  22390. * @param state defines the current compilation state (uniforms, samplers, current string)
  22391. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22392. * @returns true if already built
  22393. */
  22394. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22395. protected _inputRename(name: string): string;
  22396. protected _outputRename(name: string): string;
  22397. protected _dumpPropertiesCode(): string;
  22398. /** @hidden */
  22399. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22400. /** @hidden */
  22401. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22402. /**
  22403. * Clone the current block to a new identical block
  22404. * @param scene defines the hosting scene
  22405. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22406. * @returns a copy of the current block
  22407. */
  22408. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22409. /**
  22410. * Serializes this block in a JSON representation
  22411. * @returns the serialized block object
  22412. */
  22413. serialize(): any;
  22414. /** @hidden */
  22415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22416. private _deserializePortDisplayNamesAndExposedOnFrame;
  22417. /**
  22418. * Release resources
  22419. */
  22420. dispose(): void;
  22421. }
  22422. }
  22423. declare module "babylonjs/Materials/pushMaterial" {
  22424. import { Nullable } from "babylonjs/types";
  22425. import { Scene } from "babylonjs/scene";
  22426. import { Matrix } from "babylonjs/Maths/math.vector";
  22427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22428. import { Mesh } from "babylonjs/Meshes/mesh";
  22429. import { Material } from "babylonjs/Materials/material";
  22430. import { Effect } from "babylonjs/Materials/effect";
  22431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22432. /**
  22433. * Base class of materials working in push mode in babylon JS
  22434. * @hidden
  22435. */
  22436. export class PushMaterial extends Material {
  22437. protected _activeEffect: Effect;
  22438. protected _normalMatrix: Matrix;
  22439. constructor(name: string, scene: Scene);
  22440. getEffect(): Effect;
  22441. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22442. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22443. /**
  22444. * Binds the given world matrix to the active effect
  22445. *
  22446. * @param world the matrix to bind
  22447. */
  22448. bindOnlyWorldMatrix(world: Matrix): void;
  22449. /**
  22450. * Binds the given normal matrix to the active effect
  22451. *
  22452. * @param normalMatrix the matrix to bind
  22453. */
  22454. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22455. bind(world: Matrix, mesh?: Mesh): void;
  22456. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22457. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22458. }
  22459. }
  22460. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22462. /**
  22463. * Root class for all node material optimizers
  22464. */
  22465. export class NodeMaterialOptimizer {
  22466. /**
  22467. * Function used to optimize a NodeMaterial graph
  22468. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22469. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22470. */
  22471. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22472. }
  22473. }
  22474. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22478. import { Scene } from "babylonjs/scene";
  22479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22480. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22482. /**
  22483. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22484. */
  22485. export class TransformBlock extends NodeMaterialBlock {
  22486. /**
  22487. * Defines the value to use to complement W value to transform it to a Vector4
  22488. */
  22489. complementW: number;
  22490. /**
  22491. * Defines the value to use to complement z value to transform it to a Vector4
  22492. */
  22493. complementZ: number;
  22494. /**
  22495. * Creates a new TransformBlock
  22496. * @param name defines the block name
  22497. */
  22498. constructor(name: string);
  22499. /**
  22500. * Gets the current class name
  22501. * @returns the class name
  22502. */
  22503. getClassName(): string;
  22504. /**
  22505. * Gets the vector input
  22506. */
  22507. get vector(): NodeMaterialConnectionPoint;
  22508. /**
  22509. * Gets the output component
  22510. */
  22511. get output(): NodeMaterialConnectionPoint;
  22512. /**
  22513. * Gets the xyz output component
  22514. */
  22515. get xyz(): NodeMaterialConnectionPoint;
  22516. /**
  22517. * Gets the matrix transform input
  22518. */
  22519. get transform(): NodeMaterialConnectionPoint;
  22520. protected _buildBlock(state: NodeMaterialBuildState): this;
  22521. /**
  22522. * Update defines for shader compilation
  22523. * @param mesh defines the mesh to be rendered
  22524. * @param nodeMaterial defines the node material requesting the update
  22525. * @param defines defines the material defines to update
  22526. * @param useInstances specifies that instances should be used
  22527. * @param subMesh defines which submesh to render
  22528. */
  22529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22530. serialize(): any;
  22531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22532. protected _dumpPropertiesCode(): string;
  22533. }
  22534. }
  22535. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22539. /**
  22540. * Block used to output the vertex position
  22541. */
  22542. export class VertexOutputBlock extends NodeMaterialBlock {
  22543. /**
  22544. * Creates a new VertexOutputBlock
  22545. * @param name defines the block name
  22546. */
  22547. constructor(name: string);
  22548. /**
  22549. * Gets the current class name
  22550. * @returns the class name
  22551. */
  22552. getClassName(): string;
  22553. /**
  22554. * Gets the vector input component
  22555. */
  22556. get vector(): NodeMaterialConnectionPoint;
  22557. protected _buildBlock(state: NodeMaterialBuildState): this;
  22558. }
  22559. }
  22560. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22564. /**
  22565. * Block used to output the final color
  22566. */
  22567. export class FragmentOutputBlock extends NodeMaterialBlock {
  22568. /**
  22569. * Create a new FragmentOutputBlock
  22570. * @param name defines the block name
  22571. */
  22572. constructor(name: string);
  22573. /**
  22574. * Gets the current class name
  22575. * @returns the class name
  22576. */
  22577. getClassName(): string;
  22578. /**
  22579. * Gets the rgba input component
  22580. */
  22581. get rgba(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the rgb input component
  22584. */
  22585. get rgb(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the a input component
  22588. */
  22589. get a(): NodeMaterialConnectionPoint;
  22590. protected _buildBlock(state: NodeMaterialBuildState): this;
  22591. }
  22592. }
  22593. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22597. /**
  22598. * Block used for the particle ramp gradient section
  22599. */
  22600. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22601. /**
  22602. * Create a new ParticleRampGradientBlock
  22603. * @param name defines the block name
  22604. */
  22605. constructor(name: string);
  22606. /**
  22607. * Gets the current class name
  22608. * @returns the class name
  22609. */
  22610. getClassName(): string;
  22611. /**
  22612. * Gets the color input component
  22613. */
  22614. get color(): NodeMaterialConnectionPoint;
  22615. /**
  22616. * Gets the rampColor output component
  22617. */
  22618. get rampColor(): NodeMaterialConnectionPoint;
  22619. /**
  22620. * Initialize the block and prepare the context for build
  22621. * @param state defines the state that will be used for the build
  22622. */
  22623. initialize(state: NodeMaterialBuildState): void;
  22624. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22625. }
  22626. }
  22627. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22631. /**
  22632. * Block used for the particle blend multiply section
  22633. */
  22634. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22635. /**
  22636. * Create a new ParticleBlendMultiplyBlock
  22637. * @param name defines the block name
  22638. */
  22639. constructor(name: string);
  22640. /**
  22641. * Gets the current class name
  22642. * @returns the class name
  22643. */
  22644. getClassName(): string;
  22645. /**
  22646. * Gets the color input component
  22647. */
  22648. get color(): NodeMaterialConnectionPoint;
  22649. /**
  22650. * Gets the alphaTexture input component
  22651. */
  22652. get alphaTexture(): NodeMaterialConnectionPoint;
  22653. /**
  22654. * Gets the alphaColor input component
  22655. */
  22656. get alphaColor(): NodeMaterialConnectionPoint;
  22657. /**
  22658. * Gets the blendColor output component
  22659. */
  22660. get blendColor(): NodeMaterialConnectionPoint;
  22661. /**
  22662. * Initialize the block and prepare the context for build
  22663. * @param state defines the state that will be used for the build
  22664. */
  22665. initialize(state: NodeMaterialBuildState): void;
  22666. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22667. }
  22668. }
  22669. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22673. /**
  22674. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22675. */
  22676. export class VectorMergerBlock extends NodeMaterialBlock {
  22677. /**
  22678. * Create a new VectorMergerBlock
  22679. * @param name defines the block name
  22680. */
  22681. constructor(name: string);
  22682. /**
  22683. * Gets the current class name
  22684. * @returns the class name
  22685. */
  22686. getClassName(): string;
  22687. /**
  22688. * Gets the xyz component (input)
  22689. */
  22690. get xyzIn(): NodeMaterialConnectionPoint;
  22691. /**
  22692. * Gets the xy component (input)
  22693. */
  22694. get xyIn(): NodeMaterialConnectionPoint;
  22695. /**
  22696. * Gets the x component (input)
  22697. */
  22698. get x(): NodeMaterialConnectionPoint;
  22699. /**
  22700. * Gets the y component (input)
  22701. */
  22702. get y(): NodeMaterialConnectionPoint;
  22703. /**
  22704. * Gets the z component (input)
  22705. */
  22706. get z(): NodeMaterialConnectionPoint;
  22707. /**
  22708. * Gets the w component (input)
  22709. */
  22710. get w(): NodeMaterialConnectionPoint;
  22711. /**
  22712. * Gets the xyzw component (output)
  22713. */
  22714. get xyzw(): NodeMaterialConnectionPoint;
  22715. /**
  22716. * Gets the xyz component (output)
  22717. */
  22718. get xyzOut(): NodeMaterialConnectionPoint;
  22719. /**
  22720. * Gets the xy component (output)
  22721. */
  22722. get xyOut(): NodeMaterialConnectionPoint;
  22723. /**
  22724. * Gets the xy component (output)
  22725. * @deprecated Please use xyOut instead.
  22726. */
  22727. get xy(): NodeMaterialConnectionPoint;
  22728. /**
  22729. * Gets the xyz component (output)
  22730. * @deprecated Please use xyzOut instead.
  22731. */
  22732. get xyz(): NodeMaterialConnectionPoint;
  22733. protected _buildBlock(state: NodeMaterialBuildState): this;
  22734. }
  22735. }
  22736. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22740. import { Vector2 } from "babylonjs/Maths/math.vector";
  22741. import { Scene } from "babylonjs/scene";
  22742. /**
  22743. * Block used to remap a float from a range to a new one
  22744. */
  22745. export class RemapBlock extends NodeMaterialBlock {
  22746. /**
  22747. * Gets or sets the source range
  22748. */
  22749. sourceRange: Vector2;
  22750. /**
  22751. * Gets or sets the target range
  22752. */
  22753. targetRange: Vector2;
  22754. /**
  22755. * Creates a new RemapBlock
  22756. * @param name defines the block name
  22757. */
  22758. constructor(name: string);
  22759. /**
  22760. * Gets the current class name
  22761. * @returns the class name
  22762. */
  22763. getClassName(): string;
  22764. /**
  22765. * Gets the input component
  22766. */
  22767. get input(): NodeMaterialConnectionPoint;
  22768. /**
  22769. * Gets the source min input component
  22770. */
  22771. get sourceMin(): NodeMaterialConnectionPoint;
  22772. /**
  22773. * Gets the source max input component
  22774. */
  22775. get sourceMax(): NodeMaterialConnectionPoint;
  22776. /**
  22777. * Gets the target min input component
  22778. */
  22779. get targetMin(): NodeMaterialConnectionPoint;
  22780. /**
  22781. * Gets the target max input component
  22782. */
  22783. get targetMax(): NodeMaterialConnectionPoint;
  22784. /**
  22785. * Gets the output component
  22786. */
  22787. get output(): NodeMaterialConnectionPoint;
  22788. protected _buildBlock(state: NodeMaterialBuildState): this;
  22789. protected _dumpPropertiesCode(): string;
  22790. serialize(): any;
  22791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22792. }
  22793. }
  22794. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22798. /**
  22799. * Block used to multiply 2 values
  22800. */
  22801. export class MultiplyBlock extends NodeMaterialBlock {
  22802. /**
  22803. * Creates a new MultiplyBlock
  22804. * @param name defines the block name
  22805. */
  22806. constructor(name: string);
  22807. /**
  22808. * Gets the current class name
  22809. * @returns the class name
  22810. */
  22811. getClassName(): string;
  22812. /**
  22813. * Gets the left operand input component
  22814. */
  22815. get left(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the right operand input component
  22818. */
  22819. get right(): NodeMaterialConnectionPoint;
  22820. /**
  22821. * Gets the output component
  22822. */
  22823. get output(): NodeMaterialConnectionPoint;
  22824. protected _buildBlock(state: NodeMaterialBuildState): this;
  22825. }
  22826. }
  22827. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22831. /**
  22832. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22833. */
  22834. export class ColorSplitterBlock extends NodeMaterialBlock {
  22835. /**
  22836. * Create a new ColorSplitterBlock
  22837. * @param name defines the block name
  22838. */
  22839. constructor(name: string);
  22840. /**
  22841. * Gets the current class name
  22842. * @returns the class name
  22843. */
  22844. getClassName(): string;
  22845. /**
  22846. * Gets the rgba component (input)
  22847. */
  22848. get rgba(): NodeMaterialConnectionPoint;
  22849. /**
  22850. * Gets the rgb component (input)
  22851. */
  22852. get rgbIn(): NodeMaterialConnectionPoint;
  22853. /**
  22854. * Gets the rgb component (output)
  22855. */
  22856. get rgbOut(): NodeMaterialConnectionPoint;
  22857. /**
  22858. * Gets the r component (output)
  22859. */
  22860. get r(): NodeMaterialConnectionPoint;
  22861. /**
  22862. * Gets the g component (output)
  22863. */
  22864. get g(): NodeMaterialConnectionPoint;
  22865. /**
  22866. * Gets the b component (output)
  22867. */
  22868. get b(): NodeMaterialConnectionPoint;
  22869. /**
  22870. * Gets the a component (output)
  22871. */
  22872. get a(): NodeMaterialConnectionPoint;
  22873. protected _inputRename(name: string): string;
  22874. protected _outputRename(name: string): string;
  22875. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22876. }
  22877. }
  22878. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22880. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22881. import { Scene } from "babylonjs/scene";
  22882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22883. import { Matrix } from "babylonjs/Maths/math.vector";
  22884. import { Mesh } from "babylonjs/Meshes/mesh";
  22885. import { Engine } from "babylonjs/Engines/engine";
  22886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22887. import { Observable } from "babylonjs/Misc/observable";
  22888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22889. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22890. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22891. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22892. import { Nullable } from "babylonjs/types";
  22893. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22894. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22895. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22896. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22897. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22898. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22899. import { Effect } from "babylonjs/Materials/effect";
  22900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22901. import { Camera } from "babylonjs/Cameras/camera";
  22902. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22903. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22904. /**
  22905. * Interface used to configure the node material editor
  22906. */
  22907. export interface INodeMaterialEditorOptions {
  22908. /** Define the URl to load node editor script */
  22909. editorURL?: string;
  22910. }
  22911. /** @hidden */
  22912. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22913. NORMAL: boolean;
  22914. TANGENT: boolean;
  22915. UV1: boolean;
  22916. /** BONES */
  22917. NUM_BONE_INFLUENCERS: number;
  22918. BonesPerMesh: number;
  22919. BONETEXTURE: boolean;
  22920. /** MORPH TARGETS */
  22921. MORPHTARGETS: boolean;
  22922. MORPHTARGETS_NORMAL: boolean;
  22923. MORPHTARGETS_TANGENT: boolean;
  22924. MORPHTARGETS_UV: boolean;
  22925. NUM_MORPH_INFLUENCERS: number;
  22926. /** IMAGE PROCESSING */
  22927. IMAGEPROCESSING: boolean;
  22928. VIGNETTE: boolean;
  22929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22930. VIGNETTEBLENDMODEOPAQUE: boolean;
  22931. TONEMAPPING: boolean;
  22932. TONEMAPPING_ACES: boolean;
  22933. CONTRAST: boolean;
  22934. EXPOSURE: boolean;
  22935. COLORCURVES: boolean;
  22936. COLORGRADING: boolean;
  22937. COLORGRADING3D: boolean;
  22938. SAMPLER3DGREENDEPTH: boolean;
  22939. SAMPLER3DBGRMAP: boolean;
  22940. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22941. /** MISC. */
  22942. BUMPDIRECTUV: number;
  22943. constructor();
  22944. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22945. }
  22946. /**
  22947. * Class used to configure NodeMaterial
  22948. */
  22949. export interface INodeMaterialOptions {
  22950. /**
  22951. * Defines if blocks should emit comments
  22952. */
  22953. emitComments: boolean;
  22954. }
  22955. /**
  22956. * Class used to create a node based material built by assembling shader blocks
  22957. */
  22958. export class NodeMaterial extends PushMaterial {
  22959. private static _BuildIdGenerator;
  22960. private _options;
  22961. private _vertexCompilationState;
  22962. private _fragmentCompilationState;
  22963. private _sharedData;
  22964. private _buildId;
  22965. private _buildWasSuccessful;
  22966. private _cachedWorldViewMatrix;
  22967. private _cachedWorldViewProjectionMatrix;
  22968. private _optimizers;
  22969. private _animationFrame;
  22970. /** Define the Url to load node editor script */
  22971. static EditorURL: string;
  22972. /** Define the Url to load snippets */
  22973. static SnippetUrl: string;
  22974. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22975. static IgnoreTexturesAtLoadTime: boolean;
  22976. private BJSNODEMATERIALEDITOR;
  22977. /** Get the inspector from bundle or global */
  22978. private _getGlobalNodeMaterialEditor;
  22979. /**
  22980. * Snippet ID if the material was created from the snippet server
  22981. */
  22982. snippetId: string;
  22983. /**
  22984. * Gets or sets data used by visual editor
  22985. * @see https://nme.babylonjs.com
  22986. */
  22987. editorData: any;
  22988. /**
  22989. * 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)
  22990. */
  22991. ignoreAlpha: boolean;
  22992. /**
  22993. * Defines the maximum number of lights that can be used in the material
  22994. */
  22995. maxSimultaneousLights: number;
  22996. /**
  22997. * Observable raised when the material is built
  22998. */
  22999. onBuildObservable: Observable<NodeMaterial>;
  23000. /**
  23001. * Gets or sets the root nodes of the material vertex shader
  23002. */
  23003. _vertexOutputNodes: NodeMaterialBlock[];
  23004. /**
  23005. * Gets or sets the root nodes of the material fragment (pixel) shader
  23006. */
  23007. _fragmentOutputNodes: NodeMaterialBlock[];
  23008. /** Gets or sets options to control the node material overall behavior */
  23009. get options(): INodeMaterialOptions;
  23010. set options(options: INodeMaterialOptions);
  23011. /**
  23012. * Default configuration related to image processing available in the standard Material.
  23013. */
  23014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23015. /**
  23016. * Gets the image processing configuration used either in this material.
  23017. */
  23018. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23019. /**
  23020. * Sets the Default image processing configuration used either in the this material.
  23021. *
  23022. * If sets to null, the scene one is in use.
  23023. */
  23024. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23025. /**
  23026. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23027. */
  23028. attachedBlocks: NodeMaterialBlock[];
  23029. /**
  23030. * Specifies the mode of the node material
  23031. * @hidden
  23032. */
  23033. _mode: NodeMaterialModes;
  23034. /**
  23035. * Gets the mode property
  23036. */
  23037. get mode(): NodeMaterialModes;
  23038. /**
  23039. * Create a new node based material
  23040. * @param name defines the material name
  23041. * @param scene defines the hosting scene
  23042. * @param options defines creation option
  23043. */
  23044. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23045. /**
  23046. * Gets the current class name of the material e.g. "NodeMaterial"
  23047. * @returns the class name
  23048. */
  23049. getClassName(): string;
  23050. /**
  23051. * Keep track of the image processing observer to allow dispose and replace.
  23052. */
  23053. private _imageProcessingObserver;
  23054. /**
  23055. * Attaches a new image processing configuration to the Standard Material.
  23056. * @param configuration
  23057. */
  23058. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23059. /**
  23060. * Get a block by its name
  23061. * @param name defines the name of the block to retrieve
  23062. * @returns the required block or null if not found
  23063. */
  23064. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23065. /**
  23066. * Get a block by its name
  23067. * @param predicate defines the predicate used to find the good candidate
  23068. * @returns the required block or null if not found
  23069. */
  23070. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23071. /**
  23072. * Get an input block by its name
  23073. * @param predicate defines the predicate used to find the good candidate
  23074. * @returns the required input block or null if not found
  23075. */
  23076. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23077. /**
  23078. * Gets the list of input blocks attached to this material
  23079. * @returns an array of InputBlocks
  23080. */
  23081. getInputBlocks(): InputBlock[];
  23082. /**
  23083. * Adds a new optimizer to the list of optimizers
  23084. * @param optimizer defines the optimizers to add
  23085. * @returns the current material
  23086. */
  23087. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23088. /**
  23089. * Remove an optimizer from the list of optimizers
  23090. * @param optimizer defines the optimizers to remove
  23091. * @returns the current material
  23092. */
  23093. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23094. /**
  23095. * Add a new block to the list of output nodes
  23096. * @param node defines the node to add
  23097. * @returns the current material
  23098. */
  23099. addOutputNode(node: NodeMaterialBlock): this;
  23100. /**
  23101. * Remove a block from the list of root nodes
  23102. * @param node defines the node to remove
  23103. * @returns the current material
  23104. */
  23105. removeOutputNode(node: NodeMaterialBlock): this;
  23106. private _addVertexOutputNode;
  23107. private _removeVertexOutputNode;
  23108. private _addFragmentOutputNode;
  23109. private _removeFragmentOutputNode;
  23110. /**
  23111. * Specifies if the material will require alpha blending
  23112. * @returns a boolean specifying if alpha blending is needed
  23113. */
  23114. needAlphaBlending(): boolean;
  23115. /**
  23116. * Specifies if this material should be rendered in alpha test mode
  23117. * @returns a boolean specifying if an alpha test is needed.
  23118. */
  23119. needAlphaTesting(): boolean;
  23120. private _initializeBlock;
  23121. private _resetDualBlocks;
  23122. /**
  23123. * Remove a block from the current node material
  23124. * @param block defines the block to remove
  23125. */
  23126. removeBlock(block: NodeMaterialBlock): void;
  23127. /**
  23128. * Build the material and generates the inner effect
  23129. * @param verbose defines if the build should log activity
  23130. */
  23131. build(verbose?: boolean): void;
  23132. /**
  23133. * Runs an otpimization phase to try to improve the shader code
  23134. */
  23135. optimize(): void;
  23136. private _prepareDefinesForAttributes;
  23137. /**
  23138. * Create a post process from the material
  23139. * @param camera The camera to apply the render pass to.
  23140. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23142. * @param engine The engine which the post process will be applied. (default: current engine)
  23143. * @param reusable If the post process can be reused on the same frame. (default: false)
  23144. * @param textureType Type of textures used when performing the post process. (default: 0)
  23145. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23146. * @returns the post process created
  23147. */
  23148. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23149. /**
  23150. * Create the post process effect from the material
  23151. * @param postProcess The post process to create the effect for
  23152. */
  23153. createEffectForPostProcess(postProcess: PostProcess): void;
  23154. private _createEffectOrPostProcess;
  23155. private _createEffectForParticles;
  23156. /**
  23157. * Create the effect to be used as the custom effect for a particle system
  23158. * @param particleSystem Particle system to create the effect for
  23159. * @param onCompiled defines a function to call when the effect creation is successful
  23160. * @param onError defines a function to call when the effect creation has failed
  23161. */
  23162. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23163. private _processDefines;
  23164. /**
  23165. * Get if the submesh is ready to be used and all its information available.
  23166. * Child classes can use it to update shaders
  23167. * @param mesh defines the mesh to check
  23168. * @param subMesh defines which submesh to check
  23169. * @param useInstances specifies that instances should be used
  23170. * @returns a boolean indicating that the submesh is ready or not
  23171. */
  23172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23173. /**
  23174. * Get a string representing the shaders built by the current node graph
  23175. */
  23176. get compiledShaders(): string;
  23177. /**
  23178. * Binds the world matrix to the material
  23179. * @param world defines the world transformation matrix
  23180. */
  23181. bindOnlyWorldMatrix(world: Matrix): void;
  23182. /**
  23183. * Binds the submesh to this material by preparing the effect and shader to draw
  23184. * @param world defines the world transformation matrix
  23185. * @param mesh defines the mesh containing the submesh
  23186. * @param subMesh defines the submesh to bind the material to
  23187. */
  23188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23189. /**
  23190. * Gets the active textures from the material
  23191. * @returns an array of textures
  23192. */
  23193. getActiveTextures(): BaseTexture[];
  23194. /**
  23195. * Gets the list of texture blocks
  23196. * @returns an array of texture blocks
  23197. */
  23198. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23199. /**
  23200. * Specifies if the material uses a texture
  23201. * @param texture defines the texture to check against the material
  23202. * @returns a boolean specifying if the material uses the texture
  23203. */
  23204. hasTexture(texture: BaseTexture): boolean;
  23205. /**
  23206. * Disposes the material
  23207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23209. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23210. */
  23211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23212. /** Creates the node editor window. */
  23213. private _createNodeEditor;
  23214. /**
  23215. * Launch the node material editor
  23216. * @param config Define the configuration of the editor
  23217. * @return a promise fulfilled when the node editor is visible
  23218. */
  23219. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23220. /**
  23221. * Clear the current material
  23222. */
  23223. clear(): void;
  23224. /**
  23225. * Clear the current material and set it to a default state
  23226. */
  23227. setToDefault(): void;
  23228. /**
  23229. * Clear the current material and set it to a default state for post process
  23230. */
  23231. setToDefaultPostProcess(): void;
  23232. /**
  23233. * Clear the current material and set it to a default state for particle
  23234. */
  23235. setToDefaultParticle(): void;
  23236. /**
  23237. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23238. * @param url defines the url to load from
  23239. * @returns a promise that will fullfil when the material is fully loaded
  23240. */
  23241. loadAsync(url: string): Promise<void>;
  23242. private _gatherBlocks;
  23243. /**
  23244. * Generate a string containing the code declaration required to create an equivalent of this material
  23245. * @returns a string
  23246. */
  23247. generateCode(): string;
  23248. /**
  23249. * Serializes this material in a JSON representation
  23250. * @returns the serialized material object
  23251. */
  23252. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23253. private _restoreConnections;
  23254. /**
  23255. * Clear the current graph and load a new one from a serialization object
  23256. * @param source defines the JSON representation of the material
  23257. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23258. * @param merge defines whether or not the source must be merged or replace the current content
  23259. */
  23260. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23261. /**
  23262. * Makes a duplicate of the current material.
  23263. * @param name - name to use for the new material.
  23264. */
  23265. clone(name: string): NodeMaterial;
  23266. /**
  23267. * Creates a node material from parsed material data
  23268. * @param source defines the JSON representation of the material
  23269. * @param scene defines the hosting scene
  23270. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23271. * @returns a new node material
  23272. */
  23273. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23274. /**
  23275. * Creates a node material from a snippet saved in a remote file
  23276. * @param name defines the name of the material to create
  23277. * @param url defines the url to load from
  23278. * @param scene defines the hosting scene
  23279. * @returns a promise that will resolve to the new node material
  23280. */
  23281. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23282. /**
  23283. * Creates a node material from a snippet saved by the node material editor
  23284. * @param snippetId defines the snippet to load
  23285. * @param scene defines the hosting scene
  23286. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23287. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23288. * @returns a promise that will resolve to the new node material
  23289. */
  23290. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23291. /**
  23292. * Creates a new node material set to default basic configuration
  23293. * @param name defines the name of the material
  23294. * @param scene defines the hosting scene
  23295. * @returns a new NodeMaterial
  23296. */
  23297. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23298. }
  23299. }
  23300. declare module "babylonjs/PostProcesses/postProcess" {
  23301. import { Nullable } from "babylonjs/types";
  23302. import { SmartArray } from "babylonjs/Misc/smartArray";
  23303. import { Observable } from "babylonjs/Misc/observable";
  23304. import { Vector2 } from "babylonjs/Maths/math.vector";
  23305. import { Camera } from "babylonjs/Cameras/camera";
  23306. import { Effect } from "babylonjs/Materials/effect";
  23307. import "babylonjs/Shaders/postprocess.vertex";
  23308. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23309. import { Engine } from "babylonjs/Engines/engine";
  23310. import { Color4 } from "babylonjs/Maths/math.color";
  23311. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23312. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23313. import { Scene } from "babylonjs/scene";
  23314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23315. /**
  23316. * Size options for a post process
  23317. */
  23318. export type PostProcessOptions = {
  23319. width: number;
  23320. height: number;
  23321. };
  23322. /**
  23323. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23324. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23325. */
  23326. export class PostProcess {
  23327. /** Name of the PostProcess. */
  23328. name: string;
  23329. /**
  23330. * Gets or sets the unique id of the post process
  23331. */
  23332. uniqueId: number;
  23333. /**
  23334. * Width of the texture to apply the post process on
  23335. */
  23336. width: number;
  23337. /**
  23338. * Height of the texture to apply the post process on
  23339. */
  23340. height: number;
  23341. /**
  23342. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23343. */
  23344. nodeMaterialSource: Nullable<NodeMaterial>;
  23345. /**
  23346. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23347. * @hidden
  23348. */
  23349. _outputTexture: Nullable<InternalTexture>;
  23350. /**
  23351. * Sampling mode used by the shader
  23352. * See https://doc.babylonjs.com/classes/3.1/texture
  23353. */
  23354. renderTargetSamplingMode: number;
  23355. /**
  23356. * Clear color to use when screen clearing
  23357. */
  23358. clearColor: Color4;
  23359. /**
  23360. * If the buffer needs to be cleared before applying the post process. (default: true)
  23361. * Should be set to false if shader will overwrite all previous pixels.
  23362. */
  23363. autoClear: boolean;
  23364. /**
  23365. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23366. */
  23367. alphaMode: number;
  23368. /**
  23369. * Sets the setAlphaBlendConstants of the babylon engine
  23370. */
  23371. alphaConstants: Color4;
  23372. /**
  23373. * Animations to be used for the post processing
  23374. */
  23375. animations: import("babylonjs/Animations/animation").Animation[];
  23376. /**
  23377. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23378. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23379. */
  23380. enablePixelPerfectMode: boolean;
  23381. /**
  23382. * Force the postprocess to be applied without taking in account viewport
  23383. */
  23384. forceFullscreenViewport: boolean;
  23385. /**
  23386. * List of inspectable custom properties (used by the Inspector)
  23387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23388. */
  23389. inspectableCustomProperties: IInspectable[];
  23390. /**
  23391. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23392. *
  23393. * | Value | Type | Description |
  23394. * | ----- | ----------------------------------- | ----------- |
  23395. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23396. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23397. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23398. *
  23399. */
  23400. scaleMode: number;
  23401. /**
  23402. * Force textures to be a power of two (default: false)
  23403. */
  23404. alwaysForcePOT: boolean;
  23405. private _samples;
  23406. /**
  23407. * Number of sample textures (default: 1)
  23408. */
  23409. get samples(): number;
  23410. set samples(n: number);
  23411. /**
  23412. * Modify the scale of the post process to be the same as the viewport (default: false)
  23413. */
  23414. adaptScaleToCurrentViewport: boolean;
  23415. private _camera;
  23416. protected _scene: Scene;
  23417. private _engine;
  23418. private _options;
  23419. private _reusable;
  23420. private _textureType;
  23421. private _textureFormat;
  23422. /**
  23423. * Smart array of input and output textures for the post process.
  23424. * @hidden
  23425. */
  23426. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23427. /**
  23428. * The index in _textures that corresponds to the output texture.
  23429. * @hidden
  23430. */
  23431. _currentRenderTextureInd: number;
  23432. private _effect;
  23433. private _samplers;
  23434. private _fragmentUrl;
  23435. private _vertexUrl;
  23436. private _parameters;
  23437. private _scaleRatio;
  23438. protected _indexParameters: any;
  23439. private _shareOutputWithPostProcess;
  23440. private _texelSize;
  23441. private _forcedOutputTexture;
  23442. /**
  23443. * Returns the fragment url or shader name used in the post process.
  23444. * @returns the fragment url or name in the shader store.
  23445. */
  23446. getEffectName(): string;
  23447. /**
  23448. * An event triggered when the postprocess is activated.
  23449. */
  23450. onActivateObservable: Observable<Camera>;
  23451. private _onActivateObserver;
  23452. /**
  23453. * A function that is added to the onActivateObservable
  23454. */
  23455. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23456. /**
  23457. * An event triggered when the postprocess changes its size.
  23458. */
  23459. onSizeChangedObservable: Observable<PostProcess>;
  23460. private _onSizeChangedObserver;
  23461. /**
  23462. * A function that is added to the onSizeChangedObservable
  23463. */
  23464. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23465. /**
  23466. * An event triggered when the postprocess applies its effect.
  23467. */
  23468. onApplyObservable: Observable<Effect>;
  23469. private _onApplyObserver;
  23470. /**
  23471. * A function that is added to the onApplyObservable
  23472. */
  23473. set onApply(callback: (effect: Effect) => void);
  23474. /**
  23475. * An event triggered before rendering the postprocess
  23476. */
  23477. onBeforeRenderObservable: Observable<Effect>;
  23478. private _onBeforeRenderObserver;
  23479. /**
  23480. * A function that is added to the onBeforeRenderObservable
  23481. */
  23482. set onBeforeRender(callback: (effect: Effect) => void);
  23483. /**
  23484. * An event triggered after rendering the postprocess
  23485. */
  23486. onAfterRenderObservable: Observable<Effect>;
  23487. private _onAfterRenderObserver;
  23488. /**
  23489. * A function that is added to the onAfterRenderObservable
  23490. */
  23491. set onAfterRender(callback: (efect: Effect) => void);
  23492. /**
  23493. * 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
  23494. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23495. */
  23496. get inputTexture(): InternalTexture;
  23497. set inputTexture(value: InternalTexture);
  23498. /**
  23499. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23500. * the only way to unset it is to use this function to restore its internal state
  23501. */
  23502. restoreDefaultInputTexture(): void;
  23503. /**
  23504. * Gets the camera which post process is applied to.
  23505. * @returns The camera the post process is applied to.
  23506. */
  23507. getCamera(): Camera;
  23508. /**
  23509. * Gets the texel size of the postprocess.
  23510. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23511. */
  23512. get texelSize(): Vector2;
  23513. /**
  23514. * Creates a new instance PostProcess
  23515. * @param name The name of the PostProcess.
  23516. * @param fragmentUrl The url of the fragment shader to be used.
  23517. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23518. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23519. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23520. * @param camera The camera to apply the render pass to.
  23521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23522. * @param engine The engine which the post process will be applied. (default: current engine)
  23523. * @param reusable If the post process can be reused on the same frame. (default: false)
  23524. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23525. * @param textureType Type of textures used when performing the post process. (default: 0)
  23526. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23527. * @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
  23528. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23529. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23530. */
  23531. constructor(
  23532. /** Name of the PostProcess. */
  23533. 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);
  23534. /**
  23535. * Gets a string idenfifying the name of the class
  23536. * @returns "PostProcess" string
  23537. */
  23538. getClassName(): string;
  23539. /**
  23540. * Gets the engine which this post process belongs to.
  23541. * @returns The engine the post process was enabled with.
  23542. */
  23543. getEngine(): Engine;
  23544. /**
  23545. * The effect that is created when initializing the post process.
  23546. * @returns The created effect corresponding the the postprocess.
  23547. */
  23548. getEffect(): Effect;
  23549. /**
  23550. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23551. * @param postProcess The post process to share the output with.
  23552. * @returns This post process.
  23553. */
  23554. shareOutputWith(postProcess: PostProcess): PostProcess;
  23555. /**
  23556. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23557. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23558. */
  23559. useOwnOutput(): void;
  23560. /**
  23561. * Updates the effect with the current post process compile time values and recompiles the shader.
  23562. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23563. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23564. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23565. * @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
  23566. * @param onCompiled Called when the shader has been compiled.
  23567. * @param onError Called if there is an error when compiling a shader.
  23568. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23569. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23570. */
  23571. 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;
  23572. /**
  23573. * The post process is reusable if it can be used multiple times within one frame.
  23574. * @returns If the post process is reusable
  23575. */
  23576. isReusable(): boolean;
  23577. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23578. markTextureDirty(): void;
  23579. /**
  23580. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23581. * 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.
  23582. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23583. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23584. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23585. * @returns The target texture that was bound to be written to.
  23586. */
  23587. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23588. /**
  23589. * If the post process is supported.
  23590. */
  23591. get isSupported(): boolean;
  23592. /**
  23593. * The aspect ratio of the output texture.
  23594. */
  23595. get aspectRatio(): number;
  23596. /**
  23597. * Get a value indicating if the post-process is ready to be used
  23598. * @returns true if the post-process is ready (shader is compiled)
  23599. */
  23600. isReady(): boolean;
  23601. /**
  23602. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23603. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23604. */
  23605. apply(): Nullable<Effect>;
  23606. private _disposeTextures;
  23607. /**
  23608. * Disposes the post process.
  23609. * @param camera The camera to dispose the post process on.
  23610. */
  23611. dispose(camera?: Camera): void;
  23612. }
  23613. }
  23614. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23615. /** @hidden */
  23616. export var kernelBlurVaryingDeclaration: {
  23617. name: string;
  23618. shader: string;
  23619. };
  23620. }
  23621. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23622. /** @hidden */
  23623. export var kernelBlurFragment: {
  23624. name: string;
  23625. shader: string;
  23626. };
  23627. }
  23628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23629. /** @hidden */
  23630. export var kernelBlurFragment2: {
  23631. name: string;
  23632. shader: string;
  23633. };
  23634. }
  23635. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23636. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23637. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23638. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23639. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23640. /** @hidden */
  23641. export var kernelBlurPixelShader: {
  23642. name: string;
  23643. shader: string;
  23644. };
  23645. }
  23646. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23647. /** @hidden */
  23648. export var kernelBlurVertex: {
  23649. name: string;
  23650. shader: string;
  23651. };
  23652. }
  23653. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23654. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23655. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23656. /** @hidden */
  23657. export var kernelBlurVertexShader: {
  23658. name: string;
  23659. shader: string;
  23660. };
  23661. }
  23662. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23663. import { Vector2 } from "babylonjs/Maths/math.vector";
  23664. import { Nullable } from "babylonjs/types";
  23665. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23666. import { Camera } from "babylonjs/Cameras/camera";
  23667. import { Effect } from "babylonjs/Materials/effect";
  23668. import { Engine } from "babylonjs/Engines/engine";
  23669. import "babylonjs/Shaders/kernelBlur.fragment";
  23670. import "babylonjs/Shaders/kernelBlur.vertex";
  23671. /**
  23672. * The Blur Post Process which blurs an image based on a kernel and direction.
  23673. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23674. */
  23675. export class BlurPostProcess extends PostProcess {
  23676. /** The direction in which to blur the image. */
  23677. direction: Vector2;
  23678. private blockCompilation;
  23679. protected _kernel: number;
  23680. protected _idealKernel: number;
  23681. protected _packedFloat: boolean;
  23682. private _staticDefines;
  23683. /**
  23684. * Sets the length in pixels of the blur sample region
  23685. */
  23686. set kernel(v: number);
  23687. /**
  23688. * Gets the length in pixels of the blur sample region
  23689. */
  23690. get kernel(): number;
  23691. /**
  23692. * Sets wether or not the blur needs to unpack/repack floats
  23693. */
  23694. set packedFloat(v: boolean);
  23695. /**
  23696. * Gets wether or not the blur is unpacking/repacking floats
  23697. */
  23698. get packedFloat(): boolean;
  23699. /**
  23700. * Creates a new instance BlurPostProcess
  23701. * @param name The name of the effect.
  23702. * @param direction The direction in which to blur the image.
  23703. * @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.
  23704. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23705. * @param camera The camera to apply the render pass to.
  23706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23707. * @param engine The engine which the post process will be applied. (default: current engine)
  23708. * @param reusable If the post process can be reused on the same frame. (default: false)
  23709. * @param textureType Type of textures used when performing the post process. (default: 0)
  23710. * @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)
  23711. */
  23712. constructor(name: string,
  23713. /** The direction in which to blur the image. */
  23714. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23715. /**
  23716. * Updates the effect with the current post process compile time values and recompiles the shader.
  23717. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23718. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23719. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23720. * @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
  23721. * @param onCompiled Called when the shader has been compiled.
  23722. * @param onError Called if there is an error when compiling a shader.
  23723. */
  23724. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23725. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23726. /**
  23727. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23728. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23729. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23730. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23731. * The gaps between physical kernels are compensated for in the weighting of the samples
  23732. * @param idealKernel Ideal blur kernel.
  23733. * @return Nearest best kernel.
  23734. */
  23735. protected _nearestBestKernel(idealKernel: number): number;
  23736. /**
  23737. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23738. * @param x The point on the Gaussian distribution to sample.
  23739. * @return the value of the Gaussian function at x.
  23740. */
  23741. protected _gaussianWeight(x: number): number;
  23742. /**
  23743. * Generates a string that can be used as a floating point number in GLSL.
  23744. * @param x Value to print.
  23745. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23746. * @return GLSL float string.
  23747. */
  23748. protected _glslFloat(x: number, decimalFigures?: number): string;
  23749. }
  23750. }
  23751. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23752. import { Scene } from "babylonjs/scene";
  23753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23754. import { Plane } from "babylonjs/Maths/math.plane";
  23755. /**
  23756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23758. * You can then easily use it as a reflectionTexture on a flat surface.
  23759. * In case the surface is not a plane, please consider relying on reflection probes.
  23760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23761. */
  23762. export class MirrorTexture extends RenderTargetTexture {
  23763. private scene;
  23764. /**
  23765. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23766. * 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.
  23767. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23768. */
  23769. mirrorPlane: Plane;
  23770. /**
  23771. * Define the blur ratio used to blur the reflection if needed.
  23772. */
  23773. set blurRatio(value: number);
  23774. get blurRatio(): number;
  23775. /**
  23776. * Define the adaptive blur kernel used to blur the reflection if needed.
  23777. * This will autocompute the closest best match for the `blurKernel`
  23778. */
  23779. set adaptiveBlurKernel(value: number);
  23780. /**
  23781. * Define the blur kernel used to blur the reflection if needed.
  23782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23783. */
  23784. set blurKernel(value: number);
  23785. /**
  23786. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23787. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23788. */
  23789. set blurKernelX(value: number);
  23790. get blurKernelX(): number;
  23791. /**
  23792. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23794. */
  23795. set blurKernelY(value: number);
  23796. get blurKernelY(): number;
  23797. private _autoComputeBlurKernel;
  23798. protected _onRatioRescale(): void;
  23799. private _updateGammaSpace;
  23800. private _imageProcessingConfigChangeObserver;
  23801. private _transformMatrix;
  23802. private _mirrorMatrix;
  23803. private _savedViewMatrix;
  23804. private _blurX;
  23805. private _blurY;
  23806. private _adaptiveBlurKernel;
  23807. private _blurKernelX;
  23808. private _blurKernelY;
  23809. private _blurRatio;
  23810. /**
  23811. * Instantiates a Mirror Texture.
  23812. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23813. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23814. * You can then easily use it as a reflectionTexture on a flat surface.
  23815. * In case the surface is not a plane, please consider relying on reflection probes.
  23816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23817. * @param name
  23818. * @param size
  23819. * @param scene
  23820. * @param generateMipMaps
  23821. * @param type
  23822. * @param samplingMode
  23823. * @param generateDepthBuffer
  23824. */
  23825. constructor(name: string, size: number | {
  23826. width: number;
  23827. height: number;
  23828. } | {
  23829. ratio: number;
  23830. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23831. private _preparePostProcesses;
  23832. /**
  23833. * Clone the mirror texture.
  23834. * @returns the cloned texture
  23835. */
  23836. clone(): MirrorTexture;
  23837. /**
  23838. * Serialize the texture to a JSON representation you could use in Parse later on
  23839. * @returns the serialized JSON representation
  23840. */
  23841. serialize(): any;
  23842. /**
  23843. * Dispose the texture and release its associated resources.
  23844. */
  23845. dispose(): void;
  23846. }
  23847. }
  23848. declare module "babylonjs/Materials/Textures/texture" {
  23849. import { Observable } from "babylonjs/Misc/observable";
  23850. import { Nullable } from "babylonjs/types";
  23851. import { Matrix } from "babylonjs/Maths/math.vector";
  23852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23853. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23854. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23855. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23856. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23858. import { Scene } from "babylonjs/scene";
  23859. /**
  23860. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23861. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23862. */
  23863. export class Texture extends BaseTexture {
  23864. /**
  23865. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23866. */
  23867. static SerializeBuffers: boolean;
  23868. /** @hidden */
  23869. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23870. /** @hidden */
  23871. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23872. /** @hidden */
  23873. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23874. /** nearest is mag = nearest and min = nearest and mip = linear */
  23875. static readonly NEAREST_SAMPLINGMODE: number;
  23876. /** nearest is mag = nearest and min = nearest and mip = linear */
  23877. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23879. static readonly BILINEAR_SAMPLINGMODE: number;
  23880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23881. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23882. /** Trilinear is mag = linear and min = linear and mip = linear */
  23883. static readonly TRILINEAR_SAMPLINGMODE: number;
  23884. /** Trilinear is mag = linear and min = linear and mip = linear */
  23885. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23886. /** mag = nearest and min = nearest and mip = nearest */
  23887. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23888. /** mag = nearest and min = linear and mip = nearest */
  23889. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23890. /** mag = nearest and min = linear and mip = linear */
  23891. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23892. /** mag = nearest and min = linear and mip = none */
  23893. static readonly NEAREST_LINEAR: number;
  23894. /** mag = nearest and min = nearest and mip = none */
  23895. static readonly NEAREST_NEAREST: number;
  23896. /** mag = linear and min = nearest and mip = nearest */
  23897. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23898. /** mag = linear and min = nearest and mip = linear */
  23899. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23900. /** mag = linear and min = linear and mip = none */
  23901. static readonly LINEAR_LINEAR: number;
  23902. /** mag = linear and min = nearest and mip = none */
  23903. static readonly LINEAR_NEAREST: number;
  23904. /** Explicit coordinates mode */
  23905. static readonly EXPLICIT_MODE: number;
  23906. /** Spherical coordinates mode */
  23907. static readonly SPHERICAL_MODE: number;
  23908. /** Planar coordinates mode */
  23909. static readonly PLANAR_MODE: number;
  23910. /** Cubic coordinates mode */
  23911. static readonly CUBIC_MODE: number;
  23912. /** Projection coordinates mode */
  23913. static readonly PROJECTION_MODE: number;
  23914. /** Inverse Cubic coordinates mode */
  23915. static readonly SKYBOX_MODE: number;
  23916. /** Inverse Cubic coordinates mode */
  23917. static readonly INVCUBIC_MODE: number;
  23918. /** Equirectangular coordinates mode */
  23919. static readonly EQUIRECTANGULAR_MODE: number;
  23920. /** Equirectangular Fixed coordinates mode */
  23921. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23922. /** Equirectangular Fixed Mirrored coordinates mode */
  23923. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23924. /** Texture is not repeating outside of 0..1 UVs */
  23925. static readonly CLAMP_ADDRESSMODE: number;
  23926. /** Texture is repeating outside of 0..1 UVs */
  23927. static readonly WRAP_ADDRESSMODE: number;
  23928. /** Texture is repeating and mirrored */
  23929. static readonly MIRROR_ADDRESSMODE: number;
  23930. /**
  23931. * 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
  23932. */
  23933. static UseSerializedUrlIfAny: boolean;
  23934. /**
  23935. * Define the url of the texture.
  23936. */
  23937. url: Nullable<string>;
  23938. /**
  23939. * Define an offset on the texture to offset the u coordinates of the UVs
  23940. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23941. */
  23942. uOffset: number;
  23943. /**
  23944. * Define an offset on the texture to offset the v coordinates of the UVs
  23945. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23946. */
  23947. vOffset: number;
  23948. /**
  23949. * Define an offset on the texture to scale the u coordinates of the UVs
  23950. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23951. */
  23952. uScale: number;
  23953. /**
  23954. * Define an offset on the texture to scale the v coordinates of the UVs
  23955. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23956. */
  23957. vScale: number;
  23958. /**
  23959. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23960. * @see https://doc.babylonjs.com/how_to/more_materials
  23961. */
  23962. uAng: number;
  23963. /**
  23964. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23965. * @see https://doc.babylonjs.com/how_to/more_materials
  23966. */
  23967. vAng: number;
  23968. /**
  23969. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23970. * @see https://doc.babylonjs.com/how_to/more_materials
  23971. */
  23972. wAng: number;
  23973. /**
  23974. * Defines the center of rotation (U)
  23975. */
  23976. uRotationCenter: number;
  23977. /**
  23978. * Defines the center of rotation (V)
  23979. */
  23980. vRotationCenter: number;
  23981. /**
  23982. * Defines the center of rotation (W)
  23983. */
  23984. wRotationCenter: number;
  23985. /**
  23986. * Are mip maps generated for this texture or not.
  23987. */
  23988. get noMipmap(): boolean;
  23989. /**
  23990. * List of inspectable custom properties (used by the Inspector)
  23991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23992. */
  23993. inspectableCustomProperties: Nullable<IInspectable[]>;
  23994. private _noMipmap;
  23995. /** @hidden */
  23996. _invertY: boolean;
  23997. private _rowGenerationMatrix;
  23998. private _cachedTextureMatrix;
  23999. private _projectionModeMatrix;
  24000. private _t0;
  24001. private _t1;
  24002. private _t2;
  24003. private _cachedUOffset;
  24004. private _cachedVOffset;
  24005. private _cachedUScale;
  24006. private _cachedVScale;
  24007. private _cachedUAng;
  24008. private _cachedVAng;
  24009. private _cachedWAng;
  24010. private _cachedProjectionMatrixId;
  24011. private _cachedCoordinatesMode;
  24012. /** @hidden */
  24013. protected _initialSamplingMode: number;
  24014. /** @hidden */
  24015. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24016. private _deleteBuffer;
  24017. protected _format: Nullable<number>;
  24018. private _delayedOnLoad;
  24019. private _delayedOnError;
  24020. private _mimeType?;
  24021. /**
  24022. * Observable triggered once the texture has been loaded.
  24023. */
  24024. onLoadObservable: Observable<Texture>;
  24025. protected _isBlocking: boolean;
  24026. /**
  24027. * Is the texture preventing material to render while loading.
  24028. * If false, a default texture will be used instead of the loading one during the preparation step.
  24029. */
  24030. set isBlocking(value: boolean);
  24031. get isBlocking(): boolean;
  24032. /**
  24033. * Get the current sampling mode associated with the texture.
  24034. */
  24035. get samplingMode(): number;
  24036. /**
  24037. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24038. */
  24039. get invertY(): boolean;
  24040. /**
  24041. * Instantiates a new texture.
  24042. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24043. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24044. * @param url defines the url of the picture to load as a texture
  24045. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24046. * @param noMipmap defines if the texture will require mip maps or not
  24047. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24048. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24049. * @param onLoad defines a callback triggered when the texture has been loaded
  24050. * @param onError defines a callback triggered when an error occurred during the loading session
  24051. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24052. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24053. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24054. * @param mimeType defines an optional mime type information
  24055. */
  24056. 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);
  24057. /**
  24058. * Update the url (and optional buffer) of this texture if url was null during construction.
  24059. * @param url the url of the texture
  24060. * @param buffer the buffer of the texture (defaults to null)
  24061. * @param onLoad callback called when the texture is loaded (defaults to null)
  24062. */
  24063. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24064. /**
  24065. * Finish the loading sequence of a texture flagged as delayed load.
  24066. * @hidden
  24067. */
  24068. delayLoad(): void;
  24069. private _prepareRowForTextureGeneration;
  24070. /**
  24071. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24072. * @returns the transform matrix of the texture.
  24073. */
  24074. getTextureMatrix(uBase?: number): Matrix;
  24075. /**
  24076. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24077. * @returns The reflection texture transform
  24078. */
  24079. getReflectionTextureMatrix(): Matrix;
  24080. /**
  24081. * Clones the texture.
  24082. * @returns the cloned texture
  24083. */
  24084. clone(): Texture;
  24085. /**
  24086. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24087. * @returns The JSON representation of the texture
  24088. */
  24089. serialize(): any;
  24090. /**
  24091. * Get the current class name of the texture useful for serialization or dynamic coding.
  24092. * @returns "Texture"
  24093. */
  24094. getClassName(): string;
  24095. /**
  24096. * Dispose the texture and release its associated resources.
  24097. */
  24098. dispose(): void;
  24099. /**
  24100. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24101. * @param parsedTexture Define the JSON representation of the texture
  24102. * @param scene Define the scene the parsed texture should be instantiated in
  24103. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24104. * @returns The parsed texture if successful
  24105. */
  24106. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24107. /**
  24108. * Creates a texture from its base 64 representation.
  24109. * @param data Define the base64 payload without the data: prefix
  24110. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24111. * @param scene Define the scene the texture should belong to
  24112. * @param noMipmap Forces the texture to not create mip map information if true
  24113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24115. * @param onLoad define a callback triggered when the texture has been loaded
  24116. * @param onError define a callback triggered when an error occurred during the loading session
  24117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24118. * @returns the created texture
  24119. */
  24120. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24121. /**
  24122. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24123. * @param data Define the base64 payload without the data: prefix
  24124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24125. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24126. * @param scene Define the scene the texture should belong to
  24127. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24128. * @param noMipmap Forces the texture to not create mip map information if true
  24129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24131. * @param onLoad define a callback triggered when the texture has been loaded
  24132. * @param onError define a callback triggered when an error occurred during the loading session
  24133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24134. * @returns the created texture
  24135. */
  24136. 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;
  24137. }
  24138. }
  24139. declare module "babylonjs/PostProcesses/postProcessManager" {
  24140. import { Nullable } from "babylonjs/types";
  24141. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24142. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24143. import { Scene } from "babylonjs/scene";
  24144. /**
  24145. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24146. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24147. */
  24148. export class PostProcessManager {
  24149. private _scene;
  24150. private _indexBuffer;
  24151. private _vertexBuffers;
  24152. /**
  24153. * Creates a new instance PostProcess
  24154. * @param scene The scene that the post process is associated with.
  24155. */
  24156. constructor(scene: Scene);
  24157. private _prepareBuffers;
  24158. private _buildIndexBuffer;
  24159. /**
  24160. * Rebuilds the vertex buffers of the manager.
  24161. * @hidden
  24162. */
  24163. _rebuild(): void;
  24164. /**
  24165. * Prepares a frame to be run through a post process.
  24166. * @param sourceTexture The input texture to the post procesess. (default: null)
  24167. * @param postProcesses An array of post processes to be run. (default: null)
  24168. * @returns True if the post processes were able to be run.
  24169. * @hidden
  24170. */
  24171. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24172. /**
  24173. * Manually render a set of post processes to a texture.
  24174. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24175. * @param postProcesses An array of post processes to be run.
  24176. * @param targetTexture The target texture to render to.
  24177. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24178. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24179. * @param lodLevel defines which lod of the texture to render to
  24180. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24181. */
  24182. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24183. /**
  24184. * Finalize the result of the output of the postprocesses.
  24185. * @param doNotPresent If true the result will not be displayed to the screen.
  24186. * @param targetTexture The target texture to render to.
  24187. * @param faceIndex The index of the face to bind the target texture to.
  24188. * @param postProcesses The array of post processes to render.
  24189. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24190. * @hidden
  24191. */
  24192. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24193. /**
  24194. * Disposes of the post process manager.
  24195. */
  24196. dispose(): void;
  24197. }
  24198. }
  24199. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24200. import { Observable } from "babylonjs/Misc/observable";
  24201. import { SmartArray } from "babylonjs/Misc/smartArray";
  24202. import { Nullable, Immutable } from "babylonjs/types";
  24203. import { Camera } from "babylonjs/Cameras/camera";
  24204. import { Scene } from "babylonjs/scene";
  24205. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24206. import { Color4 } from "babylonjs/Maths/math.color";
  24207. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24209. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24210. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24211. import { Texture } from "babylonjs/Materials/Textures/texture";
  24212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24213. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24214. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24215. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24216. import { Engine } from "babylonjs/Engines/engine";
  24217. /**
  24218. * This Helps creating a texture that will be created from a camera in your scene.
  24219. * It is basically a dynamic texture that could be used to create special effects for instance.
  24220. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24221. */
  24222. export class RenderTargetTexture extends Texture {
  24223. isCube: boolean;
  24224. /**
  24225. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24226. */
  24227. static readonly REFRESHRATE_RENDER_ONCE: number;
  24228. /**
  24229. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24230. */
  24231. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24232. /**
  24233. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24234. * the central point of your effect and can save a lot of performances.
  24235. */
  24236. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24237. /**
  24238. * Use this predicate to dynamically define the list of mesh you want to render.
  24239. * If set, the renderList property will be overwritten.
  24240. */
  24241. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24242. private _renderList;
  24243. /**
  24244. * Use this list to define the list of mesh you want to render.
  24245. */
  24246. get renderList(): Nullable<Array<AbstractMesh>>;
  24247. set renderList(value: Nullable<Array<AbstractMesh>>);
  24248. /**
  24249. * Use this function to overload the renderList array at rendering time.
  24250. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24251. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24252. * the cube (if the RTT is a cube, else layerOrFace=0).
  24253. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24254. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24255. * hold dummy elements!
  24256. */
  24257. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24258. private _hookArray;
  24259. /**
  24260. * Define if particles should be rendered in your texture.
  24261. */
  24262. renderParticles: boolean;
  24263. /**
  24264. * Define if sprites should be rendered in your texture.
  24265. */
  24266. renderSprites: boolean;
  24267. /**
  24268. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24269. */
  24270. coordinatesMode: number;
  24271. /**
  24272. * Define the camera used to render the texture.
  24273. */
  24274. activeCamera: Nullable<Camera>;
  24275. /**
  24276. * Override the mesh isReady function with your own one.
  24277. */
  24278. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24279. /**
  24280. * Override the render function of the texture with your own one.
  24281. */
  24282. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24283. /**
  24284. * Define if camera post processes should be use while rendering the texture.
  24285. */
  24286. useCameraPostProcesses: boolean;
  24287. /**
  24288. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24289. */
  24290. ignoreCameraViewport: boolean;
  24291. private _postProcessManager;
  24292. private _postProcesses;
  24293. private _resizeObserver;
  24294. /**
  24295. * An event triggered when the texture is unbind.
  24296. */
  24297. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24298. /**
  24299. * An event triggered when the texture is unbind.
  24300. */
  24301. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24302. private _onAfterUnbindObserver;
  24303. /**
  24304. * Set a after unbind callback in the texture.
  24305. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24306. */
  24307. set onAfterUnbind(callback: () => void);
  24308. /**
  24309. * An event triggered before rendering the texture
  24310. */
  24311. onBeforeRenderObservable: Observable<number>;
  24312. private _onBeforeRenderObserver;
  24313. /**
  24314. * Set a before render callback in the texture.
  24315. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24316. */
  24317. set onBeforeRender(callback: (faceIndex: number) => void);
  24318. /**
  24319. * An event triggered after rendering the texture
  24320. */
  24321. onAfterRenderObservable: Observable<number>;
  24322. private _onAfterRenderObserver;
  24323. /**
  24324. * Set a after render callback in the texture.
  24325. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24326. */
  24327. set onAfterRender(callback: (faceIndex: number) => void);
  24328. /**
  24329. * An event triggered after the texture clear
  24330. */
  24331. onClearObservable: Observable<Engine>;
  24332. private _onClearObserver;
  24333. /**
  24334. * Set a clear callback in the texture.
  24335. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24336. */
  24337. set onClear(callback: (Engine: Engine) => void);
  24338. /**
  24339. * An event triggered when the texture is resized.
  24340. */
  24341. onResizeObservable: Observable<RenderTargetTexture>;
  24342. /**
  24343. * Define the clear color of the Render Target if it should be different from the scene.
  24344. */
  24345. clearColor: Color4;
  24346. protected _size: number | {
  24347. width: number;
  24348. height: number;
  24349. layers?: number;
  24350. };
  24351. protected _initialSizeParameter: number | {
  24352. width: number;
  24353. height: number;
  24354. } | {
  24355. ratio: number;
  24356. };
  24357. protected _sizeRatio: Nullable<number>;
  24358. /** @hidden */
  24359. _generateMipMaps: boolean;
  24360. protected _renderingManager: RenderingManager;
  24361. /** @hidden */
  24362. _waitingRenderList: string[];
  24363. protected _doNotChangeAspectRatio: boolean;
  24364. protected _currentRefreshId: number;
  24365. protected _refreshRate: number;
  24366. protected _textureMatrix: Matrix;
  24367. protected _samples: number;
  24368. protected _renderTargetOptions: RenderTargetCreationOptions;
  24369. /**
  24370. * Gets render target creation options that were used.
  24371. */
  24372. get renderTargetOptions(): RenderTargetCreationOptions;
  24373. protected _onRatioRescale(): void;
  24374. /**
  24375. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24376. * It must define where the camera used to render the texture is set
  24377. */
  24378. boundingBoxPosition: Vector3;
  24379. private _boundingBoxSize;
  24380. /**
  24381. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24382. * When defined, the cubemap will switch to local mode
  24383. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24384. * @example https://www.babylonjs-playground.com/#RNASML
  24385. */
  24386. set boundingBoxSize(value: Vector3);
  24387. get boundingBoxSize(): Vector3;
  24388. /**
  24389. * In case the RTT has been created with a depth texture, get the associated
  24390. * depth texture.
  24391. * Otherwise, return null.
  24392. */
  24393. get depthStencilTexture(): Nullable<InternalTexture>;
  24394. /**
  24395. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24396. * or used a shadow, depth texture...
  24397. * @param name The friendly name of the texture
  24398. * @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)
  24399. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24400. * @param generateMipMaps True if mip maps need to be generated after render.
  24401. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24402. * @param type The type of the buffer in the RTT (int, half float, float...)
  24403. * @param isCube True if a cube texture needs to be created
  24404. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24405. * @param generateDepthBuffer True to generate a depth buffer
  24406. * @param generateStencilBuffer True to generate a stencil buffer
  24407. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24408. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24409. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24410. */
  24411. constructor(name: string, size: number | {
  24412. width: number;
  24413. height: number;
  24414. layers?: number;
  24415. } | {
  24416. ratio: number;
  24417. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24418. /**
  24419. * Creates a depth stencil texture.
  24420. * This is only available in WebGL 2 or with the depth texture extension available.
  24421. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24422. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24423. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24424. */
  24425. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24426. private _processSizeParameter;
  24427. /**
  24428. * Define the number of samples to use in case of MSAA.
  24429. * It defaults to one meaning no MSAA has been enabled.
  24430. */
  24431. get samples(): number;
  24432. set samples(value: number);
  24433. /**
  24434. * Resets the refresh counter of the texture and start bak from scratch.
  24435. * Could be useful to regenerate the texture if it is setup to render only once.
  24436. */
  24437. resetRefreshCounter(): void;
  24438. /**
  24439. * Define the refresh rate of the texture or the rendering frequency.
  24440. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24441. */
  24442. get refreshRate(): number;
  24443. set refreshRate(value: number);
  24444. /**
  24445. * Adds a post process to the render target rendering passes.
  24446. * @param postProcess define the post process to add
  24447. */
  24448. addPostProcess(postProcess: PostProcess): void;
  24449. /**
  24450. * Clear all the post processes attached to the render target
  24451. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24452. */
  24453. clearPostProcesses(dispose?: boolean): void;
  24454. /**
  24455. * Remove one of the post process from the list of attached post processes to the texture
  24456. * @param postProcess define the post process to remove from the list
  24457. */
  24458. removePostProcess(postProcess: PostProcess): void;
  24459. /** @hidden */
  24460. _shouldRender(): boolean;
  24461. /**
  24462. * Gets the actual render size of the texture.
  24463. * @returns the width of the render size
  24464. */
  24465. getRenderSize(): number;
  24466. /**
  24467. * Gets the actual render width of the texture.
  24468. * @returns the width of the render size
  24469. */
  24470. getRenderWidth(): number;
  24471. /**
  24472. * Gets the actual render height of the texture.
  24473. * @returns the height of the render size
  24474. */
  24475. getRenderHeight(): number;
  24476. /**
  24477. * Gets the actual number of layers of the texture.
  24478. * @returns the number of layers
  24479. */
  24480. getRenderLayers(): number;
  24481. /**
  24482. * Get if the texture can be rescaled or not.
  24483. */
  24484. get canRescale(): boolean;
  24485. /**
  24486. * Resize the texture using a ratio.
  24487. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24488. */
  24489. scale(ratio: number): void;
  24490. /**
  24491. * Get the texture reflection matrix used to rotate/transform the reflection.
  24492. * @returns the reflection matrix
  24493. */
  24494. getReflectionTextureMatrix(): Matrix;
  24495. /**
  24496. * Resize the texture to a new desired size.
  24497. * Be carrefull as it will recreate all the data in the new texture.
  24498. * @param size Define the new size. It can be:
  24499. * - a number for squared texture,
  24500. * - an object containing { width: number, height: number }
  24501. * - or an object containing a ratio { ratio: number }
  24502. */
  24503. resize(size: number | {
  24504. width: number;
  24505. height: number;
  24506. } | {
  24507. ratio: number;
  24508. }): void;
  24509. private _defaultRenderListPrepared;
  24510. /**
  24511. * Renders all the objects from the render list into the texture.
  24512. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24513. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24514. */
  24515. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24516. private _bestReflectionRenderTargetDimension;
  24517. private _prepareRenderingManager;
  24518. /**
  24519. * @hidden
  24520. * @param faceIndex face index to bind to if this is a cubetexture
  24521. * @param layer defines the index of the texture to bind in the array
  24522. */
  24523. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24524. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24525. private renderToTarget;
  24526. /**
  24527. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24528. * This allowed control for front to back rendering or reversly depending of the special needs.
  24529. *
  24530. * @param renderingGroupId The rendering group id corresponding to its index
  24531. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24532. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24533. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24534. */
  24535. 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;
  24536. /**
  24537. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24538. *
  24539. * @param renderingGroupId The rendering group id corresponding to its index
  24540. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24541. */
  24542. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24543. /**
  24544. * Clones the texture.
  24545. * @returns the cloned texture
  24546. */
  24547. clone(): RenderTargetTexture;
  24548. /**
  24549. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24550. * @returns The JSON representation of the texture
  24551. */
  24552. serialize(): any;
  24553. /**
  24554. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24555. */
  24556. disposeFramebufferObjects(): void;
  24557. /**
  24558. * Dispose the texture and release its associated resources.
  24559. */
  24560. dispose(): void;
  24561. /** @hidden */
  24562. _rebuild(): void;
  24563. /**
  24564. * Clear the info related to rendering groups preventing retention point in material dispose.
  24565. */
  24566. freeRenderingGroups(): void;
  24567. /**
  24568. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24569. * @returns the view count
  24570. */
  24571. getViewCount(): number;
  24572. }
  24573. }
  24574. declare module "babylonjs/Misc/guid" {
  24575. /**
  24576. * Class used to manipulate GUIDs
  24577. */
  24578. export class GUID {
  24579. /**
  24580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24581. * Be aware Math.random() could cause collisions, but:
  24582. * "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"
  24583. * @returns a pseudo random id
  24584. */
  24585. static RandomId(): string;
  24586. }
  24587. }
  24588. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24589. import { Nullable } from "babylonjs/types";
  24590. import { Scene } from "babylonjs/scene";
  24591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24592. import { Material } from "babylonjs/Materials/material";
  24593. import { Effect } from "babylonjs/Materials/effect";
  24594. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24595. /**
  24596. * Options to be used when creating a shadow depth material
  24597. */
  24598. export interface IIOptionShadowDepthMaterial {
  24599. /** Variables in the vertex shader code that need to have their names remapped.
  24600. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24601. * "var_name" should be either: worldPos or vNormalW
  24602. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24603. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24604. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24605. */
  24606. remappedVariables?: string[];
  24607. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24608. standalone?: boolean;
  24609. }
  24610. /**
  24611. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24612. */
  24613. export class ShadowDepthWrapper {
  24614. private _scene;
  24615. private _options?;
  24616. private _baseMaterial;
  24617. private _onEffectCreatedObserver;
  24618. private _subMeshToEffect;
  24619. private _subMeshToDepthEffect;
  24620. private _meshes;
  24621. /** @hidden */
  24622. _matriceNames: any;
  24623. /** Gets the standalone status of the wrapper */
  24624. get standalone(): boolean;
  24625. /** Gets the base material the wrapper is built upon */
  24626. get baseMaterial(): Material;
  24627. /**
  24628. * Instantiate a new shadow depth wrapper.
  24629. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24630. * generate the shadow depth map. For more information, please refer to the documentation:
  24631. * https://doc.babylonjs.com/babylon101/shadows
  24632. * @param baseMaterial Material to wrap
  24633. * @param scene Define the scene the material belongs to
  24634. * @param options Options used to create the wrapper
  24635. */
  24636. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24637. /**
  24638. * Gets the effect to use to generate the depth map
  24639. * @param subMesh subMesh to get the effect for
  24640. * @param shadowGenerator shadow generator to get the effect for
  24641. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24642. */
  24643. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24644. /**
  24645. * Specifies that the submesh is ready to be used for depth rendering
  24646. * @param subMesh submesh to check
  24647. * @param defines the list of defines to take into account when checking the effect
  24648. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24649. * @param useInstances specifies that instances should be used
  24650. * @returns a boolean indicating that the submesh is ready or not
  24651. */
  24652. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24653. /**
  24654. * Disposes the resources
  24655. */
  24656. dispose(): void;
  24657. private _makeEffect;
  24658. }
  24659. }
  24660. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24662. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24663. import { Nullable } from "babylonjs/types";
  24664. module "babylonjs/Engines/thinEngine" {
  24665. interface ThinEngine {
  24666. /**
  24667. * Unbind a list of render target textures from the webGL context
  24668. * This is used only when drawBuffer extension or webGL2 are active
  24669. * @param textures defines the render target textures to unbind
  24670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24672. */
  24673. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24674. /**
  24675. * Create a multi render target texture
  24676. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24677. * @param size defines the size of the texture
  24678. * @param options defines the creation options
  24679. * @returns the cube texture as an InternalTexture
  24680. */
  24681. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24682. /**
  24683. * Update the sample count for a given multiple render target texture
  24684. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24685. * @param textures defines the textures to update
  24686. * @param samples defines the sample count to set
  24687. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24688. */
  24689. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24690. /**
  24691. * Select a subsets of attachments to draw to.
  24692. * @param attachments gl attachments
  24693. */
  24694. bindAttachments(attachments: number[]): void;
  24695. }
  24696. }
  24697. }
  24698. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24699. import { Scene } from "babylonjs/scene";
  24700. import { Engine } from "babylonjs/Engines/engine";
  24701. import { Texture } from "babylonjs/Materials/Textures/texture";
  24702. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24703. import "babylonjs/Engines/Extensions/engine.multiRender";
  24704. /**
  24705. * Creation options of the multi render target texture.
  24706. */
  24707. export interface IMultiRenderTargetOptions {
  24708. /**
  24709. * Define if the texture needs to create mip maps after render.
  24710. */
  24711. generateMipMaps?: boolean;
  24712. /**
  24713. * Define the types of all the draw buffers we want to create
  24714. */
  24715. types?: number[];
  24716. /**
  24717. * Define the sampling modes of all the draw buffers we want to create
  24718. */
  24719. samplingModes?: number[];
  24720. /**
  24721. * Define if a depth buffer is required
  24722. */
  24723. generateDepthBuffer?: boolean;
  24724. /**
  24725. * Define if a stencil buffer is required
  24726. */
  24727. generateStencilBuffer?: boolean;
  24728. /**
  24729. * Define if a depth texture is required instead of a depth buffer
  24730. */
  24731. generateDepthTexture?: boolean;
  24732. /**
  24733. * Define the number of desired draw buffers
  24734. */
  24735. textureCount?: number;
  24736. /**
  24737. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24738. */
  24739. doNotChangeAspectRatio?: boolean;
  24740. /**
  24741. * Define the default type of the buffers we are creating
  24742. */
  24743. defaultType?: number;
  24744. }
  24745. /**
  24746. * A multi render target, like a render target provides the ability to render to a texture.
  24747. * Unlike the render target, it can render to several draw buffers in one draw.
  24748. * This is specially interesting in deferred rendering or for any effects requiring more than
  24749. * just one color from a single pass.
  24750. */
  24751. export class MultiRenderTarget extends RenderTargetTexture {
  24752. private _internalTextures;
  24753. private _textures;
  24754. private _multiRenderTargetOptions;
  24755. private _count;
  24756. /**
  24757. * Get if draw buffers are currently supported by the used hardware and browser.
  24758. */
  24759. get isSupported(): boolean;
  24760. /**
  24761. * Get the list of textures generated by the multi render target.
  24762. */
  24763. get textures(): Texture[];
  24764. /**
  24765. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24766. */
  24767. get count(): number;
  24768. /**
  24769. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24770. */
  24771. get depthTexture(): Texture;
  24772. /**
  24773. * Set the wrapping mode on U of all the textures we are rendering to.
  24774. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24775. */
  24776. set wrapU(wrap: number);
  24777. /**
  24778. * Set the wrapping mode on V of all the textures we are rendering to.
  24779. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24780. */
  24781. set wrapV(wrap: number);
  24782. /**
  24783. * Instantiate a new multi render target texture.
  24784. * A multi render target, like a render target provides the ability to render to a texture.
  24785. * Unlike the render target, it can render to several draw buffers in one draw.
  24786. * This is specially interesting in deferred rendering or for any effects requiring more than
  24787. * just one color from a single pass.
  24788. * @param name Define the name of the texture
  24789. * @param size Define the size of the buffers to render to
  24790. * @param count Define the number of target we are rendering into
  24791. * @param scene Define the scene the texture belongs to
  24792. * @param options Define the options used to create the multi render target
  24793. */
  24794. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24795. /** @hidden */
  24796. _rebuild(): void;
  24797. private _createInternalTextures;
  24798. private _createTextures;
  24799. /**
  24800. * Define the number of samples used if MSAA is enabled.
  24801. */
  24802. get samples(): number;
  24803. set samples(value: number);
  24804. /**
  24805. * Resize all the textures in the multi render target.
  24806. * Be carrefull as it will recreate all the data in the new texture.
  24807. * @param size Define the new size
  24808. */
  24809. resize(size: any): void;
  24810. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24811. /**
  24812. * Dispose the render targets and their associated resources
  24813. */
  24814. dispose(): void;
  24815. /**
  24816. * Release all the underlying texture used as draw buffers.
  24817. */
  24818. releaseInternalTextures(): void;
  24819. }
  24820. }
  24821. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24822. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24824. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24825. /** @hidden */
  24826. export var imageProcessingPixelShader: {
  24827. name: string;
  24828. shader: string;
  24829. };
  24830. }
  24831. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24832. import { Nullable } from "babylonjs/types";
  24833. import { Color4 } from "babylonjs/Maths/math.color";
  24834. import { Camera } from "babylonjs/Cameras/camera";
  24835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24836. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24837. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24838. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24839. import { Engine } from "babylonjs/Engines/engine";
  24840. import "babylonjs/Shaders/imageProcessing.fragment";
  24841. import "babylonjs/Shaders/postprocess.vertex";
  24842. /**
  24843. * ImageProcessingPostProcess
  24844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24845. */
  24846. export class ImageProcessingPostProcess extends PostProcess {
  24847. /**
  24848. * Default configuration related to image processing available in the PBR Material.
  24849. */
  24850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24851. /**
  24852. * Gets the image processing configuration used either in this material.
  24853. */
  24854. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24855. /**
  24856. * Sets the Default image processing configuration used either in the this material.
  24857. *
  24858. * If sets to null, the scene one is in use.
  24859. */
  24860. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24861. /**
  24862. * Keep track of the image processing observer to allow dispose and replace.
  24863. */
  24864. private _imageProcessingObserver;
  24865. /**
  24866. * Attaches a new image processing configuration to the PBR Material.
  24867. * @param configuration
  24868. */
  24869. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24870. /**
  24871. * If the post process is supported.
  24872. */
  24873. get isSupported(): boolean;
  24874. /**
  24875. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24876. */
  24877. get colorCurves(): Nullable<ColorCurves>;
  24878. /**
  24879. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24880. */
  24881. set colorCurves(value: Nullable<ColorCurves>);
  24882. /**
  24883. * Gets wether the color curves effect is enabled.
  24884. */
  24885. get colorCurvesEnabled(): boolean;
  24886. /**
  24887. * Sets wether the color curves effect is enabled.
  24888. */
  24889. set colorCurvesEnabled(value: boolean);
  24890. /**
  24891. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24892. */
  24893. get colorGradingTexture(): Nullable<BaseTexture>;
  24894. /**
  24895. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24896. */
  24897. set colorGradingTexture(value: Nullable<BaseTexture>);
  24898. /**
  24899. * Gets wether the color grading effect is enabled.
  24900. */
  24901. get colorGradingEnabled(): boolean;
  24902. /**
  24903. * Gets wether the color grading effect is enabled.
  24904. */
  24905. set colorGradingEnabled(value: boolean);
  24906. /**
  24907. * Gets exposure used in the effect.
  24908. */
  24909. get exposure(): number;
  24910. /**
  24911. * Sets exposure used in the effect.
  24912. */
  24913. set exposure(value: number);
  24914. /**
  24915. * Gets wether tonemapping is enabled or not.
  24916. */
  24917. get toneMappingEnabled(): boolean;
  24918. /**
  24919. * Sets wether tonemapping is enabled or not
  24920. */
  24921. set toneMappingEnabled(value: boolean);
  24922. /**
  24923. * Gets the type of tone mapping effect.
  24924. */
  24925. get toneMappingType(): number;
  24926. /**
  24927. * Sets the type of tone mapping effect.
  24928. */
  24929. set toneMappingType(value: number);
  24930. /**
  24931. * Gets contrast used in the effect.
  24932. */
  24933. get contrast(): number;
  24934. /**
  24935. * Sets contrast used in the effect.
  24936. */
  24937. set contrast(value: number);
  24938. /**
  24939. * Gets Vignette stretch size.
  24940. */
  24941. get vignetteStretch(): number;
  24942. /**
  24943. * Sets Vignette stretch size.
  24944. */
  24945. set vignetteStretch(value: number);
  24946. /**
  24947. * Gets Vignette centre X Offset.
  24948. */
  24949. get vignetteCentreX(): number;
  24950. /**
  24951. * Sets Vignette centre X Offset.
  24952. */
  24953. set vignetteCentreX(value: number);
  24954. /**
  24955. * Gets Vignette centre Y Offset.
  24956. */
  24957. get vignetteCentreY(): number;
  24958. /**
  24959. * Sets Vignette centre Y Offset.
  24960. */
  24961. set vignetteCentreY(value: number);
  24962. /**
  24963. * Gets Vignette weight or intensity of the vignette effect.
  24964. */
  24965. get vignetteWeight(): number;
  24966. /**
  24967. * Sets Vignette weight or intensity of the vignette effect.
  24968. */
  24969. set vignetteWeight(value: number);
  24970. /**
  24971. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24972. * if vignetteEnabled is set to true.
  24973. */
  24974. get vignetteColor(): Color4;
  24975. /**
  24976. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24977. * if vignetteEnabled is set to true.
  24978. */
  24979. set vignetteColor(value: Color4);
  24980. /**
  24981. * Gets Camera field of view used by the Vignette effect.
  24982. */
  24983. get vignetteCameraFov(): number;
  24984. /**
  24985. * Sets Camera field of view used by the Vignette effect.
  24986. */
  24987. set vignetteCameraFov(value: number);
  24988. /**
  24989. * Gets the vignette blend mode allowing different kind of effect.
  24990. */
  24991. get vignetteBlendMode(): number;
  24992. /**
  24993. * Sets the vignette blend mode allowing different kind of effect.
  24994. */
  24995. set vignetteBlendMode(value: number);
  24996. /**
  24997. * Gets wether the vignette effect is enabled.
  24998. */
  24999. get vignetteEnabled(): boolean;
  25000. /**
  25001. * Sets wether the vignette effect is enabled.
  25002. */
  25003. set vignetteEnabled(value: boolean);
  25004. private _fromLinearSpace;
  25005. /**
  25006. * Gets wether the input of the processing is in Gamma or Linear Space.
  25007. */
  25008. get fromLinearSpace(): boolean;
  25009. /**
  25010. * Sets wether the input of the processing is in Gamma or Linear Space.
  25011. */
  25012. set fromLinearSpace(value: boolean);
  25013. /**
  25014. * Defines cache preventing GC.
  25015. */
  25016. private _defines;
  25017. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25018. /**
  25019. * "ImageProcessingPostProcess"
  25020. * @returns "ImageProcessingPostProcess"
  25021. */
  25022. getClassName(): string;
  25023. /**
  25024. * @hidden
  25025. */
  25026. _updateParameters(): void;
  25027. dispose(camera?: Camera): void;
  25028. }
  25029. }
  25030. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25031. /** @hidden */
  25032. export var fibonacci: {
  25033. name: string;
  25034. shader: string;
  25035. };
  25036. }
  25037. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25038. /** @hidden */
  25039. export var subSurfaceScatteringFunctions: {
  25040. name: string;
  25041. shader: string;
  25042. };
  25043. }
  25044. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25045. /** @hidden */
  25046. export var diffusionProfile: {
  25047. name: string;
  25048. shader: string;
  25049. };
  25050. }
  25051. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25052. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25054. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25055. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25056. /** @hidden */
  25057. export var subSurfaceScatteringPixelShader: {
  25058. name: string;
  25059. shader: string;
  25060. };
  25061. }
  25062. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25063. import { Nullable } from "babylonjs/types";
  25064. import { Camera } from "babylonjs/Cameras/camera";
  25065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25066. import { Engine } from "babylonjs/Engines/engine";
  25067. import { Scene } from "babylonjs/scene";
  25068. import "babylonjs/Shaders/imageProcessing.fragment";
  25069. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25070. import "babylonjs/Shaders/postprocess.vertex";
  25071. /**
  25072. * Sub surface scattering post process
  25073. */
  25074. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25075. /** @hidden */
  25076. texelWidth: number;
  25077. /** @hidden */
  25078. texelHeight: number;
  25079. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25080. }
  25081. }
  25082. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25083. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25084. /**
  25085. * Interface for defining prepass effects in the prepass post-process pipeline
  25086. */
  25087. export interface PrePassEffectConfiguration {
  25088. /**
  25089. * Post process to attach for this effect
  25090. */
  25091. postProcess: PostProcess;
  25092. /**
  25093. * Is the effect enabled
  25094. */
  25095. enabled: boolean;
  25096. /**
  25097. * Disposes the effect configuration
  25098. */
  25099. dispose(): void;
  25100. /**
  25101. * Disposes the effect configuration
  25102. */
  25103. createPostProcess: () => PostProcess;
  25104. }
  25105. }
  25106. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25107. import { Scene } from "babylonjs/scene";
  25108. import { Color3 } from "babylonjs/Maths/math.color";
  25109. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25110. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25111. /**
  25112. * Contains all parameters needed for the prepass to perform
  25113. * screen space subsurface scattering
  25114. */
  25115. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25116. private _ssDiffusionS;
  25117. private _ssFilterRadii;
  25118. private _ssDiffusionD;
  25119. /**
  25120. * Post process to attach for screen space subsurface scattering
  25121. */
  25122. postProcess: SubSurfaceScatteringPostProcess;
  25123. /**
  25124. * Diffusion profile color for subsurface scattering
  25125. */
  25126. get ssDiffusionS(): number[];
  25127. /**
  25128. * Diffusion profile max color channel value for subsurface scattering
  25129. */
  25130. get ssDiffusionD(): number[];
  25131. /**
  25132. * Diffusion profile filter radius for subsurface scattering
  25133. */
  25134. get ssFilterRadii(): number[];
  25135. /**
  25136. * Is subsurface enabled
  25137. */
  25138. enabled: boolean;
  25139. /**
  25140. * Diffusion profile colors for subsurface scattering
  25141. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25142. * See ...
  25143. * Note that you can only store up to 5 of them
  25144. */
  25145. ssDiffusionProfileColors: Color3[];
  25146. /**
  25147. * Defines the ratio real world => scene units.
  25148. * Used for subsurface scattering
  25149. */
  25150. metersPerUnit: number;
  25151. private _scene;
  25152. /**
  25153. * Builds a subsurface configuration object
  25154. * @param scene The scene
  25155. */
  25156. constructor(scene: Scene);
  25157. /**
  25158. * Adds a new diffusion profile.
  25159. * Useful for more realistic subsurface scattering on diverse materials.
  25160. * @param color The color of the diffusion profile. Should be the average color of the material.
  25161. * @return The index of the diffusion profile for the material subsurface configuration
  25162. */
  25163. addDiffusionProfile(color: Color3): number;
  25164. /**
  25165. * Creates the sss post process
  25166. * @return The created post process
  25167. */
  25168. createPostProcess(): SubSurfaceScatteringPostProcess;
  25169. /**
  25170. * Deletes all diffusion profiles.
  25171. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25172. */
  25173. clearAllDiffusionProfiles(): void;
  25174. /**
  25175. * Disposes this object
  25176. */
  25177. dispose(): void;
  25178. /**
  25179. * @hidden
  25180. * https://zero-radiance.github.io/post/sampling-diffusion/
  25181. *
  25182. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25183. * ------------------------------------------------------------------------------------
  25184. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25185. * PDF[r, phi, s] = r * R[r, phi, s]
  25186. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25187. * ------------------------------------------------------------------------------------
  25188. * We importance sample the color channel with the widest scattering distance.
  25189. */
  25190. getDiffusionProfileParameters(color: Color3): number;
  25191. /**
  25192. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25193. * 'u' is the random number (the value of the CDF): [0, 1).
  25194. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25195. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25196. */
  25197. private _sampleBurleyDiffusionProfile;
  25198. }
  25199. }
  25200. declare module "babylonjs/Rendering/prePassRenderer" {
  25201. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25202. import { Scene } from "babylonjs/scene";
  25203. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25204. import { Effect } from "babylonjs/Materials/effect";
  25205. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25206. /**
  25207. * Renders a pre pass of the scene
  25208. * This means every mesh in the scene will be rendered to a render target texture
  25209. * And then this texture will be composited to the rendering canvas with post processes
  25210. * It is necessary for effects like subsurface scattering or deferred shading
  25211. */
  25212. export class PrePassRenderer {
  25213. /** @hidden */
  25214. static _SceneComponentInitialization: (scene: Scene) => void;
  25215. private _scene;
  25216. private _engine;
  25217. private _isDirty;
  25218. /**
  25219. * Number of textures in the multi render target texture where the scene is directly rendered
  25220. */
  25221. readonly mrtCount: number;
  25222. /**
  25223. * The render target where the scene is directly rendered
  25224. */
  25225. prePassRT: MultiRenderTarget;
  25226. private _mrtTypes;
  25227. private _multiRenderAttachments;
  25228. private _defaultAttachments;
  25229. private _clearAttachments;
  25230. private _postProcesses;
  25231. private readonly _clearColor;
  25232. /**
  25233. * Image processing post process for composition
  25234. */
  25235. imageProcessingPostProcess: ImageProcessingPostProcess;
  25236. /**
  25237. * Configuration for sub surface scattering post process
  25238. */
  25239. subSurfaceConfiguration: SubSurfaceConfiguration;
  25240. /**
  25241. * Should materials render their geometry on the MRT
  25242. */
  25243. materialsShouldRenderGeometry: boolean;
  25244. /**
  25245. * Should materials render the irradiance information on the MRT
  25246. */
  25247. materialsShouldRenderIrradiance: boolean;
  25248. private _enabled;
  25249. /**
  25250. * Indicates if the prepass is enabled
  25251. */
  25252. get enabled(): boolean;
  25253. /**
  25254. * How many samples are used for MSAA of the scene render target
  25255. */
  25256. get samples(): number;
  25257. set samples(n: number);
  25258. /**
  25259. * Instanciates a prepass renderer
  25260. * @param scene The scene
  25261. */
  25262. constructor(scene: Scene);
  25263. private _initializeAttachments;
  25264. private _createCompositionEffect;
  25265. /**
  25266. * Indicates if rendering a prepass is supported
  25267. */
  25268. get isSupported(): boolean;
  25269. /**
  25270. * Sets the proper output textures to draw in the engine.
  25271. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25272. */
  25273. bindAttachmentsForEffect(effect: Effect): void;
  25274. /**
  25275. * @hidden
  25276. */
  25277. _beforeCameraDraw(): void;
  25278. /**
  25279. * @hidden
  25280. */
  25281. _afterCameraDraw(): void;
  25282. private _checkRTSize;
  25283. private _bindFrameBuffer;
  25284. /**
  25285. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25286. */
  25287. clear(): void;
  25288. private _setState;
  25289. private _enable;
  25290. private _disable;
  25291. private _resetPostProcessChain;
  25292. private _bindPostProcessChain;
  25293. /**
  25294. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25295. */
  25296. markAsDirty(): void;
  25297. private _update;
  25298. /**
  25299. * Disposes the prepass renderer.
  25300. */
  25301. dispose(): void;
  25302. }
  25303. }
  25304. declare module "babylonjs/Materials/material" {
  25305. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25306. import { SmartArray } from "babylonjs/Misc/smartArray";
  25307. import { Observable } from "babylonjs/Misc/observable";
  25308. import { Nullable } from "babylonjs/types";
  25309. import { Scene } from "babylonjs/scene";
  25310. import { Matrix } from "babylonjs/Maths/math.vector";
  25311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25313. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25314. import { Effect } from "babylonjs/Materials/effect";
  25315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25316. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25317. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25318. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25319. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25320. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25321. import { Mesh } from "babylonjs/Meshes/mesh";
  25322. import { Animation } from "babylonjs/Animations/animation";
  25323. /**
  25324. * Options for compiling materials.
  25325. */
  25326. export interface IMaterialCompilationOptions {
  25327. /**
  25328. * Defines whether clip planes are enabled.
  25329. */
  25330. clipPlane: boolean;
  25331. /**
  25332. * Defines whether instances are enabled.
  25333. */
  25334. useInstances: boolean;
  25335. }
  25336. /**
  25337. * Options passed when calling customShaderNameResolve
  25338. */
  25339. export interface ICustomShaderNameResolveOptions {
  25340. /**
  25341. * 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
  25342. */
  25343. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25344. }
  25345. /**
  25346. * Base class for the main features of a material in Babylon.js
  25347. */
  25348. export class Material implements IAnimatable {
  25349. /**
  25350. * Returns the triangle fill mode
  25351. */
  25352. static readonly TriangleFillMode: number;
  25353. /**
  25354. * Returns the wireframe mode
  25355. */
  25356. static readonly WireFrameFillMode: number;
  25357. /**
  25358. * Returns the point fill mode
  25359. */
  25360. static readonly PointFillMode: number;
  25361. /**
  25362. * Returns the point list draw mode
  25363. */
  25364. static readonly PointListDrawMode: number;
  25365. /**
  25366. * Returns the line list draw mode
  25367. */
  25368. static readonly LineListDrawMode: number;
  25369. /**
  25370. * Returns the line loop draw mode
  25371. */
  25372. static readonly LineLoopDrawMode: number;
  25373. /**
  25374. * Returns the line strip draw mode
  25375. */
  25376. static readonly LineStripDrawMode: number;
  25377. /**
  25378. * Returns the triangle strip draw mode
  25379. */
  25380. static readonly TriangleStripDrawMode: number;
  25381. /**
  25382. * Returns the triangle fan draw mode
  25383. */
  25384. static readonly TriangleFanDrawMode: number;
  25385. /**
  25386. * Stores the clock-wise side orientation
  25387. */
  25388. static readonly ClockWiseSideOrientation: number;
  25389. /**
  25390. * Stores the counter clock-wise side orientation
  25391. */
  25392. static readonly CounterClockWiseSideOrientation: number;
  25393. /**
  25394. * The dirty texture flag value
  25395. */
  25396. static readonly TextureDirtyFlag: number;
  25397. /**
  25398. * The dirty light flag value
  25399. */
  25400. static readonly LightDirtyFlag: number;
  25401. /**
  25402. * The dirty fresnel flag value
  25403. */
  25404. static readonly FresnelDirtyFlag: number;
  25405. /**
  25406. * The dirty attribute flag value
  25407. */
  25408. static readonly AttributesDirtyFlag: number;
  25409. /**
  25410. * The dirty misc flag value
  25411. */
  25412. static readonly MiscDirtyFlag: number;
  25413. /**
  25414. * The all dirty flag value
  25415. */
  25416. static readonly AllDirtyFlag: number;
  25417. /**
  25418. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25419. */
  25420. static readonly MATERIAL_OPAQUE: number;
  25421. /**
  25422. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25423. */
  25424. static readonly MATERIAL_ALPHATEST: number;
  25425. /**
  25426. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25427. */
  25428. static readonly MATERIAL_ALPHABLEND: number;
  25429. /**
  25430. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25431. * They are also discarded below the alpha cutoff threshold to improve performances.
  25432. */
  25433. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25434. /**
  25435. * The Whiteout method is used to blend normals.
  25436. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25437. */
  25438. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25439. /**
  25440. * The Reoriented Normal Mapping method is used to blend normals.
  25441. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25442. */
  25443. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25444. /**
  25445. * Custom callback helping to override the default shader used in the material.
  25446. */
  25447. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25448. /**
  25449. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25450. */
  25451. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25452. /**
  25453. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25454. * This means that the material can keep using a previous shader while a new one is being compiled.
  25455. * This is mostly used when shader parallel compilation is supported (true by default)
  25456. */
  25457. allowShaderHotSwapping: boolean;
  25458. /**
  25459. * The ID of the material
  25460. */
  25461. id: string;
  25462. /**
  25463. * Gets or sets the unique id of the material
  25464. */
  25465. uniqueId: number;
  25466. /**
  25467. * The name of the material
  25468. */
  25469. name: string;
  25470. /**
  25471. * Gets or sets user defined metadata
  25472. */
  25473. metadata: any;
  25474. /**
  25475. * For internal use only. Please do not use.
  25476. */
  25477. reservedDataStore: any;
  25478. /**
  25479. * Specifies if the ready state should be checked on each call
  25480. */
  25481. checkReadyOnEveryCall: boolean;
  25482. /**
  25483. * Specifies if the ready state should be checked once
  25484. */
  25485. checkReadyOnlyOnce: boolean;
  25486. /**
  25487. * The state of the material
  25488. */
  25489. state: string;
  25490. /**
  25491. * If the material can be rendered to several textures with MRT extension
  25492. */
  25493. get canRenderToMRT(): boolean;
  25494. /**
  25495. * The alpha value of the material
  25496. */
  25497. protected _alpha: number;
  25498. /**
  25499. * List of inspectable custom properties (used by the Inspector)
  25500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25501. */
  25502. inspectableCustomProperties: IInspectable[];
  25503. /**
  25504. * Sets the alpha value of the material
  25505. */
  25506. set alpha(value: number);
  25507. /**
  25508. * Gets the alpha value of the material
  25509. */
  25510. get alpha(): number;
  25511. /**
  25512. * Specifies if back face culling is enabled
  25513. */
  25514. protected _backFaceCulling: boolean;
  25515. /**
  25516. * Sets the back-face culling state
  25517. */
  25518. set backFaceCulling(value: boolean);
  25519. /**
  25520. * Gets the back-face culling state
  25521. */
  25522. get backFaceCulling(): boolean;
  25523. /**
  25524. * Stores the value for side orientation
  25525. */
  25526. sideOrientation: number;
  25527. /**
  25528. * Callback triggered when the material is compiled
  25529. */
  25530. onCompiled: Nullable<(effect: Effect) => void>;
  25531. /**
  25532. * Callback triggered when an error occurs
  25533. */
  25534. onError: Nullable<(effect: Effect, errors: string) => void>;
  25535. /**
  25536. * Callback triggered to get the render target textures
  25537. */
  25538. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25539. /**
  25540. * Gets a boolean indicating that current material needs to register RTT
  25541. */
  25542. get hasRenderTargetTextures(): boolean;
  25543. /**
  25544. * Specifies if the material should be serialized
  25545. */
  25546. doNotSerialize: boolean;
  25547. /**
  25548. * @hidden
  25549. */
  25550. _storeEffectOnSubMeshes: boolean;
  25551. /**
  25552. * Stores the animations for the material
  25553. */
  25554. animations: Nullable<Array<Animation>>;
  25555. /**
  25556. * An event triggered when the material is disposed
  25557. */
  25558. onDisposeObservable: Observable<Material>;
  25559. /**
  25560. * An observer which watches for dispose events
  25561. */
  25562. private _onDisposeObserver;
  25563. private _onUnBindObservable;
  25564. /**
  25565. * Called during a dispose event
  25566. */
  25567. set onDispose(callback: () => void);
  25568. private _onBindObservable;
  25569. /**
  25570. * An event triggered when the material is bound
  25571. */
  25572. get onBindObservable(): Observable<AbstractMesh>;
  25573. /**
  25574. * An observer which watches for bind events
  25575. */
  25576. private _onBindObserver;
  25577. /**
  25578. * Called during a bind event
  25579. */
  25580. set onBind(callback: (Mesh: AbstractMesh) => void);
  25581. /**
  25582. * An event triggered when the material is unbound
  25583. */
  25584. get onUnBindObservable(): Observable<Material>;
  25585. protected _onEffectCreatedObservable: Nullable<Observable<{
  25586. effect: Effect;
  25587. subMesh: Nullable<SubMesh>;
  25588. }>>;
  25589. /**
  25590. * An event triggered when the effect is (re)created
  25591. */
  25592. get onEffectCreatedObservable(): Observable<{
  25593. effect: Effect;
  25594. subMesh: Nullable<SubMesh>;
  25595. }>;
  25596. /**
  25597. * Stores the value of the alpha mode
  25598. */
  25599. private _alphaMode;
  25600. /**
  25601. * Sets the value of the alpha mode.
  25602. *
  25603. * | Value | Type | Description |
  25604. * | --- | --- | --- |
  25605. * | 0 | ALPHA_DISABLE | |
  25606. * | 1 | ALPHA_ADD | |
  25607. * | 2 | ALPHA_COMBINE | |
  25608. * | 3 | ALPHA_SUBTRACT | |
  25609. * | 4 | ALPHA_MULTIPLY | |
  25610. * | 5 | ALPHA_MAXIMIZED | |
  25611. * | 6 | ALPHA_ONEONE | |
  25612. * | 7 | ALPHA_PREMULTIPLIED | |
  25613. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25614. * | 9 | ALPHA_INTERPOLATE | |
  25615. * | 10 | ALPHA_SCREENMODE | |
  25616. *
  25617. */
  25618. set alphaMode(value: number);
  25619. /**
  25620. * Gets the value of the alpha mode
  25621. */
  25622. get alphaMode(): number;
  25623. /**
  25624. * Stores the state of the need depth pre-pass value
  25625. */
  25626. private _needDepthPrePass;
  25627. /**
  25628. * Sets the need depth pre-pass value
  25629. */
  25630. set needDepthPrePass(value: boolean);
  25631. /**
  25632. * Gets the depth pre-pass value
  25633. */
  25634. get needDepthPrePass(): boolean;
  25635. /**
  25636. * Specifies if depth writing should be disabled
  25637. */
  25638. disableDepthWrite: boolean;
  25639. /**
  25640. * Specifies if color writing should be disabled
  25641. */
  25642. disableColorWrite: boolean;
  25643. /**
  25644. * Specifies if depth writing should be forced
  25645. */
  25646. forceDepthWrite: boolean;
  25647. /**
  25648. * Specifies the depth function that should be used. 0 means the default engine function
  25649. */
  25650. depthFunction: number;
  25651. /**
  25652. * Specifies if there should be a separate pass for culling
  25653. */
  25654. separateCullingPass: boolean;
  25655. /**
  25656. * Stores the state specifing if fog should be enabled
  25657. */
  25658. private _fogEnabled;
  25659. /**
  25660. * Sets the state for enabling fog
  25661. */
  25662. set fogEnabled(value: boolean);
  25663. /**
  25664. * Gets the value of the fog enabled state
  25665. */
  25666. get fogEnabled(): boolean;
  25667. /**
  25668. * Stores the size of points
  25669. */
  25670. pointSize: number;
  25671. /**
  25672. * Stores the z offset value
  25673. */
  25674. zOffset: number;
  25675. get wireframe(): boolean;
  25676. /**
  25677. * Sets the state of wireframe mode
  25678. */
  25679. set wireframe(value: boolean);
  25680. /**
  25681. * Gets the value specifying if point clouds are enabled
  25682. */
  25683. get pointsCloud(): boolean;
  25684. /**
  25685. * Sets the state of point cloud mode
  25686. */
  25687. set pointsCloud(value: boolean);
  25688. /**
  25689. * Gets the material fill mode
  25690. */
  25691. get fillMode(): number;
  25692. /**
  25693. * Sets the material fill mode
  25694. */
  25695. set fillMode(value: number);
  25696. /**
  25697. * @hidden
  25698. * Stores the effects for the material
  25699. */
  25700. _effect: Nullable<Effect>;
  25701. /**
  25702. * Specifies if uniform buffers should be used
  25703. */
  25704. private _useUBO;
  25705. /**
  25706. * Stores a reference to the scene
  25707. */
  25708. private _scene;
  25709. /**
  25710. * Stores the fill mode state
  25711. */
  25712. private _fillMode;
  25713. /**
  25714. * Specifies if the depth write state should be cached
  25715. */
  25716. private _cachedDepthWriteState;
  25717. /**
  25718. * Specifies if the color write state should be cached
  25719. */
  25720. private _cachedColorWriteState;
  25721. /**
  25722. * Specifies if the depth function state should be cached
  25723. */
  25724. private _cachedDepthFunctionState;
  25725. /**
  25726. * Stores the uniform buffer
  25727. */
  25728. protected _uniformBuffer: UniformBuffer;
  25729. /** @hidden */
  25730. _indexInSceneMaterialArray: number;
  25731. /** @hidden */
  25732. meshMap: Nullable<{
  25733. [id: string]: AbstractMesh | undefined;
  25734. }>;
  25735. /**
  25736. * Creates a material instance
  25737. * @param name defines the name of the material
  25738. * @param scene defines the scene to reference
  25739. * @param doNotAdd specifies if the material should be added to the scene
  25740. */
  25741. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25742. /**
  25743. * Returns a string representation of the current material
  25744. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25745. * @returns a string with material information
  25746. */
  25747. toString(fullDetails?: boolean): string;
  25748. /**
  25749. * Gets the class name of the material
  25750. * @returns a string with the class name of the material
  25751. */
  25752. getClassName(): string;
  25753. /**
  25754. * Specifies if updates for the material been locked
  25755. */
  25756. get isFrozen(): boolean;
  25757. /**
  25758. * Locks updates for the material
  25759. */
  25760. freeze(): void;
  25761. /**
  25762. * Unlocks updates for the material
  25763. */
  25764. unfreeze(): void;
  25765. /**
  25766. * Specifies if the material is ready to be used
  25767. * @param mesh defines the mesh to check
  25768. * @param useInstances specifies if instances should be used
  25769. * @returns a boolean indicating if the material is ready to be used
  25770. */
  25771. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25772. /**
  25773. * Specifies that the submesh is ready to be used
  25774. * @param mesh defines the mesh to check
  25775. * @param subMesh defines which submesh to check
  25776. * @param useInstances specifies that instances should be used
  25777. * @returns a boolean indicating that the submesh is ready or not
  25778. */
  25779. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25780. /**
  25781. * Returns the material effect
  25782. * @returns the effect associated with the material
  25783. */
  25784. getEffect(): Nullable<Effect>;
  25785. /**
  25786. * Returns the current scene
  25787. * @returns a Scene
  25788. */
  25789. getScene(): Scene;
  25790. /**
  25791. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25792. */
  25793. protected _forceAlphaTest: boolean;
  25794. /**
  25795. * The transparency mode of the material.
  25796. */
  25797. protected _transparencyMode: Nullable<number>;
  25798. /**
  25799. * Gets the current transparency mode.
  25800. */
  25801. get transparencyMode(): Nullable<number>;
  25802. /**
  25803. * Sets the transparency mode of the material.
  25804. *
  25805. * | Value | Type | Description |
  25806. * | ----- | ----------------------------------- | ----------- |
  25807. * | 0 | OPAQUE | |
  25808. * | 1 | ALPHATEST | |
  25809. * | 2 | ALPHABLEND | |
  25810. * | 3 | ALPHATESTANDBLEND | |
  25811. *
  25812. */
  25813. set transparencyMode(value: Nullable<number>);
  25814. /**
  25815. * Returns true if alpha blending should be disabled.
  25816. */
  25817. protected get _disableAlphaBlending(): boolean;
  25818. /**
  25819. * Specifies whether or not this material should be rendered in alpha blend mode.
  25820. * @returns a boolean specifying if alpha blending is needed
  25821. */
  25822. needAlphaBlending(): boolean;
  25823. /**
  25824. * Specifies if the mesh will require alpha blending
  25825. * @param mesh defines the mesh to check
  25826. * @returns a boolean specifying if alpha blending is needed for the mesh
  25827. */
  25828. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25829. /**
  25830. * Specifies whether or not this material should be rendered in alpha test mode.
  25831. * @returns a boolean specifying if an alpha test is needed.
  25832. */
  25833. needAlphaTesting(): boolean;
  25834. /**
  25835. * Specifies if material alpha testing should be turned on for the mesh
  25836. * @param mesh defines the mesh to check
  25837. */
  25838. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25839. /**
  25840. * Gets the texture used for the alpha test
  25841. * @returns the texture to use for alpha testing
  25842. */
  25843. getAlphaTestTexture(): Nullable<BaseTexture>;
  25844. /**
  25845. * Marks the material to indicate that it needs to be re-calculated
  25846. */
  25847. markDirty(): void;
  25848. /** @hidden */
  25849. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25850. /**
  25851. * Binds the material to the mesh
  25852. * @param world defines the world transformation matrix
  25853. * @param mesh defines the mesh to bind the material to
  25854. */
  25855. bind(world: Matrix, mesh?: Mesh): void;
  25856. /**
  25857. * Binds the submesh to the material
  25858. * @param world defines the world transformation matrix
  25859. * @param mesh defines the mesh containing the submesh
  25860. * @param subMesh defines the submesh to bind the material to
  25861. */
  25862. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25863. /**
  25864. * Binds the world matrix to the material
  25865. * @param world defines the world transformation matrix
  25866. */
  25867. bindOnlyWorldMatrix(world: Matrix): void;
  25868. /**
  25869. * Binds the scene's uniform buffer to the effect.
  25870. * @param effect defines the effect to bind to the scene uniform buffer
  25871. * @param sceneUbo defines the uniform buffer storing scene data
  25872. */
  25873. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25874. /**
  25875. * Binds the view matrix to the effect
  25876. * @param effect defines the effect to bind the view matrix to
  25877. */
  25878. bindView(effect: Effect): void;
  25879. /**
  25880. * Binds the view projection matrix to the effect
  25881. * @param effect defines the effect to bind the view projection matrix to
  25882. */
  25883. bindViewProjection(effect: Effect): void;
  25884. /**
  25885. * Processes to execute after binding the material to a mesh
  25886. * @param mesh defines the rendered mesh
  25887. */
  25888. protected _afterBind(mesh?: Mesh): void;
  25889. /**
  25890. * Unbinds the material from the mesh
  25891. */
  25892. unbind(): void;
  25893. /**
  25894. * Gets the active textures from the material
  25895. * @returns an array of textures
  25896. */
  25897. getActiveTextures(): BaseTexture[];
  25898. /**
  25899. * Specifies if the material uses a texture
  25900. * @param texture defines the texture to check against the material
  25901. * @returns a boolean specifying if the material uses the texture
  25902. */
  25903. hasTexture(texture: BaseTexture): boolean;
  25904. /**
  25905. * Makes a duplicate of the material, and gives it a new name
  25906. * @param name defines the new name for the duplicated material
  25907. * @returns the cloned material
  25908. */
  25909. clone(name: string): Nullable<Material>;
  25910. /**
  25911. * Gets the meshes bound to the material
  25912. * @returns an array of meshes bound to the material
  25913. */
  25914. getBindedMeshes(): AbstractMesh[];
  25915. /**
  25916. * Force shader compilation
  25917. * @param mesh defines the mesh associated with this material
  25918. * @param onCompiled defines a function to execute once the material is compiled
  25919. * @param options defines the options to configure the compilation
  25920. * @param onError defines a function to execute if the material fails compiling
  25921. */
  25922. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25923. /**
  25924. * Force shader compilation
  25925. * @param mesh defines the mesh that will use this material
  25926. * @param options defines additional options for compiling the shaders
  25927. * @returns a promise that resolves when the compilation completes
  25928. */
  25929. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25930. private static readonly _AllDirtyCallBack;
  25931. private static readonly _ImageProcessingDirtyCallBack;
  25932. private static readonly _TextureDirtyCallBack;
  25933. private static readonly _FresnelDirtyCallBack;
  25934. private static readonly _MiscDirtyCallBack;
  25935. private static readonly _LightsDirtyCallBack;
  25936. private static readonly _AttributeDirtyCallBack;
  25937. private static _FresnelAndMiscDirtyCallBack;
  25938. private static _TextureAndMiscDirtyCallBack;
  25939. private static readonly _DirtyCallbackArray;
  25940. private static readonly _RunDirtyCallBacks;
  25941. /**
  25942. * Marks a define in the material to indicate that it needs to be re-computed
  25943. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25944. */
  25945. markAsDirty(flag: number): void;
  25946. /**
  25947. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25948. * @param func defines a function which checks material defines against the submeshes
  25949. */
  25950. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25951. /**
  25952. * Indicates that the scene should check if the rendering now needs a prepass
  25953. */
  25954. protected _markScenePrePassDirty(): void;
  25955. /**
  25956. * Indicates that we need to re-calculated for all submeshes
  25957. */
  25958. protected _markAllSubMeshesAsAllDirty(): void;
  25959. /**
  25960. * Indicates that image processing needs to be re-calculated for all submeshes
  25961. */
  25962. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25963. /**
  25964. * Indicates that textures need to be re-calculated for all submeshes
  25965. */
  25966. protected _markAllSubMeshesAsTexturesDirty(): void;
  25967. /**
  25968. * Indicates that fresnel needs to be re-calculated for all submeshes
  25969. */
  25970. protected _markAllSubMeshesAsFresnelDirty(): void;
  25971. /**
  25972. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25973. */
  25974. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25975. /**
  25976. * Indicates that lights need to be re-calculated for all submeshes
  25977. */
  25978. protected _markAllSubMeshesAsLightsDirty(): void;
  25979. /**
  25980. * Indicates that attributes need to be re-calculated for all submeshes
  25981. */
  25982. protected _markAllSubMeshesAsAttributesDirty(): void;
  25983. /**
  25984. * Indicates that misc needs to be re-calculated for all submeshes
  25985. */
  25986. protected _markAllSubMeshesAsMiscDirty(): void;
  25987. /**
  25988. * Indicates that textures and misc need to be re-calculated for all submeshes
  25989. */
  25990. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25991. /**
  25992. * Sets the required values to the prepass renderer.
  25993. * @param prePassRenderer defines the prepass renderer to setup.
  25994. * @returns true if the pre pass is needed.
  25995. */
  25996. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25997. /**
  25998. * Disposes the material
  25999. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26000. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26001. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26002. */
  26003. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26004. /** @hidden */
  26005. private releaseVertexArrayObject;
  26006. /**
  26007. * Serializes this material
  26008. * @returns the serialized material object
  26009. */
  26010. serialize(): any;
  26011. /**
  26012. * Creates a material from parsed material data
  26013. * @param parsedMaterial defines parsed material data
  26014. * @param scene defines the hosting scene
  26015. * @param rootUrl defines the root URL to use to load textures
  26016. * @returns a new material
  26017. */
  26018. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26019. }
  26020. }
  26021. declare module "babylonjs/Materials/multiMaterial" {
  26022. import { Nullable } from "babylonjs/types";
  26023. import { Scene } from "babylonjs/scene";
  26024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26027. import { Material } from "babylonjs/Materials/material";
  26028. /**
  26029. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26030. * separate meshes. This can be use to improve performances.
  26031. * @see https://doc.babylonjs.com/how_to/multi_materials
  26032. */
  26033. export class MultiMaterial extends Material {
  26034. private _subMaterials;
  26035. /**
  26036. * Gets or Sets the list of Materials used within the multi material.
  26037. * They need to be ordered according to the submeshes order in the associated mesh
  26038. */
  26039. get subMaterials(): Nullable<Material>[];
  26040. set subMaterials(value: Nullable<Material>[]);
  26041. /**
  26042. * Function used to align with Node.getChildren()
  26043. * @returns the list of Materials used within the multi material
  26044. */
  26045. getChildren(): Nullable<Material>[];
  26046. /**
  26047. * Instantiates a new Multi Material
  26048. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26049. * separate meshes. This can be use to improve performances.
  26050. * @see https://doc.babylonjs.com/how_to/multi_materials
  26051. * @param name Define the name in the scene
  26052. * @param scene Define the scene the material belongs to
  26053. */
  26054. constructor(name: string, scene: Scene);
  26055. private _hookArray;
  26056. /**
  26057. * Get one of the submaterial by its index in the submaterials array
  26058. * @param index The index to look the sub material at
  26059. * @returns The Material if the index has been defined
  26060. */
  26061. getSubMaterial(index: number): Nullable<Material>;
  26062. /**
  26063. * Get the list of active textures for the whole sub materials list.
  26064. * @returns All the textures that will be used during the rendering
  26065. */
  26066. getActiveTextures(): BaseTexture[];
  26067. /**
  26068. * Gets the current class name of the material e.g. "MultiMaterial"
  26069. * Mainly use in serialization.
  26070. * @returns the class name
  26071. */
  26072. getClassName(): string;
  26073. /**
  26074. * Checks if the material is ready to render the requested sub mesh
  26075. * @param mesh Define the mesh the submesh belongs to
  26076. * @param subMesh Define the sub mesh to look readyness for
  26077. * @param useInstances Define whether or not the material is used with instances
  26078. * @returns true if ready, otherwise false
  26079. */
  26080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26081. /**
  26082. * Clones the current material and its related sub materials
  26083. * @param name Define the name of the newly cloned material
  26084. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26085. * @returns the cloned material
  26086. */
  26087. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26088. /**
  26089. * Serializes the materials into a JSON representation.
  26090. * @returns the JSON representation
  26091. */
  26092. serialize(): any;
  26093. /**
  26094. * Dispose the material and release its associated resources
  26095. * @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)
  26096. * @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)
  26097. * @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)
  26098. */
  26099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26100. /**
  26101. * Creates a MultiMaterial from parsed MultiMaterial data.
  26102. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26103. * @param scene defines the hosting scene
  26104. * @returns a new MultiMaterial
  26105. */
  26106. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26107. }
  26108. }
  26109. declare module "babylonjs/Meshes/subMesh" {
  26110. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26111. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26112. import { Engine } from "babylonjs/Engines/engine";
  26113. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26114. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26115. import { Effect } from "babylonjs/Materials/effect";
  26116. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26117. import { Plane } from "babylonjs/Maths/math.plane";
  26118. import { Collider } from "babylonjs/Collisions/collider";
  26119. import { Material } from "babylonjs/Materials/material";
  26120. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26122. import { Mesh } from "babylonjs/Meshes/mesh";
  26123. import { Ray } from "babylonjs/Culling/ray";
  26124. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26125. /**
  26126. * Defines a subdivision inside a mesh
  26127. */
  26128. export class SubMesh implements ICullable {
  26129. /** the material index to use */
  26130. materialIndex: number;
  26131. /** vertex index start */
  26132. verticesStart: number;
  26133. /** vertices count */
  26134. verticesCount: number;
  26135. /** index start */
  26136. indexStart: number;
  26137. /** indices count */
  26138. indexCount: number;
  26139. /** @hidden */
  26140. _materialDefines: Nullable<MaterialDefines>;
  26141. /** @hidden */
  26142. _materialEffect: Nullable<Effect>;
  26143. /** @hidden */
  26144. _effectOverride: Nullable<Effect>;
  26145. /**
  26146. * Gets material defines used by the effect associated to the sub mesh
  26147. */
  26148. get materialDefines(): Nullable<MaterialDefines>;
  26149. /**
  26150. * Sets material defines used by the effect associated to the sub mesh
  26151. */
  26152. set materialDefines(defines: Nullable<MaterialDefines>);
  26153. /**
  26154. * Gets associated effect
  26155. */
  26156. get effect(): Nullable<Effect>;
  26157. /**
  26158. * Sets associated effect (effect used to render this submesh)
  26159. * @param effect defines the effect to associate with
  26160. * @param defines defines the set of defines used to compile this effect
  26161. */
  26162. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26163. /** @hidden */
  26164. _linesIndexCount: number;
  26165. private _mesh;
  26166. private _renderingMesh;
  26167. private _boundingInfo;
  26168. private _linesIndexBuffer;
  26169. /** @hidden */
  26170. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26171. /** @hidden */
  26172. _trianglePlanes: Plane[];
  26173. /** @hidden */
  26174. _lastColliderTransformMatrix: Nullable<Matrix>;
  26175. /** @hidden */
  26176. _renderId: number;
  26177. /** @hidden */
  26178. _alphaIndex: number;
  26179. /** @hidden */
  26180. _distanceToCamera: number;
  26181. /** @hidden */
  26182. _id: number;
  26183. private _currentMaterial;
  26184. /**
  26185. * Add a new submesh to a mesh
  26186. * @param materialIndex defines the material index to use
  26187. * @param verticesStart defines vertex index start
  26188. * @param verticesCount defines vertices count
  26189. * @param indexStart defines index start
  26190. * @param indexCount defines indices count
  26191. * @param mesh defines the parent mesh
  26192. * @param renderingMesh defines an optional rendering mesh
  26193. * @param createBoundingBox defines if bounding box should be created for this submesh
  26194. * @returns the new submesh
  26195. */
  26196. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26197. /**
  26198. * Creates a new submesh
  26199. * @param materialIndex defines the material index to use
  26200. * @param verticesStart defines vertex index start
  26201. * @param verticesCount defines vertices count
  26202. * @param indexStart defines index start
  26203. * @param indexCount defines indices count
  26204. * @param mesh defines the parent mesh
  26205. * @param renderingMesh defines an optional rendering mesh
  26206. * @param createBoundingBox defines if bounding box should be created for this submesh
  26207. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26208. */
  26209. constructor(
  26210. /** the material index to use */
  26211. materialIndex: number,
  26212. /** vertex index start */
  26213. verticesStart: number,
  26214. /** vertices count */
  26215. verticesCount: number,
  26216. /** index start */
  26217. indexStart: number,
  26218. /** indices count */
  26219. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26220. /**
  26221. * Returns true if this submesh covers the entire parent mesh
  26222. * @ignorenaming
  26223. */
  26224. get IsGlobal(): boolean;
  26225. /**
  26226. * Returns the submesh BoudingInfo object
  26227. * @returns current bounding info (or mesh's one if the submesh is global)
  26228. */
  26229. getBoundingInfo(): BoundingInfo;
  26230. /**
  26231. * Sets the submesh BoundingInfo
  26232. * @param boundingInfo defines the new bounding info to use
  26233. * @returns the SubMesh
  26234. */
  26235. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26236. /**
  26237. * Returns the mesh of the current submesh
  26238. * @return the parent mesh
  26239. */
  26240. getMesh(): AbstractMesh;
  26241. /**
  26242. * Returns the rendering mesh of the submesh
  26243. * @returns the rendering mesh (could be different from parent mesh)
  26244. */
  26245. getRenderingMesh(): Mesh;
  26246. /**
  26247. * Returns the replacement mesh of the submesh
  26248. * @returns the replacement mesh (could be different from parent mesh)
  26249. */
  26250. getReplacementMesh(): Nullable<AbstractMesh>;
  26251. /**
  26252. * Returns the effective mesh of the submesh
  26253. * @returns the effective mesh (could be different from parent mesh)
  26254. */
  26255. getEffectiveMesh(): AbstractMesh;
  26256. /**
  26257. * Returns the submesh material
  26258. * @returns null or the current material
  26259. */
  26260. getMaterial(): Nullable<Material>;
  26261. private _IsMultiMaterial;
  26262. /**
  26263. * Sets a new updated BoundingInfo object to the submesh
  26264. * @param data defines an optional position array to use to determine the bounding info
  26265. * @returns the SubMesh
  26266. */
  26267. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26268. /** @hidden */
  26269. _checkCollision(collider: Collider): boolean;
  26270. /**
  26271. * Updates the submesh BoundingInfo
  26272. * @param world defines the world matrix to use to update the bounding info
  26273. * @returns the submesh
  26274. */
  26275. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26276. /**
  26277. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26278. * @param frustumPlanes defines the frustum planes
  26279. * @returns true if the submesh is intersecting with the frustum
  26280. */
  26281. isInFrustum(frustumPlanes: Plane[]): boolean;
  26282. /**
  26283. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26284. * @param frustumPlanes defines the frustum planes
  26285. * @returns true if the submesh is inside the frustum
  26286. */
  26287. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26288. /**
  26289. * Renders the submesh
  26290. * @param enableAlphaMode defines if alpha needs to be used
  26291. * @returns the submesh
  26292. */
  26293. render(enableAlphaMode: boolean): SubMesh;
  26294. /**
  26295. * @hidden
  26296. */
  26297. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26298. /**
  26299. * Checks if the submesh intersects with a ray
  26300. * @param ray defines the ray to test
  26301. * @returns true is the passed ray intersects the submesh bounding box
  26302. */
  26303. canIntersects(ray: Ray): boolean;
  26304. /**
  26305. * Intersects current submesh with a ray
  26306. * @param ray defines the ray to test
  26307. * @param positions defines mesh's positions array
  26308. * @param indices defines mesh's indices array
  26309. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26310. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26311. * @returns intersection info or null if no intersection
  26312. */
  26313. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26314. /** @hidden */
  26315. private _intersectLines;
  26316. /** @hidden */
  26317. private _intersectUnIndexedLines;
  26318. /** @hidden */
  26319. private _intersectTriangles;
  26320. /** @hidden */
  26321. private _intersectUnIndexedTriangles;
  26322. /** @hidden */
  26323. _rebuild(): void;
  26324. /**
  26325. * Creates a new submesh from the passed mesh
  26326. * @param newMesh defines the new hosting mesh
  26327. * @param newRenderingMesh defines an optional rendering mesh
  26328. * @returns the new submesh
  26329. */
  26330. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26331. /**
  26332. * Release associated resources
  26333. */
  26334. dispose(): void;
  26335. /**
  26336. * Gets the class name
  26337. * @returns the string "SubMesh".
  26338. */
  26339. getClassName(): string;
  26340. /**
  26341. * Creates a new submesh from indices data
  26342. * @param materialIndex the index of the main mesh material
  26343. * @param startIndex the index where to start the copy in the mesh indices array
  26344. * @param indexCount the number of indices to copy then from the startIndex
  26345. * @param mesh the main mesh to create the submesh from
  26346. * @param renderingMesh the optional rendering mesh
  26347. * @returns a new submesh
  26348. */
  26349. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26350. }
  26351. }
  26352. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26353. /**
  26354. * Class used to represent data loading progression
  26355. */
  26356. export class SceneLoaderFlags {
  26357. private static _ForceFullSceneLoadingForIncremental;
  26358. private static _ShowLoadingScreen;
  26359. private static _CleanBoneMatrixWeights;
  26360. private static _loggingLevel;
  26361. /**
  26362. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26363. */
  26364. static get ForceFullSceneLoadingForIncremental(): boolean;
  26365. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26366. /**
  26367. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26368. */
  26369. static get ShowLoadingScreen(): boolean;
  26370. static set ShowLoadingScreen(value: boolean);
  26371. /**
  26372. * Defines the current logging level (while loading the scene)
  26373. * @ignorenaming
  26374. */
  26375. static get loggingLevel(): number;
  26376. static set loggingLevel(value: number);
  26377. /**
  26378. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26379. */
  26380. static get CleanBoneMatrixWeights(): boolean;
  26381. static set CleanBoneMatrixWeights(value: boolean);
  26382. }
  26383. }
  26384. declare module "babylonjs/Meshes/geometry" {
  26385. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26386. import { Scene } from "babylonjs/scene";
  26387. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26388. import { Engine } from "babylonjs/Engines/engine";
  26389. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26390. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26391. import { Effect } from "babylonjs/Materials/effect";
  26392. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26393. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26394. import { Mesh } from "babylonjs/Meshes/mesh";
  26395. /**
  26396. * Class used to store geometry data (vertex buffers + index buffer)
  26397. */
  26398. export class Geometry implements IGetSetVerticesData {
  26399. /**
  26400. * Gets or sets the ID of the geometry
  26401. */
  26402. id: string;
  26403. /**
  26404. * Gets or sets the unique ID of the geometry
  26405. */
  26406. uniqueId: number;
  26407. /**
  26408. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26409. */
  26410. delayLoadState: number;
  26411. /**
  26412. * Gets the file containing the data to load when running in delay load state
  26413. */
  26414. delayLoadingFile: Nullable<string>;
  26415. /**
  26416. * Callback called when the geometry is updated
  26417. */
  26418. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26419. private _scene;
  26420. private _engine;
  26421. private _meshes;
  26422. private _totalVertices;
  26423. /** @hidden */
  26424. _indices: IndicesArray;
  26425. /** @hidden */
  26426. _vertexBuffers: {
  26427. [key: string]: VertexBuffer;
  26428. };
  26429. private _isDisposed;
  26430. private _extend;
  26431. private _boundingBias;
  26432. /** @hidden */
  26433. _delayInfo: Array<string>;
  26434. private _indexBuffer;
  26435. private _indexBufferIsUpdatable;
  26436. /** @hidden */
  26437. _boundingInfo: Nullable<BoundingInfo>;
  26438. /** @hidden */
  26439. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26440. /** @hidden */
  26441. _softwareSkinningFrameId: number;
  26442. private _vertexArrayObjects;
  26443. private _updatable;
  26444. /** @hidden */
  26445. _positions: Nullable<Vector3[]>;
  26446. /**
  26447. * 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
  26448. */
  26449. get boundingBias(): Vector2;
  26450. /**
  26451. * 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
  26452. */
  26453. set boundingBias(value: Vector2);
  26454. /**
  26455. * Static function used to attach a new empty geometry to a mesh
  26456. * @param mesh defines the mesh to attach the geometry to
  26457. * @returns the new Geometry
  26458. */
  26459. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26460. /** Get the list of meshes using this geometry */
  26461. get meshes(): Mesh[];
  26462. /**
  26463. * 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
  26464. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26465. */
  26466. useBoundingInfoFromGeometry: boolean;
  26467. /**
  26468. * Creates a new geometry
  26469. * @param id defines the unique ID
  26470. * @param scene defines the hosting scene
  26471. * @param vertexData defines the VertexData used to get geometry data
  26472. * @param updatable defines if geometry must be updatable (false by default)
  26473. * @param mesh defines the mesh that will be associated with the geometry
  26474. */
  26475. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26476. /**
  26477. * Gets the current extend of the geometry
  26478. */
  26479. get extend(): {
  26480. minimum: Vector3;
  26481. maximum: Vector3;
  26482. };
  26483. /**
  26484. * Gets the hosting scene
  26485. * @returns the hosting Scene
  26486. */
  26487. getScene(): Scene;
  26488. /**
  26489. * Gets the hosting engine
  26490. * @returns the hosting Engine
  26491. */
  26492. getEngine(): Engine;
  26493. /**
  26494. * Defines if the geometry is ready to use
  26495. * @returns true if the geometry is ready to be used
  26496. */
  26497. isReady(): boolean;
  26498. /**
  26499. * Gets a value indicating that the geometry should not be serialized
  26500. */
  26501. get doNotSerialize(): boolean;
  26502. /** @hidden */
  26503. _rebuild(): void;
  26504. /**
  26505. * Affects all geometry data in one call
  26506. * @param vertexData defines the geometry data
  26507. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26508. */
  26509. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26510. /**
  26511. * Set specific vertex data
  26512. * @param kind defines the data kind (Position, normal, etc...)
  26513. * @param data defines the vertex data to use
  26514. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26515. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26516. */
  26517. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26518. /**
  26519. * Removes a specific vertex data
  26520. * @param kind defines the data kind (Position, normal, etc...)
  26521. */
  26522. removeVerticesData(kind: string): void;
  26523. /**
  26524. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26525. * @param buffer defines the vertex buffer to use
  26526. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26527. */
  26528. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26529. /**
  26530. * Update a specific vertex buffer
  26531. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26532. * It will do nothing if the buffer is not updatable
  26533. * @param kind defines the data kind (Position, normal, etc...)
  26534. * @param data defines the data to use
  26535. * @param offset defines the offset in the target buffer where to store the data
  26536. * @param useBytes set to true if the offset is in bytes
  26537. */
  26538. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26539. /**
  26540. * Update a specific vertex buffer
  26541. * This function will create a new buffer if the current one is not updatable
  26542. * @param kind defines the data kind (Position, normal, etc...)
  26543. * @param data defines the data to use
  26544. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26545. */
  26546. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26547. private _updateBoundingInfo;
  26548. /** @hidden */
  26549. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26550. /**
  26551. * Gets total number of vertices
  26552. * @returns the total number of vertices
  26553. */
  26554. getTotalVertices(): number;
  26555. /**
  26556. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26557. * @param kind defines the data kind (Position, normal, etc...)
  26558. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26560. * @returns a float array containing vertex data
  26561. */
  26562. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26563. /**
  26564. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26565. * @param kind defines the data kind (Position, normal, etc...)
  26566. * @returns true if the vertex buffer with the specified kind is updatable
  26567. */
  26568. isVertexBufferUpdatable(kind: string): boolean;
  26569. /**
  26570. * Gets a specific vertex buffer
  26571. * @param kind defines the data kind (Position, normal, etc...)
  26572. * @returns a VertexBuffer
  26573. */
  26574. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26575. /**
  26576. * Returns all vertex buffers
  26577. * @return an object holding all vertex buffers indexed by kind
  26578. */
  26579. getVertexBuffers(): Nullable<{
  26580. [key: string]: VertexBuffer;
  26581. }>;
  26582. /**
  26583. * Gets a boolean indicating if specific vertex buffer is present
  26584. * @param kind defines the data kind (Position, normal, etc...)
  26585. * @returns true if data is present
  26586. */
  26587. isVerticesDataPresent(kind: string): boolean;
  26588. /**
  26589. * Gets a list of all attached data kinds (Position, normal, etc...)
  26590. * @returns a list of string containing all kinds
  26591. */
  26592. getVerticesDataKinds(): string[];
  26593. /**
  26594. * Update index buffer
  26595. * @param indices defines the indices to store in the index buffer
  26596. * @param offset defines the offset in the target buffer where to store the data
  26597. * @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)
  26598. */
  26599. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26600. /**
  26601. * Creates a new index buffer
  26602. * @param indices defines the indices to store in the index buffer
  26603. * @param totalVertices defines the total number of vertices (could be null)
  26604. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26605. */
  26606. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26607. /**
  26608. * Return the total number of indices
  26609. * @returns the total number of indices
  26610. */
  26611. getTotalIndices(): number;
  26612. /**
  26613. * Gets the index buffer array
  26614. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26615. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26616. * @returns the index buffer array
  26617. */
  26618. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26619. /**
  26620. * Gets the index buffer
  26621. * @return the index buffer
  26622. */
  26623. getIndexBuffer(): Nullable<DataBuffer>;
  26624. /** @hidden */
  26625. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26626. /**
  26627. * Release the associated resources for a specific mesh
  26628. * @param mesh defines the source mesh
  26629. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26630. */
  26631. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26632. /**
  26633. * Apply current geometry to a given mesh
  26634. * @param mesh defines the mesh to apply geometry to
  26635. */
  26636. applyToMesh(mesh: Mesh): void;
  26637. private _updateExtend;
  26638. private _applyToMesh;
  26639. private notifyUpdate;
  26640. /**
  26641. * Load the geometry if it was flagged as delay loaded
  26642. * @param scene defines the hosting scene
  26643. * @param onLoaded defines a callback called when the geometry is loaded
  26644. */
  26645. load(scene: Scene, onLoaded?: () => void): void;
  26646. private _queueLoad;
  26647. /**
  26648. * Invert the geometry to move from a right handed system to a left handed one.
  26649. */
  26650. toLeftHanded(): void;
  26651. /** @hidden */
  26652. _resetPointsArrayCache(): void;
  26653. /** @hidden */
  26654. _generatePointsArray(): boolean;
  26655. /**
  26656. * Gets a value indicating if the geometry is disposed
  26657. * @returns true if the geometry was disposed
  26658. */
  26659. isDisposed(): boolean;
  26660. private _disposeVertexArrayObjects;
  26661. /**
  26662. * Free all associated resources
  26663. */
  26664. dispose(): void;
  26665. /**
  26666. * Clone the current geometry into a new geometry
  26667. * @param id defines the unique ID of the new geometry
  26668. * @returns a new geometry object
  26669. */
  26670. copy(id: string): Geometry;
  26671. /**
  26672. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26673. * @return a JSON representation of the current geometry data (without the vertices data)
  26674. */
  26675. serialize(): any;
  26676. private toNumberArray;
  26677. /**
  26678. * Serialize all vertices data into a JSON oject
  26679. * @returns a JSON representation of the current geometry data
  26680. */
  26681. serializeVerticeData(): any;
  26682. /**
  26683. * Extracts a clone of a mesh geometry
  26684. * @param mesh defines the source mesh
  26685. * @param id defines the unique ID of the new geometry object
  26686. * @returns the new geometry object
  26687. */
  26688. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26689. /**
  26690. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26691. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26692. * Be aware Math.random() could cause collisions, but:
  26693. * "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"
  26694. * @returns a string containing a new GUID
  26695. */
  26696. static RandomId(): string;
  26697. /** @hidden */
  26698. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26699. private static _CleanMatricesWeights;
  26700. /**
  26701. * Create a new geometry from persisted data (Using .babylon file format)
  26702. * @param parsedVertexData defines the persisted data
  26703. * @param scene defines the hosting scene
  26704. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26705. * @returns the new geometry object
  26706. */
  26707. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26708. }
  26709. }
  26710. declare module "babylonjs/Meshes/mesh.vertexData" {
  26711. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26712. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26713. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26714. import { Geometry } from "babylonjs/Meshes/geometry";
  26715. import { Mesh } from "babylonjs/Meshes/mesh";
  26716. /**
  26717. * Define an interface for all classes that will get and set the data on vertices
  26718. */
  26719. export interface IGetSetVerticesData {
  26720. /**
  26721. * Gets a boolean indicating if specific vertex data is present
  26722. * @param kind defines the vertex data kind to use
  26723. * @returns true is data kind is present
  26724. */
  26725. isVerticesDataPresent(kind: string): boolean;
  26726. /**
  26727. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26728. * @param kind defines the data kind (Position, normal, etc...)
  26729. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26731. * @returns a float array containing vertex data
  26732. */
  26733. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26734. /**
  26735. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26736. * @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.
  26737. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26738. * @returns the indices array or an empty array if the mesh has no geometry
  26739. */
  26740. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26741. /**
  26742. * Set specific vertex data
  26743. * @param kind defines the data kind (Position, normal, etc...)
  26744. * @param data defines the vertex data to use
  26745. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26746. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26747. */
  26748. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26749. /**
  26750. * Update a specific associated vertex buffer
  26751. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26752. * - VertexBuffer.PositionKind
  26753. * - VertexBuffer.UVKind
  26754. * - VertexBuffer.UV2Kind
  26755. * - VertexBuffer.UV3Kind
  26756. * - VertexBuffer.UV4Kind
  26757. * - VertexBuffer.UV5Kind
  26758. * - VertexBuffer.UV6Kind
  26759. * - VertexBuffer.ColorKind
  26760. * - VertexBuffer.MatricesIndicesKind
  26761. * - VertexBuffer.MatricesIndicesExtraKind
  26762. * - VertexBuffer.MatricesWeightsKind
  26763. * - VertexBuffer.MatricesWeightsExtraKind
  26764. * @param data defines the data source
  26765. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26766. * @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)
  26767. */
  26768. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26769. /**
  26770. * Creates a new index buffer
  26771. * @param indices defines the indices to store in the index buffer
  26772. * @param totalVertices defines the total number of vertices (could be null)
  26773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26774. */
  26775. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26776. }
  26777. /**
  26778. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26779. */
  26780. export class VertexData {
  26781. /**
  26782. * Mesh side orientation : usually the external or front surface
  26783. */
  26784. static readonly FRONTSIDE: number;
  26785. /**
  26786. * Mesh side orientation : usually the internal or back surface
  26787. */
  26788. static readonly BACKSIDE: number;
  26789. /**
  26790. * Mesh side orientation : both internal and external or front and back surfaces
  26791. */
  26792. static readonly DOUBLESIDE: number;
  26793. /**
  26794. * Mesh side orientation : by default, `FRONTSIDE`
  26795. */
  26796. static readonly DEFAULTSIDE: number;
  26797. /**
  26798. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26799. */
  26800. positions: Nullable<FloatArray>;
  26801. /**
  26802. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26803. */
  26804. normals: Nullable<FloatArray>;
  26805. /**
  26806. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26807. */
  26808. tangents: Nullable<FloatArray>;
  26809. /**
  26810. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26811. */
  26812. uvs: Nullable<FloatArray>;
  26813. /**
  26814. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26815. */
  26816. uvs2: Nullable<FloatArray>;
  26817. /**
  26818. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26819. */
  26820. uvs3: Nullable<FloatArray>;
  26821. /**
  26822. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26823. */
  26824. uvs4: Nullable<FloatArray>;
  26825. /**
  26826. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26827. */
  26828. uvs5: Nullable<FloatArray>;
  26829. /**
  26830. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26831. */
  26832. uvs6: Nullable<FloatArray>;
  26833. /**
  26834. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26835. */
  26836. colors: Nullable<FloatArray>;
  26837. /**
  26838. * 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).
  26839. */
  26840. matricesIndices: Nullable<FloatArray>;
  26841. /**
  26842. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26843. */
  26844. matricesWeights: Nullable<FloatArray>;
  26845. /**
  26846. * An array extending the number of possible indices
  26847. */
  26848. matricesIndicesExtra: Nullable<FloatArray>;
  26849. /**
  26850. * An array extending the number of possible weights when the number of indices is extended
  26851. */
  26852. matricesWeightsExtra: Nullable<FloatArray>;
  26853. /**
  26854. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26855. */
  26856. indices: Nullable<IndicesArray>;
  26857. /**
  26858. * Uses the passed data array to set the set the values for the specified kind of data
  26859. * @param data a linear array of floating numbers
  26860. * @param kind the type of data that is being set, eg positions, colors etc
  26861. */
  26862. set(data: FloatArray, kind: string): void;
  26863. /**
  26864. * Associates the vertexData to the passed Mesh.
  26865. * Sets it as updatable or not (default `false`)
  26866. * @param mesh the mesh the vertexData is applied to
  26867. * @param updatable when used and having the value true allows new data to update the vertexData
  26868. * @returns the VertexData
  26869. */
  26870. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26871. /**
  26872. * Associates the vertexData to the passed Geometry.
  26873. * Sets it as updatable or not (default `false`)
  26874. * @param geometry the geometry the vertexData is applied to
  26875. * @param updatable when used and having the value true allows new data to update the vertexData
  26876. * @returns VertexData
  26877. */
  26878. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26879. /**
  26880. * Updates the associated mesh
  26881. * @param mesh the mesh to be updated
  26882. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26883. * @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
  26884. * @returns VertexData
  26885. */
  26886. updateMesh(mesh: Mesh): VertexData;
  26887. /**
  26888. * Updates the associated geometry
  26889. * @param geometry the geometry to be updated
  26890. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26891. * @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
  26892. * @returns VertexData.
  26893. */
  26894. updateGeometry(geometry: Geometry): VertexData;
  26895. private _applyTo;
  26896. private _update;
  26897. /**
  26898. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26899. * @param matrix the transforming matrix
  26900. * @returns the VertexData
  26901. */
  26902. transform(matrix: Matrix): VertexData;
  26903. /**
  26904. * Merges the passed VertexData into the current one
  26905. * @param other the VertexData to be merged into the current one
  26906. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26907. * @returns the modified VertexData
  26908. */
  26909. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26910. private _mergeElement;
  26911. private _validate;
  26912. /**
  26913. * Serializes the VertexData
  26914. * @returns a serialized object
  26915. */
  26916. serialize(): any;
  26917. /**
  26918. * Extracts the vertexData from a mesh
  26919. * @param mesh the mesh from which to extract the VertexData
  26920. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26921. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26922. * @returns the object VertexData associated to the passed mesh
  26923. */
  26924. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26925. /**
  26926. * Extracts the vertexData from the geometry
  26927. * @param geometry the geometry from which to extract the VertexData
  26928. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26929. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26930. * @returns the object VertexData associated to the passed mesh
  26931. */
  26932. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26933. private static _ExtractFrom;
  26934. /**
  26935. * Creates the VertexData for a Ribbon
  26936. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26937. * * pathArray array of paths, each of which an array of successive Vector3
  26938. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26939. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26940. * * 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
  26941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26942. * * 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)
  26943. * * 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)
  26944. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26945. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26946. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26947. * @returns the VertexData of the ribbon
  26948. */
  26949. static CreateRibbon(options: {
  26950. pathArray: Vector3[][];
  26951. closeArray?: boolean;
  26952. closePath?: boolean;
  26953. offset?: number;
  26954. sideOrientation?: number;
  26955. frontUVs?: Vector4;
  26956. backUVs?: Vector4;
  26957. invertUV?: boolean;
  26958. uvs?: Vector2[];
  26959. colors?: Color4[];
  26960. }): VertexData;
  26961. /**
  26962. * Creates the VertexData for a box
  26963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26964. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26965. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26966. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26967. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26968. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26969. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26971. * * 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)
  26972. * * 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)
  26973. * @returns the VertexData of the box
  26974. */
  26975. static CreateBox(options: {
  26976. size?: number;
  26977. width?: number;
  26978. height?: number;
  26979. depth?: number;
  26980. faceUV?: Vector4[];
  26981. faceColors?: Color4[];
  26982. sideOrientation?: number;
  26983. frontUVs?: Vector4;
  26984. backUVs?: Vector4;
  26985. }): VertexData;
  26986. /**
  26987. * Creates the VertexData for a tiled box
  26988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26989. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26990. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26991. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26993. * @returns the VertexData of the box
  26994. */
  26995. static CreateTiledBox(options: {
  26996. pattern?: number;
  26997. width?: number;
  26998. height?: number;
  26999. depth?: number;
  27000. tileSize?: number;
  27001. tileWidth?: number;
  27002. tileHeight?: number;
  27003. alignHorizontal?: number;
  27004. alignVertical?: number;
  27005. faceUV?: Vector4[];
  27006. faceColors?: Color4[];
  27007. sideOrientation?: number;
  27008. }): VertexData;
  27009. /**
  27010. * Creates the VertexData for a tiled plane
  27011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27012. * * pattern a limited pattern arrangement depending on the number
  27013. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27014. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27015. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27017. * * 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)
  27018. * * 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)
  27019. * @returns the VertexData of the tiled plane
  27020. */
  27021. static CreateTiledPlane(options: {
  27022. pattern?: number;
  27023. tileSize?: number;
  27024. tileWidth?: number;
  27025. tileHeight?: number;
  27026. size?: number;
  27027. width?: number;
  27028. height?: number;
  27029. alignHorizontal?: number;
  27030. alignVertical?: number;
  27031. sideOrientation?: number;
  27032. frontUVs?: Vector4;
  27033. backUVs?: Vector4;
  27034. }): VertexData;
  27035. /**
  27036. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27038. * * segments sets the number of horizontal strips optional, default 32
  27039. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27040. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27041. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27042. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27043. * * 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
  27044. * * 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
  27045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27046. * * 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)
  27047. * * 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)
  27048. * @returns the VertexData of the ellipsoid
  27049. */
  27050. static CreateSphere(options: {
  27051. segments?: number;
  27052. diameter?: number;
  27053. diameterX?: number;
  27054. diameterY?: number;
  27055. diameterZ?: number;
  27056. arc?: number;
  27057. slice?: number;
  27058. sideOrientation?: number;
  27059. frontUVs?: Vector4;
  27060. backUVs?: Vector4;
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a cylinder, cone or prism
  27064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27065. * * height sets the height (y direction) of the cylinder, optional, default 2
  27066. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27067. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27068. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27070. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27071. * * 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
  27072. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27073. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27074. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27075. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27077. * * 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)
  27078. * * 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)
  27079. * @returns the VertexData of the cylinder, cone or prism
  27080. */
  27081. static CreateCylinder(options: {
  27082. height?: number;
  27083. diameterTop?: number;
  27084. diameterBottom?: number;
  27085. diameter?: number;
  27086. tessellation?: number;
  27087. subdivisions?: number;
  27088. arc?: number;
  27089. faceColors?: Color4[];
  27090. faceUV?: Vector4[];
  27091. hasRings?: boolean;
  27092. enclose?: boolean;
  27093. sideOrientation?: number;
  27094. frontUVs?: Vector4;
  27095. backUVs?: Vector4;
  27096. }): VertexData;
  27097. /**
  27098. * Creates the VertexData for a torus
  27099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27100. * * diameter the diameter of the torus, optional default 1
  27101. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27102. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27104. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27105. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27106. * @returns the VertexData of the torus
  27107. */
  27108. static CreateTorus(options: {
  27109. diameter?: number;
  27110. thickness?: number;
  27111. tessellation?: number;
  27112. sideOrientation?: number;
  27113. frontUVs?: Vector4;
  27114. backUVs?: Vector4;
  27115. }): VertexData;
  27116. /**
  27117. * Creates the VertexData of the LineSystem
  27118. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27119. * - lines an array of lines, each line being an array of successive Vector3
  27120. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27121. * @returns the VertexData of the LineSystem
  27122. */
  27123. static CreateLineSystem(options: {
  27124. lines: Vector3[][];
  27125. colors?: Nullable<Color4[][]>;
  27126. }): VertexData;
  27127. /**
  27128. * Create the VertexData for a DashedLines
  27129. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27130. * - points an array successive Vector3
  27131. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27132. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27133. * - dashNb the intended total number of dashes, optional, default 200
  27134. * @returns the VertexData for the DashedLines
  27135. */
  27136. static CreateDashedLines(options: {
  27137. points: Vector3[];
  27138. dashSize?: number;
  27139. gapSize?: number;
  27140. dashNb?: number;
  27141. }): VertexData;
  27142. /**
  27143. * Creates the VertexData for a Ground
  27144. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27145. * - width the width (x direction) of the ground, optional, default 1
  27146. * - height the height (z direction) of the ground, optional, default 1
  27147. * - subdivisions the number of subdivisions per side, optional, default 1
  27148. * @returns the VertexData of the Ground
  27149. */
  27150. static CreateGround(options: {
  27151. width?: number;
  27152. height?: number;
  27153. subdivisions?: number;
  27154. subdivisionsX?: number;
  27155. subdivisionsY?: number;
  27156. }): VertexData;
  27157. /**
  27158. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27159. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27160. * * xmin the ground minimum X coordinate, optional, default -1
  27161. * * zmin the ground minimum Z coordinate, optional, default -1
  27162. * * xmax the ground maximum X coordinate, optional, default 1
  27163. * * zmax the ground maximum Z coordinate, optional, default 1
  27164. * * 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}
  27165. * * 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}
  27166. * @returns the VertexData of the TiledGround
  27167. */
  27168. static CreateTiledGround(options: {
  27169. xmin: number;
  27170. zmin: number;
  27171. xmax: number;
  27172. zmax: number;
  27173. subdivisions?: {
  27174. w: number;
  27175. h: number;
  27176. };
  27177. precision?: {
  27178. w: number;
  27179. h: number;
  27180. };
  27181. }): VertexData;
  27182. /**
  27183. * Creates the VertexData of the Ground designed from a heightmap
  27184. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27185. * * width the width (x direction) of the ground
  27186. * * height the height (z direction) of the ground
  27187. * * subdivisions the number of subdivisions per side
  27188. * * minHeight the minimum altitude on the ground, optional, default 0
  27189. * * maxHeight the maximum altitude on the ground, optional default 1
  27190. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27191. * * buffer the array holding the image color data
  27192. * * bufferWidth the width of image
  27193. * * bufferHeight the height of image
  27194. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27195. * @returns the VertexData of the Ground designed from a heightmap
  27196. */
  27197. static CreateGroundFromHeightMap(options: {
  27198. width: number;
  27199. height: number;
  27200. subdivisions: number;
  27201. minHeight: number;
  27202. maxHeight: number;
  27203. colorFilter: Color3;
  27204. buffer: Uint8Array;
  27205. bufferWidth: number;
  27206. bufferHeight: number;
  27207. alphaFilter: number;
  27208. }): VertexData;
  27209. /**
  27210. * Creates the VertexData for a Plane
  27211. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27212. * * size sets the width and height of the plane to the value of size, optional default 1
  27213. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27214. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27216. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27217. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27218. * @returns the VertexData of the box
  27219. */
  27220. static CreatePlane(options: {
  27221. size?: number;
  27222. width?: number;
  27223. height?: number;
  27224. sideOrientation?: number;
  27225. frontUVs?: Vector4;
  27226. backUVs?: Vector4;
  27227. }): VertexData;
  27228. /**
  27229. * Creates the VertexData of the Disc or regular Polygon
  27230. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27231. * * radius the radius of the disc, optional default 0.5
  27232. * * tessellation the number of polygon sides, optional, default 64
  27233. * * 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
  27234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27235. * * 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)
  27236. * * 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)
  27237. * @returns the VertexData of the box
  27238. */
  27239. static CreateDisc(options: {
  27240. radius?: number;
  27241. tessellation?: number;
  27242. arc?: number;
  27243. sideOrientation?: number;
  27244. frontUVs?: Vector4;
  27245. backUVs?: Vector4;
  27246. }): VertexData;
  27247. /**
  27248. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27249. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27250. * @param polygon a mesh built from polygonTriangulation.build()
  27251. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27252. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27253. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27254. * @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)
  27255. * @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)
  27256. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27257. * @returns the VertexData of the Polygon
  27258. */
  27259. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27260. /**
  27261. * Creates the VertexData of the IcoSphere
  27262. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27263. * * radius the radius of the IcoSphere, optional default 1
  27264. * * radiusX allows stretching in the x direction, optional, default radius
  27265. * * radiusY allows stretching in the y direction, optional, default radius
  27266. * * radiusZ allows stretching in the z direction, optional, default radius
  27267. * * flat when true creates a flat shaded mesh, optional, default true
  27268. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27270. * * 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)
  27271. * * 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)
  27272. * @returns the VertexData of the IcoSphere
  27273. */
  27274. static CreateIcoSphere(options: {
  27275. radius?: number;
  27276. radiusX?: number;
  27277. radiusY?: number;
  27278. radiusZ?: number;
  27279. flat?: boolean;
  27280. subdivisions?: number;
  27281. sideOrientation?: number;
  27282. frontUVs?: Vector4;
  27283. backUVs?: Vector4;
  27284. }): VertexData;
  27285. /**
  27286. * Creates the VertexData for a Polyhedron
  27287. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27288. * * type provided types are:
  27289. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27290. * * 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)
  27291. * * size the size of the IcoSphere, optional default 1
  27292. * * sizeX allows stretching in the x direction, optional, default size
  27293. * * sizeY allows stretching in the y direction, optional, default size
  27294. * * sizeZ allows stretching in the z direction, optional, default size
  27295. * * 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
  27296. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27297. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27298. * * flat when true creates a flat shaded mesh, optional, default true
  27299. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27301. * * 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)
  27302. * * 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)
  27303. * @returns the VertexData of the Polyhedron
  27304. */
  27305. static CreatePolyhedron(options: {
  27306. type?: number;
  27307. size?: number;
  27308. sizeX?: number;
  27309. sizeY?: number;
  27310. sizeZ?: number;
  27311. custom?: any;
  27312. faceUV?: Vector4[];
  27313. faceColors?: Color4[];
  27314. flat?: boolean;
  27315. sideOrientation?: number;
  27316. frontUVs?: Vector4;
  27317. backUVs?: Vector4;
  27318. }): VertexData;
  27319. /**
  27320. * Creates the VertexData for a TorusKnot
  27321. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27322. * * radius the radius of the torus knot, optional, default 2
  27323. * * tube the thickness of the tube, optional, default 0.5
  27324. * * radialSegments the number of sides on each tube segments, optional, default 32
  27325. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27326. * * p the number of windings around the z axis, optional, default 2
  27327. * * q the number of windings around the x axis, optional, default 3
  27328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27329. * * 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)
  27330. * * 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)
  27331. * @returns the VertexData of the Torus Knot
  27332. */
  27333. static CreateTorusKnot(options: {
  27334. radius?: number;
  27335. tube?: number;
  27336. radialSegments?: number;
  27337. tubularSegments?: number;
  27338. p?: number;
  27339. q?: number;
  27340. sideOrientation?: number;
  27341. frontUVs?: Vector4;
  27342. backUVs?: Vector4;
  27343. }): VertexData;
  27344. /**
  27345. * Compute normals for given positions and indices
  27346. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27347. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27348. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27349. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27350. * * facetNormals : optional array of facet normals (vector3)
  27351. * * facetPositions : optional array of facet positions (vector3)
  27352. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27353. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27354. * * bInfo : optional bounding info, required for facetPartitioning computation
  27355. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27356. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27357. * * useRightHandedSystem: optional boolean to for right handed system computation
  27358. * * depthSort : optional boolean to enable the facet depth sort computation
  27359. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27360. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27361. */
  27362. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27363. facetNormals?: any;
  27364. facetPositions?: any;
  27365. facetPartitioning?: any;
  27366. ratio?: number;
  27367. bInfo?: any;
  27368. bbSize?: Vector3;
  27369. subDiv?: any;
  27370. useRightHandedSystem?: boolean;
  27371. depthSort?: boolean;
  27372. distanceTo?: Vector3;
  27373. depthSortedFacets?: any;
  27374. }): void;
  27375. /** @hidden */
  27376. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27377. /**
  27378. * Applies VertexData created from the imported parameters to the geometry
  27379. * @param parsedVertexData the parsed data from an imported file
  27380. * @param geometry the geometry to apply the VertexData to
  27381. */
  27382. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27383. }
  27384. }
  27385. declare module "babylonjs/Morph/morphTarget" {
  27386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27387. import { Observable } from "babylonjs/Misc/observable";
  27388. import { Nullable, FloatArray } from "babylonjs/types";
  27389. import { Scene } from "babylonjs/scene";
  27390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27391. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27392. /**
  27393. * Defines a target to use with MorphTargetManager
  27394. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27395. */
  27396. export class MorphTarget implements IAnimatable {
  27397. /** defines the name of the target */
  27398. name: string;
  27399. /**
  27400. * Gets or sets the list of animations
  27401. */
  27402. animations: import("babylonjs/Animations/animation").Animation[];
  27403. private _scene;
  27404. private _positions;
  27405. private _normals;
  27406. private _tangents;
  27407. private _uvs;
  27408. private _influence;
  27409. private _uniqueId;
  27410. /**
  27411. * Observable raised when the influence changes
  27412. */
  27413. onInfluenceChanged: Observable<boolean>;
  27414. /** @hidden */
  27415. _onDataLayoutChanged: Observable<void>;
  27416. /**
  27417. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27418. */
  27419. get influence(): number;
  27420. set influence(influence: number);
  27421. /**
  27422. * Gets or sets the id of the morph Target
  27423. */
  27424. id: string;
  27425. private _animationPropertiesOverride;
  27426. /**
  27427. * Gets or sets the animation properties override
  27428. */
  27429. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27430. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27431. /**
  27432. * Creates a new MorphTarget
  27433. * @param name defines the name of the target
  27434. * @param influence defines the influence to use
  27435. * @param scene defines the scene the morphtarget belongs to
  27436. */
  27437. constructor(
  27438. /** defines the name of the target */
  27439. name: string, influence?: number, scene?: Nullable<Scene>);
  27440. /**
  27441. * Gets the unique ID of this manager
  27442. */
  27443. get uniqueId(): number;
  27444. /**
  27445. * Gets a boolean defining if the target contains position data
  27446. */
  27447. get hasPositions(): boolean;
  27448. /**
  27449. * Gets a boolean defining if the target contains normal data
  27450. */
  27451. get hasNormals(): boolean;
  27452. /**
  27453. * Gets a boolean defining if the target contains tangent data
  27454. */
  27455. get hasTangents(): boolean;
  27456. /**
  27457. * Gets a boolean defining if the target contains texture coordinates data
  27458. */
  27459. get hasUVs(): boolean;
  27460. /**
  27461. * Affects position data to this target
  27462. * @param data defines the position data to use
  27463. */
  27464. setPositions(data: Nullable<FloatArray>): void;
  27465. /**
  27466. * Gets the position data stored in this target
  27467. * @returns a FloatArray containing the position data (or null if not present)
  27468. */
  27469. getPositions(): Nullable<FloatArray>;
  27470. /**
  27471. * Affects normal data to this target
  27472. * @param data defines the normal data to use
  27473. */
  27474. setNormals(data: Nullable<FloatArray>): void;
  27475. /**
  27476. * Gets the normal data stored in this target
  27477. * @returns a FloatArray containing the normal data (or null if not present)
  27478. */
  27479. getNormals(): Nullable<FloatArray>;
  27480. /**
  27481. * Affects tangent data to this target
  27482. * @param data defines the tangent data to use
  27483. */
  27484. setTangents(data: Nullable<FloatArray>): void;
  27485. /**
  27486. * Gets the tangent data stored in this target
  27487. * @returns a FloatArray containing the tangent data (or null if not present)
  27488. */
  27489. getTangents(): Nullable<FloatArray>;
  27490. /**
  27491. * Affects texture coordinates data to this target
  27492. * @param data defines the texture coordinates data to use
  27493. */
  27494. setUVs(data: Nullable<FloatArray>): void;
  27495. /**
  27496. * Gets the texture coordinates data stored in this target
  27497. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27498. */
  27499. getUVs(): Nullable<FloatArray>;
  27500. /**
  27501. * Clone the current target
  27502. * @returns a new MorphTarget
  27503. */
  27504. clone(): MorphTarget;
  27505. /**
  27506. * Serializes the current target into a Serialization object
  27507. * @returns the serialized object
  27508. */
  27509. serialize(): any;
  27510. /**
  27511. * Returns the string "MorphTarget"
  27512. * @returns "MorphTarget"
  27513. */
  27514. getClassName(): string;
  27515. /**
  27516. * Creates a new target from serialized data
  27517. * @param serializationObject defines the serialized data to use
  27518. * @returns a new MorphTarget
  27519. */
  27520. static Parse(serializationObject: any): MorphTarget;
  27521. /**
  27522. * Creates a MorphTarget from mesh data
  27523. * @param mesh defines the source mesh
  27524. * @param name defines the name to use for the new target
  27525. * @param influence defines the influence to attach to the target
  27526. * @returns a new MorphTarget
  27527. */
  27528. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27529. }
  27530. }
  27531. declare module "babylonjs/Morph/morphTargetManager" {
  27532. import { Nullable } from "babylonjs/types";
  27533. import { Scene } from "babylonjs/scene";
  27534. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27535. /**
  27536. * This class is used to deform meshes using morphing between different targets
  27537. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27538. */
  27539. export class MorphTargetManager {
  27540. private _targets;
  27541. private _targetInfluenceChangedObservers;
  27542. private _targetDataLayoutChangedObservers;
  27543. private _activeTargets;
  27544. private _scene;
  27545. private _influences;
  27546. private _supportsNormals;
  27547. private _supportsTangents;
  27548. private _supportsUVs;
  27549. private _vertexCount;
  27550. private _uniqueId;
  27551. private _tempInfluences;
  27552. /**
  27553. * Gets or sets a boolean indicating if normals must be morphed
  27554. */
  27555. enableNormalMorphing: boolean;
  27556. /**
  27557. * Gets or sets a boolean indicating if tangents must be morphed
  27558. */
  27559. enableTangentMorphing: boolean;
  27560. /**
  27561. * Gets or sets a boolean indicating if UV must be morphed
  27562. */
  27563. enableUVMorphing: boolean;
  27564. /**
  27565. * Creates a new MorphTargetManager
  27566. * @param scene defines the current scene
  27567. */
  27568. constructor(scene?: Nullable<Scene>);
  27569. /**
  27570. * Gets the unique ID of this manager
  27571. */
  27572. get uniqueId(): number;
  27573. /**
  27574. * Gets the number of vertices handled by this manager
  27575. */
  27576. get vertexCount(): number;
  27577. /**
  27578. * Gets a boolean indicating if this manager supports morphing of normals
  27579. */
  27580. get supportsNormals(): boolean;
  27581. /**
  27582. * Gets a boolean indicating if this manager supports morphing of tangents
  27583. */
  27584. get supportsTangents(): boolean;
  27585. /**
  27586. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27587. */
  27588. get supportsUVs(): boolean;
  27589. /**
  27590. * Gets the number of targets stored in this manager
  27591. */
  27592. get numTargets(): number;
  27593. /**
  27594. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27595. */
  27596. get numInfluencers(): number;
  27597. /**
  27598. * Gets the list of influences (one per target)
  27599. */
  27600. get influences(): Float32Array;
  27601. /**
  27602. * Gets the active target at specified index. An active target is a target with an influence > 0
  27603. * @param index defines the index to check
  27604. * @returns the requested target
  27605. */
  27606. getActiveTarget(index: number): MorphTarget;
  27607. /**
  27608. * Gets the target at specified index
  27609. * @param index defines the index to check
  27610. * @returns the requested target
  27611. */
  27612. getTarget(index: number): MorphTarget;
  27613. /**
  27614. * Add a new target to this manager
  27615. * @param target defines the target to add
  27616. */
  27617. addTarget(target: MorphTarget): void;
  27618. /**
  27619. * Removes a target from the manager
  27620. * @param target defines the target to remove
  27621. */
  27622. removeTarget(target: MorphTarget): void;
  27623. /**
  27624. * Clone the current manager
  27625. * @returns a new MorphTargetManager
  27626. */
  27627. clone(): MorphTargetManager;
  27628. /**
  27629. * Serializes the current manager into a Serialization object
  27630. * @returns the serialized object
  27631. */
  27632. serialize(): any;
  27633. private _syncActiveTargets;
  27634. /**
  27635. * Syncrhonize the targets with all the meshes using this morph target manager
  27636. */
  27637. synchronize(): void;
  27638. /**
  27639. * Creates a new MorphTargetManager from serialized data
  27640. * @param serializationObject defines the serialized data
  27641. * @param scene defines the hosting scene
  27642. * @returns the new MorphTargetManager
  27643. */
  27644. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27645. }
  27646. }
  27647. declare module "babylonjs/Meshes/meshLODLevel" {
  27648. import { Mesh } from "babylonjs/Meshes/mesh";
  27649. import { Nullable } from "babylonjs/types";
  27650. /**
  27651. * Class used to represent a specific level of detail of a mesh
  27652. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27653. */
  27654. export class MeshLODLevel {
  27655. /** Defines the distance where this level should start being displayed */
  27656. distance: number;
  27657. /** Defines the mesh to use to render this level */
  27658. mesh: Nullable<Mesh>;
  27659. /**
  27660. * Creates a new LOD level
  27661. * @param distance defines the distance where this level should star being displayed
  27662. * @param mesh defines the mesh to use to render this level
  27663. */
  27664. constructor(
  27665. /** Defines the distance where this level should start being displayed */
  27666. distance: number,
  27667. /** Defines the mesh to use to render this level */
  27668. mesh: Nullable<Mesh>);
  27669. }
  27670. }
  27671. declare module "babylonjs/Misc/canvasGenerator" {
  27672. /**
  27673. * Helper class used to generate a canvas to manipulate images
  27674. */
  27675. export class CanvasGenerator {
  27676. /**
  27677. * Create a new canvas (or offscreen canvas depending on the context)
  27678. * @param width defines the expected width
  27679. * @param height defines the expected height
  27680. * @return a new canvas or offscreen canvas
  27681. */
  27682. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27683. }
  27684. }
  27685. declare module "babylonjs/Meshes/groundMesh" {
  27686. import { Scene } from "babylonjs/scene";
  27687. import { Vector3 } from "babylonjs/Maths/math.vector";
  27688. import { Mesh } from "babylonjs/Meshes/mesh";
  27689. /**
  27690. * Mesh representing the gorund
  27691. */
  27692. export class GroundMesh extends Mesh {
  27693. /** If octree should be generated */
  27694. generateOctree: boolean;
  27695. private _heightQuads;
  27696. /** @hidden */
  27697. _subdivisionsX: number;
  27698. /** @hidden */
  27699. _subdivisionsY: number;
  27700. /** @hidden */
  27701. _width: number;
  27702. /** @hidden */
  27703. _height: number;
  27704. /** @hidden */
  27705. _minX: number;
  27706. /** @hidden */
  27707. _maxX: number;
  27708. /** @hidden */
  27709. _minZ: number;
  27710. /** @hidden */
  27711. _maxZ: number;
  27712. constructor(name: string, scene: Scene);
  27713. /**
  27714. * "GroundMesh"
  27715. * @returns "GroundMesh"
  27716. */
  27717. getClassName(): string;
  27718. /**
  27719. * The minimum of x and y subdivisions
  27720. */
  27721. get subdivisions(): number;
  27722. /**
  27723. * X subdivisions
  27724. */
  27725. get subdivisionsX(): number;
  27726. /**
  27727. * Y subdivisions
  27728. */
  27729. get subdivisionsY(): number;
  27730. /**
  27731. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27732. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27733. * @param chunksCount the number of subdivisions for x and y
  27734. * @param octreeBlocksSize (Default: 32)
  27735. */
  27736. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27737. /**
  27738. * Returns a height (y) value in the Worl system :
  27739. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27740. * @param x x coordinate
  27741. * @param z z coordinate
  27742. * @returns the ground y position if (x, z) are outside the ground surface.
  27743. */
  27744. getHeightAtCoordinates(x: number, z: number): number;
  27745. /**
  27746. * Returns a normalized vector (Vector3) orthogonal to the ground
  27747. * at the ground coordinates (x, z) expressed in the World system.
  27748. * @param x x coordinate
  27749. * @param z z coordinate
  27750. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27751. */
  27752. getNormalAtCoordinates(x: number, z: number): Vector3;
  27753. /**
  27754. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27755. * at the ground coordinates (x, z) expressed in the World system.
  27756. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27757. * @param x x coordinate
  27758. * @param z z coordinate
  27759. * @param ref vector to store the result
  27760. * @returns the GroundMesh.
  27761. */
  27762. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27763. /**
  27764. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27765. * if the ground has been updated.
  27766. * This can be used in the render loop.
  27767. * @returns the GroundMesh.
  27768. */
  27769. updateCoordinateHeights(): GroundMesh;
  27770. private _getFacetAt;
  27771. private _initHeightQuads;
  27772. private _computeHeightQuads;
  27773. /**
  27774. * Serializes this ground mesh
  27775. * @param serializationObject object to write serialization to
  27776. */
  27777. serialize(serializationObject: any): void;
  27778. /**
  27779. * Parses a serialized ground mesh
  27780. * @param parsedMesh the serialized mesh
  27781. * @param scene the scene to create the ground mesh in
  27782. * @returns the created ground mesh
  27783. */
  27784. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27785. }
  27786. }
  27787. declare module "babylonjs/Physics/physicsJoint" {
  27788. import { Vector3 } from "babylonjs/Maths/math.vector";
  27789. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27790. /**
  27791. * Interface for Physics-Joint data
  27792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27793. */
  27794. export interface PhysicsJointData {
  27795. /**
  27796. * The main pivot of the joint
  27797. */
  27798. mainPivot?: Vector3;
  27799. /**
  27800. * The connected pivot of the joint
  27801. */
  27802. connectedPivot?: Vector3;
  27803. /**
  27804. * The main axis of the joint
  27805. */
  27806. mainAxis?: Vector3;
  27807. /**
  27808. * The connected axis of the joint
  27809. */
  27810. connectedAxis?: Vector3;
  27811. /**
  27812. * The collision of the joint
  27813. */
  27814. collision?: boolean;
  27815. /**
  27816. * Native Oimo/Cannon/Energy data
  27817. */
  27818. nativeParams?: any;
  27819. }
  27820. /**
  27821. * This is a holder class for the physics joint created by the physics plugin
  27822. * It holds a set of functions to control the underlying joint
  27823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27824. */
  27825. export class PhysicsJoint {
  27826. /**
  27827. * The type of the physics joint
  27828. */
  27829. type: number;
  27830. /**
  27831. * The data for the physics joint
  27832. */
  27833. jointData: PhysicsJointData;
  27834. private _physicsJoint;
  27835. protected _physicsPlugin: IPhysicsEnginePlugin;
  27836. /**
  27837. * Initializes the physics joint
  27838. * @param type The type of the physics joint
  27839. * @param jointData The data for the physics joint
  27840. */
  27841. constructor(
  27842. /**
  27843. * The type of the physics joint
  27844. */
  27845. type: number,
  27846. /**
  27847. * The data for the physics joint
  27848. */
  27849. jointData: PhysicsJointData);
  27850. /**
  27851. * Gets the physics joint
  27852. */
  27853. get physicsJoint(): any;
  27854. /**
  27855. * Sets the physics joint
  27856. */
  27857. set physicsJoint(newJoint: any);
  27858. /**
  27859. * Sets the physics plugin
  27860. */
  27861. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27862. /**
  27863. * Execute a function that is physics-plugin specific.
  27864. * @param {Function} func the function that will be executed.
  27865. * It accepts two parameters: the physics world and the physics joint
  27866. */
  27867. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27868. /**
  27869. * Distance-Joint type
  27870. */
  27871. static DistanceJoint: number;
  27872. /**
  27873. * Hinge-Joint type
  27874. */
  27875. static HingeJoint: number;
  27876. /**
  27877. * Ball-and-Socket joint type
  27878. */
  27879. static BallAndSocketJoint: number;
  27880. /**
  27881. * Wheel-Joint type
  27882. */
  27883. static WheelJoint: number;
  27884. /**
  27885. * Slider-Joint type
  27886. */
  27887. static SliderJoint: number;
  27888. /**
  27889. * Prismatic-Joint type
  27890. */
  27891. static PrismaticJoint: number;
  27892. /**
  27893. * Universal-Joint type
  27894. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27895. */
  27896. static UniversalJoint: number;
  27897. /**
  27898. * Hinge-Joint 2 type
  27899. */
  27900. static Hinge2Joint: number;
  27901. /**
  27902. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27903. */
  27904. static PointToPointJoint: number;
  27905. /**
  27906. * Spring-Joint type
  27907. */
  27908. static SpringJoint: number;
  27909. /**
  27910. * Lock-Joint type
  27911. */
  27912. static LockJoint: number;
  27913. }
  27914. /**
  27915. * A class representing a physics distance joint
  27916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27917. */
  27918. export class DistanceJoint extends PhysicsJoint {
  27919. /**
  27920. *
  27921. * @param jointData The data for the Distance-Joint
  27922. */
  27923. constructor(jointData: DistanceJointData);
  27924. /**
  27925. * Update the predefined distance.
  27926. * @param maxDistance The maximum preferred distance
  27927. * @param minDistance The minimum preferred distance
  27928. */
  27929. updateDistance(maxDistance: number, minDistance?: number): void;
  27930. }
  27931. /**
  27932. * Represents a Motor-Enabled Joint
  27933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27934. */
  27935. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27936. /**
  27937. * Initializes the Motor-Enabled Joint
  27938. * @param type The type of the joint
  27939. * @param jointData The physica joint data for the joint
  27940. */
  27941. constructor(type: number, jointData: PhysicsJointData);
  27942. /**
  27943. * Set the motor values.
  27944. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27945. * @param force the force to apply
  27946. * @param maxForce max force for this motor.
  27947. */
  27948. setMotor(force?: number, maxForce?: number): void;
  27949. /**
  27950. * Set the motor's limits.
  27951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27952. * @param upperLimit The upper limit of the motor
  27953. * @param lowerLimit The lower limit of the motor
  27954. */
  27955. setLimit(upperLimit: number, lowerLimit?: number): void;
  27956. }
  27957. /**
  27958. * This class represents a single physics Hinge-Joint
  27959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27960. */
  27961. export class HingeJoint extends MotorEnabledJoint {
  27962. /**
  27963. * Initializes the Hinge-Joint
  27964. * @param jointData The joint data for the Hinge-Joint
  27965. */
  27966. constructor(jointData: PhysicsJointData);
  27967. /**
  27968. * Set the motor values.
  27969. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27970. * @param {number} force the force to apply
  27971. * @param {number} maxForce max force for this motor.
  27972. */
  27973. setMotor(force?: number, maxForce?: number): void;
  27974. /**
  27975. * Set the motor's limits.
  27976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27977. * @param upperLimit The upper limit of the motor
  27978. * @param lowerLimit The lower limit of the motor
  27979. */
  27980. setLimit(upperLimit: number, lowerLimit?: number): void;
  27981. }
  27982. /**
  27983. * This class represents a dual hinge physics joint (same as wheel joint)
  27984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27985. */
  27986. export class Hinge2Joint extends MotorEnabledJoint {
  27987. /**
  27988. * Initializes the Hinge2-Joint
  27989. * @param jointData The joint data for the Hinge2-Joint
  27990. */
  27991. constructor(jointData: PhysicsJointData);
  27992. /**
  27993. * Set the motor values.
  27994. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27995. * @param {number} targetSpeed the speed the motor is to reach
  27996. * @param {number} maxForce max force for this motor.
  27997. * @param {motorIndex} the motor's index, 0 or 1.
  27998. */
  27999. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28000. /**
  28001. * Set the motor limits.
  28002. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28003. * @param {number} upperLimit the upper limit
  28004. * @param {number} lowerLimit lower limit
  28005. * @param {motorIndex} the motor's index, 0 or 1.
  28006. */
  28007. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28008. }
  28009. /**
  28010. * Interface for a motor enabled joint
  28011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28012. */
  28013. export interface IMotorEnabledJoint {
  28014. /**
  28015. * Physics joint
  28016. */
  28017. physicsJoint: any;
  28018. /**
  28019. * Sets the motor of the motor-enabled joint
  28020. * @param force The force of the motor
  28021. * @param maxForce The maximum force of the motor
  28022. * @param motorIndex The index of the motor
  28023. */
  28024. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28025. /**
  28026. * Sets the limit of the motor
  28027. * @param upperLimit The upper limit of the motor
  28028. * @param lowerLimit The lower limit of the motor
  28029. * @param motorIndex The index of the motor
  28030. */
  28031. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28032. }
  28033. /**
  28034. * Joint data for a Distance-Joint
  28035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28036. */
  28037. export interface DistanceJointData extends PhysicsJointData {
  28038. /**
  28039. * Max distance the 2 joint objects can be apart
  28040. */
  28041. maxDistance: number;
  28042. }
  28043. /**
  28044. * Joint data from a spring joint
  28045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28046. */
  28047. export interface SpringJointData extends PhysicsJointData {
  28048. /**
  28049. * Length of the spring
  28050. */
  28051. length: number;
  28052. /**
  28053. * Stiffness of the spring
  28054. */
  28055. stiffness: number;
  28056. /**
  28057. * Damping of the spring
  28058. */
  28059. damping: number;
  28060. /** this callback will be called when applying the force to the impostors. */
  28061. forceApplicationCallback: () => void;
  28062. }
  28063. }
  28064. declare module "babylonjs/Physics/physicsRaycastResult" {
  28065. import { Vector3 } from "babylonjs/Maths/math.vector";
  28066. /**
  28067. * Holds the data for the raycast result
  28068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28069. */
  28070. export class PhysicsRaycastResult {
  28071. private _hasHit;
  28072. private _hitDistance;
  28073. private _hitNormalWorld;
  28074. private _hitPointWorld;
  28075. private _rayFromWorld;
  28076. private _rayToWorld;
  28077. /**
  28078. * Gets if there was a hit
  28079. */
  28080. get hasHit(): boolean;
  28081. /**
  28082. * Gets the distance from the hit
  28083. */
  28084. get hitDistance(): number;
  28085. /**
  28086. * Gets the hit normal/direction in the world
  28087. */
  28088. get hitNormalWorld(): Vector3;
  28089. /**
  28090. * Gets the hit point in the world
  28091. */
  28092. get hitPointWorld(): Vector3;
  28093. /**
  28094. * Gets the ray "start point" of the ray in the world
  28095. */
  28096. get rayFromWorld(): Vector3;
  28097. /**
  28098. * Gets the ray "end point" of the ray in the world
  28099. */
  28100. get rayToWorld(): Vector3;
  28101. /**
  28102. * Sets the hit data (normal & point in world space)
  28103. * @param hitNormalWorld defines the normal in world space
  28104. * @param hitPointWorld defines the point in world space
  28105. */
  28106. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28107. /**
  28108. * Sets the distance from the start point to the hit point
  28109. * @param distance
  28110. */
  28111. setHitDistance(distance: number): void;
  28112. /**
  28113. * Calculates the distance manually
  28114. */
  28115. calculateHitDistance(): void;
  28116. /**
  28117. * Resets all the values to default
  28118. * @param from The from point on world space
  28119. * @param to The to point on world space
  28120. */
  28121. reset(from?: Vector3, to?: Vector3): void;
  28122. }
  28123. /**
  28124. * Interface for the size containing width and height
  28125. */
  28126. interface IXYZ {
  28127. /**
  28128. * X
  28129. */
  28130. x: number;
  28131. /**
  28132. * Y
  28133. */
  28134. y: number;
  28135. /**
  28136. * Z
  28137. */
  28138. z: number;
  28139. }
  28140. }
  28141. declare module "babylonjs/Physics/IPhysicsEngine" {
  28142. import { Nullable } from "babylonjs/types";
  28143. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28145. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28146. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28147. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28148. /**
  28149. * Interface used to describe a physics joint
  28150. */
  28151. export interface PhysicsImpostorJoint {
  28152. /** Defines the main impostor to which the joint is linked */
  28153. mainImpostor: PhysicsImpostor;
  28154. /** Defines the impostor that is connected to the main impostor using this joint */
  28155. connectedImpostor: PhysicsImpostor;
  28156. /** Defines the joint itself */
  28157. joint: PhysicsJoint;
  28158. }
  28159. /** @hidden */
  28160. export interface IPhysicsEnginePlugin {
  28161. world: any;
  28162. name: string;
  28163. setGravity(gravity: Vector3): void;
  28164. setTimeStep(timeStep: number): void;
  28165. getTimeStep(): number;
  28166. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28170. removePhysicsBody(impostor: PhysicsImpostor): void;
  28171. generateJoint(joint: PhysicsImpostorJoint): void;
  28172. removeJoint(joint: PhysicsImpostorJoint): void;
  28173. isSupported(): boolean;
  28174. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28175. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28177. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28179. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28180. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28181. getBodyMass(impostor: PhysicsImpostor): number;
  28182. getBodyFriction(impostor: PhysicsImpostor): number;
  28183. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28184. getBodyRestitution(impostor: PhysicsImpostor): number;
  28185. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28186. getBodyPressure?(impostor: PhysicsImpostor): number;
  28187. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28188. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28189. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28190. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28191. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28192. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28193. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28194. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28195. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28196. sleepBody(impostor: PhysicsImpostor): void;
  28197. wakeUpBody(impostor: PhysicsImpostor): void;
  28198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28200. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28202. getRadius(impostor: PhysicsImpostor): number;
  28203. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28204. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28205. dispose(): void;
  28206. }
  28207. /**
  28208. * Interface used to define a physics engine
  28209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28210. */
  28211. export interface IPhysicsEngine {
  28212. /**
  28213. * Gets the gravity vector used by the simulation
  28214. */
  28215. gravity: Vector3;
  28216. /**
  28217. * Sets the gravity vector used by the simulation
  28218. * @param gravity defines the gravity vector to use
  28219. */
  28220. setGravity(gravity: Vector3): void;
  28221. /**
  28222. * Set the time step of the physics engine.
  28223. * Default is 1/60.
  28224. * To slow it down, enter 1/600 for example.
  28225. * To speed it up, 1/30
  28226. * @param newTimeStep the new timestep to apply to this world.
  28227. */
  28228. setTimeStep(newTimeStep: number): void;
  28229. /**
  28230. * Get the time step of the physics engine.
  28231. * @returns the current time step
  28232. */
  28233. getTimeStep(): number;
  28234. /**
  28235. * Set the sub time step of the physics engine.
  28236. * Default is 0 meaning there is no sub steps
  28237. * To increase physics resolution precision, set a small value (like 1 ms)
  28238. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28239. */
  28240. setSubTimeStep(subTimeStep: number): void;
  28241. /**
  28242. * Get the sub time step of the physics engine.
  28243. * @returns the current sub time step
  28244. */
  28245. getSubTimeStep(): number;
  28246. /**
  28247. * Release all resources
  28248. */
  28249. dispose(): void;
  28250. /**
  28251. * Gets the name of the current physics plugin
  28252. * @returns the name of the plugin
  28253. */
  28254. getPhysicsPluginName(): string;
  28255. /**
  28256. * Adding a new impostor for the impostor tracking.
  28257. * This will be done by the impostor itself.
  28258. * @param impostor the impostor to add
  28259. */
  28260. addImpostor(impostor: PhysicsImpostor): void;
  28261. /**
  28262. * Remove an impostor from the engine.
  28263. * This impostor and its mesh will not longer be updated by the physics engine.
  28264. * @param impostor the impostor to remove
  28265. */
  28266. removeImpostor(impostor: PhysicsImpostor): void;
  28267. /**
  28268. * Add a joint to the physics engine
  28269. * @param mainImpostor defines the main impostor to which the joint is added.
  28270. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28271. * @param joint defines the joint that will connect both impostors.
  28272. */
  28273. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28274. /**
  28275. * Removes a joint from the simulation
  28276. * @param mainImpostor defines the impostor used with the joint
  28277. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28278. * @param joint defines the joint to remove
  28279. */
  28280. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28281. /**
  28282. * Gets the current plugin used to run the simulation
  28283. * @returns current plugin
  28284. */
  28285. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28286. /**
  28287. * Gets the list of physic impostors
  28288. * @returns an array of PhysicsImpostor
  28289. */
  28290. getImpostors(): Array<PhysicsImpostor>;
  28291. /**
  28292. * Gets the impostor for a physics enabled object
  28293. * @param object defines the object impersonated by the impostor
  28294. * @returns the PhysicsImpostor or null if not found
  28295. */
  28296. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28297. /**
  28298. * Gets the impostor for a physics body object
  28299. * @param body defines physics body used by the impostor
  28300. * @returns the PhysicsImpostor or null if not found
  28301. */
  28302. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28303. /**
  28304. * Does a raycast in the physics world
  28305. * @param from when should the ray start?
  28306. * @param to when should the ray end?
  28307. * @returns PhysicsRaycastResult
  28308. */
  28309. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28310. /**
  28311. * Called by the scene. No need to call it.
  28312. * @param delta defines the timespam between frames
  28313. */
  28314. _step(delta: number): void;
  28315. }
  28316. }
  28317. declare module "babylonjs/Physics/physicsImpostor" {
  28318. import { Nullable, IndicesArray } from "babylonjs/types";
  28319. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28320. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28322. import { Scene } from "babylonjs/scene";
  28323. import { Bone } from "babylonjs/Bones/bone";
  28324. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28325. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28326. import { Space } from "babylonjs/Maths/math.axis";
  28327. /**
  28328. * The interface for the physics imposter parameters
  28329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28330. */
  28331. export interface PhysicsImpostorParameters {
  28332. /**
  28333. * The mass of the physics imposter
  28334. */
  28335. mass: number;
  28336. /**
  28337. * The friction of the physics imposter
  28338. */
  28339. friction?: number;
  28340. /**
  28341. * The coefficient of restitution of the physics imposter
  28342. */
  28343. restitution?: number;
  28344. /**
  28345. * The native options of the physics imposter
  28346. */
  28347. nativeOptions?: any;
  28348. /**
  28349. * Specifies if the parent should be ignored
  28350. */
  28351. ignoreParent?: boolean;
  28352. /**
  28353. * Specifies if bi-directional transformations should be disabled
  28354. */
  28355. disableBidirectionalTransformation?: boolean;
  28356. /**
  28357. * The pressure inside the physics imposter, soft object only
  28358. */
  28359. pressure?: number;
  28360. /**
  28361. * The stiffness the physics imposter, soft object only
  28362. */
  28363. stiffness?: number;
  28364. /**
  28365. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28366. */
  28367. velocityIterations?: number;
  28368. /**
  28369. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28370. */
  28371. positionIterations?: number;
  28372. /**
  28373. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28374. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28375. * Add to fix multiple points
  28376. */
  28377. fixedPoints?: number;
  28378. /**
  28379. * The collision margin around a soft object
  28380. */
  28381. margin?: number;
  28382. /**
  28383. * The collision margin around a soft object
  28384. */
  28385. damping?: number;
  28386. /**
  28387. * The path for a rope based on an extrusion
  28388. */
  28389. path?: any;
  28390. /**
  28391. * The shape of an extrusion used for a rope based on an extrusion
  28392. */
  28393. shape?: any;
  28394. }
  28395. /**
  28396. * Interface for a physics-enabled object
  28397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28398. */
  28399. export interface IPhysicsEnabledObject {
  28400. /**
  28401. * The position of the physics-enabled object
  28402. */
  28403. position: Vector3;
  28404. /**
  28405. * The rotation of the physics-enabled object
  28406. */
  28407. rotationQuaternion: Nullable<Quaternion>;
  28408. /**
  28409. * The scale of the physics-enabled object
  28410. */
  28411. scaling: Vector3;
  28412. /**
  28413. * The rotation of the physics-enabled object
  28414. */
  28415. rotation?: Vector3;
  28416. /**
  28417. * The parent of the physics-enabled object
  28418. */
  28419. parent?: any;
  28420. /**
  28421. * The bounding info of the physics-enabled object
  28422. * @returns The bounding info of the physics-enabled object
  28423. */
  28424. getBoundingInfo(): BoundingInfo;
  28425. /**
  28426. * Computes the world matrix
  28427. * @param force Specifies if the world matrix should be computed by force
  28428. * @returns A world matrix
  28429. */
  28430. computeWorldMatrix(force: boolean): Matrix;
  28431. /**
  28432. * Gets the world matrix
  28433. * @returns A world matrix
  28434. */
  28435. getWorldMatrix?(): Matrix;
  28436. /**
  28437. * Gets the child meshes
  28438. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28439. * @returns An array of abstract meshes
  28440. */
  28441. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28442. /**
  28443. * Gets the vertex data
  28444. * @param kind The type of vertex data
  28445. * @returns A nullable array of numbers, or a float32 array
  28446. */
  28447. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28448. /**
  28449. * Gets the indices from the mesh
  28450. * @returns A nullable array of index arrays
  28451. */
  28452. getIndices?(): Nullable<IndicesArray>;
  28453. /**
  28454. * Gets the scene from the mesh
  28455. * @returns the indices array or null
  28456. */
  28457. getScene?(): Scene;
  28458. /**
  28459. * Gets the absolute position from the mesh
  28460. * @returns the absolute position
  28461. */
  28462. getAbsolutePosition(): Vector3;
  28463. /**
  28464. * Gets the absolute pivot point from the mesh
  28465. * @returns the absolute pivot point
  28466. */
  28467. getAbsolutePivotPoint(): Vector3;
  28468. /**
  28469. * Rotates the mesh
  28470. * @param axis The axis of rotation
  28471. * @param amount The amount of rotation
  28472. * @param space The space of the rotation
  28473. * @returns The rotation transform node
  28474. */
  28475. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28476. /**
  28477. * Translates the mesh
  28478. * @param axis The axis of translation
  28479. * @param distance The distance of translation
  28480. * @param space The space of the translation
  28481. * @returns The transform node
  28482. */
  28483. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28484. /**
  28485. * Sets the absolute position of the mesh
  28486. * @param absolutePosition The absolute position of the mesh
  28487. * @returns The transform node
  28488. */
  28489. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28490. /**
  28491. * Gets the class name of the mesh
  28492. * @returns The class name
  28493. */
  28494. getClassName(): string;
  28495. }
  28496. /**
  28497. * Represents a physics imposter
  28498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28499. */
  28500. export class PhysicsImpostor {
  28501. /**
  28502. * The physics-enabled object used as the physics imposter
  28503. */
  28504. object: IPhysicsEnabledObject;
  28505. /**
  28506. * The type of the physics imposter
  28507. */
  28508. type: number;
  28509. private _options;
  28510. private _scene?;
  28511. /**
  28512. * The default object size of the imposter
  28513. */
  28514. static DEFAULT_OBJECT_SIZE: Vector3;
  28515. /**
  28516. * The identity quaternion of the imposter
  28517. */
  28518. static IDENTITY_QUATERNION: Quaternion;
  28519. /** @hidden */
  28520. _pluginData: any;
  28521. private _physicsEngine;
  28522. private _physicsBody;
  28523. private _bodyUpdateRequired;
  28524. private _onBeforePhysicsStepCallbacks;
  28525. private _onAfterPhysicsStepCallbacks;
  28526. /** @hidden */
  28527. _onPhysicsCollideCallbacks: Array<{
  28528. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28529. otherImpostors: Array<PhysicsImpostor>;
  28530. }>;
  28531. private _deltaPosition;
  28532. private _deltaRotation;
  28533. private _deltaRotationConjugated;
  28534. /** @hidden */
  28535. _isFromLine: boolean;
  28536. private _parent;
  28537. private _isDisposed;
  28538. private static _tmpVecs;
  28539. private static _tmpQuat;
  28540. /**
  28541. * Specifies if the physics imposter is disposed
  28542. */
  28543. get isDisposed(): boolean;
  28544. /**
  28545. * Gets the mass of the physics imposter
  28546. */
  28547. get mass(): number;
  28548. set mass(value: number);
  28549. /**
  28550. * Gets the coefficient of friction
  28551. */
  28552. get friction(): number;
  28553. /**
  28554. * Sets the coefficient of friction
  28555. */
  28556. set friction(value: number);
  28557. /**
  28558. * Gets the coefficient of restitution
  28559. */
  28560. get restitution(): number;
  28561. /**
  28562. * Sets the coefficient of restitution
  28563. */
  28564. set restitution(value: number);
  28565. /**
  28566. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28567. */
  28568. get pressure(): number;
  28569. /**
  28570. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28571. */
  28572. set pressure(value: number);
  28573. /**
  28574. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28575. */
  28576. get stiffness(): number;
  28577. /**
  28578. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28579. */
  28580. set stiffness(value: number);
  28581. /**
  28582. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28583. */
  28584. get velocityIterations(): number;
  28585. /**
  28586. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28587. */
  28588. set velocityIterations(value: number);
  28589. /**
  28590. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28591. */
  28592. get positionIterations(): number;
  28593. /**
  28594. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28595. */
  28596. set positionIterations(value: number);
  28597. /**
  28598. * The unique id of the physics imposter
  28599. * set by the physics engine when adding this impostor to the array
  28600. */
  28601. uniqueId: number;
  28602. /**
  28603. * @hidden
  28604. */
  28605. soft: boolean;
  28606. /**
  28607. * @hidden
  28608. */
  28609. segments: number;
  28610. private _joints;
  28611. /**
  28612. * Initializes the physics imposter
  28613. * @param object The physics-enabled object used as the physics imposter
  28614. * @param type The type of the physics imposter
  28615. * @param _options The options for the physics imposter
  28616. * @param _scene The Babylon scene
  28617. */
  28618. constructor(
  28619. /**
  28620. * The physics-enabled object used as the physics imposter
  28621. */
  28622. object: IPhysicsEnabledObject,
  28623. /**
  28624. * The type of the physics imposter
  28625. */
  28626. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28627. /**
  28628. * This function will completly initialize this impostor.
  28629. * It will create a new body - but only if this mesh has no parent.
  28630. * If it has, this impostor will not be used other than to define the impostor
  28631. * of the child mesh.
  28632. * @hidden
  28633. */
  28634. _init(): void;
  28635. private _getPhysicsParent;
  28636. /**
  28637. * Should a new body be generated.
  28638. * @returns boolean specifying if body initialization is required
  28639. */
  28640. isBodyInitRequired(): boolean;
  28641. /**
  28642. * Sets the updated scaling
  28643. * @param updated Specifies if the scaling is updated
  28644. */
  28645. setScalingUpdated(): void;
  28646. /**
  28647. * Force a regeneration of this or the parent's impostor's body.
  28648. * Use under cautious - This will remove all joints already implemented.
  28649. */
  28650. forceUpdate(): void;
  28651. /**
  28652. * Gets the body that holds this impostor. Either its own, or its parent.
  28653. */
  28654. get physicsBody(): any;
  28655. /**
  28656. * Get the parent of the physics imposter
  28657. * @returns Physics imposter or null
  28658. */
  28659. get parent(): Nullable<PhysicsImpostor>;
  28660. /**
  28661. * Sets the parent of the physics imposter
  28662. */
  28663. set parent(value: Nullable<PhysicsImpostor>);
  28664. /**
  28665. * Set the physics body. Used mainly by the physics engine/plugin
  28666. */
  28667. set physicsBody(physicsBody: any);
  28668. /**
  28669. * Resets the update flags
  28670. */
  28671. resetUpdateFlags(): void;
  28672. /**
  28673. * Gets the object extend size
  28674. * @returns the object extend size
  28675. */
  28676. getObjectExtendSize(): Vector3;
  28677. /**
  28678. * Gets the object center
  28679. * @returns The object center
  28680. */
  28681. getObjectCenter(): Vector3;
  28682. /**
  28683. * Get a specific parameter from the options parameters
  28684. * @param paramName The object parameter name
  28685. * @returns The object parameter
  28686. */
  28687. getParam(paramName: string): any;
  28688. /**
  28689. * Sets a specific parameter in the options given to the physics plugin
  28690. * @param paramName The parameter name
  28691. * @param value The value of the parameter
  28692. */
  28693. setParam(paramName: string, value: number): void;
  28694. /**
  28695. * Specifically change the body's mass option. Won't recreate the physics body object
  28696. * @param mass The mass of the physics imposter
  28697. */
  28698. setMass(mass: number): void;
  28699. /**
  28700. * Gets the linear velocity
  28701. * @returns linear velocity or null
  28702. */
  28703. getLinearVelocity(): Nullable<Vector3>;
  28704. /**
  28705. * Sets the linear velocity
  28706. * @param velocity linear velocity or null
  28707. */
  28708. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28709. /**
  28710. * Gets the angular velocity
  28711. * @returns angular velocity or null
  28712. */
  28713. getAngularVelocity(): Nullable<Vector3>;
  28714. /**
  28715. * Sets the angular velocity
  28716. * @param velocity The velocity or null
  28717. */
  28718. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28719. /**
  28720. * Execute a function with the physics plugin native code
  28721. * Provide a function the will have two variables - the world object and the physics body object
  28722. * @param func The function to execute with the physics plugin native code
  28723. */
  28724. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28725. /**
  28726. * Register a function that will be executed before the physics world is stepping forward
  28727. * @param func The function to execute before the physics world is stepped forward
  28728. */
  28729. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28730. /**
  28731. * Unregister a function that will be executed before the physics world is stepping forward
  28732. * @param func The function to execute before the physics world is stepped forward
  28733. */
  28734. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28735. /**
  28736. * Register a function that will be executed after the physics step
  28737. * @param func The function to execute after physics step
  28738. */
  28739. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28740. /**
  28741. * Unregisters a function that will be executed after the physics step
  28742. * @param func The function to execute after physics step
  28743. */
  28744. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28745. /**
  28746. * register a function that will be executed when this impostor collides against a different body
  28747. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28748. * @param func Callback that is executed on collision
  28749. */
  28750. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28751. /**
  28752. * Unregisters the physics imposter on contact
  28753. * @param collideAgainst The physics object to collide against
  28754. * @param func Callback to execute on collision
  28755. */
  28756. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28757. private _tmpQuat;
  28758. private _tmpQuat2;
  28759. /**
  28760. * Get the parent rotation
  28761. * @returns The parent rotation
  28762. */
  28763. getParentsRotation(): Quaternion;
  28764. /**
  28765. * this function is executed by the physics engine.
  28766. */
  28767. beforeStep: () => void;
  28768. /**
  28769. * this function is executed by the physics engine
  28770. */
  28771. afterStep: () => void;
  28772. /**
  28773. * Legacy collision detection event support
  28774. */
  28775. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28776. /**
  28777. * event and body object due to cannon's event-based architecture.
  28778. */
  28779. onCollide: (e: {
  28780. body: any;
  28781. }) => void;
  28782. /**
  28783. * Apply a force
  28784. * @param force The force to apply
  28785. * @param contactPoint The contact point for the force
  28786. * @returns The physics imposter
  28787. */
  28788. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28789. /**
  28790. * Apply an impulse
  28791. * @param force The impulse force
  28792. * @param contactPoint The contact point for the impulse force
  28793. * @returns The physics imposter
  28794. */
  28795. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28796. /**
  28797. * A help function to create a joint
  28798. * @param otherImpostor A physics imposter used to create a joint
  28799. * @param jointType The type of joint
  28800. * @param jointData The data for the joint
  28801. * @returns The physics imposter
  28802. */
  28803. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28804. /**
  28805. * Add a joint to this impostor with a different impostor
  28806. * @param otherImpostor A physics imposter used to add a joint
  28807. * @param joint The joint to add
  28808. * @returns The physics imposter
  28809. */
  28810. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28811. /**
  28812. * Add an anchor to a cloth impostor
  28813. * @param otherImpostor rigid impostor to anchor to
  28814. * @param width ratio across width from 0 to 1
  28815. * @param height ratio up height from 0 to 1
  28816. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28817. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28818. * @returns impostor the soft imposter
  28819. */
  28820. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28821. /**
  28822. * Add a hook to a rope impostor
  28823. * @param otherImpostor rigid impostor to anchor to
  28824. * @param length ratio across rope from 0 to 1
  28825. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28826. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28827. * @returns impostor the rope imposter
  28828. */
  28829. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28830. /**
  28831. * Will keep this body still, in a sleep mode.
  28832. * @returns the physics imposter
  28833. */
  28834. sleep(): PhysicsImpostor;
  28835. /**
  28836. * Wake the body up.
  28837. * @returns The physics imposter
  28838. */
  28839. wakeUp(): PhysicsImpostor;
  28840. /**
  28841. * Clones the physics imposter
  28842. * @param newObject The physics imposter clones to this physics-enabled object
  28843. * @returns A nullable physics imposter
  28844. */
  28845. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28846. /**
  28847. * Disposes the physics imposter
  28848. */
  28849. dispose(): void;
  28850. /**
  28851. * Sets the delta position
  28852. * @param position The delta position amount
  28853. */
  28854. setDeltaPosition(position: Vector3): void;
  28855. /**
  28856. * Sets the delta rotation
  28857. * @param rotation The delta rotation amount
  28858. */
  28859. setDeltaRotation(rotation: Quaternion): void;
  28860. /**
  28861. * Gets the box size of the physics imposter and stores the result in the input parameter
  28862. * @param result Stores the box size
  28863. * @returns The physics imposter
  28864. */
  28865. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28866. /**
  28867. * Gets the radius of the physics imposter
  28868. * @returns Radius of the physics imposter
  28869. */
  28870. getRadius(): number;
  28871. /**
  28872. * Sync a bone with this impostor
  28873. * @param bone The bone to sync to the impostor.
  28874. * @param boneMesh The mesh that the bone is influencing.
  28875. * @param jointPivot The pivot of the joint / bone in local space.
  28876. * @param distToJoint Optional distance from the impostor to the joint.
  28877. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28878. */
  28879. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28880. /**
  28881. * Sync impostor to a bone
  28882. * @param bone The bone that the impostor will be synced to.
  28883. * @param boneMesh The mesh that the bone is influencing.
  28884. * @param jointPivot The pivot of the joint / bone in local space.
  28885. * @param distToJoint Optional distance from the impostor to the joint.
  28886. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28887. * @param boneAxis Optional vector3 axis the bone is aligned with
  28888. */
  28889. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28890. /**
  28891. * No-Imposter type
  28892. */
  28893. static NoImpostor: number;
  28894. /**
  28895. * Sphere-Imposter type
  28896. */
  28897. static SphereImpostor: number;
  28898. /**
  28899. * Box-Imposter type
  28900. */
  28901. static BoxImpostor: number;
  28902. /**
  28903. * Plane-Imposter type
  28904. */
  28905. static PlaneImpostor: number;
  28906. /**
  28907. * Mesh-imposter type
  28908. */
  28909. static MeshImpostor: number;
  28910. /**
  28911. * Capsule-Impostor type (Ammo.js plugin only)
  28912. */
  28913. static CapsuleImpostor: number;
  28914. /**
  28915. * Cylinder-Imposter type
  28916. */
  28917. static CylinderImpostor: number;
  28918. /**
  28919. * Particle-Imposter type
  28920. */
  28921. static ParticleImpostor: number;
  28922. /**
  28923. * Heightmap-Imposter type
  28924. */
  28925. static HeightmapImpostor: number;
  28926. /**
  28927. * ConvexHull-Impostor type (Ammo.js plugin only)
  28928. */
  28929. static ConvexHullImpostor: number;
  28930. /**
  28931. * Custom-Imposter type (Ammo.js plugin only)
  28932. */
  28933. static CustomImpostor: number;
  28934. /**
  28935. * Rope-Imposter type
  28936. */
  28937. static RopeImpostor: number;
  28938. /**
  28939. * Cloth-Imposter type
  28940. */
  28941. static ClothImpostor: number;
  28942. /**
  28943. * Softbody-Imposter type
  28944. */
  28945. static SoftbodyImpostor: number;
  28946. }
  28947. }
  28948. declare module "babylonjs/Meshes/mesh" {
  28949. import { Observable } from "babylonjs/Misc/observable";
  28950. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28951. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28952. import { Camera } from "babylonjs/Cameras/camera";
  28953. import { Scene } from "babylonjs/scene";
  28954. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28955. import { Color4 } from "babylonjs/Maths/math.color";
  28956. import { Engine } from "babylonjs/Engines/engine";
  28957. import { Node } from "babylonjs/node";
  28958. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28959. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28960. import { Buffer } from "babylonjs/Meshes/buffer";
  28961. import { Geometry } from "babylonjs/Meshes/geometry";
  28962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28963. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28964. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28965. import { Effect } from "babylonjs/Materials/effect";
  28966. import { Material } from "babylonjs/Materials/material";
  28967. import { Skeleton } from "babylonjs/Bones/skeleton";
  28968. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28969. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28970. import { Path3D } from "babylonjs/Maths/math.path";
  28971. import { Plane } from "babylonjs/Maths/math.plane";
  28972. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28973. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28974. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28975. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28976. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28977. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28978. /**
  28979. * @hidden
  28980. **/
  28981. export class _CreationDataStorage {
  28982. closePath?: boolean;
  28983. closeArray?: boolean;
  28984. idx: number[];
  28985. dashSize: number;
  28986. gapSize: number;
  28987. path3D: Path3D;
  28988. pathArray: Vector3[][];
  28989. arc: number;
  28990. radius: number;
  28991. cap: number;
  28992. tessellation: number;
  28993. }
  28994. /**
  28995. * @hidden
  28996. **/
  28997. class _InstanceDataStorage {
  28998. visibleInstances: any;
  28999. batchCache: _InstancesBatch;
  29000. instancesBufferSize: number;
  29001. instancesBuffer: Nullable<Buffer>;
  29002. instancesData: Float32Array;
  29003. overridenInstanceCount: number;
  29004. isFrozen: boolean;
  29005. previousBatch: Nullable<_InstancesBatch>;
  29006. hardwareInstancedRendering: boolean;
  29007. sideOrientation: number;
  29008. manualUpdate: boolean;
  29009. }
  29010. /**
  29011. * @hidden
  29012. **/
  29013. export class _InstancesBatch {
  29014. mustReturn: boolean;
  29015. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29016. renderSelf: boolean[];
  29017. hardwareInstancedRendering: boolean[];
  29018. }
  29019. /**
  29020. * @hidden
  29021. **/
  29022. class _ThinInstanceDataStorage {
  29023. instancesCount: number;
  29024. matrixBuffer: Nullable<Buffer>;
  29025. matrixBufferSize: number;
  29026. matrixData: Nullable<Float32Array>;
  29027. boundingVectors: Array<Vector3>;
  29028. worldMatrices: Nullable<Matrix[]>;
  29029. }
  29030. /**
  29031. * Class used to represent renderable models
  29032. */
  29033. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29034. /**
  29035. * Mesh side orientation : usually the external or front surface
  29036. */
  29037. static readonly FRONTSIDE: number;
  29038. /**
  29039. * Mesh side orientation : usually the internal or back surface
  29040. */
  29041. static readonly BACKSIDE: number;
  29042. /**
  29043. * Mesh side orientation : both internal and external or front and back surfaces
  29044. */
  29045. static readonly DOUBLESIDE: number;
  29046. /**
  29047. * Mesh side orientation : by default, `FRONTSIDE`
  29048. */
  29049. static readonly DEFAULTSIDE: number;
  29050. /**
  29051. * Mesh cap setting : no cap
  29052. */
  29053. static readonly NO_CAP: number;
  29054. /**
  29055. * Mesh cap setting : one cap at the beginning of the mesh
  29056. */
  29057. static readonly CAP_START: number;
  29058. /**
  29059. * Mesh cap setting : one cap at the end of the mesh
  29060. */
  29061. static readonly CAP_END: number;
  29062. /**
  29063. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29064. */
  29065. static readonly CAP_ALL: number;
  29066. /**
  29067. * Mesh pattern setting : no flip or rotate
  29068. */
  29069. static readonly NO_FLIP: number;
  29070. /**
  29071. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29072. */
  29073. static readonly FLIP_TILE: number;
  29074. /**
  29075. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29076. */
  29077. static readonly ROTATE_TILE: number;
  29078. /**
  29079. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29080. */
  29081. static readonly FLIP_ROW: number;
  29082. /**
  29083. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29084. */
  29085. static readonly ROTATE_ROW: number;
  29086. /**
  29087. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29088. */
  29089. static readonly FLIP_N_ROTATE_TILE: number;
  29090. /**
  29091. * Mesh pattern setting : rotate pattern and rotate
  29092. */
  29093. static readonly FLIP_N_ROTATE_ROW: number;
  29094. /**
  29095. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29096. */
  29097. static readonly CENTER: number;
  29098. /**
  29099. * Mesh tile positioning : part tiles on left
  29100. */
  29101. static readonly LEFT: number;
  29102. /**
  29103. * Mesh tile positioning : part tiles on right
  29104. */
  29105. static readonly RIGHT: number;
  29106. /**
  29107. * Mesh tile positioning : part tiles on top
  29108. */
  29109. static readonly TOP: number;
  29110. /**
  29111. * Mesh tile positioning : part tiles on bottom
  29112. */
  29113. static readonly BOTTOM: number;
  29114. /**
  29115. * Gets the default side orientation.
  29116. * @param orientation the orientation to value to attempt to get
  29117. * @returns the default orientation
  29118. * @hidden
  29119. */
  29120. static _GetDefaultSideOrientation(orientation?: number): number;
  29121. private _internalMeshDataInfo;
  29122. get computeBonesUsingShaders(): boolean;
  29123. set computeBonesUsingShaders(value: boolean);
  29124. /**
  29125. * An event triggered before rendering the mesh
  29126. */
  29127. get onBeforeRenderObservable(): Observable<Mesh>;
  29128. /**
  29129. * An event triggered before binding the mesh
  29130. */
  29131. get onBeforeBindObservable(): Observable<Mesh>;
  29132. /**
  29133. * An event triggered after rendering the mesh
  29134. */
  29135. get onAfterRenderObservable(): Observable<Mesh>;
  29136. /**
  29137. * An event triggered before drawing the mesh
  29138. */
  29139. get onBeforeDrawObservable(): Observable<Mesh>;
  29140. private _onBeforeDrawObserver;
  29141. /**
  29142. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29143. */
  29144. set onBeforeDraw(callback: () => void);
  29145. get hasInstances(): boolean;
  29146. get hasThinInstances(): boolean;
  29147. /**
  29148. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29149. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29150. */
  29151. delayLoadState: number;
  29152. /**
  29153. * Gets the list of instances created from this mesh
  29154. * it is not supposed to be modified manually.
  29155. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29156. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29157. */
  29158. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29159. /**
  29160. * Gets the file containing delay loading data for this mesh
  29161. */
  29162. delayLoadingFile: string;
  29163. /** @hidden */
  29164. _binaryInfo: any;
  29165. /**
  29166. * User defined function used to change how LOD level selection is done
  29167. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29168. */
  29169. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29170. /**
  29171. * Gets or sets the morph target manager
  29172. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29173. */
  29174. get morphTargetManager(): Nullable<MorphTargetManager>;
  29175. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29176. /** @hidden */
  29177. _creationDataStorage: Nullable<_CreationDataStorage>;
  29178. /** @hidden */
  29179. _geometry: Nullable<Geometry>;
  29180. /** @hidden */
  29181. _delayInfo: Array<string>;
  29182. /** @hidden */
  29183. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29184. /** @hidden */
  29185. _instanceDataStorage: _InstanceDataStorage;
  29186. /** @hidden */
  29187. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29188. private _effectiveMaterial;
  29189. /** @hidden */
  29190. _shouldGenerateFlatShading: boolean;
  29191. /** @hidden */
  29192. _originalBuilderSideOrientation: number;
  29193. /**
  29194. * Use this property to change the original side orientation defined at construction time
  29195. */
  29196. overrideMaterialSideOrientation: Nullable<number>;
  29197. /**
  29198. * Gets the source mesh (the one used to clone this one from)
  29199. */
  29200. get source(): Nullable<Mesh>;
  29201. /**
  29202. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29203. */
  29204. get isUnIndexed(): boolean;
  29205. set isUnIndexed(value: boolean);
  29206. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29207. get worldMatrixInstancedBuffer(): Float32Array;
  29208. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29209. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29210. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29211. /**
  29212. * @constructor
  29213. * @param name The value used by scene.getMeshByName() to do a lookup.
  29214. * @param scene The scene to add this mesh to.
  29215. * @param parent The parent of this mesh, if it has one
  29216. * @param source An optional Mesh from which geometry is shared, cloned.
  29217. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29218. * When false, achieved by calling a clone(), also passing False.
  29219. * This will make creation of children, recursive.
  29220. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29221. */
  29222. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29223. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29224. doNotInstantiate: boolean;
  29225. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29226. /**
  29227. * Gets the class name
  29228. * @returns the string "Mesh".
  29229. */
  29230. getClassName(): string;
  29231. /** @hidden */
  29232. get _isMesh(): boolean;
  29233. /**
  29234. * Returns a description of this mesh
  29235. * @param fullDetails define if full details about this mesh must be used
  29236. * @returns a descriptive string representing this mesh
  29237. */
  29238. toString(fullDetails?: boolean): string;
  29239. /** @hidden */
  29240. _unBindEffect(): void;
  29241. /**
  29242. * Gets a boolean indicating if this mesh has LOD
  29243. */
  29244. get hasLODLevels(): boolean;
  29245. /**
  29246. * Gets the list of MeshLODLevel associated with the current mesh
  29247. * @returns an array of MeshLODLevel
  29248. */
  29249. getLODLevels(): MeshLODLevel[];
  29250. private _sortLODLevels;
  29251. /**
  29252. * Add a mesh as LOD level triggered at the given distance.
  29253. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29254. * @param distance The distance from the center of the object to show this level
  29255. * @param mesh The mesh to be added as LOD level (can be null)
  29256. * @return This mesh (for chaining)
  29257. */
  29258. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29259. /**
  29260. * Returns the LOD level mesh at the passed distance or null if not found.
  29261. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29262. * @param distance The distance from the center of the object to show this level
  29263. * @returns a Mesh or `null`
  29264. */
  29265. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29266. /**
  29267. * Remove a mesh from the LOD array
  29268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29269. * @param mesh defines the mesh to be removed
  29270. * @return This mesh (for chaining)
  29271. */
  29272. removeLODLevel(mesh: Mesh): Mesh;
  29273. /**
  29274. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29275. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29276. * @param camera defines the camera to use to compute distance
  29277. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29278. * @return This mesh (for chaining)
  29279. */
  29280. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29281. /**
  29282. * Gets the mesh internal Geometry object
  29283. */
  29284. get geometry(): Nullable<Geometry>;
  29285. /**
  29286. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29287. * @returns the total number of vertices
  29288. */
  29289. getTotalVertices(): number;
  29290. /**
  29291. * Returns the content of an associated vertex buffer
  29292. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29293. * - VertexBuffer.PositionKind
  29294. * - VertexBuffer.UVKind
  29295. * - VertexBuffer.UV2Kind
  29296. * - VertexBuffer.UV3Kind
  29297. * - VertexBuffer.UV4Kind
  29298. * - VertexBuffer.UV5Kind
  29299. * - VertexBuffer.UV6Kind
  29300. * - VertexBuffer.ColorKind
  29301. * - VertexBuffer.MatricesIndicesKind
  29302. * - VertexBuffer.MatricesIndicesExtraKind
  29303. * - VertexBuffer.MatricesWeightsKind
  29304. * - VertexBuffer.MatricesWeightsExtraKind
  29305. * @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
  29306. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29307. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29308. */
  29309. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29310. /**
  29311. * Returns the mesh VertexBuffer object from the requested `kind`
  29312. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29313. * - VertexBuffer.PositionKind
  29314. * - VertexBuffer.NormalKind
  29315. * - VertexBuffer.UVKind
  29316. * - VertexBuffer.UV2Kind
  29317. * - VertexBuffer.UV3Kind
  29318. * - VertexBuffer.UV4Kind
  29319. * - VertexBuffer.UV5Kind
  29320. * - VertexBuffer.UV6Kind
  29321. * - VertexBuffer.ColorKind
  29322. * - VertexBuffer.MatricesIndicesKind
  29323. * - VertexBuffer.MatricesIndicesExtraKind
  29324. * - VertexBuffer.MatricesWeightsKind
  29325. * - VertexBuffer.MatricesWeightsExtraKind
  29326. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29327. */
  29328. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29329. /**
  29330. * Tests if a specific vertex buffer is associated with this mesh
  29331. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29332. * - VertexBuffer.PositionKind
  29333. * - VertexBuffer.NormalKind
  29334. * - VertexBuffer.UVKind
  29335. * - VertexBuffer.UV2Kind
  29336. * - VertexBuffer.UV3Kind
  29337. * - VertexBuffer.UV4Kind
  29338. * - VertexBuffer.UV5Kind
  29339. * - VertexBuffer.UV6Kind
  29340. * - VertexBuffer.ColorKind
  29341. * - VertexBuffer.MatricesIndicesKind
  29342. * - VertexBuffer.MatricesIndicesExtraKind
  29343. * - VertexBuffer.MatricesWeightsKind
  29344. * - VertexBuffer.MatricesWeightsExtraKind
  29345. * @returns a boolean
  29346. */
  29347. isVerticesDataPresent(kind: string): boolean;
  29348. /**
  29349. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29350. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29351. * - VertexBuffer.PositionKind
  29352. * - VertexBuffer.UVKind
  29353. * - VertexBuffer.UV2Kind
  29354. * - VertexBuffer.UV3Kind
  29355. * - VertexBuffer.UV4Kind
  29356. * - VertexBuffer.UV5Kind
  29357. * - VertexBuffer.UV6Kind
  29358. * - VertexBuffer.ColorKind
  29359. * - VertexBuffer.MatricesIndicesKind
  29360. * - VertexBuffer.MatricesIndicesExtraKind
  29361. * - VertexBuffer.MatricesWeightsKind
  29362. * - VertexBuffer.MatricesWeightsExtraKind
  29363. * @returns a boolean
  29364. */
  29365. isVertexBufferUpdatable(kind: string): boolean;
  29366. /**
  29367. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29368. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29369. * - VertexBuffer.PositionKind
  29370. * - VertexBuffer.NormalKind
  29371. * - VertexBuffer.UVKind
  29372. * - VertexBuffer.UV2Kind
  29373. * - VertexBuffer.UV3Kind
  29374. * - VertexBuffer.UV4Kind
  29375. * - VertexBuffer.UV5Kind
  29376. * - VertexBuffer.UV6Kind
  29377. * - VertexBuffer.ColorKind
  29378. * - VertexBuffer.MatricesIndicesKind
  29379. * - VertexBuffer.MatricesIndicesExtraKind
  29380. * - VertexBuffer.MatricesWeightsKind
  29381. * - VertexBuffer.MatricesWeightsExtraKind
  29382. * @returns an array of strings
  29383. */
  29384. getVerticesDataKinds(): string[];
  29385. /**
  29386. * Returns a positive integer : the total number of indices in this mesh geometry.
  29387. * @returns the numner of indices or zero if the mesh has no geometry.
  29388. */
  29389. getTotalIndices(): number;
  29390. /**
  29391. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29392. * @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.
  29393. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29394. * @returns the indices array or an empty array if the mesh has no geometry
  29395. */
  29396. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29397. get isBlocked(): boolean;
  29398. /**
  29399. * Determine if the current mesh is ready to be rendered
  29400. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29401. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29402. * @returns true if all associated assets are ready (material, textures, shaders)
  29403. */
  29404. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29405. /**
  29406. * 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.
  29407. */
  29408. get areNormalsFrozen(): boolean;
  29409. /**
  29410. * 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.
  29411. * @returns the current mesh
  29412. */
  29413. freezeNormals(): Mesh;
  29414. /**
  29415. * 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
  29416. * @returns the current mesh
  29417. */
  29418. unfreezeNormals(): Mesh;
  29419. /**
  29420. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29421. */
  29422. set overridenInstanceCount(count: number);
  29423. /** @hidden */
  29424. _preActivate(): Mesh;
  29425. /** @hidden */
  29426. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29427. /** @hidden */
  29428. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29429. protected _afterComputeWorldMatrix(): void;
  29430. /** @hidden */
  29431. _postActivate(): void;
  29432. /**
  29433. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29434. * This means the mesh underlying bounding box and sphere are recomputed.
  29435. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29436. * @returns the current mesh
  29437. */
  29438. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29439. /** @hidden */
  29440. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29441. /**
  29442. * This function will subdivide the mesh into multiple submeshes
  29443. * @param count defines the expected number of submeshes
  29444. */
  29445. subdivide(count: number): void;
  29446. /**
  29447. * Copy a FloatArray into a specific associated vertex buffer
  29448. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29449. * - VertexBuffer.PositionKind
  29450. * - VertexBuffer.UVKind
  29451. * - VertexBuffer.UV2Kind
  29452. * - VertexBuffer.UV3Kind
  29453. * - VertexBuffer.UV4Kind
  29454. * - VertexBuffer.UV5Kind
  29455. * - VertexBuffer.UV6Kind
  29456. * - VertexBuffer.ColorKind
  29457. * - VertexBuffer.MatricesIndicesKind
  29458. * - VertexBuffer.MatricesIndicesExtraKind
  29459. * - VertexBuffer.MatricesWeightsKind
  29460. * - VertexBuffer.MatricesWeightsExtraKind
  29461. * @param data defines the data source
  29462. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29463. * @param stride defines the data stride size (can be null)
  29464. * @returns the current mesh
  29465. */
  29466. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29467. /**
  29468. * Delete a vertex buffer associated with this mesh
  29469. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29470. * - VertexBuffer.PositionKind
  29471. * - VertexBuffer.UVKind
  29472. * - VertexBuffer.UV2Kind
  29473. * - VertexBuffer.UV3Kind
  29474. * - VertexBuffer.UV4Kind
  29475. * - VertexBuffer.UV5Kind
  29476. * - VertexBuffer.UV6Kind
  29477. * - VertexBuffer.ColorKind
  29478. * - VertexBuffer.MatricesIndicesKind
  29479. * - VertexBuffer.MatricesIndicesExtraKind
  29480. * - VertexBuffer.MatricesWeightsKind
  29481. * - VertexBuffer.MatricesWeightsExtraKind
  29482. */
  29483. removeVerticesData(kind: string): void;
  29484. /**
  29485. * Flags an associated vertex buffer as updatable
  29486. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29487. * - VertexBuffer.PositionKind
  29488. * - VertexBuffer.UVKind
  29489. * - VertexBuffer.UV2Kind
  29490. * - VertexBuffer.UV3Kind
  29491. * - VertexBuffer.UV4Kind
  29492. * - VertexBuffer.UV5Kind
  29493. * - VertexBuffer.UV6Kind
  29494. * - VertexBuffer.ColorKind
  29495. * - VertexBuffer.MatricesIndicesKind
  29496. * - VertexBuffer.MatricesIndicesExtraKind
  29497. * - VertexBuffer.MatricesWeightsKind
  29498. * - VertexBuffer.MatricesWeightsExtraKind
  29499. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29500. */
  29501. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29502. /**
  29503. * Sets the mesh global Vertex Buffer
  29504. * @param buffer defines the buffer to use
  29505. * @returns the current mesh
  29506. */
  29507. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29508. /**
  29509. * Update a specific associated vertex buffer
  29510. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29511. * - VertexBuffer.PositionKind
  29512. * - VertexBuffer.UVKind
  29513. * - VertexBuffer.UV2Kind
  29514. * - VertexBuffer.UV3Kind
  29515. * - VertexBuffer.UV4Kind
  29516. * - VertexBuffer.UV5Kind
  29517. * - VertexBuffer.UV6Kind
  29518. * - VertexBuffer.ColorKind
  29519. * - VertexBuffer.MatricesIndicesKind
  29520. * - VertexBuffer.MatricesIndicesExtraKind
  29521. * - VertexBuffer.MatricesWeightsKind
  29522. * - VertexBuffer.MatricesWeightsExtraKind
  29523. * @param data defines the data source
  29524. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29525. * @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)
  29526. * @returns the current mesh
  29527. */
  29528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29529. /**
  29530. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29531. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29532. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29533. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29534. * @returns the current mesh
  29535. */
  29536. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29537. /**
  29538. * Creates a un-shared specific occurence of the geometry for the mesh.
  29539. * @returns the current mesh
  29540. */
  29541. makeGeometryUnique(): Mesh;
  29542. /**
  29543. * Set the index buffer of this mesh
  29544. * @param indices defines the source data
  29545. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29546. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29547. * @returns the current mesh
  29548. */
  29549. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29550. /**
  29551. * Update the current index buffer
  29552. * @param indices defines the source data
  29553. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29554. * @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)
  29555. * @returns the current mesh
  29556. */
  29557. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29558. /**
  29559. * Invert the geometry to move from a right handed system to a left handed one.
  29560. * @returns the current mesh
  29561. */
  29562. toLeftHanded(): Mesh;
  29563. /** @hidden */
  29564. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29565. /** @hidden */
  29566. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29567. /**
  29568. * Registers for this mesh a javascript function called just before the rendering process
  29569. * @param func defines the function to call before rendering this mesh
  29570. * @returns the current mesh
  29571. */
  29572. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29573. /**
  29574. * Disposes a previously registered javascript function called before the rendering
  29575. * @param func defines the function to remove
  29576. * @returns the current mesh
  29577. */
  29578. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29579. /**
  29580. * Registers for this mesh a javascript function called just after the rendering is complete
  29581. * @param func defines the function to call after rendering this mesh
  29582. * @returns the current mesh
  29583. */
  29584. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29585. /**
  29586. * Disposes a previously registered javascript function called after the rendering.
  29587. * @param func defines the function to remove
  29588. * @returns the current mesh
  29589. */
  29590. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29591. /** @hidden */
  29592. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29593. /** @hidden */
  29594. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29595. /** @hidden */
  29596. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29597. /** @hidden */
  29598. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29599. /** @hidden */
  29600. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29601. /** @hidden */
  29602. _rebuild(): void;
  29603. /** @hidden */
  29604. _freeze(): void;
  29605. /** @hidden */
  29606. _unFreeze(): void;
  29607. /**
  29608. * 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
  29609. * @param subMesh defines the subMesh to render
  29610. * @param enableAlphaMode defines if alpha mode can be changed
  29611. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29612. * @returns the current mesh
  29613. */
  29614. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29615. private _onBeforeDraw;
  29616. /**
  29617. * Renormalize the mesh and patch it up if there are no weights
  29618. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29619. * However in the case of zero weights then we set just a single influence to 1.
  29620. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29621. */
  29622. cleanMatrixWeights(): void;
  29623. private normalizeSkinFourWeights;
  29624. private normalizeSkinWeightsAndExtra;
  29625. /**
  29626. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29627. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29628. * the user know there was an issue with importing the mesh
  29629. * @returns a validation object with skinned, valid and report string
  29630. */
  29631. validateSkinning(): {
  29632. skinned: boolean;
  29633. valid: boolean;
  29634. report: string;
  29635. };
  29636. /** @hidden */
  29637. _checkDelayState(): Mesh;
  29638. private _queueLoad;
  29639. /**
  29640. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29641. * A mesh is in the frustum if its bounding box intersects the frustum
  29642. * @param frustumPlanes defines the frustum to test
  29643. * @returns true if the mesh is in the frustum planes
  29644. */
  29645. isInFrustum(frustumPlanes: Plane[]): boolean;
  29646. /**
  29647. * Sets the mesh material by the material or multiMaterial `id` property
  29648. * @param id is a string identifying the material or the multiMaterial
  29649. * @returns the current mesh
  29650. */
  29651. setMaterialByID(id: string): Mesh;
  29652. /**
  29653. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29654. * @returns an array of IAnimatable
  29655. */
  29656. getAnimatables(): IAnimatable[];
  29657. /**
  29658. * Modifies the mesh geometry according to the passed transformation matrix.
  29659. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29660. * The mesh normals are modified using the same transformation.
  29661. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29662. * @param transform defines the transform matrix to use
  29663. * @see https://doc.babylonjs.com/resources/baking_transformations
  29664. * @returns the current mesh
  29665. */
  29666. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29667. /**
  29668. * Modifies the mesh geometry according to its own current World Matrix.
  29669. * The mesh World Matrix is then reset.
  29670. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29671. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29672. * @see https://doc.babylonjs.com/resources/baking_transformations
  29673. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29674. * @returns the current mesh
  29675. */
  29676. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29677. /** @hidden */
  29678. get _positions(): Nullable<Vector3[]>;
  29679. /** @hidden */
  29680. _resetPointsArrayCache(): Mesh;
  29681. /** @hidden */
  29682. _generatePointsArray(): boolean;
  29683. /**
  29684. * Returns a new Mesh object generated from the current mesh properties.
  29685. * This method must not get confused with createInstance()
  29686. * @param name is a string, the name given to the new mesh
  29687. * @param newParent can be any Node object (default `null`)
  29688. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29689. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29690. * @returns a new mesh
  29691. */
  29692. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29693. /**
  29694. * Releases resources associated with this mesh.
  29695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29697. */
  29698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29699. /** @hidden */
  29700. _disposeInstanceSpecificData(): void;
  29701. /** @hidden */
  29702. _disposeThinInstanceSpecificData(): void;
  29703. /**
  29704. * Modifies the mesh geometry according to a displacement map.
  29705. * 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.
  29706. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29707. * @param url is a string, the URL from the image file is to be downloaded.
  29708. * @param minHeight is the lower limit of the displacement.
  29709. * @param maxHeight is the upper limit of the displacement.
  29710. * @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.
  29711. * @param uvOffset is an optional vector2 used to offset UV.
  29712. * @param uvScale is an optional vector2 used to scale UV.
  29713. * @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.
  29714. * @returns the Mesh.
  29715. */
  29716. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29717. /**
  29718. * Modifies the mesh geometry according to a displacementMap buffer.
  29719. * 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.
  29720. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29721. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29722. * @param heightMapWidth is the width of the buffer image.
  29723. * @param heightMapHeight is the height of the buffer image.
  29724. * @param minHeight is the lower limit of the displacement.
  29725. * @param maxHeight is the upper limit of the displacement.
  29726. * @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.
  29727. * @param uvOffset is an optional vector2 used to offset UV.
  29728. * @param uvScale is an optional vector2 used to scale UV.
  29729. * @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.
  29730. * @returns the Mesh.
  29731. */
  29732. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29733. /**
  29734. * Modify the mesh to get a flat shading rendering.
  29735. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29736. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29737. * @returns current mesh
  29738. */
  29739. convertToFlatShadedMesh(): Mesh;
  29740. /**
  29741. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29742. * In other words, more vertices, no more indices and a single bigger VBO.
  29743. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29744. * @returns current mesh
  29745. */
  29746. convertToUnIndexedMesh(): Mesh;
  29747. /**
  29748. * Inverses facet orientations.
  29749. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29750. * @param flipNormals will also inverts the normals
  29751. * @returns current mesh
  29752. */
  29753. flipFaces(flipNormals?: boolean): Mesh;
  29754. /**
  29755. * Increase the number of facets and hence vertices in a mesh
  29756. * Vertex normals are interpolated from existing vertex normals
  29757. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29758. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29759. */
  29760. increaseVertices(numberPerEdge: number): void;
  29761. /**
  29762. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29763. * This will undo any application of covertToFlatShadedMesh
  29764. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29765. */
  29766. forceSharedVertices(): void;
  29767. /** @hidden */
  29768. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29769. /** @hidden */
  29770. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29771. /**
  29772. * Creates a new InstancedMesh object from the mesh model.
  29773. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29774. * @param name defines the name of the new instance
  29775. * @returns a new InstancedMesh
  29776. */
  29777. createInstance(name: string): InstancedMesh;
  29778. /**
  29779. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29780. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29781. * @returns the current mesh
  29782. */
  29783. synchronizeInstances(): Mesh;
  29784. /**
  29785. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29786. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29787. * This should be used together with the simplification to avoid disappearing triangles.
  29788. * @param successCallback an optional success callback to be called after the optimization finished.
  29789. * @returns the current mesh
  29790. */
  29791. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29792. /**
  29793. * Serialize current mesh
  29794. * @param serializationObject defines the object which will receive the serialization data
  29795. */
  29796. serialize(serializationObject: any): void;
  29797. /** @hidden */
  29798. _syncGeometryWithMorphTargetManager(): void;
  29799. /** @hidden */
  29800. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29801. /**
  29802. * Returns a new Mesh object parsed from the source provided.
  29803. * @param parsedMesh is the source
  29804. * @param scene defines the hosting scene
  29805. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29806. * @returns a new Mesh
  29807. */
  29808. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29809. /**
  29810. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29812. * @param name defines the name of the mesh to create
  29813. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29814. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29815. * @param closePath creates a seam between the first and the last points of each path of the path array
  29816. * @param offset is taken in account only if the `pathArray` is containing a single path
  29817. * @param scene defines the hosting scene
  29818. * @param updatable defines if the mesh must be flagged as updatable
  29819. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29820. * @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)
  29821. * @returns a new Mesh
  29822. */
  29823. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29824. /**
  29825. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29826. * @param name defines the name of the mesh to create
  29827. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29828. * @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
  29829. * @param scene defines the hosting scene
  29830. * @param updatable defines if the mesh must be flagged as updatable
  29831. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29832. * @returns a new Mesh
  29833. */
  29834. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29835. /**
  29836. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29837. * @param name defines the name of the mesh to create
  29838. * @param size sets the size (float) of each box side (default 1)
  29839. * @param scene defines the hosting scene
  29840. * @param updatable defines if the mesh must be flagged as updatable
  29841. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29842. * @returns a new Mesh
  29843. */
  29844. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29845. /**
  29846. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29847. * @param name defines the name of the mesh to create
  29848. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29849. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29850. * @param scene defines the hosting scene
  29851. * @param updatable defines if the mesh must be flagged as updatable
  29852. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29853. * @returns a new Mesh
  29854. */
  29855. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29856. /**
  29857. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29858. * @param name defines the name of the mesh to create
  29859. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29860. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29861. * @param scene defines the hosting scene
  29862. * @returns a new Mesh
  29863. */
  29864. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29865. /**
  29866. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29867. * @param name defines the name of the mesh to create
  29868. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29869. * @param diameterTop set the top cap diameter (floats, default 1)
  29870. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29871. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29872. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29873. * @param scene defines the hosting scene
  29874. * @param updatable defines if the mesh must be flagged as updatable
  29875. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29876. * @returns a new Mesh
  29877. */
  29878. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29879. /**
  29880. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29881. * @param name defines the name of the mesh to create
  29882. * @param diameter sets the diameter size (float) of the torus (default 1)
  29883. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29884. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29885. * @param scene defines the hosting scene
  29886. * @param updatable defines if the mesh must be flagged as updatable
  29887. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29888. * @returns a new Mesh
  29889. */
  29890. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29891. /**
  29892. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29893. * @param name defines the name of the mesh to create
  29894. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29895. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29896. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29897. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29898. * @param p the number of windings on X axis (positive integers, default 2)
  29899. * @param q the number of windings on Y axis (positive integers, default 3)
  29900. * @param scene defines the hosting scene
  29901. * @param updatable defines if the mesh must be flagged as updatable
  29902. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29903. * @returns a new Mesh
  29904. */
  29905. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29906. /**
  29907. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29908. * @param name defines the name of the mesh to create
  29909. * @param points is an array successive Vector3
  29910. * @param scene defines the hosting scene
  29911. * @param updatable defines if the mesh must be flagged as updatable
  29912. * @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).
  29913. * @returns a new Mesh
  29914. */
  29915. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29916. /**
  29917. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29918. * @param name defines the name of the mesh to create
  29919. * @param points is an array successive Vector3
  29920. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29921. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29922. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29923. * @param scene defines the hosting scene
  29924. * @param updatable defines if the mesh must be flagged as updatable
  29925. * @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)
  29926. * @returns a new Mesh
  29927. */
  29928. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29929. /**
  29930. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29931. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29932. * 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.
  29933. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29934. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29935. * Remember you can only change the shape positions, not their number when updating a polygon.
  29936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29937. * @param name defines the name of the mesh to create
  29938. * @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
  29939. * @param scene defines the hosting scene
  29940. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29941. * @param updatable defines if the mesh must be flagged as updatable
  29942. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29943. * @param earcutInjection can be used to inject your own earcut reference
  29944. * @returns a new Mesh
  29945. */
  29946. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29947. /**
  29948. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29950. * @param name defines the name of the mesh to create
  29951. * @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
  29952. * @param depth defines the height of extrusion
  29953. * @param scene defines the hosting scene
  29954. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29955. * @param updatable defines if the mesh must be flagged as updatable
  29956. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29957. * @param earcutInjection can be used to inject your own earcut reference
  29958. * @returns a new Mesh
  29959. */
  29960. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29961. /**
  29962. * Creates an extruded shape mesh.
  29963. * 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
  29964. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29966. * @param name defines the name of the mesh to create
  29967. * @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
  29968. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29969. * @param scale is the value to scale the shape
  29970. * @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
  29971. * @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
  29972. * @param scene defines the hosting scene
  29973. * @param updatable defines if the mesh must be flagged as updatable
  29974. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29975. * @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)
  29976. * @returns a new Mesh
  29977. */
  29978. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29979. /**
  29980. * Creates an custom extruded shape mesh.
  29981. * The custom extrusion is a parametric shape.
  29982. * It has no predefined shape. Its final shape will depend on the input parameters.
  29983. * Please consider using the same method from the MeshBuilder class instead
  29984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29985. * @param name defines the name of the mesh to create
  29986. * @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
  29987. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29988. * @param scaleFunction is a custom Javascript function called on each path point
  29989. * @param rotationFunction is a custom Javascript function called on each path point
  29990. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29991. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29992. * @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
  29993. * @param scene defines the hosting scene
  29994. * @param updatable defines if the mesh must be flagged as updatable
  29995. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29996. * @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)
  29997. * @returns a new Mesh
  29998. */
  29999. 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;
  30000. /**
  30001. * Creates lathe mesh.
  30002. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30003. * Please consider using the same method from the MeshBuilder class instead
  30004. * @param name defines the name of the mesh to create
  30005. * @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
  30006. * @param radius is the radius value of the lathe
  30007. * @param tessellation is the side number of the lathe.
  30008. * @param scene defines the hosting scene
  30009. * @param updatable defines if the mesh must be flagged as updatable
  30010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30011. * @returns a new Mesh
  30012. */
  30013. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30014. /**
  30015. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30016. * @param name defines the name of the mesh to create
  30017. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30018. * @param scene defines the hosting scene
  30019. * @param updatable defines if the mesh must be flagged as updatable
  30020. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30021. * @returns a new Mesh
  30022. */
  30023. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30024. /**
  30025. * Creates a ground mesh.
  30026. * Please consider using the same method from the MeshBuilder class instead
  30027. * @param name defines the name of the mesh to create
  30028. * @param width set the width of the ground
  30029. * @param height set the height of the ground
  30030. * @param subdivisions sets the number of subdivisions per side
  30031. * @param scene defines the hosting scene
  30032. * @param updatable defines if the mesh must be flagged as updatable
  30033. * @returns a new Mesh
  30034. */
  30035. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30036. /**
  30037. * Creates a tiled ground mesh.
  30038. * Please consider using the same method from the MeshBuilder class instead
  30039. * @param name defines the name of the mesh to create
  30040. * @param xmin set the ground minimum X coordinate
  30041. * @param zmin set the ground minimum Y coordinate
  30042. * @param xmax set the ground maximum X coordinate
  30043. * @param zmax set the ground maximum Z coordinate
  30044. * @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
  30045. * @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
  30046. * @param scene defines the hosting scene
  30047. * @param updatable defines if the mesh must be flagged as updatable
  30048. * @returns a new Mesh
  30049. */
  30050. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30051. w: number;
  30052. h: number;
  30053. }, precision: {
  30054. w: number;
  30055. h: number;
  30056. }, scene: Scene, updatable?: boolean): Mesh;
  30057. /**
  30058. * Creates a ground mesh from a height map.
  30059. * Please consider using the same method from the MeshBuilder class instead
  30060. * @see https://doc.babylonjs.com/babylon101/height_map
  30061. * @param name defines the name of the mesh to create
  30062. * @param url sets the URL of the height map image resource
  30063. * @param width set the ground width size
  30064. * @param height set the ground height size
  30065. * @param subdivisions sets the number of subdivision per side
  30066. * @param minHeight is the minimum altitude on the ground
  30067. * @param maxHeight is the maximum altitude on the ground
  30068. * @param scene defines the hosting scene
  30069. * @param updatable defines if the mesh must be flagged as updatable
  30070. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30071. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30072. * @returns a new Mesh
  30073. */
  30074. 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;
  30075. /**
  30076. * Creates a tube mesh.
  30077. * The tube is a parametric shape.
  30078. * It has no predefined shape. Its final shape will depend on the input parameters.
  30079. * Please consider using the same method from the MeshBuilder class instead
  30080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30081. * @param name defines the name of the mesh to create
  30082. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30083. * @param radius sets the tube radius size
  30084. * @param tessellation is the number of sides on the tubular surface
  30085. * @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
  30086. * @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
  30087. * @param scene defines the hosting scene
  30088. * @param updatable defines if the mesh must be flagged as updatable
  30089. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30090. * @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)
  30091. * @returns a new Mesh
  30092. */
  30093. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30094. (i: number, distance: number): number;
  30095. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30096. /**
  30097. * Creates a polyhedron mesh.
  30098. * Please consider using the same method from the MeshBuilder class instead.
  30099. * * 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
  30100. * * The parameter `size` (positive float, default 1) sets the polygon size
  30101. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30102. * * 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`
  30103. * * 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
  30104. * * 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)`)
  30105. * * 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
  30106. * * 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
  30107. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30110. * @param name defines the name of the mesh to create
  30111. * @param options defines the options used to create the mesh
  30112. * @param scene defines the hosting scene
  30113. * @returns a new Mesh
  30114. */
  30115. static CreatePolyhedron(name: string, options: {
  30116. type?: number;
  30117. size?: number;
  30118. sizeX?: number;
  30119. sizeY?: number;
  30120. sizeZ?: number;
  30121. custom?: any;
  30122. faceUV?: Vector4[];
  30123. faceColors?: Color4[];
  30124. updatable?: boolean;
  30125. sideOrientation?: number;
  30126. }, scene: Scene): Mesh;
  30127. /**
  30128. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30129. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30130. * * 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`)
  30131. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30132. * * 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
  30133. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30136. * @param name defines the name of the mesh
  30137. * @param options defines the options used to create the mesh
  30138. * @param scene defines the hosting scene
  30139. * @returns a new Mesh
  30140. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30141. */
  30142. static CreateIcoSphere(name: string, options: {
  30143. radius?: number;
  30144. flat?: boolean;
  30145. subdivisions?: number;
  30146. sideOrientation?: number;
  30147. updatable?: boolean;
  30148. }, scene: Scene): Mesh;
  30149. /**
  30150. * Creates a decal mesh.
  30151. * Please consider using the same method from the MeshBuilder class instead.
  30152. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30153. * @param name defines the name of the mesh
  30154. * @param sourceMesh defines the mesh receiving the decal
  30155. * @param position sets the position of the decal in world coordinates
  30156. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30157. * @param size sets the decal scaling
  30158. * @param angle sets the angle to rotate the decal
  30159. * @returns a new Mesh
  30160. */
  30161. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30162. /**
  30163. * Prepare internal position array for software CPU skinning
  30164. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30165. */
  30166. setPositionsForCPUSkinning(): Float32Array;
  30167. /**
  30168. * Prepare internal normal array for software CPU skinning
  30169. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30170. */
  30171. setNormalsForCPUSkinning(): Float32Array;
  30172. /**
  30173. * Updates the vertex buffer by applying transformation from the bones
  30174. * @param skeleton defines the skeleton to apply to current mesh
  30175. * @returns the current mesh
  30176. */
  30177. applySkeleton(skeleton: Skeleton): Mesh;
  30178. /**
  30179. * 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
  30180. * @param meshes defines the list of meshes to scan
  30181. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30182. */
  30183. static MinMax(meshes: AbstractMesh[]): {
  30184. min: Vector3;
  30185. max: Vector3;
  30186. };
  30187. /**
  30188. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30189. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30190. * @returns a vector3
  30191. */
  30192. static Center(meshesOrMinMaxVector: {
  30193. min: Vector3;
  30194. max: Vector3;
  30195. } | AbstractMesh[]): Vector3;
  30196. /**
  30197. * Merge the array of meshes into a single mesh for performance reasons.
  30198. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30199. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30200. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30201. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30202. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30203. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30204. * @returns a new mesh
  30205. */
  30206. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30207. /** @hidden */
  30208. addInstance(instance: InstancedMesh): void;
  30209. /** @hidden */
  30210. removeInstance(instance: InstancedMesh): void;
  30211. }
  30212. }
  30213. declare module "babylonjs/Cameras/camera" {
  30214. import { SmartArray } from "babylonjs/Misc/smartArray";
  30215. import { Observable } from "babylonjs/Misc/observable";
  30216. import { Nullable } from "babylonjs/types";
  30217. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30218. import { Scene } from "babylonjs/scene";
  30219. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30220. import { Node } from "babylonjs/node";
  30221. import { Mesh } from "babylonjs/Meshes/mesh";
  30222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30223. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30224. import { Viewport } from "babylonjs/Maths/math.viewport";
  30225. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30226. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30227. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30228. import { Ray } from "babylonjs/Culling/ray";
  30229. /**
  30230. * This is the base class of all the camera used in the application.
  30231. * @see https://doc.babylonjs.com/features/cameras
  30232. */
  30233. export class Camera extends Node {
  30234. /** @hidden */
  30235. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30236. /**
  30237. * This is the default projection mode used by the cameras.
  30238. * It helps recreating a feeling of perspective and better appreciate depth.
  30239. * This is the best way to simulate real life cameras.
  30240. */
  30241. static readonly PERSPECTIVE_CAMERA: number;
  30242. /**
  30243. * This helps creating camera with an orthographic mode.
  30244. * 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.
  30245. */
  30246. static readonly ORTHOGRAPHIC_CAMERA: number;
  30247. /**
  30248. * This is the default FOV mode for perspective cameras.
  30249. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30250. */
  30251. static readonly FOVMODE_VERTICAL_FIXED: number;
  30252. /**
  30253. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30254. */
  30255. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30256. /**
  30257. * This specifies ther is no need for a camera rig.
  30258. * Basically only one eye is rendered corresponding to the camera.
  30259. */
  30260. static readonly RIG_MODE_NONE: number;
  30261. /**
  30262. * Simulates a camera Rig with one blue eye and one red eye.
  30263. * This can be use with 3d blue and red glasses.
  30264. */
  30265. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30266. /**
  30267. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30268. */
  30269. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30270. /**
  30271. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30272. */
  30273. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30274. /**
  30275. * Defines that both eyes of the camera will be rendered over under each other.
  30276. */
  30277. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30278. /**
  30279. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30280. */
  30281. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30282. /**
  30283. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30284. */
  30285. static readonly RIG_MODE_VR: number;
  30286. /**
  30287. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30288. */
  30289. static readonly RIG_MODE_WEBVR: number;
  30290. /**
  30291. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30292. */
  30293. static readonly RIG_MODE_CUSTOM: number;
  30294. /**
  30295. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30296. */
  30297. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30298. /**
  30299. * Define the input manager associated with the camera.
  30300. */
  30301. inputs: CameraInputsManager<Camera>;
  30302. /** @hidden */
  30303. _position: Vector3;
  30304. /**
  30305. * Define the current local position of the camera in the scene
  30306. */
  30307. get position(): Vector3;
  30308. set position(newPosition: Vector3);
  30309. /**
  30310. * The vector the camera should consider as up.
  30311. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30312. */
  30313. upVector: Vector3;
  30314. /**
  30315. * Define the current limit on the left side for an orthographic camera
  30316. * In scene unit
  30317. */
  30318. orthoLeft: Nullable<number>;
  30319. /**
  30320. * Define the current limit on the right side for an orthographic camera
  30321. * In scene unit
  30322. */
  30323. orthoRight: Nullable<number>;
  30324. /**
  30325. * Define the current limit on the bottom side for an orthographic camera
  30326. * In scene unit
  30327. */
  30328. orthoBottom: Nullable<number>;
  30329. /**
  30330. * Define the current limit on the top side for an orthographic camera
  30331. * In scene unit
  30332. */
  30333. orthoTop: Nullable<number>;
  30334. /**
  30335. * Field Of View is set in Radians. (default is 0.8)
  30336. */
  30337. fov: number;
  30338. /**
  30339. * Define the minimum distance the camera can see from.
  30340. * This is important to note that the depth buffer are not infinite and the closer it starts
  30341. * the more your scene might encounter depth fighting issue.
  30342. */
  30343. minZ: number;
  30344. /**
  30345. * Define the maximum distance the camera can see to.
  30346. * This is important to note that the depth buffer are not infinite and the further it end
  30347. * the more your scene might encounter depth fighting issue.
  30348. */
  30349. maxZ: number;
  30350. /**
  30351. * Define the default inertia of the camera.
  30352. * This helps giving a smooth feeling to the camera movement.
  30353. */
  30354. inertia: number;
  30355. /**
  30356. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30357. */
  30358. mode: number;
  30359. /**
  30360. * Define whether the camera is intermediate.
  30361. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30362. */
  30363. isIntermediate: boolean;
  30364. /**
  30365. * Define the viewport of the camera.
  30366. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30367. */
  30368. viewport: Viewport;
  30369. /**
  30370. * Restricts the camera to viewing objects with the same layerMask.
  30371. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30372. */
  30373. layerMask: number;
  30374. /**
  30375. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30376. */
  30377. fovMode: number;
  30378. /**
  30379. * Rig mode of the camera.
  30380. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30381. * This is normally controlled byt the camera themselves as internal use.
  30382. */
  30383. cameraRigMode: number;
  30384. /**
  30385. * Defines the distance between both "eyes" in case of a RIG
  30386. */
  30387. interaxialDistance: number;
  30388. /**
  30389. * Defines if stereoscopic rendering is done side by side or over under.
  30390. */
  30391. isStereoscopicSideBySide: boolean;
  30392. /**
  30393. * 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
  30394. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30395. * else in the scene. (Eg. security camera)
  30396. *
  30397. * 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)
  30398. */
  30399. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30400. /**
  30401. * When set, the camera will render to this render target instead of the default canvas
  30402. *
  30403. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30404. */
  30405. outputRenderTarget: Nullable<RenderTargetTexture>;
  30406. /**
  30407. * Observable triggered when the camera view matrix has changed.
  30408. */
  30409. onViewMatrixChangedObservable: Observable<Camera>;
  30410. /**
  30411. * Observable triggered when the camera Projection matrix has changed.
  30412. */
  30413. onProjectionMatrixChangedObservable: Observable<Camera>;
  30414. /**
  30415. * Observable triggered when the inputs have been processed.
  30416. */
  30417. onAfterCheckInputsObservable: Observable<Camera>;
  30418. /**
  30419. * Observable triggered when reset has been called and applied to the camera.
  30420. */
  30421. onRestoreStateObservable: Observable<Camera>;
  30422. /**
  30423. * Is this camera a part of a rig system?
  30424. */
  30425. isRigCamera: boolean;
  30426. /**
  30427. * If isRigCamera set to true this will be set with the parent camera.
  30428. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30429. */
  30430. rigParent?: Camera;
  30431. /** @hidden */
  30432. _cameraRigParams: any;
  30433. /** @hidden */
  30434. _rigCameras: Camera[];
  30435. /** @hidden */
  30436. _rigPostProcess: Nullable<PostProcess>;
  30437. protected _webvrViewMatrix: Matrix;
  30438. /** @hidden */
  30439. _skipRendering: boolean;
  30440. /** @hidden */
  30441. _projectionMatrix: Matrix;
  30442. /** @hidden */
  30443. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30444. /** @hidden */
  30445. _activeMeshes: SmartArray<AbstractMesh>;
  30446. protected _globalPosition: Vector3;
  30447. /** @hidden */
  30448. _computedViewMatrix: Matrix;
  30449. private _doNotComputeProjectionMatrix;
  30450. private _transformMatrix;
  30451. private _frustumPlanes;
  30452. private _refreshFrustumPlanes;
  30453. private _storedFov;
  30454. private _stateStored;
  30455. /**
  30456. * Instantiates a new camera object.
  30457. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30458. * @see https://doc.babylonjs.com/features/cameras
  30459. * @param name Defines the name of the camera in the scene
  30460. * @param position Defines the position of the camera
  30461. * @param scene Defines the scene the camera belongs too
  30462. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30463. */
  30464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30465. /**
  30466. * Store current camera state (fov, position, etc..)
  30467. * @returns the camera
  30468. */
  30469. storeState(): Camera;
  30470. /**
  30471. * Restores the camera state values if it has been stored. You must call storeState() first
  30472. */
  30473. protected _restoreStateValues(): boolean;
  30474. /**
  30475. * Restored camera state. You must call storeState() first.
  30476. * @returns true if restored and false otherwise
  30477. */
  30478. restoreState(): boolean;
  30479. /**
  30480. * Gets the class name of the camera.
  30481. * @returns the class name
  30482. */
  30483. getClassName(): string;
  30484. /** @hidden */
  30485. readonly _isCamera: boolean;
  30486. /**
  30487. * Gets a string representation of the camera useful for debug purpose.
  30488. * @param fullDetails Defines that a more verboe level of logging is required
  30489. * @returns the string representation
  30490. */
  30491. toString(fullDetails?: boolean): string;
  30492. /**
  30493. * Gets the current world space position of the camera.
  30494. */
  30495. get globalPosition(): Vector3;
  30496. /**
  30497. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30498. * @returns the active meshe list
  30499. */
  30500. getActiveMeshes(): SmartArray<AbstractMesh>;
  30501. /**
  30502. * Check whether a mesh is part of the current active mesh list of the camera
  30503. * @param mesh Defines the mesh to check
  30504. * @returns true if active, false otherwise
  30505. */
  30506. isActiveMesh(mesh: Mesh): boolean;
  30507. /**
  30508. * Is this camera ready to be used/rendered
  30509. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30510. * @return true if the camera is ready
  30511. */
  30512. isReady(completeCheck?: boolean): boolean;
  30513. /** @hidden */
  30514. _initCache(): void;
  30515. /** @hidden */
  30516. _updateCache(ignoreParentClass?: boolean): void;
  30517. /** @hidden */
  30518. _isSynchronized(): boolean;
  30519. /** @hidden */
  30520. _isSynchronizedViewMatrix(): boolean;
  30521. /** @hidden */
  30522. _isSynchronizedProjectionMatrix(): boolean;
  30523. /**
  30524. * Attach the input controls to a specific dom element to get the input from.
  30525. * @param element Defines the element the controls should be listened from
  30526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30527. */
  30528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30529. /**
  30530. * Detach the current controls from the specified dom element.
  30531. * @param element Defines the element to stop listening the inputs from
  30532. */
  30533. detachControl(element: HTMLElement): void;
  30534. /**
  30535. * Update the camera state according to the different inputs gathered during the frame.
  30536. */
  30537. update(): void;
  30538. /** @hidden */
  30539. _checkInputs(): void;
  30540. /** @hidden */
  30541. get rigCameras(): Camera[];
  30542. /**
  30543. * Gets the post process used by the rig cameras
  30544. */
  30545. get rigPostProcess(): Nullable<PostProcess>;
  30546. /**
  30547. * Internal, gets the first post proces.
  30548. * @returns the first post process to be run on this camera.
  30549. */
  30550. _getFirstPostProcess(): Nullable<PostProcess>;
  30551. private _cascadePostProcessesToRigCams;
  30552. /**
  30553. * Attach a post process to the camera.
  30554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30555. * @param postProcess The post process to attach to the camera
  30556. * @param insertAt The position of the post process in case several of them are in use in the scene
  30557. * @returns the position the post process has been inserted at
  30558. */
  30559. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30560. /**
  30561. * Detach a post process to the camera.
  30562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30563. * @param postProcess The post process to detach from the camera
  30564. */
  30565. detachPostProcess(postProcess: PostProcess): void;
  30566. /**
  30567. * Gets the current world matrix of the camera
  30568. */
  30569. getWorldMatrix(): Matrix;
  30570. /** @hidden */
  30571. _getViewMatrix(): Matrix;
  30572. /**
  30573. * Gets the current view matrix of the camera.
  30574. * @param force forces the camera to recompute the matrix without looking at the cached state
  30575. * @returns the view matrix
  30576. */
  30577. getViewMatrix(force?: boolean): Matrix;
  30578. /**
  30579. * Freeze the projection matrix.
  30580. * It will prevent the cache check of the camera projection compute and can speed up perf
  30581. * if no parameter of the camera are meant to change
  30582. * @param projection Defines manually a projection if necessary
  30583. */
  30584. freezeProjectionMatrix(projection?: Matrix): void;
  30585. /**
  30586. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30587. */
  30588. unfreezeProjectionMatrix(): void;
  30589. /**
  30590. * Gets the current projection matrix of the camera.
  30591. * @param force forces the camera to recompute the matrix without looking at the cached state
  30592. * @returns the projection matrix
  30593. */
  30594. getProjectionMatrix(force?: boolean): Matrix;
  30595. /**
  30596. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30597. * @returns a Matrix
  30598. */
  30599. getTransformationMatrix(): Matrix;
  30600. private _updateFrustumPlanes;
  30601. /**
  30602. * Checks if a cullable object (mesh...) is in the camera frustum
  30603. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30604. * @param target The object to check
  30605. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30606. * @returns true if the object is in frustum otherwise false
  30607. */
  30608. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30609. /**
  30610. * Checks if a cullable object (mesh...) is in the camera frustum
  30611. * Unlike isInFrustum this cheks the full bounding box
  30612. * @param target The object to check
  30613. * @returns true if the object is in frustum otherwise false
  30614. */
  30615. isCompletelyInFrustum(target: ICullable): boolean;
  30616. /**
  30617. * Gets a ray in the forward direction from the camera.
  30618. * @param length Defines the length of the ray to create
  30619. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30620. * @param origin Defines the start point of the ray which defaults to the camera position
  30621. * @returns the forward ray
  30622. */
  30623. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30624. /**
  30625. * Gets a ray in the forward direction from the camera.
  30626. * @param refRay the ray to (re)use when setting the values
  30627. * @param length Defines the length of the ray to create
  30628. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30629. * @param origin Defines the start point of the ray which defaults to the camera position
  30630. * @returns the forward ray
  30631. */
  30632. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30633. /**
  30634. * Releases resources associated with this node.
  30635. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30636. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30637. */
  30638. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30639. /** @hidden */
  30640. _isLeftCamera: boolean;
  30641. /**
  30642. * Gets the left camera of a rig setup in case of Rigged Camera
  30643. */
  30644. get isLeftCamera(): boolean;
  30645. /** @hidden */
  30646. _isRightCamera: boolean;
  30647. /**
  30648. * Gets the right camera of a rig setup in case of Rigged Camera
  30649. */
  30650. get isRightCamera(): boolean;
  30651. /**
  30652. * Gets the left camera of a rig setup in case of Rigged Camera
  30653. */
  30654. get leftCamera(): Nullable<FreeCamera>;
  30655. /**
  30656. * Gets the right camera of a rig setup in case of Rigged Camera
  30657. */
  30658. get rightCamera(): Nullable<FreeCamera>;
  30659. /**
  30660. * Gets the left camera target of a rig setup in case of Rigged Camera
  30661. * @returns the target position
  30662. */
  30663. getLeftTarget(): Nullable<Vector3>;
  30664. /**
  30665. * Gets the right camera target of a rig setup in case of Rigged Camera
  30666. * @returns the target position
  30667. */
  30668. getRightTarget(): Nullable<Vector3>;
  30669. /**
  30670. * @hidden
  30671. */
  30672. setCameraRigMode(mode: number, rigParams: any): void;
  30673. /** @hidden */
  30674. static _setStereoscopicRigMode(camera: Camera): void;
  30675. /** @hidden */
  30676. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30677. /** @hidden */
  30678. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30679. /** @hidden */
  30680. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30681. /** @hidden */
  30682. _getVRProjectionMatrix(): Matrix;
  30683. protected _updateCameraRotationMatrix(): void;
  30684. protected _updateWebVRCameraRotationMatrix(): void;
  30685. /**
  30686. * This function MUST be overwritten by the different WebVR cameras available.
  30687. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30688. * @hidden
  30689. */
  30690. _getWebVRProjectionMatrix(): Matrix;
  30691. /**
  30692. * This function MUST be overwritten by the different WebVR cameras available.
  30693. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30694. * @hidden
  30695. */
  30696. _getWebVRViewMatrix(): Matrix;
  30697. /** @hidden */
  30698. setCameraRigParameter(name: string, value: any): void;
  30699. /**
  30700. * needs to be overridden by children so sub has required properties to be copied
  30701. * @hidden
  30702. */
  30703. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30704. /**
  30705. * May need to be overridden by children
  30706. * @hidden
  30707. */
  30708. _updateRigCameras(): void;
  30709. /** @hidden */
  30710. _setupInputs(): void;
  30711. /**
  30712. * Serialiaze the camera setup to a json represention
  30713. * @returns the JSON representation
  30714. */
  30715. serialize(): any;
  30716. /**
  30717. * Clones the current camera.
  30718. * @param name The cloned camera name
  30719. * @returns the cloned camera
  30720. */
  30721. clone(name: string): Camera;
  30722. /**
  30723. * Gets the direction of the camera relative to a given local axis.
  30724. * @param localAxis Defines the reference axis to provide a relative direction.
  30725. * @return the direction
  30726. */
  30727. getDirection(localAxis: Vector3): Vector3;
  30728. /**
  30729. * Returns the current camera absolute rotation
  30730. */
  30731. get absoluteRotation(): Quaternion;
  30732. /**
  30733. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30734. * @param localAxis Defines the reference axis to provide a relative direction.
  30735. * @param result Defines the vector to store the result in
  30736. */
  30737. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30738. /**
  30739. * Gets a camera constructor for a given camera type
  30740. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30741. * @param name The name of the camera the result will be able to instantiate
  30742. * @param scene The scene the result will construct the camera in
  30743. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30744. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30745. * @returns a factory method to construc the camera
  30746. */
  30747. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30748. /**
  30749. * Compute the world matrix of the camera.
  30750. * @returns the camera world matrix
  30751. */
  30752. computeWorldMatrix(): Matrix;
  30753. /**
  30754. * Parse a JSON and creates the camera from the parsed information
  30755. * @param parsedCamera The JSON to parse
  30756. * @param scene The scene to instantiate the camera in
  30757. * @returns the newly constructed camera
  30758. */
  30759. static Parse(parsedCamera: any, scene: Scene): Camera;
  30760. }
  30761. }
  30762. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30763. import { Nullable } from "babylonjs/types";
  30764. import { Scene } from "babylonjs/scene";
  30765. import { Vector4 } from "babylonjs/Maths/math.vector";
  30766. import { Mesh } from "babylonjs/Meshes/mesh";
  30767. /**
  30768. * Class containing static functions to help procedurally build meshes
  30769. */
  30770. export class DiscBuilder {
  30771. /**
  30772. * Creates a plane polygonal mesh. By default, this is a disc
  30773. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30774. * * 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
  30775. * * 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
  30776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30779. * @param name defines the name of the mesh
  30780. * @param options defines the options used to create the mesh
  30781. * @param scene defines the hosting scene
  30782. * @returns the plane polygonal mesh
  30783. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30784. */
  30785. static CreateDisc(name: string, options: {
  30786. radius?: number;
  30787. tessellation?: number;
  30788. arc?: number;
  30789. updatable?: boolean;
  30790. sideOrientation?: number;
  30791. frontUVs?: Vector4;
  30792. backUVs?: Vector4;
  30793. }, scene?: Nullable<Scene>): Mesh;
  30794. }
  30795. }
  30796. declare module "babylonjs/Materials/fresnelParameters" {
  30797. import { DeepImmutable } from "babylonjs/types";
  30798. import { Color3 } from "babylonjs/Maths/math.color";
  30799. /**
  30800. * Options to be used when creating a FresnelParameters.
  30801. */
  30802. export type IFresnelParametersCreationOptions = {
  30803. /**
  30804. * Define the color used on edges (grazing angle)
  30805. */
  30806. leftColor?: Color3;
  30807. /**
  30808. * Define the color used on center
  30809. */
  30810. rightColor?: Color3;
  30811. /**
  30812. * Define bias applied to computed fresnel term
  30813. */
  30814. bias?: number;
  30815. /**
  30816. * Defined the power exponent applied to fresnel term
  30817. */
  30818. power?: number;
  30819. /**
  30820. * Define if the fresnel effect is enable or not.
  30821. */
  30822. isEnabled?: boolean;
  30823. };
  30824. /**
  30825. * Serialized format for FresnelParameters.
  30826. */
  30827. export type IFresnelParametersSerialized = {
  30828. /**
  30829. * Define the color used on edges (grazing angle) [as an array]
  30830. */
  30831. leftColor: number[];
  30832. /**
  30833. * Define the color used on center [as an array]
  30834. */
  30835. rightColor: number[];
  30836. /**
  30837. * Define bias applied to computed fresnel term
  30838. */
  30839. bias: number;
  30840. /**
  30841. * Defined the power exponent applied to fresnel term
  30842. */
  30843. power?: number;
  30844. /**
  30845. * Define if the fresnel effect is enable or not.
  30846. */
  30847. isEnabled: boolean;
  30848. };
  30849. /**
  30850. * This represents all the required information to add a fresnel effect on a material:
  30851. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30852. */
  30853. export class FresnelParameters {
  30854. private _isEnabled;
  30855. /**
  30856. * Define if the fresnel effect is enable or not.
  30857. */
  30858. get isEnabled(): boolean;
  30859. set isEnabled(value: boolean);
  30860. /**
  30861. * Define the color used on edges (grazing angle)
  30862. */
  30863. leftColor: Color3;
  30864. /**
  30865. * Define the color used on center
  30866. */
  30867. rightColor: Color3;
  30868. /**
  30869. * Define bias applied to computed fresnel term
  30870. */
  30871. bias: number;
  30872. /**
  30873. * Defined the power exponent applied to fresnel term
  30874. */
  30875. power: number;
  30876. /**
  30877. * Creates a new FresnelParameters object.
  30878. *
  30879. * @param options provide your own settings to optionally to override defaults
  30880. */
  30881. constructor(options?: IFresnelParametersCreationOptions);
  30882. /**
  30883. * Clones the current fresnel and its valuues
  30884. * @returns a clone fresnel configuration
  30885. */
  30886. clone(): FresnelParameters;
  30887. /**
  30888. * Determines equality between FresnelParameters objects
  30889. * @param otherFresnelParameters defines the second operand
  30890. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30891. */
  30892. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30893. /**
  30894. * Serializes the current fresnel parameters to a JSON representation.
  30895. * @return the JSON serialization
  30896. */
  30897. serialize(): IFresnelParametersSerialized;
  30898. /**
  30899. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30900. * @param parsedFresnelParameters Define the JSON representation
  30901. * @returns the parsed parameters
  30902. */
  30903. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30904. }
  30905. }
  30906. declare module "babylonjs/Materials/materialFlags" {
  30907. /**
  30908. * This groups all the flags used to control the materials channel.
  30909. */
  30910. export class MaterialFlags {
  30911. private static _DiffuseTextureEnabled;
  30912. /**
  30913. * Are diffuse textures enabled in the application.
  30914. */
  30915. static get DiffuseTextureEnabled(): boolean;
  30916. static set DiffuseTextureEnabled(value: boolean);
  30917. private static _DetailTextureEnabled;
  30918. /**
  30919. * Are detail textures enabled in the application.
  30920. */
  30921. static get DetailTextureEnabled(): boolean;
  30922. static set DetailTextureEnabled(value: boolean);
  30923. private static _AmbientTextureEnabled;
  30924. /**
  30925. * Are ambient textures enabled in the application.
  30926. */
  30927. static get AmbientTextureEnabled(): boolean;
  30928. static set AmbientTextureEnabled(value: boolean);
  30929. private static _OpacityTextureEnabled;
  30930. /**
  30931. * Are opacity textures enabled in the application.
  30932. */
  30933. static get OpacityTextureEnabled(): boolean;
  30934. static set OpacityTextureEnabled(value: boolean);
  30935. private static _ReflectionTextureEnabled;
  30936. /**
  30937. * Are reflection textures enabled in the application.
  30938. */
  30939. static get ReflectionTextureEnabled(): boolean;
  30940. static set ReflectionTextureEnabled(value: boolean);
  30941. private static _EmissiveTextureEnabled;
  30942. /**
  30943. * Are emissive textures enabled in the application.
  30944. */
  30945. static get EmissiveTextureEnabled(): boolean;
  30946. static set EmissiveTextureEnabled(value: boolean);
  30947. private static _SpecularTextureEnabled;
  30948. /**
  30949. * Are specular textures enabled in the application.
  30950. */
  30951. static get SpecularTextureEnabled(): boolean;
  30952. static set SpecularTextureEnabled(value: boolean);
  30953. private static _BumpTextureEnabled;
  30954. /**
  30955. * Are bump textures enabled in the application.
  30956. */
  30957. static get BumpTextureEnabled(): boolean;
  30958. static set BumpTextureEnabled(value: boolean);
  30959. private static _LightmapTextureEnabled;
  30960. /**
  30961. * Are lightmap textures enabled in the application.
  30962. */
  30963. static get LightmapTextureEnabled(): boolean;
  30964. static set LightmapTextureEnabled(value: boolean);
  30965. private static _RefractionTextureEnabled;
  30966. /**
  30967. * Are refraction textures enabled in the application.
  30968. */
  30969. static get RefractionTextureEnabled(): boolean;
  30970. static set RefractionTextureEnabled(value: boolean);
  30971. private static _ColorGradingTextureEnabled;
  30972. /**
  30973. * Are color grading textures enabled in the application.
  30974. */
  30975. static get ColorGradingTextureEnabled(): boolean;
  30976. static set ColorGradingTextureEnabled(value: boolean);
  30977. private static _FresnelEnabled;
  30978. /**
  30979. * Are fresnels enabled in the application.
  30980. */
  30981. static get FresnelEnabled(): boolean;
  30982. static set FresnelEnabled(value: boolean);
  30983. private static _ClearCoatTextureEnabled;
  30984. /**
  30985. * Are clear coat textures enabled in the application.
  30986. */
  30987. static get ClearCoatTextureEnabled(): boolean;
  30988. static set ClearCoatTextureEnabled(value: boolean);
  30989. private static _ClearCoatBumpTextureEnabled;
  30990. /**
  30991. * Are clear coat bump textures enabled in the application.
  30992. */
  30993. static get ClearCoatBumpTextureEnabled(): boolean;
  30994. static set ClearCoatBumpTextureEnabled(value: boolean);
  30995. private static _ClearCoatTintTextureEnabled;
  30996. /**
  30997. * Are clear coat tint textures enabled in the application.
  30998. */
  30999. static get ClearCoatTintTextureEnabled(): boolean;
  31000. static set ClearCoatTintTextureEnabled(value: boolean);
  31001. private static _SheenTextureEnabled;
  31002. /**
  31003. * Are sheen textures enabled in the application.
  31004. */
  31005. static get SheenTextureEnabled(): boolean;
  31006. static set SheenTextureEnabled(value: boolean);
  31007. private static _AnisotropicTextureEnabled;
  31008. /**
  31009. * Are anisotropic textures enabled in the application.
  31010. */
  31011. static get AnisotropicTextureEnabled(): boolean;
  31012. static set AnisotropicTextureEnabled(value: boolean);
  31013. private static _ThicknessTextureEnabled;
  31014. /**
  31015. * Are thickness textures enabled in the application.
  31016. */
  31017. static get ThicknessTextureEnabled(): boolean;
  31018. static set ThicknessTextureEnabled(value: boolean);
  31019. }
  31020. }
  31021. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31022. /** @hidden */
  31023. export var defaultFragmentDeclaration: {
  31024. name: string;
  31025. shader: string;
  31026. };
  31027. }
  31028. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31029. /** @hidden */
  31030. export var defaultUboDeclaration: {
  31031. name: string;
  31032. shader: string;
  31033. };
  31034. }
  31035. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31036. /** @hidden */
  31037. export var prePassDeclaration: {
  31038. name: string;
  31039. shader: string;
  31040. };
  31041. }
  31042. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31043. /** @hidden */
  31044. export var lightFragmentDeclaration: {
  31045. name: string;
  31046. shader: string;
  31047. };
  31048. }
  31049. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31050. /** @hidden */
  31051. export var lightUboDeclaration: {
  31052. name: string;
  31053. shader: string;
  31054. };
  31055. }
  31056. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31057. /** @hidden */
  31058. export var lightsFragmentFunctions: {
  31059. name: string;
  31060. shader: string;
  31061. };
  31062. }
  31063. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31064. /** @hidden */
  31065. export var shadowsFragmentFunctions: {
  31066. name: string;
  31067. shader: string;
  31068. };
  31069. }
  31070. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31071. /** @hidden */
  31072. export var fresnelFunction: {
  31073. name: string;
  31074. shader: string;
  31075. };
  31076. }
  31077. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31078. /** @hidden */
  31079. export var bumpFragmentMainFunctions: {
  31080. name: string;
  31081. shader: string;
  31082. };
  31083. }
  31084. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31085. /** @hidden */
  31086. export var bumpFragmentFunctions: {
  31087. name: string;
  31088. shader: string;
  31089. };
  31090. }
  31091. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31092. /** @hidden */
  31093. export var logDepthDeclaration: {
  31094. name: string;
  31095. shader: string;
  31096. };
  31097. }
  31098. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31099. /** @hidden */
  31100. export var bumpFragment: {
  31101. name: string;
  31102. shader: string;
  31103. };
  31104. }
  31105. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31106. /** @hidden */
  31107. export var depthPrePass: {
  31108. name: string;
  31109. shader: string;
  31110. };
  31111. }
  31112. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31113. /** @hidden */
  31114. export var lightFragment: {
  31115. name: string;
  31116. shader: string;
  31117. };
  31118. }
  31119. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31120. /** @hidden */
  31121. export var logDepthFragment: {
  31122. name: string;
  31123. shader: string;
  31124. };
  31125. }
  31126. declare module "babylonjs/Shaders/default.fragment" {
  31127. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31128. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31129. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31130. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31131. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31132. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31133. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31134. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31135. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31136. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31137. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31138. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31139. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31140. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31141. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31142. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31143. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31144. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31145. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31146. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31147. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31148. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31149. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31150. /** @hidden */
  31151. export var defaultPixelShader: {
  31152. name: string;
  31153. shader: string;
  31154. };
  31155. }
  31156. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31157. /** @hidden */
  31158. export var defaultVertexDeclaration: {
  31159. name: string;
  31160. shader: string;
  31161. };
  31162. }
  31163. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31164. /** @hidden */
  31165. export var bumpVertexDeclaration: {
  31166. name: string;
  31167. shader: string;
  31168. };
  31169. }
  31170. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31171. /** @hidden */
  31172. export var bumpVertex: {
  31173. name: string;
  31174. shader: string;
  31175. };
  31176. }
  31177. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31178. /** @hidden */
  31179. export var fogVertex: {
  31180. name: string;
  31181. shader: string;
  31182. };
  31183. }
  31184. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31185. /** @hidden */
  31186. export var shadowsVertex: {
  31187. name: string;
  31188. shader: string;
  31189. };
  31190. }
  31191. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31192. /** @hidden */
  31193. export var pointCloudVertex: {
  31194. name: string;
  31195. shader: string;
  31196. };
  31197. }
  31198. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31199. /** @hidden */
  31200. export var logDepthVertex: {
  31201. name: string;
  31202. shader: string;
  31203. };
  31204. }
  31205. declare module "babylonjs/Shaders/default.vertex" {
  31206. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31207. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31209. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31210. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31211. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31212. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31213. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31214. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31215. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31218. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31220. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31221. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31222. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31223. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31224. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31225. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31226. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31227. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31228. /** @hidden */
  31229. export var defaultVertexShader: {
  31230. name: string;
  31231. shader: string;
  31232. };
  31233. }
  31234. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31235. import { Nullable } from "babylonjs/types";
  31236. import { Scene } from "babylonjs/scene";
  31237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31238. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31239. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31240. /**
  31241. * @hidden
  31242. */
  31243. export interface IMaterialDetailMapDefines {
  31244. DETAIL: boolean;
  31245. DETAILDIRECTUV: number;
  31246. DETAIL_NORMALBLENDMETHOD: number;
  31247. /** @hidden */
  31248. _areTexturesDirty: boolean;
  31249. }
  31250. /**
  31251. * Define the code related to the detail map parameters of a material
  31252. *
  31253. * Inspired from:
  31254. * 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
  31255. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31256. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31257. */
  31258. export class DetailMapConfiguration {
  31259. private _texture;
  31260. /**
  31261. * The detail texture of the material.
  31262. */
  31263. texture: Nullable<BaseTexture>;
  31264. /**
  31265. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31266. * Bigger values mean stronger blending
  31267. */
  31268. diffuseBlendLevel: number;
  31269. /**
  31270. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31271. * Bigger values mean stronger blending. Only used with PBR materials
  31272. */
  31273. roughnessBlendLevel: number;
  31274. /**
  31275. * Defines how strong the bump effect from the detail map is
  31276. * Bigger values mean stronger effect
  31277. */
  31278. bumpLevel: number;
  31279. private _normalBlendMethod;
  31280. /**
  31281. * The method used to blend the bump and detail normals together
  31282. */
  31283. normalBlendMethod: number;
  31284. private _isEnabled;
  31285. /**
  31286. * Enable or disable the detail map on this material
  31287. */
  31288. isEnabled: boolean;
  31289. /** @hidden */
  31290. private _internalMarkAllSubMeshesAsTexturesDirty;
  31291. /** @hidden */
  31292. _markAllSubMeshesAsTexturesDirty(): void;
  31293. /**
  31294. * Instantiate a new detail map
  31295. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31296. */
  31297. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31298. /**
  31299. * Gets whether the submesh is ready to be used or not.
  31300. * @param defines the list of "defines" to update.
  31301. * @param scene defines the scene the material belongs to.
  31302. * @returns - boolean indicating that the submesh is ready or not.
  31303. */
  31304. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31305. /**
  31306. * Update the defines for detail map usage
  31307. * @param defines the list of "defines" to update.
  31308. * @param scene defines the scene the material belongs to.
  31309. */
  31310. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31311. /**
  31312. * Binds the material data.
  31313. * @param uniformBuffer defines the Uniform buffer to fill in.
  31314. * @param scene defines the scene the material belongs to.
  31315. * @param isFrozen defines whether the material is frozen or not.
  31316. */
  31317. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31318. /**
  31319. * Checks to see if a texture is used in the material.
  31320. * @param texture - Base texture to use.
  31321. * @returns - Boolean specifying if a texture is used in the material.
  31322. */
  31323. hasTexture(texture: BaseTexture): boolean;
  31324. /**
  31325. * Returns an array of the actively used textures.
  31326. * @param activeTextures Array of BaseTextures
  31327. */
  31328. getActiveTextures(activeTextures: BaseTexture[]): void;
  31329. /**
  31330. * Returns the animatable textures.
  31331. * @param animatables Array of animatable textures.
  31332. */
  31333. getAnimatables(animatables: IAnimatable[]): void;
  31334. /**
  31335. * Disposes the resources of the material.
  31336. * @param forceDisposeTextures - Forces the disposal of all textures.
  31337. */
  31338. dispose(forceDisposeTextures?: boolean): void;
  31339. /**
  31340. * Get the current class name useful for serialization or dynamic coding.
  31341. * @returns "DetailMap"
  31342. */
  31343. getClassName(): string;
  31344. /**
  31345. * Add the required uniforms to the current list.
  31346. * @param uniforms defines the current uniform list.
  31347. */
  31348. static AddUniforms(uniforms: string[]): void;
  31349. /**
  31350. * Add the required samplers to the current list.
  31351. * @param samplers defines the current sampler list.
  31352. */
  31353. static AddSamplers(samplers: string[]): void;
  31354. /**
  31355. * Add the required uniforms to the current buffer.
  31356. * @param uniformBuffer defines the current uniform buffer.
  31357. */
  31358. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31359. /**
  31360. * Makes a duplicate of the current instance into another one.
  31361. * @param detailMap define the instance where to copy the info
  31362. */
  31363. copyTo(detailMap: DetailMapConfiguration): void;
  31364. /**
  31365. * Serializes this detail map instance
  31366. * @returns - An object with the serialized instance.
  31367. */
  31368. serialize(): any;
  31369. /**
  31370. * Parses a detail map setting from a serialized object.
  31371. * @param source - Serialized object.
  31372. * @param scene Defines the scene we are parsing for
  31373. * @param rootUrl Defines the rootUrl to load from
  31374. */
  31375. parse(source: any, scene: Scene, rootUrl: string): void;
  31376. }
  31377. }
  31378. declare module "babylonjs/Materials/standardMaterial" {
  31379. import { SmartArray } from "babylonjs/Misc/smartArray";
  31380. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31381. import { Nullable } from "babylonjs/types";
  31382. import { Scene } from "babylonjs/scene";
  31383. import { Matrix } from "babylonjs/Maths/math.vector";
  31384. import { Color3 } from "babylonjs/Maths/math.color";
  31385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31387. import { Mesh } from "babylonjs/Meshes/mesh";
  31388. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31389. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31390. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31391. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31392. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31395. import "babylonjs/Shaders/default.fragment";
  31396. import "babylonjs/Shaders/default.vertex";
  31397. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31398. /** @hidden */
  31399. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31400. MAINUV1: boolean;
  31401. MAINUV2: boolean;
  31402. DIFFUSE: boolean;
  31403. DIFFUSEDIRECTUV: number;
  31404. DETAIL: boolean;
  31405. DETAILDIRECTUV: number;
  31406. DETAIL_NORMALBLENDMETHOD: number;
  31407. AMBIENT: boolean;
  31408. AMBIENTDIRECTUV: number;
  31409. OPACITY: boolean;
  31410. OPACITYDIRECTUV: number;
  31411. OPACITYRGB: boolean;
  31412. REFLECTION: boolean;
  31413. EMISSIVE: boolean;
  31414. EMISSIVEDIRECTUV: number;
  31415. SPECULAR: boolean;
  31416. SPECULARDIRECTUV: number;
  31417. BUMP: boolean;
  31418. BUMPDIRECTUV: number;
  31419. PARALLAX: boolean;
  31420. PARALLAXOCCLUSION: boolean;
  31421. SPECULAROVERALPHA: boolean;
  31422. CLIPPLANE: boolean;
  31423. CLIPPLANE2: boolean;
  31424. CLIPPLANE3: boolean;
  31425. CLIPPLANE4: boolean;
  31426. CLIPPLANE5: boolean;
  31427. CLIPPLANE6: boolean;
  31428. ALPHATEST: boolean;
  31429. DEPTHPREPASS: boolean;
  31430. ALPHAFROMDIFFUSE: boolean;
  31431. POINTSIZE: boolean;
  31432. FOG: boolean;
  31433. SPECULARTERM: boolean;
  31434. DIFFUSEFRESNEL: boolean;
  31435. OPACITYFRESNEL: boolean;
  31436. REFLECTIONFRESNEL: boolean;
  31437. REFRACTIONFRESNEL: boolean;
  31438. EMISSIVEFRESNEL: boolean;
  31439. FRESNEL: boolean;
  31440. NORMAL: boolean;
  31441. UV1: boolean;
  31442. UV2: boolean;
  31443. VERTEXCOLOR: boolean;
  31444. VERTEXALPHA: boolean;
  31445. NUM_BONE_INFLUENCERS: number;
  31446. BonesPerMesh: number;
  31447. BONETEXTURE: boolean;
  31448. INSTANCES: boolean;
  31449. THIN_INSTANCES: boolean;
  31450. GLOSSINESS: boolean;
  31451. ROUGHNESS: boolean;
  31452. EMISSIVEASILLUMINATION: boolean;
  31453. LINKEMISSIVEWITHDIFFUSE: boolean;
  31454. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31455. LIGHTMAP: boolean;
  31456. LIGHTMAPDIRECTUV: number;
  31457. OBJECTSPACE_NORMALMAP: boolean;
  31458. USELIGHTMAPASSHADOWMAP: boolean;
  31459. REFLECTIONMAP_3D: boolean;
  31460. REFLECTIONMAP_SPHERICAL: boolean;
  31461. REFLECTIONMAP_PLANAR: boolean;
  31462. REFLECTIONMAP_CUBIC: boolean;
  31463. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31464. REFLECTIONMAP_PROJECTION: boolean;
  31465. REFLECTIONMAP_SKYBOX: boolean;
  31466. REFLECTIONMAP_EXPLICIT: boolean;
  31467. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31468. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31469. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31470. INVERTCUBICMAP: boolean;
  31471. LOGARITHMICDEPTH: boolean;
  31472. REFRACTION: boolean;
  31473. REFRACTIONMAP_3D: boolean;
  31474. REFLECTIONOVERALPHA: boolean;
  31475. TWOSIDEDLIGHTING: boolean;
  31476. SHADOWFLOAT: boolean;
  31477. MORPHTARGETS: boolean;
  31478. MORPHTARGETS_NORMAL: boolean;
  31479. MORPHTARGETS_TANGENT: boolean;
  31480. MORPHTARGETS_UV: boolean;
  31481. NUM_MORPH_INFLUENCERS: number;
  31482. NONUNIFORMSCALING: boolean;
  31483. PREMULTIPLYALPHA: boolean;
  31484. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31485. ALPHABLEND: boolean;
  31486. PREPASS: boolean;
  31487. SCENE_MRT_COUNT: number;
  31488. RGBDLIGHTMAP: boolean;
  31489. RGBDREFLECTION: boolean;
  31490. RGBDREFRACTION: boolean;
  31491. IMAGEPROCESSING: boolean;
  31492. VIGNETTE: boolean;
  31493. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31494. VIGNETTEBLENDMODEOPAQUE: boolean;
  31495. TONEMAPPING: boolean;
  31496. TONEMAPPING_ACES: boolean;
  31497. CONTRAST: boolean;
  31498. COLORCURVES: boolean;
  31499. COLORGRADING: boolean;
  31500. COLORGRADING3D: boolean;
  31501. SAMPLER3DGREENDEPTH: boolean;
  31502. SAMPLER3DBGRMAP: boolean;
  31503. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31504. MULTIVIEW: boolean;
  31505. /**
  31506. * If the reflection texture on this material is in linear color space
  31507. * @hidden
  31508. */
  31509. IS_REFLECTION_LINEAR: boolean;
  31510. /**
  31511. * If the refraction texture on this material is in linear color space
  31512. * @hidden
  31513. */
  31514. IS_REFRACTION_LINEAR: boolean;
  31515. EXPOSURE: boolean;
  31516. constructor();
  31517. setReflectionMode(modeToEnable: string): void;
  31518. }
  31519. /**
  31520. * This is the default material used in Babylon. It is the best trade off between quality
  31521. * and performances.
  31522. * @see https://doc.babylonjs.com/babylon101/materials
  31523. */
  31524. export class StandardMaterial extends PushMaterial {
  31525. private _diffuseTexture;
  31526. /**
  31527. * The basic texture of the material as viewed under a light.
  31528. */
  31529. diffuseTexture: Nullable<BaseTexture>;
  31530. private _ambientTexture;
  31531. /**
  31532. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31533. */
  31534. ambientTexture: Nullable<BaseTexture>;
  31535. private _opacityTexture;
  31536. /**
  31537. * Define the transparency of the material from a texture.
  31538. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31539. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31540. */
  31541. opacityTexture: Nullable<BaseTexture>;
  31542. private _reflectionTexture;
  31543. /**
  31544. * Define the texture used to display the reflection.
  31545. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31546. */
  31547. reflectionTexture: Nullable<BaseTexture>;
  31548. private _emissiveTexture;
  31549. /**
  31550. * Define texture of the material as if self lit.
  31551. * This will be mixed in the final result even in the absence of light.
  31552. */
  31553. emissiveTexture: Nullable<BaseTexture>;
  31554. private _specularTexture;
  31555. /**
  31556. * Define how the color and intensity of the highlight given by the light in the material.
  31557. */
  31558. specularTexture: Nullable<BaseTexture>;
  31559. private _bumpTexture;
  31560. /**
  31561. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31562. * 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.
  31563. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31564. */
  31565. bumpTexture: Nullable<BaseTexture>;
  31566. private _lightmapTexture;
  31567. /**
  31568. * Complex lighting can be computationally expensive to compute at runtime.
  31569. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31570. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31571. */
  31572. lightmapTexture: Nullable<BaseTexture>;
  31573. private _refractionTexture;
  31574. /**
  31575. * Define the texture used to display the refraction.
  31576. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31577. */
  31578. refractionTexture: Nullable<BaseTexture>;
  31579. /**
  31580. * The color of the material lit by the environmental background lighting.
  31581. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31582. */
  31583. ambientColor: Color3;
  31584. /**
  31585. * The basic color of the material as viewed under a light.
  31586. */
  31587. diffuseColor: Color3;
  31588. /**
  31589. * Define how the color and intensity of the highlight given by the light in the material.
  31590. */
  31591. specularColor: Color3;
  31592. /**
  31593. * Define the color of the material as if self lit.
  31594. * This will be mixed in the final result even in the absence of light.
  31595. */
  31596. emissiveColor: Color3;
  31597. /**
  31598. * Defines how sharp are the highlights in the material.
  31599. * The bigger the value the sharper giving a more glossy feeling to the result.
  31600. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31601. */
  31602. specularPower: number;
  31603. private _useAlphaFromDiffuseTexture;
  31604. /**
  31605. * Does the transparency come from the diffuse texture alpha channel.
  31606. */
  31607. useAlphaFromDiffuseTexture: boolean;
  31608. private _useEmissiveAsIllumination;
  31609. /**
  31610. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31611. */
  31612. useEmissiveAsIllumination: boolean;
  31613. private _linkEmissiveWithDiffuse;
  31614. /**
  31615. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31616. * the emissive level when the final color is close to one.
  31617. */
  31618. linkEmissiveWithDiffuse: boolean;
  31619. private _useSpecularOverAlpha;
  31620. /**
  31621. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31622. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31623. */
  31624. useSpecularOverAlpha: boolean;
  31625. private _useReflectionOverAlpha;
  31626. /**
  31627. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31628. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31629. */
  31630. useReflectionOverAlpha: boolean;
  31631. private _disableLighting;
  31632. /**
  31633. * Does lights from the scene impacts this material.
  31634. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31635. */
  31636. disableLighting: boolean;
  31637. private _useObjectSpaceNormalMap;
  31638. /**
  31639. * Allows using an object space normal map (instead of tangent space).
  31640. */
  31641. useObjectSpaceNormalMap: boolean;
  31642. private _useParallax;
  31643. /**
  31644. * Is parallax enabled or not.
  31645. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31646. */
  31647. useParallax: boolean;
  31648. private _useParallaxOcclusion;
  31649. /**
  31650. * Is parallax occlusion enabled or not.
  31651. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31652. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31653. */
  31654. useParallaxOcclusion: boolean;
  31655. /**
  31656. * 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.
  31657. */
  31658. parallaxScaleBias: number;
  31659. private _roughness;
  31660. /**
  31661. * Helps to define how blurry the reflections should appears in the material.
  31662. */
  31663. roughness: number;
  31664. /**
  31665. * In case of refraction, define the value of the index of refraction.
  31666. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31667. */
  31668. indexOfRefraction: number;
  31669. /**
  31670. * Invert the refraction texture alongside the y axis.
  31671. * It can be useful with procedural textures or probe for instance.
  31672. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31673. */
  31674. invertRefractionY: boolean;
  31675. /**
  31676. * Defines the alpha limits in alpha test mode.
  31677. */
  31678. alphaCutOff: number;
  31679. private _useLightmapAsShadowmap;
  31680. /**
  31681. * In case of light mapping, define whether the map contains light or shadow informations.
  31682. */
  31683. useLightmapAsShadowmap: boolean;
  31684. private _diffuseFresnelParameters;
  31685. /**
  31686. * Define the diffuse fresnel parameters of the material.
  31687. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31688. */
  31689. diffuseFresnelParameters: FresnelParameters;
  31690. private _opacityFresnelParameters;
  31691. /**
  31692. * Define the opacity fresnel parameters of the material.
  31693. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31694. */
  31695. opacityFresnelParameters: FresnelParameters;
  31696. private _reflectionFresnelParameters;
  31697. /**
  31698. * Define the reflection fresnel parameters of the material.
  31699. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31700. */
  31701. reflectionFresnelParameters: FresnelParameters;
  31702. private _refractionFresnelParameters;
  31703. /**
  31704. * Define the refraction fresnel parameters of the material.
  31705. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31706. */
  31707. refractionFresnelParameters: FresnelParameters;
  31708. private _emissiveFresnelParameters;
  31709. /**
  31710. * Define the emissive fresnel parameters of the material.
  31711. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31712. */
  31713. emissiveFresnelParameters: FresnelParameters;
  31714. private _useReflectionFresnelFromSpecular;
  31715. /**
  31716. * If true automatically deducts the fresnels values from the material specularity.
  31717. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31718. */
  31719. useReflectionFresnelFromSpecular: boolean;
  31720. private _useGlossinessFromSpecularMapAlpha;
  31721. /**
  31722. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31723. */
  31724. useGlossinessFromSpecularMapAlpha: boolean;
  31725. private _maxSimultaneousLights;
  31726. /**
  31727. * Defines the maximum number of lights that can be used in the material
  31728. */
  31729. maxSimultaneousLights: number;
  31730. private _invertNormalMapX;
  31731. /**
  31732. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31733. */
  31734. invertNormalMapX: boolean;
  31735. private _invertNormalMapY;
  31736. /**
  31737. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31738. */
  31739. invertNormalMapY: boolean;
  31740. private _twoSidedLighting;
  31741. /**
  31742. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31743. */
  31744. twoSidedLighting: boolean;
  31745. /**
  31746. * Default configuration related to image processing available in the standard Material.
  31747. */
  31748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31749. /**
  31750. * Gets the image processing configuration used either in this material.
  31751. */
  31752. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31753. /**
  31754. * Sets the Default image processing configuration used either in the this material.
  31755. *
  31756. * If sets to null, the scene one is in use.
  31757. */
  31758. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31759. /**
  31760. * Keep track of the image processing observer to allow dispose and replace.
  31761. */
  31762. private _imageProcessingObserver;
  31763. /**
  31764. * Attaches a new image processing configuration to the Standard Material.
  31765. * @param configuration
  31766. */
  31767. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31768. /**
  31769. * Gets wether the color curves effect is enabled.
  31770. */
  31771. get cameraColorCurvesEnabled(): boolean;
  31772. /**
  31773. * Sets wether the color curves effect is enabled.
  31774. */
  31775. set cameraColorCurvesEnabled(value: boolean);
  31776. /**
  31777. * Gets wether the color grading effect is enabled.
  31778. */
  31779. get cameraColorGradingEnabled(): boolean;
  31780. /**
  31781. * Gets wether the color grading effect is enabled.
  31782. */
  31783. set cameraColorGradingEnabled(value: boolean);
  31784. /**
  31785. * Gets wether tonemapping is enabled or not.
  31786. */
  31787. get cameraToneMappingEnabled(): boolean;
  31788. /**
  31789. * Sets wether tonemapping is enabled or not
  31790. */
  31791. set cameraToneMappingEnabled(value: boolean);
  31792. /**
  31793. * The camera exposure used on this material.
  31794. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31795. * This corresponds to a photographic exposure.
  31796. */
  31797. get cameraExposure(): number;
  31798. /**
  31799. * The camera exposure used on this material.
  31800. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31801. * This corresponds to a photographic exposure.
  31802. */
  31803. set cameraExposure(value: number);
  31804. /**
  31805. * Gets The camera contrast used on this material.
  31806. */
  31807. get cameraContrast(): number;
  31808. /**
  31809. * Sets The camera contrast used on this material.
  31810. */
  31811. set cameraContrast(value: number);
  31812. /**
  31813. * Gets the Color Grading 2D Lookup Texture.
  31814. */
  31815. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31816. /**
  31817. * Sets the Color Grading 2D Lookup Texture.
  31818. */
  31819. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31820. /**
  31821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31823. * 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;
  31824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31825. */
  31826. get cameraColorCurves(): Nullable<ColorCurves>;
  31827. /**
  31828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31830. * 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;
  31831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31832. */
  31833. set cameraColorCurves(value: Nullable<ColorCurves>);
  31834. /**
  31835. * Can this material render to several textures at once
  31836. */
  31837. get canRenderToMRT(): boolean;
  31838. /**
  31839. * Defines the detail map parameters for the material.
  31840. */
  31841. readonly detailMap: DetailMapConfiguration;
  31842. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31843. protected _worldViewProjectionMatrix: Matrix;
  31844. protected _globalAmbientColor: Color3;
  31845. protected _useLogarithmicDepth: boolean;
  31846. protected _rebuildInParallel: boolean;
  31847. /**
  31848. * Instantiates a new standard material.
  31849. * This is the default material used in Babylon. It is the best trade off between quality
  31850. * and performances.
  31851. * @see https://doc.babylonjs.com/babylon101/materials
  31852. * @param name Define the name of the material in the scene
  31853. * @param scene Define the scene the material belong to
  31854. */
  31855. constructor(name: string, scene: Scene);
  31856. /**
  31857. * Gets a boolean indicating that current material needs to register RTT
  31858. */
  31859. get hasRenderTargetTextures(): boolean;
  31860. /**
  31861. * Gets the current class name of the material e.g. "StandardMaterial"
  31862. * Mainly use in serialization.
  31863. * @returns the class name
  31864. */
  31865. getClassName(): string;
  31866. /**
  31867. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31868. * You can try switching to logarithmic depth.
  31869. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31870. */
  31871. get useLogarithmicDepth(): boolean;
  31872. set useLogarithmicDepth(value: boolean);
  31873. /**
  31874. * Specifies if the material will require alpha blending
  31875. * @returns a boolean specifying if alpha blending is needed
  31876. */
  31877. needAlphaBlending(): boolean;
  31878. /**
  31879. * Specifies if this material should be rendered in alpha test mode
  31880. * @returns a boolean specifying if an alpha test is needed.
  31881. */
  31882. needAlphaTesting(): boolean;
  31883. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31884. /**
  31885. * Get the texture used for alpha test purpose.
  31886. * @returns the diffuse texture in case of the standard material.
  31887. */
  31888. getAlphaTestTexture(): Nullable<BaseTexture>;
  31889. /**
  31890. * Get if the submesh is ready to be used and all its information available.
  31891. * Child classes can use it to update shaders
  31892. * @param mesh defines the mesh to check
  31893. * @param subMesh defines which submesh to check
  31894. * @param useInstances specifies that instances should be used
  31895. * @returns a boolean indicating that the submesh is ready or not
  31896. */
  31897. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31898. /**
  31899. * Builds the material UBO layouts.
  31900. * Used internally during the effect preparation.
  31901. */
  31902. buildUniformLayout(): void;
  31903. /**
  31904. * Unbinds the material from the mesh
  31905. */
  31906. unbind(): void;
  31907. /**
  31908. * Binds the submesh to this material by preparing the effect and shader to draw
  31909. * @param world defines the world transformation matrix
  31910. * @param mesh defines the mesh containing the submesh
  31911. * @param subMesh defines the submesh to bind the material to
  31912. */
  31913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31914. /**
  31915. * Get the list of animatables in the material.
  31916. * @returns the list of animatables object used in the material
  31917. */
  31918. getAnimatables(): IAnimatable[];
  31919. /**
  31920. * Gets the active textures from the material
  31921. * @returns an array of textures
  31922. */
  31923. getActiveTextures(): BaseTexture[];
  31924. /**
  31925. * Specifies if the material uses a texture
  31926. * @param texture defines the texture to check against the material
  31927. * @returns a boolean specifying if the material uses the texture
  31928. */
  31929. hasTexture(texture: BaseTexture): boolean;
  31930. /**
  31931. * Disposes the material
  31932. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31933. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31934. */
  31935. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31936. /**
  31937. * Makes a duplicate of the material, and gives it a new name
  31938. * @param name defines the new name for the duplicated material
  31939. * @returns the cloned material
  31940. */
  31941. clone(name: string): StandardMaterial;
  31942. /**
  31943. * Serializes this material in a JSON representation
  31944. * @returns the serialized material object
  31945. */
  31946. serialize(): any;
  31947. /**
  31948. * Creates a standard material from parsed material data
  31949. * @param source defines the JSON representation of the material
  31950. * @param scene defines the hosting scene
  31951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31952. * @returns a new standard material
  31953. */
  31954. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31955. /**
  31956. * Are diffuse textures enabled in the application.
  31957. */
  31958. static get DiffuseTextureEnabled(): boolean;
  31959. static set DiffuseTextureEnabled(value: boolean);
  31960. /**
  31961. * Are detail textures enabled in the application.
  31962. */
  31963. static get DetailTextureEnabled(): boolean;
  31964. static set DetailTextureEnabled(value: boolean);
  31965. /**
  31966. * Are ambient textures enabled in the application.
  31967. */
  31968. static get AmbientTextureEnabled(): boolean;
  31969. static set AmbientTextureEnabled(value: boolean);
  31970. /**
  31971. * Are opacity textures enabled in the application.
  31972. */
  31973. static get OpacityTextureEnabled(): boolean;
  31974. static set OpacityTextureEnabled(value: boolean);
  31975. /**
  31976. * Are reflection textures enabled in the application.
  31977. */
  31978. static get ReflectionTextureEnabled(): boolean;
  31979. static set ReflectionTextureEnabled(value: boolean);
  31980. /**
  31981. * Are emissive textures enabled in the application.
  31982. */
  31983. static get EmissiveTextureEnabled(): boolean;
  31984. static set EmissiveTextureEnabled(value: boolean);
  31985. /**
  31986. * Are specular textures enabled in the application.
  31987. */
  31988. static get SpecularTextureEnabled(): boolean;
  31989. static set SpecularTextureEnabled(value: boolean);
  31990. /**
  31991. * Are bump textures enabled in the application.
  31992. */
  31993. static get BumpTextureEnabled(): boolean;
  31994. static set BumpTextureEnabled(value: boolean);
  31995. /**
  31996. * Are lightmap textures enabled in the application.
  31997. */
  31998. static get LightmapTextureEnabled(): boolean;
  31999. static set LightmapTextureEnabled(value: boolean);
  32000. /**
  32001. * Are refraction textures enabled in the application.
  32002. */
  32003. static get RefractionTextureEnabled(): boolean;
  32004. static set RefractionTextureEnabled(value: boolean);
  32005. /**
  32006. * Are color grading textures enabled in the application.
  32007. */
  32008. static get ColorGradingTextureEnabled(): boolean;
  32009. static set ColorGradingTextureEnabled(value: boolean);
  32010. /**
  32011. * Are fresnels enabled in the application.
  32012. */
  32013. static get FresnelEnabled(): boolean;
  32014. static set FresnelEnabled(value: boolean);
  32015. }
  32016. }
  32017. declare module "babylonjs/Particles/solidParticleSystem" {
  32018. import { Nullable } from "babylonjs/types";
  32019. import { Mesh } from "babylonjs/Meshes/mesh";
  32020. import { Scene, IDisposable } from "babylonjs/scene";
  32021. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32022. import { Material } from "babylonjs/Materials/material";
  32023. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32024. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32025. /**
  32026. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32027. *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.
  32028. * The SPS is also a particle system. It provides some methods to manage the particles.
  32029. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32030. *
  32031. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32032. */
  32033. export class SolidParticleSystem implements IDisposable {
  32034. /**
  32035. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32036. * Example : var p = SPS.particles[i];
  32037. */
  32038. particles: SolidParticle[];
  32039. /**
  32040. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32041. */
  32042. nbParticles: number;
  32043. /**
  32044. * If the particles must ever face the camera (default false). Useful for planar particles.
  32045. */
  32046. billboard: boolean;
  32047. /**
  32048. * Recompute normals when adding a shape
  32049. */
  32050. recomputeNormals: boolean;
  32051. /**
  32052. * This a counter ofr your own usage. It's not set by any SPS functions.
  32053. */
  32054. counter: number;
  32055. /**
  32056. * The SPS name. This name is also given to the underlying mesh.
  32057. */
  32058. name: string;
  32059. /**
  32060. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32061. */
  32062. mesh: Mesh;
  32063. /**
  32064. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32065. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32066. */
  32067. vars: any;
  32068. /**
  32069. * This array is populated when the SPS is set as 'pickable'.
  32070. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32071. * Each element of this array is an object `{idx: int, faceId: int}`.
  32072. * `idx` is the picked particle index in the `SPS.particles` array
  32073. * `faceId` is the picked face index counted within this particle.
  32074. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32075. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32076. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32077. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32078. */
  32079. pickedParticles: {
  32080. idx: number;
  32081. faceId: number;
  32082. }[];
  32083. /**
  32084. * This array is populated when the SPS is set as 'pickable'
  32085. * Each key of this array is a submesh index.
  32086. * Each element of this array is a second array defined like this :
  32087. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32088. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32089. * `idx` is the picked particle index in the `SPS.particles` array
  32090. * `faceId` is the picked face index counted within this particle.
  32091. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32092. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32093. */
  32094. pickedBySubMesh: {
  32095. idx: number;
  32096. faceId: number;
  32097. }[][];
  32098. /**
  32099. * This array is populated when `enableDepthSort` is set to true.
  32100. * Each element of this array is an instance of the class DepthSortedParticle.
  32101. */
  32102. depthSortedParticles: DepthSortedParticle[];
  32103. /**
  32104. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32105. * @hidden
  32106. */
  32107. _bSphereOnly: boolean;
  32108. /**
  32109. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32110. * @hidden
  32111. */
  32112. _bSphereRadiusFactor: number;
  32113. private _scene;
  32114. private _positions;
  32115. private _indices;
  32116. private _normals;
  32117. private _colors;
  32118. private _uvs;
  32119. private _indices32;
  32120. private _positions32;
  32121. private _normals32;
  32122. private _fixedNormal32;
  32123. private _colors32;
  32124. private _uvs32;
  32125. private _index;
  32126. private _updatable;
  32127. private _pickable;
  32128. private _isVisibilityBoxLocked;
  32129. private _alwaysVisible;
  32130. private _depthSort;
  32131. private _expandable;
  32132. private _shapeCounter;
  32133. private _copy;
  32134. private _color;
  32135. private _computeParticleColor;
  32136. private _computeParticleTexture;
  32137. private _computeParticleRotation;
  32138. private _computeParticleVertex;
  32139. private _computeBoundingBox;
  32140. private _depthSortParticles;
  32141. private _camera;
  32142. private _mustUnrotateFixedNormals;
  32143. private _particlesIntersect;
  32144. private _needs32Bits;
  32145. private _isNotBuilt;
  32146. private _lastParticleId;
  32147. private _idxOfId;
  32148. private _multimaterialEnabled;
  32149. private _useModelMaterial;
  32150. private _indicesByMaterial;
  32151. private _materialIndexes;
  32152. private _depthSortFunction;
  32153. private _materialSortFunction;
  32154. private _materials;
  32155. private _multimaterial;
  32156. private _materialIndexesById;
  32157. private _defaultMaterial;
  32158. private _autoUpdateSubMeshes;
  32159. private _tmpVertex;
  32160. /**
  32161. * Creates a SPS (Solid Particle System) object.
  32162. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32163. * @param scene (Scene) is the scene in which the SPS is added.
  32164. * @param options defines the options of the sps e.g.
  32165. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32166. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32167. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32168. * * 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.
  32169. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32170. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32171. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32172. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32173. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32174. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32175. */
  32176. constructor(name: string, scene: Scene, options?: {
  32177. updatable?: boolean;
  32178. isPickable?: boolean;
  32179. enableDepthSort?: boolean;
  32180. particleIntersection?: boolean;
  32181. boundingSphereOnly?: boolean;
  32182. bSphereRadiusFactor?: number;
  32183. expandable?: boolean;
  32184. useModelMaterial?: boolean;
  32185. enableMultiMaterial?: boolean;
  32186. });
  32187. /**
  32188. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32189. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32190. * @returns the created mesh
  32191. */
  32192. buildMesh(): Mesh;
  32193. /**
  32194. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32195. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32196. * Thus the particles generated from `digest()` have their property `position` set yet.
  32197. * @param mesh ( Mesh ) is the mesh to be digested
  32198. * @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
  32199. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32200. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32201. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32202. * @returns the current SPS
  32203. */
  32204. digest(mesh: Mesh, options?: {
  32205. facetNb?: number;
  32206. number?: number;
  32207. delta?: number;
  32208. storage?: [];
  32209. }): SolidParticleSystem;
  32210. /**
  32211. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32212. * @hidden
  32213. */
  32214. private _unrotateFixedNormals;
  32215. /**
  32216. * Resets the temporary working copy particle
  32217. * @hidden
  32218. */
  32219. private _resetCopy;
  32220. /**
  32221. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32222. * @param p the current index in the positions array to be updated
  32223. * @param ind the current index in the indices array
  32224. * @param shape a Vector3 array, the shape geometry
  32225. * @param positions the positions array to be updated
  32226. * @param meshInd the shape indices array
  32227. * @param indices the indices array to be updated
  32228. * @param meshUV the shape uv array
  32229. * @param uvs the uv array to be updated
  32230. * @param meshCol the shape color array
  32231. * @param colors the color array to be updated
  32232. * @param meshNor the shape normals array
  32233. * @param normals the normals array to be updated
  32234. * @param idx the particle index
  32235. * @param idxInShape the particle index in its shape
  32236. * @param options the addShape() method passed options
  32237. * @model the particle model
  32238. * @hidden
  32239. */
  32240. private _meshBuilder;
  32241. /**
  32242. * Returns a shape Vector3 array from positions float array
  32243. * @param positions float array
  32244. * @returns a vector3 array
  32245. * @hidden
  32246. */
  32247. private _posToShape;
  32248. /**
  32249. * Returns a shapeUV array from a float uvs (array deep copy)
  32250. * @param uvs as a float array
  32251. * @returns a shapeUV array
  32252. * @hidden
  32253. */
  32254. private _uvsToShapeUV;
  32255. /**
  32256. * Adds a new particle object in the particles array
  32257. * @param idx particle index in particles array
  32258. * @param id particle id
  32259. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32260. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32261. * @param model particle ModelShape object
  32262. * @param shapeId model shape identifier
  32263. * @param idxInShape index of the particle in the current model
  32264. * @param bInfo model bounding info object
  32265. * @param storage target storage array, if any
  32266. * @hidden
  32267. */
  32268. private _addParticle;
  32269. /**
  32270. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32271. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32272. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32273. * @param nb (positive integer) the number of particles to be created from this model
  32274. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32275. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32276. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32277. * @returns the number of shapes in the system
  32278. */
  32279. addShape(mesh: Mesh, nb: number, options?: {
  32280. positionFunction?: any;
  32281. vertexFunction?: any;
  32282. storage?: [];
  32283. }): number;
  32284. /**
  32285. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32286. * @hidden
  32287. */
  32288. private _rebuildParticle;
  32289. /**
  32290. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32291. * @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.
  32292. * @returns the SPS.
  32293. */
  32294. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32295. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32296. * Returns an array with the removed particles.
  32297. * 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.
  32298. * The SPS can't be empty so at least one particle needs to remain in place.
  32299. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32300. * @param start index of the first particle to remove
  32301. * @param end index of the last particle to remove (included)
  32302. * @returns an array populated with the removed particles
  32303. */
  32304. removeParticles(start: number, end: number): SolidParticle[];
  32305. /**
  32306. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32307. * @param solidParticleArray an array populated with Solid Particles objects
  32308. * @returns the SPS
  32309. */
  32310. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32311. /**
  32312. * Creates a new particle and modifies the SPS mesh geometry :
  32313. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32314. * - calls _addParticle() to populate the particle array
  32315. * factorized code from addShape() and insertParticlesFromArray()
  32316. * @param idx particle index in the particles array
  32317. * @param i particle index in its shape
  32318. * @param modelShape particle ModelShape object
  32319. * @param shape shape vertex array
  32320. * @param meshInd shape indices array
  32321. * @param meshUV shape uv array
  32322. * @param meshCol shape color array
  32323. * @param meshNor shape normals array
  32324. * @param bbInfo shape bounding info
  32325. * @param storage target particle storage
  32326. * @options addShape() passed options
  32327. * @hidden
  32328. */
  32329. private _insertNewParticle;
  32330. /**
  32331. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32332. * This method calls `updateParticle()` for each particle of the SPS.
  32333. * For an animated SPS, it is usually called within the render loop.
  32334. * 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.
  32335. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32336. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32337. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32338. * @returns the SPS.
  32339. */
  32340. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32341. /**
  32342. * Disposes the SPS.
  32343. */
  32344. dispose(): void;
  32345. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32346. * idx is the particle index in the SPS
  32347. * faceId is the picked face index counted within this particle.
  32348. * Returns null if the pickInfo can't identify a picked particle.
  32349. * @param pickingInfo (PickingInfo object)
  32350. * @returns {idx: number, faceId: number} or null
  32351. */
  32352. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32353. idx: number;
  32354. faceId: number;
  32355. }>;
  32356. /**
  32357. * Returns a SolidParticle object from its identifier : particle.id
  32358. * @param id (integer) the particle Id
  32359. * @returns the searched particle or null if not found in the SPS.
  32360. */
  32361. getParticleById(id: number): Nullable<SolidParticle>;
  32362. /**
  32363. * Returns a new array populated with the particles having the passed shapeId.
  32364. * @param shapeId (integer) the shape identifier
  32365. * @returns a new solid particle array
  32366. */
  32367. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32368. /**
  32369. * Populates the passed array "ref" with the particles having the passed shapeId.
  32370. * @param shapeId the shape identifier
  32371. * @returns the SPS
  32372. * @param ref
  32373. */
  32374. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32375. /**
  32376. * Computes the required SubMeshes according the materials assigned to the particles.
  32377. * @returns the solid particle system.
  32378. * Does nothing if called before the SPS mesh is built.
  32379. */
  32380. computeSubMeshes(): SolidParticleSystem;
  32381. /**
  32382. * Sorts the solid particles by material when MultiMaterial is enabled.
  32383. * Updates the indices32 array.
  32384. * Updates the indicesByMaterial array.
  32385. * Updates the mesh indices array.
  32386. * @returns the SPS
  32387. * @hidden
  32388. */
  32389. private _sortParticlesByMaterial;
  32390. /**
  32391. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32392. * @hidden
  32393. */
  32394. private _setMaterialIndexesById;
  32395. /**
  32396. * Returns an array with unique values of Materials from the passed array
  32397. * @param array the material array to be checked and filtered
  32398. * @hidden
  32399. */
  32400. private _filterUniqueMaterialId;
  32401. /**
  32402. * Sets a new Standard Material as _defaultMaterial if not already set.
  32403. * @hidden
  32404. */
  32405. private _setDefaultMaterial;
  32406. /**
  32407. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32408. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32409. * @returns the SPS.
  32410. */
  32411. refreshVisibleSize(): SolidParticleSystem;
  32412. /**
  32413. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32414. * @param size the size (float) of the visibility box
  32415. * note : this doesn't lock the SPS mesh bounding box.
  32416. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32417. */
  32418. setVisibilityBox(size: number): void;
  32419. /**
  32420. * Gets whether the SPS as always visible or not
  32421. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32422. */
  32423. get isAlwaysVisible(): boolean;
  32424. /**
  32425. * Sets the SPS as always visible or not
  32426. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32427. */
  32428. set isAlwaysVisible(val: boolean);
  32429. /**
  32430. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32431. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32432. */
  32433. set isVisibilityBoxLocked(val: boolean);
  32434. /**
  32435. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32436. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32437. */
  32438. get isVisibilityBoxLocked(): boolean;
  32439. /**
  32440. * Tells to `setParticles()` to compute the particle rotations or not.
  32441. * Default value : true. The SPS is faster when it's set to false.
  32442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32443. */
  32444. set computeParticleRotation(val: boolean);
  32445. /**
  32446. * Tells to `setParticles()` to compute the particle colors or not.
  32447. * Default value : true. The SPS is faster when it's set to false.
  32448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32449. */
  32450. set computeParticleColor(val: boolean);
  32451. set computeParticleTexture(val: boolean);
  32452. /**
  32453. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32454. * Default value : false. The SPS is faster when it's set to false.
  32455. * Note : the particle custom vertex positions aren't stored values.
  32456. */
  32457. set computeParticleVertex(val: boolean);
  32458. /**
  32459. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32460. */
  32461. set computeBoundingBox(val: boolean);
  32462. /**
  32463. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32464. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32465. * Default : `true`
  32466. */
  32467. set depthSortParticles(val: boolean);
  32468. /**
  32469. * Gets if `setParticles()` computes the particle rotations or not.
  32470. * Default value : true. The SPS is faster when it's set to false.
  32471. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32472. */
  32473. get computeParticleRotation(): boolean;
  32474. /**
  32475. * Gets if `setParticles()` computes the particle colors or not.
  32476. * Default value : true. The SPS is faster when it's set to false.
  32477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32478. */
  32479. get computeParticleColor(): boolean;
  32480. /**
  32481. * Gets if `setParticles()` computes the particle textures or not.
  32482. * Default value : true. The SPS is faster when it's set to false.
  32483. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32484. */
  32485. get computeParticleTexture(): boolean;
  32486. /**
  32487. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32488. * Default value : false. The SPS is faster when it's set to false.
  32489. * Note : the particle custom vertex positions aren't stored values.
  32490. */
  32491. get computeParticleVertex(): boolean;
  32492. /**
  32493. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32494. */
  32495. get computeBoundingBox(): boolean;
  32496. /**
  32497. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32498. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32499. * Default : `true`
  32500. */
  32501. get depthSortParticles(): boolean;
  32502. /**
  32503. * Gets if the SPS is created as expandable at construction time.
  32504. * Default : `false`
  32505. */
  32506. get expandable(): boolean;
  32507. /**
  32508. * Gets if the SPS supports the Multi Materials
  32509. */
  32510. get multimaterialEnabled(): boolean;
  32511. /**
  32512. * Gets if the SPS uses the model materials for its own multimaterial.
  32513. */
  32514. get useModelMaterial(): boolean;
  32515. /**
  32516. * The SPS used material array.
  32517. */
  32518. get materials(): Material[];
  32519. /**
  32520. * Sets the SPS MultiMaterial from the passed materials.
  32521. * Note : the passed array is internally copied and not used then by reference.
  32522. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32523. */
  32524. setMultiMaterial(materials: Material[]): void;
  32525. /**
  32526. * The SPS computed multimaterial object
  32527. */
  32528. get multimaterial(): MultiMaterial;
  32529. set multimaterial(mm: MultiMaterial);
  32530. /**
  32531. * If the subMeshes must be updated on the next call to setParticles()
  32532. */
  32533. get autoUpdateSubMeshes(): boolean;
  32534. set autoUpdateSubMeshes(val: boolean);
  32535. /**
  32536. * This function does nothing. It may be overwritten to set all the particle first values.
  32537. * The SPS doesn't call this function, you may have to call it by your own.
  32538. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32539. */
  32540. initParticles(): void;
  32541. /**
  32542. * This function does nothing. It may be overwritten to recycle a particle.
  32543. * The SPS doesn't call this function, you may have to call it by your own.
  32544. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32545. * @param particle The particle to recycle
  32546. * @returns the recycled particle
  32547. */
  32548. recycleParticle(particle: SolidParticle): SolidParticle;
  32549. /**
  32550. * Updates a particle : this function should be overwritten by the user.
  32551. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32552. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32553. * @example : just set a particle position or velocity and recycle conditions
  32554. * @param particle The particle to update
  32555. * @returns the updated particle
  32556. */
  32557. updateParticle(particle: SolidParticle): SolidParticle;
  32558. /**
  32559. * Updates a vertex of a particle : it can be overwritten by the user.
  32560. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32561. * @param particle the current particle
  32562. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32563. * @param pt the index of the current vertex in the particle shape
  32564. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32565. * @example : just set a vertex particle position or color
  32566. * @returns the sps
  32567. */
  32568. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32569. /**
  32570. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32571. * This does nothing and may be overwritten by the user.
  32572. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32573. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32574. * @param update the boolean update value actually passed to setParticles()
  32575. */
  32576. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32577. /**
  32578. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32579. * This will be passed three parameters.
  32580. * This does nothing and may be overwritten by the user.
  32581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32583. * @param update the boolean update value actually passed to setParticles()
  32584. */
  32585. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32586. }
  32587. }
  32588. declare module "babylonjs/Particles/solidParticle" {
  32589. import { Nullable } from "babylonjs/types";
  32590. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32591. import { Color4 } from "babylonjs/Maths/math.color";
  32592. import { Mesh } from "babylonjs/Meshes/mesh";
  32593. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32594. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32595. import { Plane } from "babylonjs/Maths/math.plane";
  32596. import { Material } from "babylonjs/Materials/material";
  32597. /**
  32598. * Represents one particle of a solid particle system.
  32599. */
  32600. export class SolidParticle {
  32601. /**
  32602. * particle global index
  32603. */
  32604. idx: number;
  32605. /**
  32606. * particle identifier
  32607. */
  32608. id: number;
  32609. /**
  32610. * The color of the particle
  32611. */
  32612. color: Nullable<Color4>;
  32613. /**
  32614. * The world space position of the particle.
  32615. */
  32616. position: Vector3;
  32617. /**
  32618. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32619. */
  32620. rotation: Vector3;
  32621. /**
  32622. * The world space rotation quaternion of the particle.
  32623. */
  32624. rotationQuaternion: Nullable<Quaternion>;
  32625. /**
  32626. * The scaling of the particle.
  32627. */
  32628. scaling: Vector3;
  32629. /**
  32630. * The uvs of the particle.
  32631. */
  32632. uvs: Vector4;
  32633. /**
  32634. * The current speed of the particle.
  32635. */
  32636. velocity: Vector3;
  32637. /**
  32638. * The pivot point in the particle local space.
  32639. */
  32640. pivot: Vector3;
  32641. /**
  32642. * Must the particle be translated from its pivot point in its local space ?
  32643. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32644. * Default : false
  32645. */
  32646. translateFromPivot: boolean;
  32647. /**
  32648. * Is the particle active or not ?
  32649. */
  32650. alive: boolean;
  32651. /**
  32652. * Is the particle visible or not ?
  32653. */
  32654. isVisible: boolean;
  32655. /**
  32656. * Index of this particle in the global "positions" array (Internal use)
  32657. * @hidden
  32658. */
  32659. _pos: number;
  32660. /**
  32661. * @hidden Index of this particle in the global "indices" array (Internal use)
  32662. */
  32663. _ind: number;
  32664. /**
  32665. * @hidden ModelShape of this particle (Internal use)
  32666. */
  32667. _model: ModelShape;
  32668. /**
  32669. * ModelShape id of this particle
  32670. */
  32671. shapeId: number;
  32672. /**
  32673. * Index of the particle in its shape id
  32674. */
  32675. idxInShape: number;
  32676. /**
  32677. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32678. */
  32679. _modelBoundingInfo: BoundingInfo;
  32680. /**
  32681. * @hidden Particle BoundingInfo object (Internal use)
  32682. */
  32683. _boundingInfo: BoundingInfo;
  32684. /**
  32685. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32686. */
  32687. _sps: SolidParticleSystem;
  32688. /**
  32689. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32690. */
  32691. _stillInvisible: boolean;
  32692. /**
  32693. * @hidden Last computed particle rotation matrix
  32694. */
  32695. _rotationMatrix: number[];
  32696. /**
  32697. * Parent particle Id, if any.
  32698. * Default null.
  32699. */
  32700. parentId: Nullable<number>;
  32701. /**
  32702. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32703. */
  32704. materialIndex: Nullable<number>;
  32705. /**
  32706. * Custom object or properties.
  32707. */
  32708. props: Nullable<any>;
  32709. /**
  32710. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32711. * The possible values are :
  32712. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32713. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32714. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32715. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32716. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32717. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32718. * */
  32719. cullingStrategy: number;
  32720. /**
  32721. * @hidden Internal global position in the SPS.
  32722. */
  32723. _globalPosition: Vector3;
  32724. /**
  32725. * Creates a Solid Particle object.
  32726. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32727. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32728. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32729. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32730. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32731. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32732. * @param shapeId (integer) is the model shape identifier in the SPS.
  32733. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32734. * @param sps defines the sps it is associated to
  32735. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32736. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32737. */
  32738. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32739. /**
  32740. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32741. * @param target the particle target
  32742. * @returns the current particle
  32743. */
  32744. copyToRef(target: SolidParticle): SolidParticle;
  32745. /**
  32746. * Legacy support, changed scale to scaling
  32747. */
  32748. get scale(): Vector3;
  32749. /**
  32750. * Legacy support, changed scale to scaling
  32751. */
  32752. set scale(scale: Vector3);
  32753. /**
  32754. * Legacy support, changed quaternion to rotationQuaternion
  32755. */
  32756. get quaternion(): Nullable<Quaternion>;
  32757. /**
  32758. * Legacy support, changed quaternion to rotationQuaternion
  32759. */
  32760. set quaternion(q: Nullable<Quaternion>);
  32761. /**
  32762. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32763. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32764. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32765. * @returns true if it intersects
  32766. */
  32767. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32768. /**
  32769. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32770. * A particle is in the frustum if its bounding box intersects the frustum
  32771. * @param frustumPlanes defines the frustum to test
  32772. * @returns true if the particle is in the frustum planes
  32773. */
  32774. isInFrustum(frustumPlanes: Plane[]): boolean;
  32775. /**
  32776. * get the rotation matrix of the particle
  32777. * @hidden
  32778. */
  32779. getRotationMatrix(m: Matrix): void;
  32780. }
  32781. /**
  32782. * Represents the shape of the model used by one particle of a solid particle system.
  32783. * SPS internal tool, don't use it manually.
  32784. */
  32785. export class ModelShape {
  32786. /**
  32787. * The shape id
  32788. * @hidden
  32789. */
  32790. shapeID: number;
  32791. /**
  32792. * flat array of model positions (internal use)
  32793. * @hidden
  32794. */
  32795. _shape: Vector3[];
  32796. /**
  32797. * flat array of model UVs (internal use)
  32798. * @hidden
  32799. */
  32800. _shapeUV: number[];
  32801. /**
  32802. * color array of the model
  32803. * @hidden
  32804. */
  32805. _shapeColors: number[];
  32806. /**
  32807. * indices array of the model
  32808. * @hidden
  32809. */
  32810. _indices: number[];
  32811. /**
  32812. * normals array of the model
  32813. * @hidden
  32814. */
  32815. _normals: number[];
  32816. /**
  32817. * length of the shape in the model indices array (internal use)
  32818. * @hidden
  32819. */
  32820. _indicesLength: number;
  32821. /**
  32822. * Custom position function (internal use)
  32823. * @hidden
  32824. */
  32825. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32826. /**
  32827. * Custom vertex function (internal use)
  32828. * @hidden
  32829. */
  32830. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32831. /**
  32832. * Model material (internal use)
  32833. * @hidden
  32834. */
  32835. _material: Nullable<Material>;
  32836. /**
  32837. * 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.
  32838. * SPS internal tool, don't use it manually.
  32839. * @hidden
  32840. */
  32841. 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>);
  32842. }
  32843. /**
  32844. * Represents a Depth Sorted Particle in the solid particle system.
  32845. * @hidden
  32846. */
  32847. export class DepthSortedParticle {
  32848. /**
  32849. * Particle index
  32850. */
  32851. idx: number;
  32852. /**
  32853. * Index of the particle in the "indices" array
  32854. */
  32855. ind: number;
  32856. /**
  32857. * Length of the particle shape in the "indices" array
  32858. */
  32859. indicesLength: number;
  32860. /**
  32861. * Squared distance from the particle to the camera
  32862. */
  32863. sqDistance: number;
  32864. /**
  32865. * Material index when used with MultiMaterials
  32866. */
  32867. materialIndex: number;
  32868. /**
  32869. * Creates a new sorted particle
  32870. * @param materialIndex
  32871. */
  32872. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32873. }
  32874. /**
  32875. * Represents a solid particle vertex
  32876. */
  32877. export class SolidParticleVertex {
  32878. /**
  32879. * Vertex position
  32880. */
  32881. position: Vector3;
  32882. /**
  32883. * Vertex color
  32884. */
  32885. color: Color4;
  32886. /**
  32887. * Vertex UV
  32888. */
  32889. uv: Vector2;
  32890. /**
  32891. * Creates a new solid particle vertex
  32892. */
  32893. constructor();
  32894. /** Vertex x coordinate */
  32895. get x(): number;
  32896. set x(val: number);
  32897. /** Vertex y coordinate */
  32898. get y(): number;
  32899. set y(val: number);
  32900. /** Vertex z coordinate */
  32901. get z(): number;
  32902. set z(val: number);
  32903. }
  32904. }
  32905. declare module "babylonjs/Collisions/meshCollisionData" {
  32906. import { Collider } from "babylonjs/Collisions/collider";
  32907. import { Vector3 } from "babylonjs/Maths/math.vector";
  32908. import { Nullable } from "babylonjs/types";
  32909. import { Observer } from "babylonjs/Misc/observable";
  32910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32911. /**
  32912. * @hidden
  32913. */
  32914. export class _MeshCollisionData {
  32915. _checkCollisions: boolean;
  32916. _collisionMask: number;
  32917. _collisionGroup: number;
  32918. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32919. _collider: Nullable<Collider>;
  32920. _oldPositionForCollisions: Vector3;
  32921. _diffPositionForCollisions: Vector3;
  32922. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32923. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32924. }
  32925. }
  32926. declare module "babylonjs/Meshes/abstractMesh" {
  32927. import { Observable } from "babylonjs/Misc/observable";
  32928. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32929. import { Camera } from "babylonjs/Cameras/camera";
  32930. import { Scene, IDisposable } from "babylonjs/scene";
  32931. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32932. import { Node } from "babylonjs/node";
  32933. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32934. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32936. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32937. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32938. import { Material } from "babylonjs/Materials/material";
  32939. import { Light } from "babylonjs/Lights/light";
  32940. import { Skeleton } from "babylonjs/Bones/skeleton";
  32941. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32942. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32943. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32944. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32945. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32946. import { Plane } from "babylonjs/Maths/math.plane";
  32947. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32948. import { Ray } from "babylonjs/Culling/ray";
  32949. import { Collider } from "babylonjs/Collisions/collider";
  32950. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32951. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32952. /** @hidden */
  32953. class _FacetDataStorage {
  32954. facetPositions: Vector3[];
  32955. facetNormals: Vector3[];
  32956. facetPartitioning: number[][];
  32957. facetNb: number;
  32958. partitioningSubdivisions: number;
  32959. partitioningBBoxRatio: number;
  32960. facetDataEnabled: boolean;
  32961. facetParameters: any;
  32962. bbSize: Vector3;
  32963. subDiv: {
  32964. max: number;
  32965. X: number;
  32966. Y: number;
  32967. Z: number;
  32968. };
  32969. facetDepthSort: boolean;
  32970. facetDepthSortEnabled: boolean;
  32971. depthSortedIndices: IndicesArray;
  32972. depthSortedFacets: {
  32973. ind: number;
  32974. sqDistance: number;
  32975. }[];
  32976. facetDepthSortFunction: (f1: {
  32977. ind: number;
  32978. sqDistance: number;
  32979. }, f2: {
  32980. ind: number;
  32981. sqDistance: number;
  32982. }) => number;
  32983. facetDepthSortFrom: Vector3;
  32984. facetDepthSortOrigin: Vector3;
  32985. invertedMatrix: Matrix;
  32986. }
  32987. /**
  32988. * @hidden
  32989. **/
  32990. class _InternalAbstractMeshDataInfo {
  32991. _hasVertexAlpha: boolean;
  32992. _useVertexColors: boolean;
  32993. _numBoneInfluencers: number;
  32994. _applyFog: boolean;
  32995. _receiveShadows: boolean;
  32996. _facetData: _FacetDataStorage;
  32997. _visibility: number;
  32998. _skeleton: Nullable<Skeleton>;
  32999. _layerMask: number;
  33000. _computeBonesUsingShaders: boolean;
  33001. _isActive: boolean;
  33002. _onlyForInstances: boolean;
  33003. _isActiveIntermediate: boolean;
  33004. _onlyForInstancesIntermediate: boolean;
  33005. _actAsRegularMesh: boolean;
  33006. }
  33007. /**
  33008. * Class used to store all common mesh properties
  33009. */
  33010. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33011. /** No occlusion */
  33012. static OCCLUSION_TYPE_NONE: number;
  33013. /** Occlusion set to optimisitic */
  33014. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33015. /** Occlusion set to strict */
  33016. static OCCLUSION_TYPE_STRICT: number;
  33017. /** Use an accurante occlusion algorithm */
  33018. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33019. /** Use a conservative occlusion algorithm */
  33020. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33021. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33022. * Test order :
  33023. * Is the bounding sphere outside the frustum ?
  33024. * If not, are the bounding box vertices outside the frustum ?
  33025. * It not, then the cullable object is in the frustum.
  33026. */
  33027. static readonly CULLINGSTRATEGY_STANDARD: number;
  33028. /** Culling strategy : Bounding Sphere Only.
  33029. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33030. * It's also less accurate than the standard because some not visible objects can still be selected.
  33031. * Test : is the bounding sphere outside the frustum ?
  33032. * If not, then the cullable object is in the frustum.
  33033. */
  33034. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33035. /** Culling strategy : Optimistic Inclusion.
  33036. * This in an inclusion test first, then the standard exclusion test.
  33037. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33038. * 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.
  33039. * Anyway, it's as accurate as the standard strategy.
  33040. * Test :
  33041. * Is the cullable object bounding sphere center in the frustum ?
  33042. * If not, apply the default culling strategy.
  33043. */
  33044. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33045. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33046. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33047. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33048. * 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.
  33049. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33050. * Test :
  33051. * Is the cullable object bounding sphere center in the frustum ?
  33052. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33053. */
  33054. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33055. /**
  33056. * No billboard
  33057. */
  33058. static get BILLBOARDMODE_NONE(): number;
  33059. /** Billboard on X axis */
  33060. static get BILLBOARDMODE_X(): number;
  33061. /** Billboard on Y axis */
  33062. static get BILLBOARDMODE_Y(): number;
  33063. /** Billboard on Z axis */
  33064. static get BILLBOARDMODE_Z(): number;
  33065. /** Billboard on all axes */
  33066. static get BILLBOARDMODE_ALL(): number;
  33067. /** Billboard on using position instead of orientation */
  33068. static get BILLBOARDMODE_USE_POSITION(): number;
  33069. /** @hidden */
  33070. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33071. /**
  33072. * The culling strategy to use to check whether the mesh must be rendered or not.
  33073. * This value can be changed at any time and will be used on the next render mesh selection.
  33074. * The possible values are :
  33075. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33076. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33077. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33078. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33079. * Please read each static variable documentation to get details about the culling process.
  33080. * */
  33081. cullingStrategy: number;
  33082. /**
  33083. * Gets the number of facets in the mesh
  33084. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33085. */
  33086. get facetNb(): number;
  33087. /**
  33088. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33089. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33090. */
  33091. get partitioningSubdivisions(): number;
  33092. set partitioningSubdivisions(nb: number);
  33093. /**
  33094. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33095. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33096. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33097. */
  33098. get partitioningBBoxRatio(): number;
  33099. set partitioningBBoxRatio(ratio: number);
  33100. /**
  33101. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33102. * Works only for updatable meshes.
  33103. * Doesn't work with multi-materials
  33104. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33105. */
  33106. get mustDepthSortFacets(): boolean;
  33107. set mustDepthSortFacets(sort: boolean);
  33108. /**
  33109. * The location (Vector3) where the facet depth sort must be computed from.
  33110. * By default, the active camera position.
  33111. * Used only when facet depth sort is enabled
  33112. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33113. */
  33114. get facetDepthSortFrom(): Vector3;
  33115. set facetDepthSortFrom(location: Vector3);
  33116. /**
  33117. * gets a boolean indicating if facetData is enabled
  33118. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33119. */
  33120. get isFacetDataEnabled(): boolean;
  33121. /** @hidden */
  33122. _updateNonUniformScalingState(value: boolean): boolean;
  33123. /**
  33124. * An event triggered when this mesh collides with another one
  33125. */
  33126. onCollideObservable: Observable<AbstractMesh>;
  33127. /** Set a function to call when this mesh collides with another one */
  33128. set onCollide(callback: () => void);
  33129. /**
  33130. * An event triggered when the collision's position changes
  33131. */
  33132. onCollisionPositionChangeObservable: Observable<Vector3>;
  33133. /** Set a function to call when the collision's position changes */
  33134. set onCollisionPositionChange(callback: () => void);
  33135. /**
  33136. * An event triggered when material is changed
  33137. */
  33138. onMaterialChangedObservable: Observable<AbstractMesh>;
  33139. /**
  33140. * Gets or sets the orientation for POV movement & rotation
  33141. */
  33142. definedFacingForward: boolean;
  33143. /** @hidden */
  33144. _occlusionQuery: Nullable<WebGLQuery>;
  33145. /** @hidden */
  33146. _renderingGroup: Nullable<RenderingGroup>;
  33147. /**
  33148. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33149. */
  33150. get visibility(): number;
  33151. /**
  33152. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33153. */
  33154. set visibility(value: number);
  33155. /** Gets or sets the alpha index used to sort transparent meshes
  33156. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33157. */
  33158. alphaIndex: number;
  33159. /**
  33160. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33161. */
  33162. isVisible: boolean;
  33163. /**
  33164. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33165. */
  33166. isPickable: boolean;
  33167. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33168. showSubMeshesBoundingBox: boolean;
  33169. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33170. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33171. */
  33172. isBlocker: boolean;
  33173. /**
  33174. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33175. */
  33176. enablePointerMoveEvents: boolean;
  33177. /**
  33178. * Specifies the rendering group id for this mesh (0 by default)
  33179. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33180. */
  33181. renderingGroupId: number;
  33182. private _material;
  33183. /** Gets or sets current material */
  33184. get material(): Nullable<Material>;
  33185. set material(value: Nullable<Material>);
  33186. /**
  33187. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33188. * @see https://doc.babylonjs.com/babylon101/shadows
  33189. */
  33190. get receiveShadows(): boolean;
  33191. set receiveShadows(value: boolean);
  33192. /** Defines color to use when rendering outline */
  33193. outlineColor: Color3;
  33194. /** Define width to use when rendering outline */
  33195. outlineWidth: number;
  33196. /** Defines color to use when rendering overlay */
  33197. overlayColor: Color3;
  33198. /** Defines alpha to use when rendering overlay */
  33199. overlayAlpha: number;
  33200. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33201. get hasVertexAlpha(): boolean;
  33202. set hasVertexAlpha(value: boolean);
  33203. /** 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) */
  33204. get useVertexColors(): boolean;
  33205. set useVertexColors(value: boolean);
  33206. /**
  33207. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33208. */
  33209. get computeBonesUsingShaders(): boolean;
  33210. set computeBonesUsingShaders(value: boolean);
  33211. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33212. get numBoneInfluencers(): number;
  33213. set numBoneInfluencers(value: number);
  33214. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33215. get applyFog(): boolean;
  33216. set applyFog(value: boolean);
  33217. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33218. useOctreeForRenderingSelection: boolean;
  33219. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33220. useOctreeForPicking: boolean;
  33221. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33222. useOctreeForCollisions: boolean;
  33223. /**
  33224. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33225. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33226. */
  33227. get layerMask(): number;
  33228. set layerMask(value: number);
  33229. /**
  33230. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33231. */
  33232. alwaysSelectAsActiveMesh: boolean;
  33233. /**
  33234. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33235. */
  33236. doNotSyncBoundingInfo: boolean;
  33237. /**
  33238. * Gets or sets the current action manager
  33239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33240. */
  33241. actionManager: Nullable<AbstractActionManager>;
  33242. private _meshCollisionData;
  33243. /**
  33244. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33245. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33246. */
  33247. ellipsoid: Vector3;
  33248. /**
  33249. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33250. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33251. */
  33252. ellipsoidOffset: Vector3;
  33253. /**
  33254. * Gets or sets a collision mask used to mask collisions (default is -1).
  33255. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33256. */
  33257. get collisionMask(): number;
  33258. set collisionMask(mask: number);
  33259. /**
  33260. * Gets or sets the current collision group mask (-1 by default).
  33261. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33262. */
  33263. get collisionGroup(): number;
  33264. set collisionGroup(mask: number);
  33265. /**
  33266. * Gets or sets current surrounding meshes (null by default).
  33267. *
  33268. * By default collision detection is tested against every mesh in the scene.
  33269. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33270. * meshes will be tested for the collision.
  33271. *
  33272. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33273. */
  33274. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33275. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33276. /**
  33277. * Defines edge width used when edgesRenderer is enabled
  33278. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33279. */
  33280. edgesWidth: number;
  33281. /**
  33282. * Defines edge color used when edgesRenderer is enabled
  33283. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33284. */
  33285. edgesColor: Color4;
  33286. /** @hidden */
  33287. _edgesRenderer: Nullable<IEdgesRenderer>;
  33288. /** @hidden */
  33289. _masterMesh: Nullable<AbstractMesh>;
  33290. /** @hidden */
  33291. _boundingInfo: Nullable<BoundingInfo>;
  33292. /** @hidden */
  33293. _renderId: number;
  33294. /**
  33295. * Gets or sets the list of subMeshes
  33296. * @see https://doc.babylonjs.com/how_to/multi_materials
  33297. */
  33298. subMeshes: SubMesh[];
  33299. /** @hidden */
  33300. _intersectionsInProgress: AbstractMesh[];
  33301. /** @hidden */
  33302. _unIndexed: boolean;
  33303. /** @hidden */
  33304. _lightSources: Light[];
  33305. /** Gets the list of lights affecting that mesh */
  33306. get lightSources(): Light[];
  33307. /** @hidden */
  33308. get _positions(): Nullable<Vector3[]>;
  33309. /** @hidden */
  33310. _waitingData: {
  33311. lods: Nullable<any>;
  33312. actions: Nullable<any>;
  33313. freezeWorldMatrix: Nullable<boolean>;
  33314. };
  33315. /** @hidden */
  33316. _bonesTransformMatrices: Nullable<Float32Array>;
  33317. /** @hidden */
  33318. _transformMatrixTexture: Nullable<RawTexture>;
  33319. /**
  33320. * Gets or sets a skeleton to apply skining transformations
  33321. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33322. */
  33323. set skeleton(value: Nullable<Skeleton>);
  33324. get skeleton(): Nullable<Skeleton>;
  33325. /**
  33326. * An event triggered when the mesh is rebuilt.
  33327. */
  33328. onRebuildObservable: Observable<AbstractMesh>;
  33329. /**
  33330. * Creates a new AbstractMesh
  33331. * @param name defines the name of the mesh
  33332. * @param scene defines the hosting scene
  33333. */
  33334. constructor(name: string, scene?: Nullable<Scene>);
  33335. /**
  33336. * Returns the string "AbstractMesh"
  33337. * @returns "AbstractMesh"
  33338. */
  33339. getClassName(): string;
  33340. /**
  33341. * Gets a string representation of the current mesh
  33342. * @param fullDetails defines a boolean indicating if full details must be included
  33343. * @returns a string representation of the current mesh
  33344. */
  33345. toString(fullDetails?: boolean): string;
  33346. /**
  33347. * @hidden
  33348. */
  33349. protected _getEffectiveParent(): Nullable<Node>;
  33350. /** @hidden */
  33351. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33352. /** @hidden */
  33353. _rebuild(): void;
  33354. /** @hidden */
  33355. _resyncLightSources(): void;
  33356. /** @hidden */
  33357. _resyncLightSource(light: Light): void;
  33358. /** @hidden */
  33359. _unBindEffect(): void;
  33360. /** @hidden */
  33361. _removeLightSource(light: Light, dispose: boolean): void;
  33362. private _markSubMeshesAsDirty;
  33363. /** @hidden */
  33364. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33365. /** @hidden */
  33366. _markSubMeshesAsAttributesDirty(): void;
  33367. /** @hidden */
  33368. _markSubMeshesAsMiscDirty(): void;
  33369. /**
  33370. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33371. */
  33372. get scaling(): Vector3;
  33373. set scaling(newScaling: Vector3);
  33374. /**
  33375. * Returns true if the mesh is blocked. Implemented by child classes
  33376. */
  33377. get isBlocked(): boolean;
  33378. /**
  33379. * Returns the mesh itself by default. Implemented by child classes
  33380. * @param camera defines the camera to use to pick the right LOD level
  33381. * @returns the currentAbstractMesh
  33382. */
  33383. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33384. /**
  33385. * Returns 0 by default. Implemented by child classes
  33386. * @returns an integer
  33387. */
  33388. getTotalVertices(): number;
  33389. /**
  33390. * Returns a positive integer : the total number of indices in this mesh geometry.
  33391. * @returns the numner of indices or zero if the mesh has no geometry.
  33392. */
  33393. getTotalIndices(): number;
  33394. /**
  33395. * Returns null by default. Implemented by child classes
  33396. * @returns null
  33397. */
  33398. getIndices(): Nullable<IndicesArray>;
  33399. /**
  33400. * Returns the array of the requested vertex data kind. Implemented by child classes
  33401. * @param kind defines the vertex data kind to use
  33402. * @returns null
  33403. */
  33404. getVerticesData(kind: string): Nullable<FloatArray>;
  33405. /**
  33406. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33407. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33408. * Note that a new underlying VertexBuffer object is created each call.
  33409. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33410. * @param kind defines vertex data kind:
  33411. * * VertexBuffer.PositionKind
  33412. * * VertexBuffer.UVKind
  33413. * * VertexBuffer.UV2Kind
  33414. * * VertexBuffer.UV3Kind
  33415. * * VertexBuffer.UV4Kind
  33416. * * VertexBuffer.UV5Kind
  33417. * * VertexBuffer.UV6Kind
  33418. * * VertexBuffer.ColorKind
  33419. * * VertexBuffer.MatricesIndicesKind
  33420. * * VertexBuffer.MatricesIndicesExtraKind
  33421. * * VertexBuffer.MatricesWeightsKind
  33422. * * VertexBuffer.MatricesWeightsExtraKind
  33423. * @param data defines the data source
  33424. * @param updatable defines if the data must be flagged as updatable (or static)
  33425. * @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
  33426. * @returns the current mesh
  33427. */
  33428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33429. /**
  33430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33431. * If the mesh has no geometry, it is simply returned as it is.
  33432. * @param kind defines vertex data kind:
  33433. * * VertexBuffer.PositionKind
  33434. * * VertexBuffer.UVKind
  33435. * * VertexBuffer.UV2Kind
  33436. * * VertexBuffer.UV3Kind
  33437. * * VertexBuffer.UV4Kind
  33438. * * VertexBuffer.UV5Kind
  33439. * * VertexBuffer.UV6Kind
  33440. * * VertexBuffer.ColorKind
  33441. * * VertexBuffer.MatricesIndicesKind
  33442. * * VertexBuffer.MatricesIndicesExtraKind
  33443. * * VertexBuffer.MatricesWeightsKind
  33444. * * VertexBuffer.MatricesWeightsExtraKind
  33445. * @param data defines the data source
  33446. * @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
  33447. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33448. * @returns the current mesh
  33449. */
  33450. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33451. /**
  33452. * Sets the mesh indices,
  33453. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33454. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33455. * @param totalVertices Defines the total number of vertices
  33456. * @returns the current mesh
  33457. */
  33458. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33459. /**
  33460. * Gets a boolean indicating if specific vertex data is present
  33461. * @param kind defines the vertex data kind to use
  33462. * @returns true is data kind is present
  33463. */
  33464. isVerticesDataPresent(kind: string): boolean;
  33465. /**
  33466. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33467. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33468. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33469. * @returns a BoundingInfo
  33470. */
  33471. getBoundingInfo(): BoundingInfo;
  33472. /**
  33473. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33474. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33475. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33476. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33477. * @returns the current mesh
  33478. */
  33479. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33480. /**
  33481. * Overwrite the current bounding info
  33482. * @param boundingInfo defines the new bounding info
  33483. * @returns the current mesh
  33484. */
  33485. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33486. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33487. get useBones(): boolean;
  33488. /** @hidden */
  33489. _preActivate(): void;
  33490. /** @hidden */
  33491. _preActivateForIntermediateRendering(renderId: number): void;
  33492. /** @hidden */
  33493. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33494. /** @hidden */
  33495. _postActivate(): void;
  33496. /** @hidden */
  33497. _freeze(): void;
  33498. /** @hidden */
  33499. _unFreeze(): void;
  33500. /**
  33501. * Gets the current world matrix
  33502. * @returns a Matrix
  33503. */
  33504. getWorldMatrix(): Matrix;
  33505. /** @hidden */
  33506. _getWorldMatrixDeterminant(): number;
  33507. /**
  33508. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33509. */
  33510. get isAnInstance(): boolean;
  33511. /**
  33512. * Gets a boolean indicating if this mesh has instances
  33513. */
  33514. get hasInstances(): boolean;
  33515. /**
  33516. * Gets a boolean indicating if this mesh has thin instances
  33517. */
  33518. get hasThinInstances(): boolean;
  33519. /**
  33520. * Perform relative position change from the point of view of behind the front of the mesh.
  33521. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33522. * Supports definition of mesh facing forward or backward
  33523. * @param amountRight defines the distance on the right axis
  33524. * @param amountUp defines the distance on the up axis
  33525. * @param amountForward defines the distance on the forward axis
  33526. * @returns the current mesh
  33527. */
  33528. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33529. /**
  33530. * Calculate relative position change from the point of view of behind the front of the mesh.
  33531. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33532. * Supports definition of mesh facing forward or backward
  33533. * @param amountRight defines the distance on the right axis
  33534. * @param amountUp defines the distance on the up axis
  33535. * @param amountForward defines the distance on the forward axis
  33536. * @returns the new displacement vector
  33537. */
  33538. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33539. /**
  33540. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33541. * Supports definition of mesh facing forward or backward
  33542. * @param flipBack defines the flip
  33543. * @param twirlClockwise defines the twirl
  33544. * @param tiltRight defines the tilt
  33545. * @returns the current mesh
  33546. */
  33547. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33548. /**
  33549. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33550. * Supports definition of mesh facing forward or backward.
  33551. * @param flipBack defines the flip
  33552. * @param twirlClockwise defines the twirl
  33553. * @param tiltRight defines the tilt
  33554. * @returns the new rotation vector
  33555. */
  33556. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33557. /**
  33558. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33559. * This means the mesh underlying bounding box and sphere are recomputed.
  33560. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33561. * @returns the current mesh
  33562. */
  33563. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33564. /** @hidden */
  33565. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33566. /** @hidden */
  33567. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33568. /** @hidden */
  33569. _updateBoundingInfo(): AbstractMesh;
  33570. /** @hidden */
  33571. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33572. /** @hidden */
  33573. protected _afterComputeWorldMatrix(): void;
  33574. /** @hidden */
  33575. get _effectiveMesh(): AbstractMesh;
  33576. /**
  33577. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33578. * A mesh is in the frustum if its bounding box intersects the frustum
  33579. * @param frustumPlanes defines the frustum to test
  33580. * @returns true if the mesh is in the frustum planes
  33581. */
  33582. isInFrustum(frustumPlanes: Plane[]): boolean;
  33583. /**
  33584. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33585. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33586. * @param frustumPlanes defines the frustum to test
  33587. * @returns true if the mesh is completely in the frustum planes
  33588. */
  33589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33590. /**
  33591. * True if the mesh intersects another mesh or a SolidParticle object
  33592. * @param mesh defines a target mesh or SolidParticle to test
  33593. * @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)
  33594. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33595. * @returns true if there is an intersection
  33596. */
  33597. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33598. /**
  33599. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33600. * @param point defines the point to test
  33601. * @returns true if there is an intersection
  33602. */
  33603. intersectsPoint(point: Vector3): boolean;
  33604. /**
  33605. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33606. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33607. */
  33608. get checkCollisions(): boolean;
  33609. set checkCollisions(collisionEnabled: boolean);
  33610. /**
  33611. * Gets Collider object used to compute collisions (not physics)
  33612. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33613. */
  33614. get collider(): Nullable<Collider>;
  33615. /**
  33616. * Move the mesh using collision engine
  33617. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33618. * @param displacement defines the requested displacement vector
  33619. * @returns the current mesh
  33620. */
  33621. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33622. private _onCollisionPositionChange;
  33623. /** @hidden */
  33624. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33625. /** @hidden */
  33626. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33627. /** @hidden */
  33628. _checkCollision(collider: Collider): AbstractMesh;
  33629. /** @hidden */
  33630. _generatePointsArray(): boolean;
  33631. /**
  33632. * Checks if the passed Ray intersects with the mesh
  33633. * @param ray defines the ray to use
  33634. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33636. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33637. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33638. * @returns the picking info
  33639. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33640. */
  33641. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33642. /**
  33643. * Clones the current mesh
  33644. * @param name defines the mesh name
  33645. * @param newParent defines the new mesh parent
  33646. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33647. * @returns the new mesh
  33648. */
  33649. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33650. /**
  33651. * Disposes all the submeshes of the current meshnp
  33652. * @returns the current mesh
  33653. */
  33654. releaseSubMeshes(): AbstractMesh;
  33655. /**
  33656. * Releases resources associated with this abstract mesh.
  33657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33659. */
  33660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33661. /**
  33662. * Adds the passed mesh as a child to the current mesh
  33663. * @param mesh defines the child mesh
  33664. * @returns the current mesh
  33665. */
  33666. addChild(mesh: AbstractMesh): AbstractMesh;
  33667. /**
  33668. * Removes the passed mesh from the current mesh children list
  33669. * @param mesh defines the child mesh
  33670. * @returns the current mesh
  33671. */
  33672. removeChild(mesh: AbstractMesh): AbstractMesh;
  33673. /** @hidden */
  33674. private _initFacetData;
  33675. /**
  33676. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33677. * This method can be called within the render loop.
  33678. * 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
  33679. * @returns the current mesh
  33680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33681. */
  33682. updateFacetData(): AbstractMesh;
  33683. /**
  33684. * Returns the facetLocalNormals array.
  33685. * The normals are expressed in the mesh local spac
  33686. * @returns an array of Vector3
  33687. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33688. */
  33689. getFacetLocalNormals(): Vector3[];
  33690. /**
  33691. * Returns the facetLocalPositions array.
  33692. * The facet positions are expressed in the mesh local space
  33693. * @returns an array of Vector3
  33694. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33695. */
  33696. getFacetLocalPositions(): Vector3[];
  33697. /**
  33698. * Returns the facetLocalPartioning array
  33699. * @returns an array of array of numbers
  33700. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33701. */
  33702. getFacetLocalPartitioning(): number[][];
  33703. /**
  33704. * Returns the i-th facet position in the world system.
  33705. * This method allocates a new Vector3 per call
  33706. * @param i defines the facet index
  33707. * @returns a new Vector3
  33708. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33709. */
  33710. getFacetPosition(i: number): Vector3;
  33711. /**
  33712. * Sets the reference Vector3 with the i-th facet position in the world system
  33713. * @param i defines the facet index
  33714. * @param ref defines the target vector
  33715. * @returns the current mesh
  33716. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33717. */
  33718. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33719. /**
  33720. * Returns the i-th facet normal in the world system.
  33721. * This method allocates a new Vector3 per call
  33722. * @param i defines the facet index
  33723. * @returns a new Vector3
  33724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33725. */
  33726. getFacetNormal(i: number): Vector3;
  33727. /**
  33728. * Sets the reference Vector3 with the i-th facet normal in the world system
  33729. * @param i defines the facet index
  33730. * @param ref defines the target vector
  33731. * @returns the current mesh
  33732. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33733. */
  33734. getFacetNormalToRef(i: number, ref: Vector3): this;
  33735. /**
  33736. * 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)
  33737. * @param x defines x coordinate
  33738. * @param y defines y coordinate
  33739. * @param z defines z coordinate
  33740. * @returns the array of facet indexes
  33741. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33742. */
  33743. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33744. /**
  33745. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33746. * @param projected sets as the (x,y,z) world projection on the facet
  33747. * @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
  33748. * @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
  33749. * @param x defines x coordinate
  33750. * @param y defines y coordinate
  33751. * @param z defines z coordinate
  33752. * @returns the face index if found (or null instead)
  33753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33754. */
  33755. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33756. /**
  33757. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33758. * @param projected sets as the (x,y,z) local projection on the facet
  33759. * @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
  33760. * @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
  33761. * @param x defines x coordinate
  33762. * @param y defines y coordinate
  33763. * @param z defines z coordinate
  33764. * @returns the face index if found (or null instead)
  33765. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33766. */
  33767. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33768. /**
  33769. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33770. * @returns the parameters
  33771. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33772. */
  33773. getFacetDataParameters(): any;
  33774. /**
  33775. * Disables the feature FacetData and frees the related memory
  33776. * @returns the current mesh
  33777. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33778. */
  33779. disableFacetData(): AbstractMesh;
  33780. /**
  33781. * Updates the AbstractMesh indices array
  33782. * @param indices defines the data source
  33783. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33784. * @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)
  33785. * @returns the current mesh
  33786. */
  33787. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33788. /**
  33789. * Creates new normals data for the mesh
  33790. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33791. * @returns the current mesh
  33792. */
  33793. createNormals(updatable: boolean): AbstractMesh;
  33794. /**
  33795. * Align the mesh with a normal
  33796. * @param normal defines the normal to use
  33797. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33798. * @returns the current mesh
  33799. */
  33800. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33801. /** @hidden */
  33802. _checkOcclusionQuery(): boolean;
  33803. /**
  33804. * Disables the mesh edge rendering mode
  33805. * @returns the currentAbstractMesh
  33806. */
  33807. disableEdgesRendering(): AbstractMesh;
  33808. /**
  33809. * Enables the edge rendering mode on the mesh.
  33810. * This mode makes the mesh edges visible
  33811. * @param epsilon defines the maximal distance between two angles to detect a face
  33812. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33813. * @returns the currentAbstractMesh
  33814. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33815. */
  33816. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33817. /**
  33818. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33819. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33820. */
  33821. getConnectedParticleSystems(): IParticleSystem[];
  33822. }
  33823. }
  33824. declare module "babylonjs/Actions/actionEvent" {
  33825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33826. import { Nullable } from "babylonjs/types";
  33827. import { Sprite } from "babylonjs/Sprites/sprite";
  33828. import { Scene } from "babylonjs/scene";
  33829. import { Vector2 } from "babylonjs/Maths/math.vector";
  33830. /**
  33831. * Interface used to define ActionEvent
  33832. */
  33833. export interface IActionEvent {
  33834. /** The mesh or sprite that triggered the action */
  33835. source: any;
  33836. /** The X mouse cursor position at the time of the event */
  33837. pointerX: number;
  33838. /** The Y mouse cursor position at the time of the event */
  33839. pointerY: number;
  33840. /** The mesh that is currently pointed at (can be null) */
  33841. meshUnderPointer: Nullable<AbstractMesh>;
  33842. /** the original (browser) event that triggered the ActionEvent */
  33843. sourceEvent?: any;
  33844. /** additional data for the event */
  33845. additionalData?: any;
  33846. }
  33847. /**
  33848. * ActionEvent is the event being sent when an action is triggered.
  33849. */
  33850. export class ActionEvent implements IActionEvent {
  33851. /** The mesh or sprite that triggered the action */
  33852. source: any;
  33853. /** The X mouse cursor position at the time of the event */
  33854. pointerX: number;
  33855. /** The Y mouse cursor position at the time of the event */
  33856. pointerY: number;
  33857. /** The mesh that is currently pointed at (can be null) */
  33858. meshUnderPointer: Nullable<AbstractMesh>;
  33859. /** the original (browser) event that triggered the ActionEvent */
  33860. sourceEvent?: any;
  33861. /** additional data for the event */
  33862. additionalData?: any;
  33863. /**
  33864. * Creates a new ActionEvent
  33865. * @param source The mesh or sprite that triggered the action
  33866. * @param pointerX The X mouse cursor position at the time of the event
  33867. * @param pointerY The Y mouse cursor position at the time of the event
  33868. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33869. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33870. * @param additionalData additional data for the event
  33871. */
  33872. constructor(
  33873. /** The mesh or sprite that triggered the action */
  33874. source: any,
  33875. /** The X mouse cursor position at the time of the event */
  33876. pointerX: number,
  33877. /** The Y mouse cursor position at the time of the event */
  33878. pointerY: number,
  33879. /** The mesh that is currently pointed at (can be null) */
  33880. meshUnderPointer: Nullable<AbstractMesh>,
  33881. /** the original (browser) event that triggered the ActionEvent */
  33882. sourceEvent?: any,
  33883. /** additional data for the event */
  33884. additionalData?: any);
  33885. /**
  33886. * Helper function to auto-create an ActionEvent from a source mesh.
  33887. * @param source The source mesh that triggered the event
  33888. * @param evt The original (browser) event
  33889. * @param additionalData additional data for the event
  33890. * @returns the new ActionEvent
  33891. */
  33892. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33893. /**
  33894. * Helper function to auto-create an ActionEvent from a source sprite
  33895. * @param source The source sprite that triggered the event
  33896. * @param scene Scene associated with the sprite
  33897. * @param evt The original (browser) event
  33898. * @param additionalData additional data for the event
  33899. * @returns the new ActionEvent
  33900. */
  33901. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33902. /**
  33903. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33904. * @param scene the scene where the event occurred
  33905. * @param evt The original (browser) event
  33906. * @returns the new ActionEvent
  33907. */
  33908. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33909. /**
  33910. * Helper function to auto-create an ActionEvent from a primitive
  33911. * @param prim defines the target primitive
  33912. * @param pointerPos defines the pointer position
  33913. * @param evt The original (browser) event
  33914. * @param additionalData additional data for the event
  33915. * @returns the new ActionEvent
  33916. */
  33917. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33918. }
  33919. }
  33920. declare module "babylonjs/Actions/abstractActionManager" {
  33921. import { IDisposable } from "babylonjs/scene";
  33922. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33923. import { IAction } from "babylonjs/Actions/action";
  33924. import { Nullable } from "babylonjs/types";
  33925. /**
  33926. * Abstract class used to decouple action Manager from scene and meshes.
  33927. * Do not instantiate.
  33928. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33929. */
  33930. export abstract class AbstractActionManager implements IDisposable {
  33931. /** Gets the list of active triggers */
  33932. static Triggers: {
  33933. [key: string]: number;
  33934. };
  33935. /** Gets the cursor to use when hovering items */
  33936. hoverCursor: string;
  33937. /** Gets the list of actions */
  33938. actions: IAction[];
  33939. /**
  33940. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33941. */
  33942. isRecursive: boolean;
  33943. /**
  33944. * Releases all associated resources
  33945. */
  33946. abstract dispose(): void;
  33947. /**
  33948. * Does this action manager has pointer triggers
  33949. */
  33950. abstract get hasPointerTriggers(): boolean;
  33951. /**
  33952. * Does this action manager has pick triggers
  33953. */
  33954. abstract get hasPickTriggers(): boolean;
  33955. /**
  33956. * Process a specific trigger
  33957. * @param trigger defines the trigger to process
  33958. * @param evt defines the event details to be processed
  33959. */
  33960. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33961. /**
  33962. * Does this action manager handles actions of any of the given triggers
  33963. * @param triggers defines the triggers to be tested
  33964. * @return a boolean indicating whether one (or more) of the triggers is handled
  33965. */
  33966. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33967. /**
  33968. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33969. * speed.
  33970. * @param triggerA defines the trigger to be tested
  33971. * @param triggerB defines the trigger to be tested
  33972. * @return a boolean indicating whether one (or more) of the triggers is handled
  33973. */
  33974. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33975. /**
  33976. * Does this action manager handles actions of a given trigger
  33977. * @param trigger defines the trigger to be tested
  33978. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33979. * @return whether the trigger is handled
  33980. */
  33981. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33982. /**
  33983. * Serialize this manager to a JSON object
  33984. * @param name defines the property name to store this manager
  33985. * @returns a JSON representation of this manager
  33986. */
  33987. abstract serialize(name: string): any;
  33988. /**
  33989. * Registers an action to this action manager
  33990. * @param action defines the action to be registered
  33991. * @return the action amended (prepared) after registration
  33992. */
  33993. abstract registerAction(action: IAction): Nullable<IAction>;
  33994. /**
  33995. * Unregisters an action to this action manager
  33996. * @param action defines the action to be unregistered
  33997. * @return a boolean indicating whether the action has been unregistered
  33998. */
  33999. abstract unregisterAction(action: IAction): Boolean;
  34000. /**
  34001. * Does exist one action manager with at least one trigger
  34002. **/
  34003. static get HasTriggers(): boolean;
  34004. /**
  34005. * Does exist one action manager with at least one pick trigger
  34006. **/
  34007. static get HasPickTriggers(): boolean;
  34008. /**
  34009. * Does exist one action manager that handles actions of a given trigger
  34010. * @param trigger defines the trigger to be tested
  34011. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34012. **/
  34013. static HasSpecificTrigger(trigger: number): boolean;
  34014. }
  34015. }
  34016. declare module "babylonjs/node" {
  34017. import { Scene } from "babylonjs/scene";
  34018. import { Nullable } from "babylonjs/types";
  34019. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34020. import { Engine } from "babylonjs/Engines/engine";
  34021. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34022. import { Observable } from "babylonjs/Misc/observable";
  34023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34024. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34025. import { Animatable } from "babylonjs/Animations/animatable";
  34026. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34027. import { Animation } from "babylonjs/Animations/animation";
  34028. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34030. /**
  34031. * Defines how a node can be built from a string name.
  34032. */
  34033. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34034. /**
  34035. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34036. */
  34037. export class Node implements IBehaviorAware<Node> {
  34038. /** @hidden */
  34039. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34040. private static _NodeConstructors;
  34041. /**
  34042. * Add a new node constructor
  34043. * @param type defines the type name of the node to construct
  34044. * @param constructorFunc defines the constructor function
  34045. */
  34046. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34047. /**
  34048. * Returns a node constructor based on type name
  34049. * @param type defines the type name
  34050. * @param name defines the new node name
  34051. * @param scene defines the hosting scene
  34052. * @param options defines optional options to transmit to constructors
  34053. * @returns the new constructor or null
  34054. */
  34055. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34056. /**
  34057. * Gets or sets the name of the node
  34058. */
  34059. name: string;
  34060. /**
  34061. * Gets or sets the id of the node
  34062. */
  34063. id: string;
  34064. /**
  34065. * Gets or sets the unique id of the node
  34066. */
  34067. uniqueId: number;
  34068. /**
  34069. * Gets or sets a string used to store user defined state for the node
  34070. */
  34071. state: string;
  34072. /**
  34073. * Gets or sets an object used to store user defined information for the node
  34074. */
  34075. metadata: any;
  34076. /**
  34077. * For internal use only. Please do not use.
  34078. */
  34079. reservedDataStore: any;
  34080. /**
  34081. * List of inspectable custom properties (used by the Inspector)
  34082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34083. */
  34084. inspectableCustomProperties: IInspectable[];
  34085. private _doNotSerialize;
  34086. /**
  34087. * Gets or sets a boolean used to define if the node must be serialized
  34088. */
  34089. get doNotSerialize(): boolean;
  34090. set doNotSerialize(value: boolean);
  34091. /** @hidden */
  34092. _isDisposed: boolean;
  34093. /**
  34094. * Gets a list of Animations associated with the node
  34095. */
  34096. animations: import("babylonjs/Animations/animation").Animation[];
  34097. protected _ranges: {
  34098. [name: string]: Nullable<AnimationRange>;
  34099. };
  34100. /**
  34101. * Callback raised when the node is ready to be used
  34102. */
  34103. onReady: Nullable<(node: Node) => void>;
  34104. private _isEnabled;
  34105. private _isParentEnabled;
  34106. private _isReady;
  34107. /** @hidden */
  34108. _currentRenderId: number;
  34109. private _parentUpdateId;
  34110. /** @hidden */
  34111. _childUpdateId: number;
  34112. /** @hidden */
  34113. _waitingParentId: Nullable<string>;
  34114. /** @hidden */
  34115. _scene: Scene;
  34116. /** @hidden */
  34117. _cache: any;
  34118. private _parentNode;
  34119. private _children;
  34120. /** @hidden */
  34121. _worldMatrix: Matrix;
  34122. /** @hidden */
  34123. _worldMatrixDeterminant: number;
  34124. /** @hidden */
  34125. _worldMatrixDeterminantIsDirty: boolean;
  34126. /** @hidden */
  34127. private _sceneRootNodesIndex;
  34128. /**
  34129. * Gets a boolean indicating if the node has been disposed
  34130. * @returns true if the node was disposed
  34131. */
  34132. isDisposed(): boolean;
  34133. /**
  34134. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34135. * @see https://doc.babylonjs.com/how_to/parenting
  34136. */
  34137. set parent(parent: Nullable<Node>);
  34138. get parent(): Nullable<Node>;
  34139. /** @hidden */
  34140. _addToSceneRootNodes(): void;
  34141. /** @hidden */
  34142. _removeFromSceneRootNodes(): void;
  34143. private _animationPropertiesOverride;
  34144. /**
  34145. * Gets or sets the animation properties override
  34146. */
  34147. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34148. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34149. /**
  34150. * Gets a string idenfifying the name of the class
  34151. * @returns "Node" string
  34152. */
  34153. getClassName(): string;
  34154. /** @hidden */
  34155. readonly _isNode: boolean;
  34156. /**
  34157. * An event triggered when the mesh is disposed
  34158. */
  34159. onDisposeObservable: Observable<Node>;
  34160. private _onDisposeObserver;
  34161. /**
  34162. * Sets a callback that will be raised when the node will be disposed
  34163. */
  34164. set onDispose(callback: () => void);
  34165. /**
  34166. * Creates a new Node
  34167. * @param name the name and id to be given to this node
  34168. * @param scene the scene this node will be added to
  34169. */
  34170. constructor(name: string, scene?: Nullable<Scene>);
  34171. /**
  34172. * Gets the scene of the node
  34173. * @returns a scene
  34174. */
  34175. getScene(): Scene;
  34176. /**
  34177. * Gets the engine of the node
  34178. * @returns a Engine
  34179. */
  34180. getEngine(): Engine;
  34181. private _behaviors;
  34182. /**
  34183. * Attach a behavior to the node
  34184. * @see https://doc.babylonjs.com/features/behaviour
  34185. * @param behavior defines the behavior to attach
  34186. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34187. * @returns the current Node
  34188. */
  34189. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34190. /**
  34191. * Remove an attached behavior
  34192. * @see https://doc.babylonjs.com/features/behaviour
  34193. * @param behavior defines the behavior to attach
  34194. * @returns the current Node
  34195. */
  34196. removeBehavior(behavior: Behavior<Node>): Node;
  34197. /**
  34198. * Gets the list of attached behaviors
  34199. * @see https://doc.babylonjs.com/features/behaviour
  34200. */
  34201. get behaviors(): Behavior<Node>[];
  34202. /**
  34203. * Gets an attached behavior by name
  34204. * @param name defines the name of the behavior to look for
  34205. * @see https://doc.babylonjs.com/features/behaviour
  34206. * @returns null if behavior was not found else the requested behavior
  34207. */
  34208. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34209. /**
  34210. * Returns the latest update of the World matrix
  34211. * @returns a Matrix
  34212. */
  34213. getWorldMatrix(): Matrix;
  34214. /** @hidden */
  34215. _getWorldMatrixDeterminant(): number;
  34216. /**
  34217. * Returns directly the latest state of the mesh World matrix.
  34218. * A Matrix is returned.
  34219. */
  34220. get worldMatrixFromCache(): Matrix;
  34221. /** @hidden */
  34222. _initCache(): void;
  34223. /** @hidden */
  34224. updateCache(force?: boolean): void;
  34225. /** @hidden */
  34226. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34227. /** @hidden */
  34228. _updateCache(ignoreParentClass?: boolean): void;
  34229. /** @hidden */
  34230. _isSynchronized(): boolean;
  34231. /** @hidden */
  34232. _markSyncedWithParent(): void;
  34233. /** @hidden */
  34234. isSynchronizedWithParent(): boolean;
  34235. /** @hidden */
  34236. isSynchronized(): boolean;
  34237. /**
  34238. * Is this node ready to be used/rendered
  34239. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34240. * @return true if the node is ready
  34241. */
  34242. isReady(completeCheck?: boolean): boolean;
  34243. /**
  34244. * Is this node enabled?
  34245. * 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
  34246. * @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
  34247. * @return whether this node (and its parent) is enabled
  34248. */
  34249. isEnabled(checkAncestors?: boolean): boolean;
  34250. /** @hidden */
  34251. protected _syncParentEnabledState(): void;
  34252. /**
  34253. * Set the enabled state of this node
  34254. * @param value defines the new enabled state
  34255. */
  34256. setEnabled(value: boolean): void;
  34257. /**
  34258. * Is this node a descendant of the given node?
  34259. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34260. * @param ancestor defines the parent node to inspect
  34261. * @returns a boolean indicating if this node is a descendant of the given node
  34262. */
  34263. isDescendantOf(ancestor: Node): boolean;
  34264. /** @hidden */
  34265. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34266. /**
  34267. * Will return all nodes that have this node as ascendant
  34268. * @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
  34269. * @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
  34270. * @return all children nodes of all types
  34271. */
  34272. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34273. /**
  34274. * Get all child-meshes of this node
  34275. * @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)
  34276. * @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
  34277. * @returns an array of AbstractMesh
  34278. */
  34279. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34280. /**
  34281. * Get all direct children of this node
  34282. * @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
  34283. * @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)
  34284. * @returns an array of Node
  34285. */
  34286. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34287. /** @hidden */
  34288. _setReady(state: boolean): void;
  34289. /**
  34290. * Get an animation by name
  34291. * @param name defines the name of the animation to look for
  34292. * @returns null if not found else the requested animation
  34293. */
  34294. getAnimationByName(name: string): Nullable<Animation>;
  34295. /**
  34296. * Creates an animation range for this node
  34297. * @param name defines the name of the range
  34298. * @param from defines the starting key
  34299. * @param to defines the end key
  34300. */
  34301. createAnimationRange(name: string, from: number, to: number): void;
  34302. /**
  34303. * Delete a specific animation range
  34304. * @param name defines the name of the range to delete
  34305. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34306. */
  34307. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34308. /**
  34309. * Get an animation range by name
  34310. * @param name defines the name of the animation range to look for
  34311. * @returns null if not found else the requested animation range
  34312. */
  34313. getAnimationRange(name: string): Nullable<AnimationRange>;
  34314. /**
  34315. * Gets the list of all animation ranges defined on this node
  34316. * @returns an array
  34317. */
  34318. getAnimationRanges(): Nullable<AnimationRange>[];
  34319. /**
  34320. * Will start the animation sequence
  34321. * @param name defines the range frames for animation sequence
  34322. * @param loop defines if the animation should loop (false by default)
  34323. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34324. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34325. * @returns the object created for this animation. If range does not exist, it will return null
  34326. */
  34327. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34328. /**
  34329. * Serialize animation ranges into a JSON compatible object
  34330. * @returns serialization object
  34331. */
  34332. serializeAnimationRanges(): any;
  34333. /**
  34334. * Computes the world matrix of the node
  34335. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34336. * @returns the world matrix
  34337. */
  34338. computeWorldMatrix(force?: boolean): Matrix;
  34339. /**
  34340. * Releases resources associated with this node.
  34341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34343. */
  34344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34345. /**
  34346. * Parse animation range data from a serialization object and store them into a given node
  34347. * @param node defines where to store the animation ranges
  34348. * @param parsedNode defines the serialization object to read data from
  34349. * @param scene defines the hosting scene
  34350. */
  34351. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34352. /**
  34353. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34354. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34355. * @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
  34356. * @returns the new bounding vectors
  34357. */
  34358. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34359. min: Vector3;
  34360. max: Vector3;
  34361. };
  34362. }
  34363. }
  34364. declare module "babylonjs/Animations/animation" {
  34365. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34366. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34367. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34368. import { Nullable } from "babylonjs/types";
  34369. import { Scene } from "babylonjs/scene";
  34370. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34371. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34372. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34373. import { Node } from "babylonjs/node";
  34374. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34375. import { Size } from "babylonjs/Maths/math.size";
  34376. import { Animatable } from "babylonjs/Animations/animatable";
  34377. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34378. /**
  34379. * @hidden
  34380. */
  34381. export class _IAnimationState {
  34382. key: number;
  34383. repeatCount: number;
  34384. workValue?: any;
  34385. loopMode?: number;
  34386. offsetValue?: any;
  34387. highLimitValue?: any;
  34388. }
  34389. /**
  34390. * Class used to store any kind of animation
  34391. */
  34392. export class Animation {
  34393. /**Name of the animation */
  34394. name: string;
  34395. /**Property to animate */
  34396. targetProperty: string;
  34397. /**The frames per second of the animation */
  34398. framePerSecond: number;
  34399. /**The data type of the animation */
  34400. dataType: number;
  34401. /**The loop mode of the animation */
  34402. loopMode?: number | undefined;
  34403. /**Specifies if blending should be enabled */
  34404. enableBlending?: boolean | undefined;
  34405. /**
  34406. * Use matrix interpolation instead of using direct key value when animating matrices
  34407. */
  34408. static AllowMatricesInterpolation: boolean;
  34409. /**
  34410. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34411. */
  34412. static AllowMatrixDecomposeForInterpolation: boolean;
  34413. /** Define the Url to load snippets */
  34414. static SnippetUrl: string;
  34415. /** Snippet ID if the animation was created from the snippet server */
  34416. snippetId: string;
  34417. /**
  34418. * Stores the key frames of the animation
  34419. */
  34420. private _keys;
  34421. /**
  34422. * Stores the easing function of the animation
  34423. */
  34424. private _easingFunction;
  34425. /**
  34426. * @hidden Internal use only
  34427. */
  34428. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34429. /**
  34430. * The set of event that will be linked to this animation
  34431. */
  34432. private _events;
  34433. /**
  34434. * Stores an array of target property paths
  34435. */
  34436. targetPropertyPath: string[];
  34437. /**
  34438. * Stores the blending speed of the animation
  34439. */
  34440. blendingSpeed: number;
  34441. /**
  34442. * Stores the animation ranges for the animation
  34443. */
  34444. private _ranges;
  34445. /**
  34446. * @hidden Internal use
  34447. */
  34448. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34449. /**
  34450. * Sets up an animation
  34451. * @param property The property to animate
  34452. * @param animationType The animation type to apply
  34453. * @param framePerSecond The frames per second of the animation
  34454. * @param easingFunction The easing function used in the animation
  34455. * @returns The created animation
  34456. */
  34457. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34458. /**
  34459. * Create and start an animation on a node
  34460. * @param name defines the name of the global animation that will be run on all nodes
  34461. * @param node defines the root node where the animation will take place
  34462. * @param targetProperty defines property to animate
  34463. * @param framePerSecond defines the number of frame per second yo use
  34464. * @param totalFrame defines the number of frames in total
  34465. * @param from defines the initial value
  34466. * @param to defines the final value
  34467. * @param loopMode defines which loop mode you want to use (off by default)
  34468. * @param easingFunction defines the easing function to use (linear by default)
  34469. * @param onAnimationEnd defines the callback to call when animation end
  34470. * @returns the animatable created for this animation
  34471. */
  34472. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34473. /**
  34474. * Create and start an animation on a node and its descendants
  34475. * @param name defines the name of the global animation that will be run on all nodes
  34476. * @param node defines the root node where the animation will take place
  34477. * @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
  34478. * @param targetProperty defines property to animate
  34479. * @param framePerSecond defines the number of frame per second to use
  34480. * @param totalFrame defines the number of frames in total
  34481. * @param from defines the initial value
  34482. * @param to defines the final value
  34483. * @param loopMode defines which loop mode you want to use (off by default)
  34484. * @param easingFunction defines the easing function to use (linear by default)
  34485. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34486. * @returns the list of animatables created for all nodes
  34487. * @example https://www.babylonjs-playground.com/#MH0VLI
  34488. */
  34489. 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[]>;
  34490. /**
  34491. * Creates a new animation, merges it with the existing animations and starts it
  34492. * @param name Name of the animation
  34493. * @param node Node which contains the scene that begins the animations
  34494. * @param targetProperty Specifies which property to animate
  34495. * @param framePerSecond The frames per second of the animation
  34496. * @param totalFrame The total number of frames
  34497. * @param from The frame at the beginning of the animation
  34498. * @param to The frame at the end of the animation
  34499. * @param loopMode Specifies the loop mode of the animation
  34500. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34501. * @param onAnimationEnd Callback to run once the animation is complete
  34502. * @returns Nullable animation
  34503. */
  34504. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34505. /**
  34506. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34507. * @param sourceAnimation defines the Animation containing keyframes to convert
  34508. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34509. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34510. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34511. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34512. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34513. */
  34514. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34515. /**
  34516. * Transition property of an host to the target Value
  34517. * @param property The property to transition
  34518. * @param targetValue The target Value of the property
  34519. * @param host The object where the property to animate belongs
  34520. * @param scene Scene used to run the animation
  34521. * @param frameRate Framerate (in frame/s) to use
  34522. * @param transition The transition type we want to use
  34523. * @param duration The duration of the animation, in milliseconds
  34524. * @param onAnimationEnd Callback trigger at the end of the animation
  34525. * @returns Nullable animation
  34526. */
  34527. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34528. /**
  34529. * Return the array of runtime animations currently using this animation
  34530. */
  34531. get runtimeAnimations(): RuntimeAnimation[];
  34532. /**
  34533. * Specifies if any of the runtime animations are currently running
  34534. */
  34535. get hasRunningRuntimeAnimations(): boolean;
  34536. /**
  34537. * Initializes the animation
  34538. * @param name Name of the animation
  34539. * @param targetProperty Property to animate
  34540. * @param framePerSecond The frames per second of the animation
  34541. * @param dataType The data type of the animation
  34542. * @param loopMode The loop mode of the animation
  34543. * @param enableBlending Specifies if blending should be enabled
  34544. */
  34545. constructor(
  34546. /**Name of the animation */
  34547. name: string,
  34548. /**Property to animate */
  34549. targetProperty: string,
  34550. /**The frames per second of the animation */
  34551. framePerSecond: number,
  34552. /**The data type of the animation */
  34553. dataType: number,
  34554. /**The loop mode of the animation */
  34555. loopMode?: number | undefined,
  34556. /**Specifies if blending should be enabled */
  34557. enableBlending?: boolean | undefined);
  34558. /**
  34559. * Converts the animation to a string
  34560. * @param fullDetails support for multiple levels of logging within scene loading
  34561. * @returns String form of the animation
  34562. */
  34563. toString(fullDetails?: boolean): string;
  34564. /**
  34565. * Add an event to this animation
  34566. * @param event Event to add
  34567. */
  34568. addEvent(event: AnimationEvent): void;
  34569. /**
  34570. * Remove all events found at the given frame
  34571. * @param frame The frame to remove events from
  34572. */
  34573. removeEvents(frame: number): void;
  34574. /**
  34575. * Retrieves all the events from the animation
  34576. * @returns Events from the animation
  34577. */
  34578. getEvents(): AnimationEvent[];
  34579. /**
  34580. * Creates an animation range
  34581. * @param name Name of the animation range
  34582. * @param from Starting frame of the animation range
  34583. * @param to Ending frame of the animation
  34584. */
  34585. createRange(name: string, from: number, to: number): void;
  34586. /**
  34587. * Deletes an animation range by name
  34588. * @param name Name of the animation range to delete
  34589. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34590. */
  34591. deleteRange(name: string, deleteFrames?: boolean): void;
  34592. /**
  34593. * Gets the animation range by name, or null if not defined
  34594. * @param name Name of the animation range
  34595. * @returns Nullable animation range
  34596. */
  34597. getRange(name: string): Nullable<AnimationRange>;
  34598. /**
  34599. * Gets the key frames from the animation
  34600. * @returns The key frames of the animation
  34601. */
  34602. getKeys(): Array<IAnimationKey>;
  34603. /**
  34604. * Gets the highest frame rate of the animation
  34605. * @returns Highest frame rate of the animation
  34606. */
  34607. getHighestFrame(): number;
  34608. /**
  34609. * Gets the easing function of the animation
  34610. * @returns Easing function of the animation
  34611. */
  34612. getEasingFunction(): IEasingFunction;
  34613. /**
  34614. * Sets the easing function of the animation
  34615. * @param easingFunction A custom mathematical formula for animation
  34616. */
  34617. setEasingFunction(easingFunction: EasingFunction): void;
  34618. /**
  34619. * Interpolates a scalar linearly
  34620. * @param startValue Start value of the animation curve
  34621. * @param endValue End value of the animation curve
  34622. * @param gradient Scalar amount to interpolate
  34623. * @returns Interpolated scalar value
  34624. */
  34625. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34626. /**
  34627. * Interpolates a scalar cubically
  34628. * @param startValue Start value of the animation curve
  34629. * @param outTangent End tangent of the animation
  34630. * @param endValue End value of the animation curve
  34631. * @param inTangent Start tangent of the animation curve
  34632. * @param gradient Scalar amount to interpolate
  34633. * @returns Interpolated scalar value
  34634. */
  34635. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34636. /**
  34637. * Interpolates a quaternion using a spherical linear interpolation
  34638. * @param startValue Start value of the animation curve
  34639. * @param endValue End value of the animation curve
  34640. * @param gradient Scalar amount to interpolate
  34641. * @returns Interpolated quaternion value
  34642. */
  34643. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34644. /**
  34645. * Interpolates a quaternion cubically
  34646. * @param startValue Start value of the animation curve
  34647. * @param outTangent End tangent of the animation curve
  34648. * @param endValue End value of the animation curve
  34649. * @param inTangent Start tangent of the animation curve
  34650. * @param gradient Scalar amount to interpolate
  34651. * @returns Interpolated quaternion value
  34652. */
  34653. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34654. /**
  34655. * Interpolates a Vector3 linearl
  34656. * @param startValue Start value of the animation curve
  34657. * @param endValue End value of the animation curve
  34658. * @param gradient Scalar amount to interpolate
  34659. * @returns Interpolated scalar value
  34660. */
  34661. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34662. /**
  34663. * Interpolates a Vector3 cubically
  34664. * @param startValue Start value of the animation curve
  34665. * @param outTangent End tangent of the animation
  34666. * @param endValue End value of the animation curve
  34667. * @param inTangent Start tangent of the animation curve
  34668. * @param gradient Scalar amount to interpolate
  34669. * @returns InterpolatedVector3 value
  34670. */
  34671. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34672. /**
  34673. * Interpolates a Vector2 linearly
  34674. * @param startValue Start value of the animation curve
  34675. * @param endValue End value of the animation curve
  34676. * @param gradient Scalar amount to interpolate
  34677. * @returns Interpolated Vector2 value
  34678. */
  34679. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34680. /**
  34681. * Interpolates a Vector2 cubically
  34682. * @param startValue Start value of the animation curve
  34683. * @param outTangent End tangent of the animation
  34684. * @param endValue End value of the animation curve
  34685. * @param inTangent Start tangent of the animation curve
  34686. * @param gradient Scalar amount to interpolate
  34687. * @returns Interpolated Vector2 value
  34688. */
  34689. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34690. /**
  34691. * Interpolates a size linearly
  34692. * @param startValue Start value of the animation curve
  34693. * @param endValue End value of the animation curve
  34694. * @param gradient Scalar amount to interpolate
  34695. * @returns Interpolated Size value
  34696. */
  34697. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34698. /**
  34699. * Interpolates a Color3 linearly
  34700. * @param startValue Start value of the animation curve
  34701. * @param endValue End value of the animation curve
  34702. * @param gradient Scalar amount to interpolate
  34703. * @returns Interpolated Color3 value
  34704. */
  34705. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34706. /**
  34707. * Interpolates a Color4 linearly
  34708. * @param startValue Start value of the animation curve
  34709. * @param endValue End value of the animation curve
  34710. * @param gradient Scalar amount to interpolate
  34711. * @returns Interpolated Color3 value
  34712. */
  34713. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34714. /**
  34715. * @hidden Internal use only
  34716. */
  34717. _getKeyValue(value: any): any;
  34718. /**
  34719. * @hidden Internal use only
  34720. */
  34721. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34722. /**
  34723. * Defines the function to use to interpolate matrices
  34724. * @param startValue defines the start matrix
  34725. * @param endValue defines the end matrix
  34726. * @param gradient defines the gradient between both matrices
  34727. * @param result defines an optional target matrix where to store the interpolation
  34728. * @returns the interpolated matrix
  34729. */
  34730. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34731. /**
  34732. * Makes a copy of the animation
  34733. * @returns Cloned animation
  34734. */
  34735. clone(): Animation;
  34736. /**
  34737. * Sets the key frames of the animation
  34738. * @param values The animation key frames to set
  34739. */
  34740. setKeys(values: Array<IAnimationKey>): void;
  34741. /**
  34742. * Serializes the animation to an object
  34743. * @returns Serialized object
  34744. */
  34745. serialize(): any;
  34746. /**
  34747. * Float animation type
  34748. */
  34749. static readonly ANIMATIONTYPE_FLOAT: number;
  34750. /**
  34751. * Vector3 animation type
  34752. */
  34753. static readonly ANIMATIONTYPE_VECTOR3: number;
  34754. /**
  34755. * Quaternion animation type
  34756. */
  34757. static readonly ANIMATIONTYPE_QUATERNION: number;
  34758. /**
  34759. * Matrix animation type
  34760. */
  34761. static readonly ANIMATIONTYPE_MATRIX: number;
  34762. /**
  34763. * Color3 animation type
  34764. */
  34765. static readonly ANIMATIONTYPE_COLOR3: number;
  34766. /**
  34767. * Color3 animation type
  34768. */
  34769. static readonly ANIMATIONTYPE_COLOR4: number;
  34770. /**
  34771. * Vector2 animation type
  34772. */
  34773. static readonly ANIMATIONTYPE_VECTOR2: number;
  34774. /**
  34775. * Size animation type
  34776. */
  34777. static readonly ANIMATIONTYPE_SIZE: number;
  34778. /**
  34779. * Relative Loop Mode
  34780. */
  34781. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34782. /**
  34783. * Cycle Loop Mode
  34784. */
  34785. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34786. /**
  34787. * Constant Loop Mode
  34788. */
  34789. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34790. /** @hidden */
  34791. static _UniversalLerp(left: any, right: any, amount: number): any;
  34792. /**
  34793. * Parses an animation object and creates an animation
  34794. * @param parsedAnimation Parsed animation object
  34795. * @returns Animation object
  34796. */
  34797. static Parse(parsedAnimation: any): Animation;
  34798. /**
  34799. * Appends the serialized animations from the source animations
  34800. * @param source Source containing the animations
  34801. * @param destination Target to store the animations
  34802. */
  34803. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34804. /**
  34805. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34806. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34807. * @param url defines the url to load from
  34808. * @returns a promise that will resolve to the new animation or an array of animations
  34809. */
  34810. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34811. /**
  34812. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34813. * @param snippetId defines the snippet to load
  34814. * @returns a promise that will resolve to the new animation or a new array of animations
  34815. */
  34816. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34817. }
  34818. }
  34819. declare module "babylonjs/Animations/animatable.interface" {
  34820. import { Nullable } from "babylonjs/types";
  34821. import { Animation } from "babylonjs/Animations/animation";
  34822. /**
  34823. * Interface containing an array of animations
  34824. */
  34825. export interface IAnimatable {
  34826. /**
  34827. * Array of animations
  34828. */
  34829. animations: Nullable<Array<Animation>>;
  34830. }
  34831. }
  34832. declare module "babylonjs/Misc/decorators" {
  34833. import { Nullable } from "babylonjs/types";
  34834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34835. import { Scene } from "babylonjs/scene";
  34836. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34837. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34838. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34840. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34841. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34842. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34843. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34844. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34845. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34846. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34847. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34848. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34849. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34850. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34851. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34852. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34853. /**
  34854. * Decorator used to define property that can be serialized as reference to a camera
  34855. * @param sourceName defines the name of the property to decorate
  34856. */
  34857. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34858. /**
  34859. * Class used to help serialization objects
  34860. */
  34861. export class SerializationHelper {
  34862. /** @hidden */
  34863. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34864. /** @hidden */
  34865. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34866. /** @hidden */
  34867. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34868. /** @hidden */
  34869. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34870. /**
  34871. * Appends the serialized animations from the source animations
  34872. * @param source Source containing the animations
  34873. * @param destination Target to store the animations
  34874. */
  34875. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34876. /**
  34877. * Static function used to serialized a specific entity
  34878. * @param entity defines the entity to serialize
  34879. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34880. * @returns a JSON compatible object representing the serialization of the entity
  34881. */
  34882. static Serialize<T>(entity: T, serializationObject?: any): any;
  34883. /**
  34884. * Creates a new entity from a serialization data object
  34885. * @param creationFunction defines a function used to instanciated the new entity
  34886. * @param source defines the source serialization data
  34887. * @param scene defines the hosting scene
  34888. * @param rootUrl defines the root url for resources
  34889. * @returns a new entity
  34890. */
  34891. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34892. /**
  34893. * Clones an object
  34894. * @param creationFunction defines the function used to instanciate the new object
  34895. * @param source defines the source object
  34896. * @returns the cloned object
  34897. */
  34898. static Clone<T>(creationFunction: () => T, source: T): T;
  34899. /**
  34900. * Instanciates a new object based on a source one (some data will be shared between both object)
  34901. * @param creationFunction defines the function used to instanciate the new object
  34902. * @param source defines the source object
  34903. * @returns the new object
  34904. */
  34905. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34906. }
  34907. }
  34908. declare module "babylonjs/Materials/Textures/baseTexture" {
  34909. import { Observable } from "babylonjs/Misc/observable";
  34910. import { Nullable } from "babylonjs/types";
  34911. import { Scene } from "babylonjs/scene";
  34912. import { Matrix } from "babylonjs/Maths/math.vector";
  34913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34914. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34915. import { ISize } from "babylonjs/Maths/math.size";
  34916. import "babylonjs/Misc/fileTools";
  34917. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34918. /**
  34919. * Base class of all the textures in babylon.
  34920. * It groups all the common properties the materials, post process, lights... might need
  34921. * in order to make a correct use of the texture.
  34922. */
  34923. export class BaseTexture implements IAnimatable {
  34924. /**
  34925. * Default anisotropic filtering level for the application.
  34926. * It is set to 4 as a good tradeoff between perf and quality.
  34927. */
  34928. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34929. /**
  34930. * Gets or sets the unique id of the texture
  34931. */
  34932. uniqueId: number;
  34933. /**
  34934. * Define the name of the texture.
  34935. */
  34936. name: string;
  34937. /**
  34938. * Gets or sets an object used to store user defined information.
  34939. */
  34940. metadata: any;
  34941. /**
  34942. * For internal use only. Please do not use.
  34943. */
  34944. reservedDataStore: any;
  34945. private _hasAlpha;
  34946. /**
  34947. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34948. */
  34949. set hasAlpha(value: boolean);
  34950. get hasAlpha(): boolean;
  34951. /**
  34952. * Defines if the alpha value should be determined via the rgb values.
  34953. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34954. */
  34955. getAlphaFromRGB: boolean;
  34956. /**
  34957. * Intensity or strength of the texture.
  34958. * It is commonly used by materials to fine tune the intensity of the texture
  34959. */
  34960. level: number;
  34961. /**
  34962. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34963. * This is part of the texture as textures usually maps to one uv set.
  34964. */
  34965. coordinatesIndex: number;
  34966. private _coordinatesMode;
  34967. /**
  34968. * How a texture is mapped.
  34969. *
  34970. * | Value | Type | Description |
  34971. * | ----- | ----------------------------------- | ----------- |
  34972. * | 0 | EXPLICIT_MODE | |
  34973. * | 1 | SPHERICAL_MODE | |
  34974. * | 2 | PLANAR_MODE | |
  34975. * | 3 | CUBIC_MODE | |
  34976. * | 4 | PROJECTION_MODE | |
  34977. * | 5 | SKYBOX_MODE | |
  34978. * | 6 | INVCUBIC_MODE | |
  34979. * | 7 | EQUIRECTANGULAR_MODE | |
  34980. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34981. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34982. */
  34983. set coordinatesMode(value: number);
  34984. get coordinatesMode(): number;
  34985. /**
  34986. * | Value | Type | Description |
  34987. * | ----- | ------------------ | ----------- |
  34988. * | 0 | CLAMP_ADDRESSMODE | |
  34989. * | 1 | WRAP_ADDRESSMODE | |
  34990. * | 2 | MIRROR_ADDRESSMODE | |
  34991. */
  34992. wrapU: number;
  34993. /**
  34994. * | Value | Type | Description |
  34995. * | ----- | ------------------ | ----------- |
  34996. * | 0 | CLAMP_ADDRESSMODE | |
  34997. * | 1 | WRAP_ADDRESSMODE | |
  34998. * | 2 | MIRROR_ADDRESSMODE | |
  34999. */
  35000. wrapV: number;
  35001. /**
  35002. * | Value | Type | Description |
  35003. * | ----- | ------------------ | ----------- |
  35004. * | 0 | CLAMP_ADDRESSMODE | |
  35005. * | 1 | WRAP_ADDRESSMODE | |
  35006. * | 2 | MIRROR_ADDRESSMODE | |
  35007. */
  35008. wrapR: number;
  35009. /**
  35010. * With compliant hardware and browser (supporting anisotropic filtering)
  35011. * this defines the level of anisotropic filtering in the texture.
  35012. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35013. */
  35014. anisotropicFilteringLevel: number;
  35015. /**
  35016. * Define if the texture is a cube texture or if false a 2d texture.
  35017. */
  35018. get isCube(): boolean;
  35019. set isCube(value: boolean);
  35020. /**
  35021. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35022. */
  35023. get is3D(): boolean;
  35024. set is3D(value: boolean);
  35025. /**
  35026. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35027. */
  35028. get is2DArray(): boolean;
  35029. set is2DArray(value: boolean);
  35030. /**
  35031. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35032. * HDR texture are usually stored in linear space.
  35033. * This only impacts the PBR and Background materials
  35034. */
  35035. gammaSpace: boolean;
  35036. /**
  35037. * Gets or sets whether or not the texture contains RGBD data.
  35038. */
  35039. get isRGBD(): boolean;
  35040. set isRGBD(value: boolean);
  35041. /**
  35042. * Is Z inverted in the texture (useful in a cube texture).
  35043. */
  35044. invertZ: boolean;
  35045. /**
  35046. * Are mip maps generated for this texture or not.
  35047. */
  35048. get noMipmap(): boolean;
  35049. /**
  35050. * @hidden
  35051. */
  35052. lodLevelInAlpha: boolean;
  35053. /**
  35054. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35055. */
  35056. get lodGenerationOffset(): number;
  35057. set lodGenerationOffset(value: number);
  35058. /**
  35059. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35060. */
  35061. get lodGenerationScale(): number;
  35062. set lodGenerationScale(value: number);
  35063. /**
  35064. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35065. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35066. * average roughness values.
  35067. */
  35068. get linearSpecularLOD(): boolean;
  35069. set linearSpecularLOD(value: boolean);
  35070. /**
  35071. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35072. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35073. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35074. */
  35075. get irradianceTexture(): Nullable<BaseTexture>;
  35076. set irradianceTexture(value: Nullable<BaseTexture>);
  35077. /**
  35078. * Define if the texture is a render target.
  35079. */
  35080. isRenderTarget: boolean;
  35081. /**
  35082. * Define the unique id of the texture in the scene.
  35083. */
  35084. get uid(): string;
  35085. /** @hidden */
  35086. _prefiltered: boolean;
  35087. /**
  35088. * Return a string representation of the texture.
  35089. * @returns the texture as a string
  35090. */
  35091. toString(): string;
  35092. /**
  35093. * Get the class name of the texture.
  35094. * @returns "BaseTexture"
  35095. */
  35096. getClassName(): string;
  35097. /**
  35098. * Define the list of animation attached to the texture.
  35099. */
  35100. animations: import("babylonjs/Animations/animation").Animation[];
  35101. /**
  35102. * An event triggered when the texture is disposed.
  35103. */
  35104. onDisposeObservable: Observable<BaseTexture>;
  35105. private _onDisposeObserver;
  35106. /**
  35107. * Callback triggered when the texture has been disposed.
  35108. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35109. */
  35110. set onDispose(callback: () => void);
  35111. /**
  35112. * Define the current state of the loading sequence when in delayed load mode.
  35113. */
  35114. delayLoadState: number;
  35115. protected _scene: Nullable<Scene>;
  35116. protected _engine: Nullable<ThinEngine>;
  35117. /** @hidden */
  35118. _texture: Nullable<InternalTexture>;
  35119. private _uid;
  35120. /**
  35121. * Define if the texture is preventinga material to render or not.
  35122. * If not and the texture is not ready, the engine will use a default black texture instead.
  35123. */
  35124. get isBlocking(): boolean;
  35125. /**
  35126. * Instantiates a new BaseTexture.
  35127. * Base class of all the textures in babylon.
  35128. * It groups all the common properties the materials, post process, lights... might need
  35129. * in order to make a correct use of the texture.
  35130. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35131. */
  35132. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35133. /**
  35134. * Get the scene the texture belongs to.
  35135. * @returns the scene or null if undefined
  35136. */
  35137. getScene(): Nullable<Scene>;
  35138. /** @hidden */
  35139. protected _getEngine(): Nullable<ThinEngine>;
  35140. /**
  35141. * Get the texture transform matrix used to offset tile the texture for istance.
  35142. * @returns the transformation matrix
  35143. */
  35144. getTextureMatrix(): Matrix;
  35145. /**
  35146. * Get the texture reflection matrix used to rotate/transform the reflection.
  35147. * @returns the reflection matrix
  35148. */
  35149. getReflectionTextureMatrix(): Matrix;
  35150. /**
  35151. * Get the underlying lower level texture from Babylon.
  35152. * @returns the insternal texture
  35153. */
  35154. getInternalTexture(): Nullable<InternalTexture>;
  35155. /**
  35156. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35157. * @returns true if ready or not blocking
  35158. */
  35159. isReadyOrNotBlocking(): boolean;
  35160. /**
  35161. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35162. * @returns true if fully ready
  35163. */
  35164. isReady(): boolean;
  35165. private _cachedSize;
  35166. /**
  35167. * Get the size of the texture.
  35168. * @returns the texture size.
  35169. */
  35170. getSize(): ISize;
  35171. /**
  35172. * Get the base size of the texture.
  35173. * It can be different from the size if the texture has been resized for POT for instance
  35174. * @returns the base size
  35175. */
  35176. getBaseSize(): ISize;
  35177. /**
  35178. * Update the sampling mode of the texture.
  35179. * Default is Trilinear mode.
  35180. *
  35181. * | Value | Type | Description |
  35182. * | ----- | ------------------ | ----------- |
  35183. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35184. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35185. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35186. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35187. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35188. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35189. * | 7 | NEAREST_LINEAR | |
  35190. * | 8 | NEAREST_NEAREST | |
  35191. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35192. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35193. * | 11 | LINEAR_LINEAR | |
  35194. * | 12 | LINEAR_NEAREST | |
  35195. *
  35196. * > _mag_: magnification filter (close to the viewer)
  35197. * > _min_: minification filter (far from the viewer)
  35198. * > _mip_: filter used between mip map levels
  35199. *@param samplingMode Define the new sampling mode of the texture
  35200. */
  35201. updateSamplingMode(samplingMode: number): void;
  35202. /**
  35203. * Scales the texture if is `canRescale()`
  35204. * @param ratio the resize factor we want to use to rescale
  35205. */
  35206. scale(ratio: number): void;
  35207. /**
  35208. * Get if the texture can rescale.
  35209. */
  35210. get canRescale(): boolean;
  35211. /** @hidden */
  35212. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35213. /** @hidden */
  35214. _rebuild(): void;
  35215. /**
  35216. * Triggers the load sequence in delayed load mode.
  35217. */
  35218. delayLoad(): void;
  35219. /**
  35220. * Clones the texture.
  35221. * @returns the cloned texture
  35222. */
  35223. clone(): Nullable<BaseTexture>;
  35224. /**
  35225. * Get the texture underlying type (INT, FLOAT...)
  35226. */
  35227. get textureType(): number;
  35228. /**
  35229. * Get the texture underlying format (RGB, RGBA...)
  35230. */
  35231. get textureFormat(): number;
  35232. /**
  35233. * Indicates that textures need to be re-calculated for all materials
  35234. */
  35235. protected _markAllSubMeshesAsTexturesDirty(): void;
  35236. /**
  35237. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35238. * This will returns an RGBA array buffer containing either in values (0-255) or
  35239. * float values (0-1) depending of the underlying buffer type.
  35240. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35241. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35242. * @param buffer defines a user defined buffer to fill with data (can be null)
  35243. * @returns The Array buffer containing the pixels data.
  35244. */
  35245. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35246. /**
  35247. * Release and destroy the underlying lower level texture aka internalTexture.
  35248. */
  35249. releaseInternalTexture(): void;
  35250. /** @hidden */
  35251. get _lodTextureHigh(): Nullable<BaseTexture>;
  35252. /** @hidden */
  35253. get _lodTextureMid(): Nullable<BaseTexture>;
  35254. /** @hidden */
  35255. get _lodTextureLow(): Nullable<BaseTexture>;
  35256. /**
  35257. * Dispose the texture and release its associated resources.
  35258. */
  35259. dispose(): void;
  35260. /**
  35261. * Serialize the texture into a JSON representation that can be parsed later on.
  35262. * @returns the JSON representation of the texture
  35263. */
  35264. serialize(): any;
  35265. /**
  35266. * Helper function to be called back once a list of texture contains only ready textures.
  35267. * @param textures Define the list of textures to wait for
  35268. * @param callback Define the callback triggered once the entire list will be ready
  35269. */
  35270. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35271. private static _isScene;
  35272. }
  35273. }
  35274. declare module "babylonjs/Materials/effect" {
  35275. import { Observable } from "babylonjs/Misc/observable";
  35276. import { Nullable } from "babylonjs/types";
  35277. import { IDisposable } from "babylonjs/scene";
  35278. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35279. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35280. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35281. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35282. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35283. import { Engine } from "babylonjs/Engines/engine";
  35284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35286. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35287. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35288. /**
  35289. * Options to be used when creating an effect.
  35290. */
  35291. export interface IEffectCreationOptions {
  35292. /**
  35293. * Atrributes that will be used in the shader.
  35294. */
  35295. attributes: string[];
  35296. /**
  35297. * Uniform varible names that will be set in the shader.
  35298. */
  35299. uniformsNames: string[];
  35300. /**
  35301. * Uniform buffer variable names that will be set in the shader.
  35302. */
  35303. uniformBuffersNames: string[];
  35304. /**
  35305. * Sampler texture variable names that will be set in the shader.
  35306. */
  35307. samplers: string[];
  35308. /**
  35309. * Define statements that will be set in the shader.
  35310. */
  35311. defines: any;
  35312. /**
  35313. * Possible fallbacks for this effect to improve performance when needed.
  35314. */
  35315. fallbacks: Nullable<IEffectFallbacks>;
  35316. /**
  35317. * Callback that will be called when the shader is compiled.
  35318. */
  35319. onCompiled: Nullable<(effect: Effect) => void>;
  35320. /**
  35321. * Callback that will be called if an error occurs during shader compilation.
  35322. */
  35323. onError: Nullable<(effect: Effect, errors: string) => void>;
  35324. /**
  35325. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35326. */
  35327. indexParameters?: any;
  35328. /**
  35329. * Max number of lights that can be used in the shader.
  35330. */
  35331. maxSimultaneousLights?: number;
  35332. /**
  35333. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35334. */
  35335. transformFeedbackVaryings?: Nullable<string[]>;
  35336. /**
  35337. * 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
  35338. */
  35339. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35340. /**
  35341. * Is this effect rendering to several color attachments ?
  35342. */
  35343. multiTarget?: boolean;
  35344. }
  35345. /**
  35346. * Effect containing vertex and fragment shader that can be executed on an object.
  35347. */
  35348. export class Effect implements IDisposable {
  35349. /**
  35350. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35351. */
  35352. static ShadersRepository: string;
  35353. /**
  35354. * Enable logging of the shader code when a compilation error occurs
  35355. */
  35356. static LogShaderCodeOnCompilationError: boolean;
  35357. /**
  35358. * Name of the effect.
  35359. */
  35360. name: any;
  35361. /**
  35362. * String container all the define statements that should be set on the shader.
  35363. */
  35364. defines: string;
  35365. /**
  35366. * Callback that will be called when the shader is compiled.
  35367. */
  35368. onCompiled: Nullable<(effect: Effect) => void>;
  35369. /**
  35370. * Callback that will be called if an error occurs during shader compilation.
  35371. */
  35372. onError: Nullable<(effect: Effect, errors: string) => void>;
  35373. /**
  35374. * Callback that will be called when effect is bound.
  35375. */
  35376. onBind: Nullable<(effect: Effect) => void>;
  35377. /**
  35378. * Unique ID of the effect.
  35379. */
  35380. uniqueId: number;
  35381. /**
  35382. * Observable that will be called when the shader is compiled.
  35383. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35384. */
  35385. onCompileObservable: Observable<Effect>;
  35386. /**
  35387. * Observable that will be called if an error occurs during shader compilation.
  35388. */
  35389. onErrorObservable: Observable<Effect>;
  35390. /** @hidden */
  35391. _onBindObservable: Nullable<Observable<Effect>>;
  35392. /**
  35393. * @hidden
  35394. * Specifies if the effect was previously ready
  35395. */
  35396. _wasPreviouslyReady: boolean;
  35397. /**
  35398. * Observable that will be called when effect is bound.
  35399. */
  35400. get onBindObservable(): Observable<Effect>;
  35401. /** @hidden */
  35402. _bonesComputationForcedToCPU: boolean;
  35403. /** @hidden */
  35404. _multiTarget: boolean;
  35405. private static _uniqueIdSeed;
  35406. private _engine;
  35407. private _uniformBuffersNames;
  35408. private _uniformBuffersNamesList;
  35409. private _uniformsNames;
  35410. private _samplerList;
  35411. private _samplers;
  35412. private _isReady;
  35413. private _compilationError;
  35414. private _allFallbacksProcessed;
  35415. private _attributesNames;
  35416. private _attributes;
  35417. private _attributeLocationByName;
  35418. private _uniforms;
  35419. /**
  35420. * Key for the effect.
  35421. * @hidden
  35422. */
  35423. _key: string;
  35424. private _indexParameters;
  35425. private _fallbacks;
  35426. private _vertexSourceCode;
  35427. private _fragmentSourceCode;
  35428. private _vertexSourceCodeOverride;
  35429. private _fragmentSourceCodeOverride;
  35430. private _transformFeedbackVaryings;
  35431. /**
  35432. * Compiled shader to webGL program.
  35433. * @hidden
  35434. */
  35435. _pipelineContext: Nullable<IPipelineContext>;
  35436. private _valueCache;
  35437. private static _baseCache;
  35438. /**
  35439. * Instantiates an effect.
  35440. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35441. * @param baseName Name of the effect.
  35442. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35443. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35444. * @param samplers List of sampler variables that will be passed to the shader.
  35445. * @param engine Engine to be used to render the effect
  35446. * @param defines Define statements to be added to the shader.
  35447. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35448. * @param onCompiled Callback that will be called when the shader is compiled.
  35449. * @param onError Callback that will be called if an error occurs during shader compilation.
  35450. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35451. */
  35452. 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);
  35453. private _useFinalCode;
  35454. /**
  35455. * Unique key for this effect
  35456. */
  35457. get key(): string;
  35458. /**
  35459. * If the effect has been compiled and prepared.
  35460. * @returns if the effect is compiled and prepared.
  35461. */
  35462. isReady(): boolean;
  35463. private _isReadyInternal;
  35464. /**
  35465. * The engine the effect was initialized with.
  35466. * @returns the engine.
  35467. */
  35468. getEngine(): Engine;
  35469. /**
  35470. * The pipeline context for this effect
  35471. * @returns the associated pipeline context
  35472. */
  35473. getPipelineContext(): Nullable<IPipelineContext>;
  35474. /**
  35475. * The set of names of attribute variables for the shader.
  35476. * @returns An array of attribute names.
  35477. */
  35478. getAttributesNames(): string[];
  35479. /**
  35480. * Returns the attribute at the given index.
  35481. * @param index The index of the attribute.
  35482. * @returns The location of the attribute.
  35483. */
  35484. getAttributeLocation(index: number): number;
  35485. /**
  35486. * Returns the attribute based on the name of the variable.
  35487. * @param name of the attribute to look up.
  35488. * @returns the attribute location.
  35489. */
  35490. getAttributeLocationByName(name: string): number;
  35491. /**
  35492. * The number of attributes.
  35493. * @returns the numnber of attributes.
  35494. */
  35495. getAttributesCount(): number;
  35496. /**
  35497. * Gets the index of a uniform variable.
  35498. * @param uniformName of the uniform to look up.
  35499. * @returns the index.
  35500. */
  35501. getUniformIndex(uniformName: string): number;
  35502. /**
  35503. * Returns the attribute based on the name of the variable.
  35504. * @param uniformName of the uniform to look up.
  35505. * @returns the location of the uniform.
  35506. */
  35507. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35508. /**
  35509. * Returns an array of sampler variable names
  35510. * @returns The array of sampler variable names.
  35511. */
  35512. getSamplers(): string[];
  35513. /**
  35514. * Returns an array of uniform variable names
  35515. * @returns The array of uniform variable names.
  35516. */
  35517. getUniformNames(): string[];
  35518. /**
  35519. * Returns an array of uniform buffer variable names
  35520. * @returns The array of uniform buffer variable names.
  35521. */
  35522. getUniformBuffersNames(): string[];
  35523. /**
  35524. * Returns the index parameters used to create the effect
  35525. * @returns The index parameters object
  35526. */
  35527. getIndexParameters(): any;
  35528. /**
  35529. * The error from the last compilation.
  35530. * @returns the error string.
  35531. */
  35532. getCompilationError(): string;
  35533. /**
  35534. * Gets a boolean indicating that all fallbacks were used during compilation
  35535. * @returns true if all fallbacks were used
  35536. */
  35537. allFallbacksProcessed(): boolean;
  35538. /**
  35539. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35540. * @param func The callback to be used.
  35541. */
  35542. executeWhenCompiled(func: (effect: Effect) => void): void;
  35543. private _checkIsReady;
  35544. private _loadShader;
  35545. /**
  35546. * Gets the vertex shader source code of this effect
  35547. */
  35548. get vertexSourceCode(): string;
  35549. /**
  35550. * Gets the fragment shader source code of this effect
  35551. */
  35552. get fragmentSourceCode(): string;
  35553. /**
  35554. * Recompiles the webGL program
  35555. * @param vertexSourceCode The source code for the vertex shader.
  35556. * @param fragmentSourceCode The source code for the fragment shader.
  35557. * @param onCompiled Callback called when completed.
  35558. * @param onError Callback called on error.
  35559. * @hidden
  35560. */
  35561. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35562. /**
  35563. * Prepares the effect
  35564. * @hidden
  35565. */
  35566. _prepareEffect(): void;
  35567. private _getShaderCodeAndErrorLine;
  35568. private _processCompilationErrors;
  35569. /**
  35570. * Checks if the effect is supported. (Must be called after compilation)
  35571. */
  35572. get isSupported(): boolean;
  35573. /**
  35574. * Binds a texture to the engine to be used as output of the shader.
  35575. * @param channel Name of the output variable.
  35576. * @param texture Texture to bind.
  35577. * @hidden
  35578. */
  35579. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35580. /**
  35581. * Sets a texture on the engine to be used in the shader.
  35582. * @param channel Name of the sampler variable.
  35583. * @param texture Texture to set.
  35584. */
  35585. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35586. /**
  35587. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35588. * @param channel Name of the sampler variable.
  35589. * @param texture Texture to set.
  35590. */
  35591. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35592. /**
  35593. * Sets an array of textures on the engine to be used in the shader.
  35594. * @param channel Name of the variable.
  35595. * @param textures Textures to set.
  35596. */
  35597. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35598. /**
  35599. * 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)
  35600. * @param channel Name of the sampler variable.
  35601. * @param postProcess Post process to get the input texture from.
  35602. */
  35603. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35604. /**
  35605. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35606. * 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)
  35607. * @param channel Name of the sampler variable.
  35608. * @param postProcess Post process to get the output texture from.
  35609. */
  35610. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35611. /** @hidden */
  35612. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35613. /** @hidden */
  35614. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35615. /** @hidden */
  35616. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35617. /** @hidden */
  35618. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35619. /**
  35620. * Binds a buffer to a uniform.
  35621. * @param buffer Buffer to bind.
  35622. * @param name Name of the uniform variable to bind to.
  35623. */
  35624. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35625. /**
  35626. * Binds block to a uniform.
  35627. * @param blockName Name of the block to bind.
  35628. * @param index Index to bind.
  35629. */
  35630. bindUniformBlock(blockName: string, index: number): void;
  35631. /**
  35632. * Sets an interger value on a uniform variable.
  35633. * @param uniformName Name of the variable.
  35634. * @param value Value to be set.
  35635. * @returns this effect.
  35636. */
  35637. setInt(uniformName: string, value: number): Effect;
  35638. /**
  35639. * Sets an int array on a uniform variable.
  35640. * @param uniformName Name of the variable.
  35641. * @param array array to be set.
  35642. * @returns this effect.
  35643. */
  35644. setIntArray(uniformName: string, array: Int32Array): Effect;
  35645. /**
  35646. * 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)
  35647. * @param uniformName Name of the variable.
  35648. * @param array array to be set.
  35649. * @returns this effect.
  35650. */
  35651. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35652. /**
  35653. * 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)
  35654. * @param uniformName Name of the variable.
  35655. * @param array array to be set.
  35656. * @returns this effect.
  35657. */
  35658. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35659. /**
  35660. * 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)
  35661. * @param uniformName Name of the variable.
  35662. * @param array array to be set.
  35663. * @returns this effect.
  35664. */
  35665. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35666. /**
  35667. * Sets an float array on a uniform variable.
  35668. * @param uniformName Name of the variable.
  35669. * @param array array to be set.
  35670. * @returns this effect.
  35671. */
  35672. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35673. /**
  35674. * 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)
  35675. * @param uniformName Name of the variable.
  35676. * @param array array to be set.
  35677. * @returns this effect.
  35678. */
  35679. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35680. /**
  35681. * 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)
  35682. * @param uniformName Name of the variable.
  35683. * @param array array to be set.
  35684. * @returns this effect.
  35685. */
  35686. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35687. /**
  35688. * 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)
  35689. * @param uniformName Name of the variable.
  35690. * @param array array to be set.
  35691. * @returns this effect.
  35692. */
  35693. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35694. /**
  35695. * Sets an array on a uniform variable.
  35696. * @param uniformName Name of the variable.
  35697. * @param array array to be set.
  35698. * @returns this effect.
  35699. */
  35700. setArray(uniformName: string, array: number[]): Effect;
  35701. /**
  35702. * 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)
  35703. * @param uniformName Name of the variable.
  35704. * @param array array to be set.
  35705. * @returns this effect.
  35706. */
  35707. setArray2(uniformName: string, array: number[]): Effect;
  35708. /**
  35709. * 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)
  35710. * @param uniformName Name of the variable.
  35711. * @param array array to be set.
  35712. * @returns this effect.
  35713. */
  35714. setArray3(uniformName: string, array: number[]): Effect;
  35715. /**
  35716. * 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)
  35717. * @param uniformName Name of the variable.
  35718. * @param array array to be set.
  35719. * @returns this effect.
  35720. */
  35721. setArray4(uniformName: string, array: number[]): Effect;
  35722. /**
  35723. * Sets matrices on a uniform variable.
  35724. * @param uniformName Name of the variable.
  35725. * @param matrices matrices to be set.
  35726. * @returns this effect.
  35727. */
  35728. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35729. /**
  35730. * Sets matrix on a uniform variable.
  35731. * @param uniformName Name of the variable.
  35732. * @param matrix matrix to be set.
  35733. * @returns this effect.
  35734. */
  35735. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35736. /**
  35737. * 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)
  35738. * @param uniformName Name of the variable.
  35739. * @param matrix matrix to be set.
  35740. * @returns this effect.
  35741. */
  35742. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35743. /**
  35744. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35745. * @param uniformName Name of the variable.
  35746. * @param matrix matrix to be set.
  35747. * @returns this effect.
  35748. */
  35749. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35750. /**
  35751. * Sets a float on a uniform variable.
  35752. * @param uniformName Name of the variable.
  35753. * @param value value to be set.
  35754. * @returns this effect.
  35755. */
  35756. setFloat(uniformName: string, value: number): Effect;
  35757. /**
  35758. * Sets a boolean on a uniform variable.
  35759. * @param uniformName Name of the variable.
  35760. * @param bool value to be set.
  35761. * @returns this effect.
  35762. */
  35763. setBool(uniformName: string, bool: boolean): Effect;
  35764. /**
  35765. * Sets a Vector2 on a uniform variable.
  35766. * @param uniformName Name of the variable.
  35767. * @param vector2 vector2 to be set.
  35768. * @returns this effect.
  35769. */
  35770. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35771. /**
  35772. * Sets a float2 on a uniform variable.
  35773. * @param uniformName Name of the variable.
  35774. * @param x First float in float2.
  35775. * @param y Second float in float2.
  35776. * @returns this effect.
  35777. */
  35778. setFloat2(uniformName: string, x: number, y: number): Effect;
  35779. /**
  35780. * Sets a Vector3 on a uniform variable.
  35781. * @param uniformName Name of the variable.
  35782. * @param vector3 Value to be set.
  35783. * @returns this effect.
  35784. */
  35785. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35786. /**
  35787. * Sets a float3 on a uniform variable.
  35788. * @param uniformName Name of the variable.
  35789. * @param x First float in float3.
  35790. * @param y Second float in float3.
  35791. * @param z Third float in float3.
  35792. * @returns this effect.
  35793. */
  35794. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35795. /**
  35796. * Sets a Vector4 on a uniform variable.
  35797. * @param uniformName Name of the variable.
  35798. * @param vector4 Value to be set.
  35799. * @returns this effect.
  35800. */
  35801. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35802. /**
  35803. * Sets a float4 on a uniform variable.
  35804. * @param uniformName Name of the variable.
  35805. * @param x First float in float4.
  35806. * @param y Second float in float4.
  35807. * @param z Third float in float4.
  35808. * @param w Fourth float in float4.
  35809. * @returns this effect.
  35810. */
  35811. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35812. /**
  35813. * Sets a Color3 on a uniform variable.
  35814. * @param uniformName Name of the variable.
  35815. * @param color3 Value to be set.
  35816. * @returns this effect.
  35817. */
  35818. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35819. /**
  35820. * Sets a Color4 on a uniform variable.
  35821. * @param uniformName Name of the variable.
  35822. * @param color3 Value to be set.
  35823. * @param alpha Alpha value to be set.
  35824. * @returns this effect.
  35825. */
  35826. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35827. /**
  35828. * Sets a Color4 on a uniform variable
  35829. * @param uniformName defines the name of the variable
  35830. * @param color4 defines the value to be set
  35831. * @returns this effect.
  35832. */
  35833. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35834. /** Release all associated resources */
  35835. dispose(): void;
  35836. /**
  35837. * This function will add a new shader to the shader store
  35838. * @param name the name of the shader
  35839. * @param pixelShader optional pixel shader content
  35840. * @param vertexShader optional vertex shader content
  35841. */
  35842. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35843. /**
  35844. * Store of each shader (The can be looked up using effect.key)
  35845. */
  35846. static ShadersStore: {
  35847. [key: string]: string;
  35848. };
  35849. /**
  35850. * Store of each included file for a shader (The can be looked up using effect.key)
  35851. */
  35852. static IncludesShadersStore: {
  35853. [key: string]: string;
  35854. };
  35855. /**
  35856. * Resets the cache of effects.
  35857. */
  35858. static ResetCache(): void;
  35859. }
  35860. }
  35861. declare module "babylonjs/Engines/engineCapabilities" {
  35862. /**
  35863. * Interface used to describe the capabilities of the engine relatively to the current browser
  35864. */
  35865. export interface EngineCapabilities {
  35866. /** Maximum textures units per fragment shader */
  35867. maxTexturesImageUnits: number;
  35868. /** Maximum texture units per vertex shader */
  35869. maxVertexTextureImageUnits: number;
  35870. /** Maximum textures units in the entire pipeline */
  35871. maxCombinedTexturesImageUnits: number;
  35872. /** Maximum texture size */
  35873. maxTextureSize: number;
  35874. /** Maximum texture samples */
  35875. maxSamples?: number;
  35876. /** Maximum cube texture size */
  35877. maxCubemapTextureSize: number;
  35878. /** Maximum render texture size */
  35879. maxRenderTextureSize: number;
  35880. /** Maximum number of vertex attributes */
  35881. maxVertexAttribs: number;
  35882. /** Maximum number of varyings */
  35883. maxVaryingVectors: number;
  35884. /** Maximum number of uniforms per vertex shader */
  35885. maxVertexUniformVectors: number;
  35886. /** Maximum number of uniforms per fragment shader */
  35887. maxFragmentUniformVectors: number;
  35888. /** Defines if standard derivates (dx/dy) are supported */
  35889. standardDerivatives: boolean;
  35890. /** Defines if s3tc texture compression is supported */
  35891. s3tc?: WEBGL_compressed_texture_s3tc;
  35892. /** Defines if pvrtc texture compression is supported */
  35893. pvrtc: any;
  35894. /** Defines if etc1 texture compression is supported */
  35895. etc1: any;
  35896. /** Defines if etc2 texture compression is supported */
  35897. etc2: any;
  35898. /** Defines if astc texture compression is supported */
  35899. astc: any;
  35900. /** Defines if float textures are supported */
  35901. textureFloat: boolean;
  35902. /** Defines if vertex array objects are supported */
  35903. vertexArrayObject: boolean;
  35904. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35905. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35906. /** Gets the maximum level of anisotropy supported */
  35907. maxAnisotropy: number;
  35908. /** Defines if instancing is supported */
  35909. instancedArrays: boolean;
  35910. /** Defines if 32 bits indices are supported */
  35911. uintIndices: boolean;
  35912. /** Defines if high precision shaders are supported */
  35913. highPrecisionShaderSupported: boolean;
  35914. /** Defines if depth reading in the fragment shader is supported */
  35915. fragmentDepthSupported: boolean;
  35916. /** Defines if float texture linear filtering is supported*/
  35917. textureFloatLinearFiltering: boolean;
  35918. /** Defines if rendering to float textures is supported */
  35919. textureFloatRender: boolean;
  35920. /** Defines if half float textures are supported*/
  35921. textureHalfFloat: boolean;
  35922. /** Defines if half float texture linear filtering is supported*/
  35923. textureHalfFloatLinearFiltering: boolean;
  35924. /** Defines if rendering to half float textures is supported */
  35925. textureHalfFloatRender: boolean;
  35926. /** Defines if textureLOD shader command is supported */
  35927. textureLOD: boolean;
  35928. /** Defines if draw buffers extension is supported */
  35929. drawBuffersExtension: boolean;
  35930. /** Defines if depth textures are supported */
  35931. depthTextureExtension: boolean;
  35932. /** Defines if float color buffer are supported */
  35933. colorBufferFloat: boolean;
  35934. /** Gets disjoint timer query extension (null if not supported) */
  35935. timerQuery?: EXT_disjoint_timer_query;
  35936. /** Defines if timestamp can be used with timer query */
  35937. canUseTimestampForTimerQuery: boolean;
  35938. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35939. multiview?: any;
  35940. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35941. oculusMultiview?: any;
  35942. /** Function used to let the system compiles shaders in background */
  35943. parallelShaderCompile?: {
  35944. COMPLETION_STATUS_KHR: number;
  35945. };
  35946. /** Max number of texture samples for MSAA */
  35947. maxMSAASamples: number;
  35948. /** Defines if the blend min max extension is supported */
  35949. blendMinMax: boolean;
  35950. }
  35951. }
  35952. declare module "babylonjs/States/depthCullingState" {
  35953. import { Nullable } from "babylonjs/types";
  35954. /**
  35955. * @hidden
  35956. **/
  35957. export class DepthCullingState {
  35958. private _isDepthTestDirty;
  35959. private _isDepthMaskDirty;
  35960. private _isDepthFuncDirty;
  35961. private _isCullFaceDirty;
  35962. private _isCullDirty;
  35963. private _isZOffsetDirty;
  35964. private _isFrontFaceDirty;
  35965. private _depthTest;
  35966. private _depthMask;
  35967. private _depthFunc;
  35968. private _cull;
  35969. private _cullFace;
  35970. private _zOffset;
  35971. private _frontFace;
  35972. /**
  35973. * Initializes the state.
  35974. */
  35975. constructor();
  35976. get isDirty(): boolean;
  35977. get zOffset(): number;
  35978. set zOffset(value: number);
  35979. get cullFace(): Nullable<number>;
  35980. set cullFace(value: Nullable<number>);
  35981. get cull(): Nullable<boolean>;
  35982. set cull(value: Nullable<boolean>);
  35983. get depthFunc(): Nullable<number>;
  35984. set depthFunc(value: Nullable<number>);
  35985. get depthMask(): boolean;
  35986. set depthMask(value: boolean);
  35987. get depthTest(): boolean;
  35988. set depthTest(value: boolean);
  35989. get frontFace(): Nullable<number>;
  35990. set frontFace(value: Nullable<number>);
  35991. reset(): void;
  35992. apply(gl: WebGLRenderingContext): void;
  35993. }
  35994. }
  35995. declare module "babylonjs/States/stencilState" {
  35996. /**
  35997. * @hidden
  35998. **/
  35999. export class StencilState {
  36000. /** 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 */
  36001. static readonly ALWAYS: number;
  36002. /** Passed to stencilOperation to specify that stencil value must be kept */
  36003. static readonly KEEP: number;
  36004. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36005. static readonly REPLACE: number;
  36006. private _isStencilTestDirty;
  36007. private _isStencilMaskDirty;
  36008. private _isStencilFuncDirty;
  36009. private _isStencilOpDirty;
  36010. private _stencilTest;
  36011. private _stencilMask;
  36012. private _stencilFunc;
  36013. private _stencilFuncRef;
  36014. private _stencilFuncMask;
  36015. private _stencilOpStencilFail;
  36016. private _stencilOpDepthFail;
  36017. private _stencilOpStencilDepthPass;
  36018. get isDirty(): boolean;
  36019. get stencilFunc(): number;
  36020. set stencilFunc(value: number);
  36021. get stencilFuncRef(): number;
  36022. set stencilFuncRef(value: number);
  36023. get stencilFuncMask(): number;
  36024. set stencilFuncMask(value: number);
  36025. get stencilOpStencilFail(): number;
  36026. set stencilOpStencilFail(value: number);
  36027. get stencilOpDepthFail(): number;
  36028. set stencilOpDepthFail(value: number);
  36029. get stencilOpStencilDepthPass(): number;
  36030. set stencilOpStencilDepthPass(value: number);
  36031. get stencilMask(): number;
  36032. set stencilMask(value: number);
  36033. get stencilTest(): boolean;
  36034. set stencilTest(value: boolean);
  36035. constructor();
  36036. reset(): void;
  36037. apply(gl: WebGLRenderingContext): void;
  36038. }
  36039. }
  36040. declare module "babylonjs/States/alphaCullingState" {
  36041. /**
  36042. * @hidden
  36043. **/
  36044. export class AlphaState {
  36045. private _isAlphaBlendDirty;
  36046. private _isBlendFunctionParametersDirty;
  36047. private _isBlendEquationParametersDirty;
  36048. private _isBlendConstantsDirty;
  36049. private _alphaBlend;
  36050. private _blendFunctionParameters;
  36051. private _blendEquationParameters;
  36052. private _blendConstants;
  36053. /**
  36054. * Initializes the state.
  36055. */
  36056. constructor();
  36057. get isDirty(): boolean;
  36058. get alphaBlend(): boolean;
  36059. set alphaBlend(value: boolean);
  36060. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36061. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36062. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36063. reset(): void;
  36064. apply(gl: WebGLRenderingContext): void;
  36065. }
  36066. }
  36067. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36068. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36069. /** @hidden */
  36070. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36071. attributeProcessor(attribute: string): string;
  36072. varyingProcessor(varying: string, isFragment: boolean): string;
  36073. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36074. }
  36075. }
  36076. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36077. /**
  36078. * Interface for attribute information associated with buffer instanciation
  36079. */
  36080. export interface InstancingAttributeInfo {
  36081. /**
  36082. * Name of the GLSL attribute
  36083. * if attribute index is not specified, this is used to retrieve the index from the effect
  36084. */
  36085. attributeName: string;
  36086. /**
  36087. * Index/offset of the attribute in the vertex shader
  36088. * if not specified, this will be computes from the name.
  36089. */
  36090. index?: number;
  36091. /**
  36092. * size of the attribute, 1, 2, 3 or 4
  36093. */
  36094. attributeSize: number;
  36095. /**
  36096. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36097. */
  36098. offset: number;
  36099. /**
  36100. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36101. * default to 1
  36102. */
  36103. divisor?: number;
  36104. /**
  36105. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36106. * default is FLOAT
  36107. */
  36108. attributeType?: number;
  36109. /**
  36110. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36111. */
  36112. normalized?: boolean;
  36113. }
  36114. }
  36115. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36117. import { Nullable } from "babylonjs/types";
  36118. module "babylonjs/Engines/thinEngine" {
  36119. interface ThinEngine {
  36120. /**
  36121. * Update a video texture
  36122. * @param texture defines the texture to update
  36123. * @param video defines the video element to use
  36124. * @param invertY defines if data must be stored with Y axis inverted
  36125. */
  36126. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36127. }
  36128. }
  36129. }
  36130. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36132. import { Nullable } from "babylonjs/types";
  36133. module "babylonjs/Engines/thinEngine" {
  36134. interface ThinEngine {
  36135. /**
  36136. * Creates a dynamic texture
  36137. * @param width defines the width of the texture
  36138. * @param height defines the height of the texture
  36139. * @param generateMipMaps defines if the engine should generate the mip levels
  36140. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36141. * @returns the dynamic texture inside an InternalTexture
  36142. */
  36143. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36144. /**
  36145. * Update the content of a dynamic texture
  36146. * @param texture defines the texture to update
  36147. * @param canvas defines the canvas containing the source
  36148. * @param invertY defines if data must be stored with Y axis inverted
  36149. * @param premulAlpha defines if alpha is stored as premultiplied
  36150. * @param format defines the format of the data
  36151. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36152. */
  36153. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36154. }
  36155. }
  36156. }
  36157. declare module "babylonjs/Materials/Textures/videoTexture" {
  36158. import { Observable } from "babylonjs/Misc/observable";
  36159. import { Nullable } from "babylonjs/types";
  36160. import { Scene } from "babylonjs/scene";
  36161. import { Texture } from "babylonjs/Materials/Textures/texture";
  36162. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36163. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36164. /**
  36165. * Settings for finer control over video usage
  36166. */
  36167. export interface VideoTextureSettings {
  36168. /**
  36169. * Applies `autoplay` to video, if specified
  36170. */
  36171. autoPlay?: boolean;
  36172. /**
  36173. * Applies `loop` to video, if specified
  36174. */
  36175. loop?: boolean;
  36176. /**
  36177. * Automatically updates internal texture from video at every frame in the render loop
  36178. */
  36179. autoUpdateTexture: boolean;
  36180. /**
  36181. * Image src displayed during the video loading or until the user interacts with the video.
  36182. */
  36183. poster?: string;
  36184. }
  36185. /**
  36186. * If you want to display a video in your scene, this is the special texture for that.
  36187. * This special texture works similar to other textures, with the exception of a few parameters.
  36188. * @see https://doc.babylonjs.com/how_to/video_texture
  36189. */
  36190. export class VideoTexture extends Texture {
  36191. /**
  36192. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36193. */
  36194. readonly autoUpdateTexture: boolean;
  36195. /**
  36196. * The video instance used by the texture internally
  36197. */
  36198. readonly video: HTMLVideoElement;
  36199. private _onUserActionRequestedObservable;
  36200. /**
  36201. * Event triggerd when a dom action is required by the user to play the video.
  36202. * This happens due to recent changes in browser policies preventing video to auto start.
  36203. */
  36204. get onUserActionRequestedObservable(): Observable<Texture>;
  36205. private _generateMipMaps;
  36206. private _stillImageCaptured;
  36207. private _displayingPosterTexture;
  36208. private _settings;
  36209. private _createInternalTextureOnEvent;
  36210. private _frameId;
  36211. private _currentSrc;
  36212. /**
  36213. * Creates a video texture.
  36214. * If you want to display a video in your scene, this is the special texture for that.
  36215. * This special texture works similar to other textures, with the exception of a few parameters.
  36216. * @see https://doc.babylonjs.com/how_to/video_texture
  36217. * @param name optional name, will detect from video source, if not defined
  36218. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36219. * @param scene is obviously the current scene.
  36220. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36221. * @param invertY is false by default but can be used to invert video on Y axis
  36222. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36223. * @param settings allows finer control over video usage
  36224. */
  36225. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36226. private _getName;
  36227. private _getVideo;
  36228. private _createInternalTexture;
  36229. private reset;
  36230. /**
  36231. * @hidden Internal method to initiate `update`.
  36232. */
  36233. _rebuild(): void;
  36234. /**
  36235. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36236. */
  36237. update(): void;
  36238. /**
  36239. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36240. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36241. */
  36242. updateTexture(isVisible: boolean): void;
  36243. protected _updateInternalTexture: () => void;
  36244. /**
  36245. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36246. * @param url New url.
  36247. */
  36248. updateURL(url: string): void;
  36249. /**
  36250. * Clones the texture.
  36251. * @returns the cloned texture
  36252. */
  36253. clone(): VideoTexture;
  36254. /**
  36255. * Dispose the texture and release its associated resources.
  36256. */
  36257. dispose(): void;
  36258. /**
  36259. * Creates a video texture straight from a stream.
  36260. * @param scene Define the scene the texture should be created in
  36261. * @param stream Define the stream the texture should be created from
  36262. * @returns The created video texture as a promise
  36263. */
  36264. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36265. /**
  36266. * Creates a video texture straight from your WebCam video feed.
  36267. * @param scene Define the scene the texture should be created in
  36268. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36269. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36270. * @returns The created video texture as a promise
  36271. */
  36272. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36273. minWidth: number;
  36274. maxWidth: number;
  36275. minHeight: number;
  36276. maxHeight: number;
  36277. deviceId: string;
  36278. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36279. /**
  36280. * Creates a video texture straight from your WebCam video feed.
  36281. * @param scene Define the scene the texture should be created in
  36282. * @param onReady Define a callback to triggered once the texture will be ready
  36283. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36284. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36285. */
  36286. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36287. minWidth: number;
  36288. maxWidth: number;
  36289. minHeight: number;
  36290. maxHeight: number;
  36291. deviceId: string;
  36292. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36293. }
  36294. }
  36295. declare module "babylonjs/Engines/thinEngine" {
  36296. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36297. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36298. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36299. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36300. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36301. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36302. import { Observable } from "babylonjs/Misc/observable";
  36303. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36304. import { StencilState } from "babylonjs/States/stencilState";
  36305. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36307. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36309. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36310. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36311. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36312. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36313. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36315. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36316. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36317. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36318. import { WebRequest } from "babylonjs/Misc/webRequest";
  36319. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36320. /**
  36321. * Defines the interface used by objects working like Scene
  36322. * @hidden
  36323. */
  36324. export interface ISceneLike {
  36325. _addPendingData(data: any): void;
  36326. _removePendingData(data: any): void;
  36327. offlineProvider: IOfflineProvider;
  36328. }
  36329. /** Interface defining initialization parameters for Engine class */
  36330. export interface EngineOptions extends WebGLContextAttributes {
  36331. /**
  36332. * Defines if the engine should no exceed a specified device ratio
  36333. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36334. */
  36335. limitDeviceRatio?: number;
  36336. /**
  36337. * Defines if webvr should be enabled automatically
  36338. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36339. */
  36340. autoEnableWebVR?: boolean;
  36341. /**
  36342. * Defines if webgl2 should be turned off even if supported
  36343. * @see https://doc.babylonjs.com/features/webgl2
  36344. */
  36345. disableWebGL2Support?: boolean;
  36346. /**
  36347. * Defines if webaudio should be initialized as well
  36348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36349. */
  36350. audioEngine?: boolean;
  36351. /**
  36352. * Defines if animations should run using a deterministic lock step
  36353. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36354. */
  36355. deterministicLockstep?: boolean;
  36356. /** Defines the maximum steps to use with deterministic lock step mode */
  36357. lockstepMaxSteps?: number;
  36358. /** Defines the seconds between each deterministic lock step */
  36359. timeStep?: number;
  36360. /**
  36361. * Defines that engine should ignore context lost events
  36362. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36363. */
  36364. doNotHandleContextLost?: boolean;
  36365. /**
  36366. * Defines that engine should ignore modifying touch action attribute and style
  36367. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36368. */
  36369. doNotHandleTouchAction?: boolean;
  36370. /**
  36371. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36372. */
  36373. useHighPrecisionFloats?: boolean;
  36374. /**
  36375. * Make the canvas XR Compatible for XR sessions
  36376. */
  36377. xrCompatible?: boolean;
  36378. /**
  36379. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36380. */
  36381. useHighPrecisionMatrix?: boolean;
  36382. }
  36383. /**
  36384. * The base engine class (root of all engines)
  36385. */
  36386. export class ThinEngine {
  36387. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36388. static ExceptionList: ({
  36389. key: string;
  36390. capture: string;
  36391. captureConstraint: number;
  36392. targets: string[];
  36393. } | {
  36394. key: string;
  36395. capture: null;
  36396. captureConstraint: null;
  36397. targets: string[];
  36398. })[];
  36399. /** @hidden */
  36400. static _TextureLoaders: IInternalTextureLoader[];
  36401. /**
  36402. * Returns the current npm package of the sdk
  36403. */
  36404. static get NpmPackage(): string;
  36405. /**
  36406. * Returns the current version of the framework
  36407. */
  36408. static get Version(): string;
  36409. /**
  36410. * Returns a string describing the current engine
  36411. */
  36412. get description(): string;
  36413. /**
  36414. * Gets or sets the epsilon value used by collision engine
  36415. */
  36416. static CollisionsEpsilon: number;
  36417. /**
  36418. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36419. */
  36420. static get ShadersRepository(): string;
  36421. static set ShadersRepository(value: string);
  36422. /** @hidden */
  36423. _shaderProcessor: IShaderProcessor;
  36424. /**
  36425. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36426. */
  36427. forcePOTTextures: boolean;
  36428. /**
  36429. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36430. */
  36431. isFullscreen: boolean;
  36432. /**
  36433. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36434. */
  36435. cullBackFaces: boolean;
  36436. /**
  36437. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36438. */
  36439. renderEvenInBackground: boolean;
  36440. /**
  36441. * Gets or sets a boolean indicating that cache can be kept between frames
  36442. */
  36443. preventCacheWipeBetweenFrames: boolean;
  36444. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36445. validateShaderPrograms: boolean;
  36446. /**
  36447. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36448. * This can provide greater z depth for distant objects.
  36449. */
  36450. useReverseDepthBuffer: boolean;
  36451. /**
  36452. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36453. */
  36454. disableUniformBuffers: boolean;
  36455. /** @hidden */
  36456. _uniformBuffers: UniformBuffer[];
  36457. /**
  36458. * Gets a boolean indicating that the engine supports uniform buffers
  36459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36460. */
  36461. get supportsUniformBuffers(): boolean;
  36462. /** @hidden */
  36463. _gl: WebGLRenderingContext;
  36464. /** @hidden */
  36465. _webGLVersion: number;
  36466. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36467. protected _windowIsBackground: boolean;
  36468. protected _creationOptions: EngineOptions;
  36469. protected _highPrecisionShadersAllowed: boolean;
  36470. /** @hidden */
  36471. get _shouldUseHighPrecisionShader(): boolean;
  36472. /**
  36473. * Gets a boolean indicating that only power of 2 textures are supported
  36474. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36475. */
  36476. get needPOTTextures(): boolean;
  36477. /** @hidden */
  36478. _badOS: boolean;
  36479. /** @hidden */
  36480. _badDesktopOS: boolean;
  36481. private _hardwareScalingLevel;
  36482. /** @hidden */
  36483. _caps: EngineCapabilities;
  36484. private _isStencilEnable;
  36485. private _glVersion;
  36486. private _glRenderer;
  36487. private _glVendor;
  36488. /** @hidden */
  36489. _videoTextureSupported: boolean;
  36490. protected _renderingQueueLaunched: boolean;
  36491. protected _activeRenderLoops: (() => void)[];
  36492. /**
  36493. * Observable signaled when a context lost event is raised
  36494. */
  36495. onContextLostObservable: Observable<ThinEngine>;
  36496. /**
  36497. * Observable signaled when a context restored event is raised
  36498. */
  36499. onContextRestoredObservable: Observable<ThinEngine>;
  36500. private _onContextLost;
  36501. private _onContextRestored;
  36502. protected _contextWasLost: boolean;
  36503. /** @hidden */
  36504. _doNotHandleContextLost: boolean;
  36505. /**
  36506. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36507. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36508. */
  36509. get doNotHandleContextLost(): boolean;
  36510. set doNotHandleContextLost(value: boolean);
  36511. /**
  36512. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36513. */
  36514. disableVertexArrayObjects: boolean;
  36515. /** @hidden */
  36516. protected _colorWrite: boolean;
  36517. /** @hidden */
  36518. protected _colorWriteChanged: boolean;
  36519. /** @hidden */
  36520. protected _depthCullingState: DepthCullingState;
  36521. /** @hidden */
  36522. protected _stencilState: StencilState;
  36523. /** @hidden */
  36524. _alphaState: AlphaState;
  36525. /** @hidden */
  36526. _alphaMode: number;
  36527. /** @hidden */
  36528. _alphaEquation: number;
  36529. /** @hidden */
  36530. _internalTexturesCache: InternalTexture[];
  36531. /** @hidden */
  36532. protected _activeChannel: number;
  36533. private _currentTextureChannel;
  36534. /** @hidden */
  36535. protected _boundTexturesCache: {
  36536. [key: string]: Nullable<InternalTexture>;
  36537. };
  36538. /** @hidden */
  36539. protected _currentEffect: Nullable<Effect>;
  36540. /** @hidden */
  36541. protected _currentProgram: Nullable<WebGLProgram>;
  36542. private _compiledEffects;
  36543. private _vertexAttribArraysEnabled;
  36544. /** @hidden */
  36545. protected _cachedViewport: Nullable<IViewportLike>;
  36546. private _cachedVertexArrayObject;
  36547. /** @hidden */
  36548. protected _cachedVertexBuffers: any;
  36549. /** @hidden */
  36550. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36551. /** @hidden */
  36552. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36553. /** @hidden */
  36554. _currentRenderTarget: Nullable<InternalTexture>;
  36555. private _uintIndicesCurrentlySet;
  36556. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36557. /** @hidden */
  36558. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36559. /** @hidden */
  36560. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36561. private _currentBufferPointers;
  36562. private _currentInstanceLocations;
  36563. private _currentInstanceBuffers;
  36564. private _textureUnits;
  36565. /** @hidden */
  36566. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36567. /** @hidden */
  36568. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36569. /** @hidden */
  36570. _boundRenderFunction: any;
  36571. private _vaoRecordInProgress;
  36572. private _mustWipeVertexAttributes;
  36573. private _emptyTexture;
  36574. private _emptyCubeTexture;
  36575. private _emptyTexture3D;
  36576. private _emptyTexture2DArray;
  36577. /** @hidden */
  36578. _frameHandler: number;
  36579. private _nextFreeTextureSlots;
  36580. private _maxSimultaneousTextures;
  36581. private _activeRequests;
  36582. /** @hidden */
  36583. _transformTextureUrl: Nullable<(url: string) => string>;
  36584. protected get _supportsHardwareTextureRescaling(): boolean;
  36585. private _framebufferDimensionsObject;
  36586. /**
  36587. * sets the object from which width and height will be taken from when getting render width and height
  36588. * Will fallback to the gl object
  36589. * @param dimensions the framebuffer width and height that will be used.
  36590. */
  36591. set framebufferDimensionsObject(dimensions: Nullable<{
  36592. framebufferWidth: number;
  36593. framebufferHeight: number;
  36594. }>);
  36595. /**
  36596. * Gets the current viewport
  36597. */
  36598. get currentViewport(): Nullable<IViewportLike>;
  36599. /**
  36600. * Gets the default empty texture
  36601. */
  36602. get emptyTexture(): InternalTexture;
  36603. /**
  36604. * Gets the default empty 3D texture
  36605. */
  36606. get emptyTexture3D(): InternalTexture;
  36607. /**
  36608. * Gets the default empty 2D array texture
  36609. */
  36610. get emptyTexture2DArray(): InternalTexture;
  36611. /**
  36612. * Gets the default empty cube texture
  36613. */
  36614. get emptyCubeTexture(): InternalTexture;
  36615. /**
  36616. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36617. */
  36618. readonly premultipliedAlpha: boolean;
  36619. /**
  36620. * Observable event triggered before each texture is initialized
  36621. */
  36622. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36623. /**
  36624. * Creates a new engine
  36625. * @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
  36626. * @param antialias defines enable antialiasing (default: false)
  36627. * @param options defines further options to be sent to the getContext() function
  36628. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36629. */
  36630. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36631. private _rebuildInternalTextures;
  36632. private _rebuildEffects;
  36633. /**
  36634. * Gets a boolean indicating if all created effects are ready
  36635. * @returns true if all effects are ready
  36636. */
  36637. areAllEffectsReady(): boolean;
  36638. protected _rebuildBuffers(): void;
  36639. protected _initGLContext(): void;
  36640. /**
  36641. * Gets version of the current webGL context
  36642. */
  36643. get webGLVersion(): number;
  36644. /**
  36645. * Gets a string idenfifying the name of the class
  36646. * @returns "Engine" string
  36647. */
  36648. getClassName(): string;
  36649. /**
  36650. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36651. */
  36652. get isStencilEnable(): boolean;
  36653. /** @hidden */
  36654. _prepareWorkingCanvas(): void;
  36655. /**
  36656. * Reset the texture cache to empty state
  36657. */
  36658. resetTextureCache(): void;
  36659. /**
  36660. * Gets an object containing information about the current webGL context
  36661. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36662. */
  36663. getGlInfo(): {
  36664. vendor: string;
  36665. renderer: string;
  36666. version: string;
  36667. };
  36668. /**
  36669. * Defines the hardware scaling level.
  36670. * By default the hardware scaling level is computed from the window device ratio.
  36671. * 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.
  36672. * @param level defines the level to use
  36673. */
  36674. setHardwareScalingLevel(level: number): void;
  36675. /**
  36676. * Gets the current hardware scaling level.
  36677. * By default the hardware scaling level is computed from the window device ratio.
  36678. * 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.
  36679. * @returns a number indicating the current hardware scaling level
  36680. */
  36681. getHardwareScalingLevel(): number;
  36682. /**
  36683. * Gets the list of loaded textures
  36684. * @returns an array containing all loaded textures
  36685. */
  36686. getLoadedTexturesCache(): InternalTexture[];
  36687. /**
  36688. * Gets the object containing all engine capabilities
  36689. * @returns the EngineCapabilities object
  36690. */
  36691. getCaps(): EngineCapabilities;
  36692. /**
  36693. * stop executing a render loop function and remove it from the execution array
  36694. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36695. */
  36696. stopRenderLoop(renderFunction?: () => void): void;
  36697. /** @hidden */
  36698. _renderLoop(): void;
  36699. /**
  36700. * Gets the HTML canvas attached with the current webGL context
  36701. * @returns a HTML canvas
  36702. */
  36703. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36704. /**
  36705. * Gets host window
  36706. * @returns the host window object
  36707. */
  36708. getHostWindow(): Nullable<Window>;
  36709. /**
  36710. * Gets the current render width
  36711. * @param useScreen defines if screen size must be used (or the current render target if any)
  36712. * @returns a number defining the current render width
  36713. */
  36714. getRenderWidth(useScreen?: boolean): number;
  36715. /**
  36716. * Gets the current render height
  36717. * @param useScreen defines if screen size must be used (or the current render target if any)
  36718. * @returns a number defining the current render height
  36719. */
  36720. getRenderHeight(useScreen?: boolean): number;
  36721. /**
  36722. * Can be used to override the current requestAnimationFrame requester.
  36723. * @hidden
  36724. */
  36725. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36726. /**
  36727. * Register and execute a render loop. The engine can have more than one render function
  36728. * @param renderFunction defines the function to continuously execute
  36729. */
  36730. runRenderLoop(renderFunction: () => void): void;
  36731. /**
  36732. * Clear the current render buffer or the current render target (if any is set up)
  36733. * @param color defines the color to use
  36734. * @param backBuffer defines if the back buffer must be cleared
  36735. * @param depth defines if the depth buffer must be cleared
  36736. * @param stencil defines if the stencil buffer must be cleared
  36737. */
  36738. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36739. private _viewportCached;
  36740. /** @hidden */
  36741. _viewport(x: number, y: number, width: number, height: number): void;
  36742. /**
  36743. * Set the WebGL's viewport
  36744. * @param viewport defines the viewport element to be used
  36745. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36746. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36747. */
  36748. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36749. /**
  36750. * Begin a new frame
  36751. */
  36752. beginFrame(): void;
  36753. /**
  36754. * Enf the current frame
  36755. */
  36756. endFrame(): void;
  36757. /**
  36758. * Resize the view according to the canvas' size
  36759. */
  36760. resize(): void;
  36761. /**
  36762. * Force a specific size of the canvas
  36763. * @param width defines the new canvas' width
  36764. * @param height defines the new canvas' height
  36765. * @returns true if the size was changed
  36766. */
  36767. setSize(width: number, height: number): boolean;
  36768. /**
  36769. * Binds the frame buffer to the specified texture.
  36770. * @param texture The texture to render to or null for the default canvas
  36771. * @param faceIndex The face of the texture to render to in case of cube texture
  36772. * @param requiredWidth The width of the target to render to
  36773. * @param requiredHeight The height of the target to render to
  36774. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36775. * @param lodLevel defines the lod level to bind to the frame buffer
  36776. * @param layer defines the 2d array index to bind to frame buffer to
  36777. */
  36778. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36779. /** @hidden */
  36780. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36781. /**
  36782. * Unbind the current render target texture from the webGL context
  36783. * @param texture defines the render target texture to unbind
  36784. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36785. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36786. */
  36787. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36788. /**
  36789. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36790. */
  36791. flushFramebuffer(): void;
  36792. /**
  36793. * Unbind the current render target and bind the default framebuffer
  36794. */
  36795. restoreDefaultFramebuffer(): void;
  36796. /** @hidden */
  36797. protected _resetVertexBufferBinding(): void;
  36798. /**
  36799. * Creates a vertex buffer
  36800. * @param data the data for the vertex buffer
  36801. * @returns the new WebGL static buffer
  36802. */
  36803. createVertexBuffer(data: DataArray): DataBuffer;
  36804. private _createVertexBuffer;
  36805. /**
  36806. * Creates a dynamic vertex buffer
  36807. * @param data the data for the dynamic vertex buffer
  36808. * @returns the new WebGL dynamic buffer
  36809. */
  36810. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36811. protected _resetIndexBufferBinding(): void;
  36812. /**
  36813. * Creates a new index buffer
  36814. * @param indices defines the content of the index buffer
  36815. * @param updatable defines if the index buffer must be updatable
  36816. * @returns a new webGL buffer
  36817. */
  36818. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36819. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36820. /**
  36821. * Bind a webGL buffer to the webGL context
  36822. * @param buffer defines the buffer to bind
  36823. */
  36824. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36825. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36826. private bindBuffer;
  36827. /**
  36828. * update the bound buffer with the given data
  36829. * @param data defines the data to update
  36830. */
  36831. updateArrayBuffer(data: Float32Array): void;
  36832. private _vertexAttribPointer;
  36833. /** @hidden */
  36834. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36835. private _bindVertexBuffersAttributes;
  36836. /**
  36837. * Records a vertex array object
  36838. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36839. * @param vertexBuffers defines the list of vertex buffers to store
  36840. * @param indexBuffer defines the index buffer to store
  36841. * @param effect defines the effect to store
  36842. * @returns the new vertex array object
  36843. */
  36844. recordVertexArrayObject(vertexBuffers: {
  36845. [key: string]: VertexBuffer;
  36846. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36847. /**
  36848. * Bind a specific vertex array object
  36849. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36850. * @param vertexArrayObject defines the vertex array object to bind
  36851. * @param indexBuffer defines the index buffer to bind
  36852. */
  36853. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36854. /**
  36855. * Bind webGl buffers directly to the webGL context
  36856. * @param vertexBuffer defines the vertex buffer to bind
  36857. * @param indexBuffer defines the index buffer to bind
  36858. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36859. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36860. * @param effect defines the effect associated with the vertex buffer
  36861. */
  36862. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36863. private _unbindVertexArrayObject;
  36864. /**
  36865. * Bind a list of vertex buffers to the webGL context
  36866. * @param vertexBuffers defines the list of vertex buffers to bind
  36867. * @param indexBuffer defines the index buffer to bind
  36868. * @param effect defines the effect associated with the vertex buffers
  36869. */
  36870. bindBuffers(vertexBuffers: {
  36871. [key: string]: Nullable<VertexBuffer>;
  36872. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36873. /**
  36874. * Unbind all instance attributes
  36875. */
  36876. unbindInstanceAttributes(): void;
  36877. /**
  36878. * Release and free the memory of a vertex array object
  36879. * @param vao defines the vertex array object to delete
  36880. */
  36881. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36882. /** @hidden */
  36883. _releaseBuffer(buffer: DataBuffer): boolean;
  36884. protected _deleteBuffer(buffer: DataBuffer): void;
  36885. /**
  36886. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36887. * @param instancesBuffer defines the webGL buffer to update and bind
  36888. * @param data defines the data to store in the buffer
  36889. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36890. */
  36891. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36892. /**
  36893. * Bind the content of a webGL buffer used with instantiation
  36894. * @param instancesBuffer defines the webGL buffer to bind
  36895. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36896. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36897. */
  36898. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36899. /**
  36900. * Disable the instance attribute corresponding to the name in parameter
  36901. * @param name defines the name of the attribute to disable
  36902. */
  36903. disableInstanceAttributeByName(name: string): void;
  36904. /**
  36905. * Disable the instance attribute corresponding to the location in parameter
  36906. * @param attributeLocation defines the attribute location of the attribute to disable
  36907. */
  36908. disableInstanceAttribute(attributeLocation: number): void;
  36909. /**
  36910. * Disable the attribute corresponding to the location in parameter
  36911. * @param attributeLocation defines the attribute location of the attribute to disable
  36912. */
  36913. disableAttributeByIndex(attributeLocation: number): void;
  36914. /**
  36915. * Send a draw order
  36916. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36917. * @param indexStart defines the starting index
  36918. * @param indexCount defines the number of index to draw
  36919. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36920. */
  36921. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36922. /**
  36923. * Draw a list of points
  36924. * @param verticesStart defines the index of first vertex to draw
  36925. * @param verticesCount defines the count of vertices to draw
  36926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36927. */
  36928. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36929. /**
  36930. * Draw a list of unindexed primitives
  36931. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36932. * @param verticesStart defines the index of first vertex to draw
  36933. * @param verticesCount defines the count of vertices to draw
  36934. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36935. */
  36936. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36937. /**
  36938. * Draw a list of indexed primitives
  36939. * @param fillMode defines the primitive to use
  36940. * @param indexStart defines the starting index
  36941. * @param indexCount defines the number of index to draw
  36942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36943. */
  36944. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36945. /**
  36946. * Draw a list of unindexed primitives
  36947. * @param fillMode defines the primitive to use
  36948. * @param verticesStart defines the index of first vertex to draw
  36949. * @param verticesCount defines the count of vertices to draw
  36950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36951. */
  36952. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36953. private _drawMode;
  36954. /** @hidden */
  36955. protected _reportDrawCall(): void;
  36956. /** @hidden */
  36957. _releaseEffect(effect: Effect): void;
  36958. /** @hidden */
  36959. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36960. /**
  36961. * Create a new effect (used to store vertex/fragment shaders)
  36962. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36963. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36964. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36965. * @param samplers defines an array of string used to represent textures
  36966. * @param defines defines the string containing the defines to use to compile the shaders
  36967. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36968. * @param onCompiled defines a function to call when the effect creation is successful
  36969. * @param onError defines a function to call when the effect creation has failed
  36970. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36971. * @returns the new Effect
  36972. */
  36973. 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;
  36974. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36975. private _compileShader;
  36976. private _compileRawShader;
  36977. /** @hidden */
  36978. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36979. /**
  36980. * Directly creates a webGL program
  36981. * @param pipelineContext defines the pipeline context to attach to
  36982. * @param vertexCode defines the vertex shader code to use
  36983. * @param fragmentCode defines the fragment shader code to use
  36984. * @param context defines the webGL context to use (if not set, the current one will be used)
  36985. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36986. * @returns the new webGL program
  36987. */
  36988. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36989. /**
  36990. * Creates a webGL program
  36991. * @param pipelineContext defines the pipeline context to attach to
  36992. * @param vertexCode defines the vertex shader code to use
  36993. * @param fragmentCode defines the fragment shader code to use
  36994. * @param defines defines the string containing the defines to use to compile the shaders
  36995. * @param context defines the webGL context to use (if not set, the current one will be used)
  36996. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36997. * @returns the new webGL program
  36998. */
  36999. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37000. /**
  37001. * Creates a new pipeline context
  37002. * @returns the new pipeline
  37003. */
  37004. createPipelineContext(): IPipelineContext;
  37005. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37006. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37007. /** @hidden */
  37008. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37009. /** @hidden */
  37010. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37011. /** @hidden */
  37012. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37013. /**
  37014. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37015. * @param pipelineContext defines the pipeline context to use
  37016. * @param uniformsNames defines the list of uniform names
  37017. * @returns an array of webGL uniform locations
  37018. */
  37019. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37020. /**
  37021. * Gets the lsit of active attributes for a given webGL program
  37022. * @param pipelineContext defines the pipeline context to use
  37023. * @param attributesNames defines the list of attribute names to get
  37024. * @returns an array of indices indicating the offset of each attribute
  37025. */
  37026. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37027. /**
  37028. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37029. * @param effect defines the effect to activate
  37030. */
  37031. enableEffect(effect: Nullable<Effect>): void;
  37032. /**
  37033. * Set the value of an uniform to a number (int)
  37034. * @param uniform defines the webGL uniform location where to store the value
  37035. * @param value defines the int number to store
  37036. */
  37037. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37038. /**
  37039. * Set the value of an uniform to an array of int32
  37040. * @param uniform defines the webGL uniform location where to store the value
  37041. * @param array defines the array of int32 to store
  37042. */
  37043. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37044. /**
  37045. * Set the value of an uniform to an array of int32 (stored as vec2)
  37046. * @param uniform defines the webGL uniform location where to store the value
  37047. * @param array defines the array of int32 to store
  37048. */
  37049. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37050. /**
  37051. * Set the value of an uniform to an array of int32 (stored as vec3)
  37052. * @param uniform defines the webGL uniform location where to store the value
  37053. * @param array defines the array of int32 to store
  37054. */
  37055. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37056. /**
  37057. * Set the value of an uniform to an array of int32 (stored as vec4)
  37058. * @param uniform defines the webGL uniform location where to store the value
  37059. * @param array defines the array of int32 to store
  37060. */
  37061. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37062. /**
  37063. * Set the value of an uniform to an array of number
  37064. * @param uniform defines the webGL uniform location where to store the value
  37065. * @param array defines the array of number to store
  37066. */
  37067. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37068. /**
  37069. * Set the value of an uniform to an array of number (stored as vec2)
  37070. * @param uniform defines the webGL uniform location where to store the value
  37071. * @param array defines the array of number to store
  37072. */
  37073. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37074. /**
  37075. * Set the value of an uniform to an array of number (stored as vec3)
  37076. * @param uniform defines the webGL uniform location where to store the value
  37077. * @param array defines the array of number to store
  37078. */
  37079. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37080. /**
  37081. * Set the value of an uniform to an array of number (stored as vec4)
  37082. * @param uniform defines the webGL uniform location where to store the value
  37083. * @param array defines the array of number to store
  37084. */
  37085. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37086. /**
  37087. * Set the value of an uniform to an array of float32 (stored as matrices)
  37088. * @param uniform defines the webGL uniform location where to store the value
  37089. * @param matrices defines the array of float32 to store
  37090. */
  37091. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37092. /**
  37093. * Set the value of an uniform to a matrix (3x3)
  37094. * @param uniform defines the webGL uniform location where to store the value
  37095. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37096. */
  37097. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37098. /**
  37099. * Set the value of an uniform to a matrix (2x2)
  37100. * @param uniform defines the webGL uniform location where to store the value
  37101. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37102. */
  37103. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37104. /**
  37105. * Set the value of an uniform to a number (float)
  37106. * @param uniform defines the webGL uniform location where to store the value
  37107. * @param value defines the float number to store
  37108. */
  37109. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37110. /**
  37111. * Set the value of an uniform to a vec2
  37112. * @param uniform defines the webGL uniform location where to store the value
  37113. * @param x defines the 1st component of the value
  37114. * @param y defines the 2nd component of the value
  37115. */
  37116. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37117. /**
  37118. * Set the value of an uniform to a vec3
  37119. * @param uniform defines the webGL uniform location where to store the value
  37120. * @param x defines the 1st component of the value
  37121. * @param y defines the 2nd component of the value
  37122. * @param z defines the 3rd component of the value
  37123. */
  37124. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37125. /**
  37126. * Set the value of an uniform to a vec4
  37127. * @param uniform defines the webGL uniform location where to store the value
  37128. * @param x defines the 1st component of the value
  37129. * @param y defines the 2nd component of the value
  37130. * @param z defines the 3rd component of the value
  37131. * @param w defines the 4th component of the value
  37132. */
  37133. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37134. /**
  37135. * Apply all cached states (depth, culling, stencil and alpha)
  37136. */
  37137. applyStates(): void;
  37138. /**
  37139. * Enable or disable color writing
  37140. * @param enable defines the state to set
  37141. */
  37142. setColorWrite(enable: boolean): void;
  37143. /**
  37144. * Gets a boolean indicating if color writing is enabled
  37145. * @returns the current color writing state
  37146. */
  37147. getColorWrite(): boolean;
  37148. /**
  37149. * Gets the depth culling state manager
  37150. */
  37151. get depthCullingState(): DepthCullingState;
  37152. /**
  37153. * Gets the alpha state manager
  37154. */
  37155. get alphaState(): AlphaState;
  37156. /**
  37157. * Gets the stencil state manager
  37158. */
  37159. get stencilState(): StencilState;
  37160. /**
  37161. * Clears the list of texture accessible through engine.
  37162. * This can help preventing texture load conflict due to name collision.
  37163. */
  37164. clearInternalTexturesCache(): void;
  37165. /**
  37166. * Force the entire cache to be cleared
  37167. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37168. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37169. */
  37170. wipeCaches(bruteForce?: boolean): void;
  37171. /** @hidden */
  37172. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37173. min: number;
  37174. mag: number;
  37175. };
  37176. /** @hidden */
  37177. _createTexture(): WebGLTexture;
  37178. /**
  37179. * Usually called from Texture.ts.
  37180. * Passed information to create a WebGLTexture
  37181. * @param url defines a value which contains one of the following:
  37182. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37183. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37184. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37185. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37186. * @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)
  37187. * @param scene needed for loading to the correct scene
  37188. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37189. * @param onLoad optional callback to be called upon successful completion
  37190. * @param onError optional callback to be called upon failure
  37191. * @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
  37192. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37193. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37194. * @param forcedExtension defines the extension to use to pick the right loader
  37195. * @param mimeType defines an optional mime type
  37196. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37197. */
  37198. 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;
  37199. /**
  37200. * Loads an image as an HTMLImageElement.
  37201. * @param input url string, ArrayBuffer, or Blob to load
  37202. * @param onLoad callback called when the image successfully loads
  37203. * @param onError callback called when the image fails to load
  37204. * @param offlineProvider offline provider for caching
  37205. * @param mimeType optional mime type
  37206. * @returns the HTMLImageElement of the loaded image
  37207. * @hidden
  37208. */
  37209. 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>;
  37210. /**
  37211. * @hidden
  37212. */
  37213. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37214. private _unpackFlipYCached;
  37215. /**
  37216. * In case you are sharing the context with other applications, it might
  37217. * be interested to not cache the unpack flip y state to ensure a consistent
  37218. * value would be set.
  37219. */
  37220. enableUnpackFlipYCached: boolean;
  37221. /** @hidden */
  37222. _unpackFlipY(value: boolean): void;
  37223. /** @hidden */
  37224. _getUnpackAlignement(): number;
  37225. private _getTextureTarget;
  37226. /**
  37227. * Update the sampling mode of a given texture
  37228. * @param samplingMode defines the required sampling mode
  37229. * @param texture defines the texture to update
  37230. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37231. */
  37232. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37233. /**
  37234. * Update the sampling mode of a given texture
  37235. * @param texture defines the texture to update
  37236. * @param wrapU defines the texture wrap mode of the u coordinates
  37237. * @param wrapV defines the texture wrap mode of the v coordinates
  37238. * @param wrapR defines the texture wrap mode of the r coordinates
  37239. */
  37240. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37241. /** @hidden */
  37242. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37243. width: number;
  37244. height: number;
  37245. layers?: number;
  37246. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37247. /** @hidden */
  37248. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37249. /** @hidden */
  37250. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37251. /**
  37252. * Update a portion of an internal texture
  37253. * @param texture defines the texture to update
  37254. * @param imageData defines the data to store into the texture
  37255. * @param xOffset defines the x coordinates of the update rectangle
  37256. * @param yOffset defines the y coordinates of the update rectangle
  37257. * @param width defines the width of the update rectangle
  37258. * @param height defines the height of the update rectangle
  37259. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37260. * @param lod defines the lod level to update (0 by default)
  37261. */
  37262. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37263. /** @hidden */
  37264. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37265. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37266. private _prepareWebGLTexture;
  37267. /** @hidden */
  37268. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37269. private _getDepthStencilBuffer;
  37270. /** @hidden */
  37271. _releaseFramebufferObjects(texture: InternalTexture): void;
  37272. /** @hidden */
  37273. _releaseTexture(texture: InternalTexture): void;
  37274. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37275. protected _setProgram(program: WebGLProgram): void;
  37276. protected _boundUniforms: {
  37277. [key: number]: WebGLUniformLocation;
  37278. };
  37279. /**
  37280. * Binds an effect to the webGL context
  37281. * @param effect defines the effect to bind
  37282. */
  37283. bindSamplers(effect: Effect): void;
  37284. private _activateCurrentTexture;
  37285. /** @hidden */
  37286. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37287. /** @hidden */
  37288. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37289. /**
  37290. * Unbind all textures from the webGL context
  37291. */
  37292. unbindAllTextures(): void;
  37293. /**
  37294. * Sets a texture to the according uniform.
  37295. * @param channel The texture channel
  37296. * @param uniform The uniform to set
  37297. * @param texture The texture to apply
  37298. */
  37299. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37300. private _bindSamplerUniformToChannel;
  37301. private _getTextureWrapMode;
  37302. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37303. /**
  37304. * Sets an array of texture to the webGL context
  37305. * @param channel defines the channel where the texture array must be set
  37306. * @param uniform defines the associated uniform location
  37307. * @param textures defines the array of textures to bind
  37308. */
  37309. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37310. /** @hidden */
  37311. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37312. private _setTextureParameterFloat;
  37313. private _setTextureParameterInteger;
  37314. /**
  37315. * Unbind all vertex attributes from the webGL context
  37316. */
  37317. unbindAllAttributes(): void;
  37318. /**
  37319. * 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
  37320. */
  37321. releaseEffects(): void;
  37322. /**
  37323. * Dispose and release all associated resources
  37324. */
  37325. dispose(): void;
  37326. /**
  37327. * Attach a new callback raised when context lost event is fired
  37328. * @param callback defines the callback to call
  37329. */
  37330. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37331. /**
  37332. * Attach a new callback raised when context restored event is fired
  37333. * @param callback defines the callback to call
  37334. */
  37335. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37336. /**
  37337. * Get the current error code of the webGL context
  37338. * @returns the error code
  37339. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37340. */
  37341. getError(): number;
  37342. private _canRenderToFloatFramebuffer;
  37343. private _canRenderToHalfFloatFramebuffer;
  37344. private _canRenderToFramebuffer;
  37345. /** @hidden */
  37346. _getWebGLTextureType(type: number): number;
  37347. /** @hidden */
  37348. _getInternalFormat(format: number): number;
  37349. /** @hidden */
  37350. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37351. /** @hidden */
  37352. _getRGBAMultiSampleBufferFormat(type: number): number;
  37353. /** @hidden */
  37354. _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;
  37355. /**
  37356. * Loads a file from a url
  37357. * @param url url to load
  37358. * @param onSuccess callback called when the file successfully loads
  37359. * @param onProgress callback called while file is loading (if the server supports this mode)
  37360. * @param offlineProvider defines the offline provider for caching
  37361. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37362. * @param onError callback called when the file fails to load
  37363. * @returns a file request object
  37364. * @hidden
  37365. */
  37366. 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;
  37367. /**
  37368. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37369. * @param x defines the x coordinate of the rectangle where pixels must be read
  37370. * @param y defines the y coordinate of the rectangle where pixels must be read
  37371. * @param width defines the width of the rectangle where pixels must be read
  37372. * @param height defines the height of the rectangle where pixels must be read
  37373. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37374. * @returns a Uint8Array containing RGBA colors
  37375. */
  37376. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37377. private static _isSupported;
  37378. /**
  37379. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37380. * @returns true if the engine can be created
  37381. * @ignorenaming
  37382. */
  37383. static isSupported(): boolean;
  37384. /**
  37385. * Find the next highest power of two.
  37386. * @param x Number to start search from.
  37387. * @return Next highest power of two.
  37388. */
  37389. static CeilingPOT(x: number): number;
  37390. /**
  37391. * Find the next lowest power of two.
  37392. * @param x Number to start search from.
  37393. * @return Next lowest power of two.
  37394. */
  37395. static FloorPOT(x: number): number;
  37396. /**
  37397. * Find the nearest power of two.
  37398. * @param x Number to start search from.
  37399. * @return Next nearest power of two.
  37400. */
  37401. static NearestPOT(x: number): number;
  37402. /**
  37403. * Get the closest exponent of two
  37404. * @param value defines the value to approximate
  37405. * @param max defines the maximum value to return
  37406. * @param mode defines how to define the closest value
  37407. * @returns closest exponent of two of the given value
  37408. */
  37409. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37410. /**
  37411. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37412. * @param func - the function to be called
  37413. * @param requester - the object that will request the next frame. Falls back to window.
  37414. * @returns frame number
  37415. */
  37416. static QueueNewFrame(func: () => void, requester?: any): number;
  37417. /**
  37418. * Gets host document
  37419. * @returns the host document object
  37420. */
  37421. getHostDocument(): Nullable<Document>;
  37422. }
  37423. }
  37424. declare module "babylonjs/Maths/sphericalPolynomial" {
  37425. import { Vector3 } from "babylonjs/Maths/math.vector";
  37426. import { Color3 } from "babylonjs/Maths/math.color";
  37427. /**
  37428. * Class representing spherical harmonics coefficients to the 3rd degree
  37429. */
  37430. export class SphericalHarmonics {
  37431. /**
  37432. * Defines whether or not the harmonics have been prescaled for rendering.
  37433. */
  37434. preScaled: boolean;
  37435. /**
  37436. * The l0,0 coefficients of the spherical harmonics
  37437. */
  37438. l00: Vector3;
  37439. /**
  37440. * The l1,-1 coefficients of the spherical harmonics
  37441. */
  37442. l1_1: Vector3;
  37443. /**
  37444. * The l1,0 coefficients of the spherical harmonics
  37445. */
  37446. l10: Vector3;
  37447. /**
  37448. * The l1,1 coefficients of the spherical harmonics
  37449. */
  37450. l11: Vector3;
  37451. /**
  37452. * The l2,-2 coefficients of the spherical harmonics
  37453. */
  37454. l2_2: Vector3;
  37455. /**
  37456. * The l2,-1 coefficients of the spherical harmonics
  37457. */
  37458. l2_1: Vector3;
  37459. /**
  37460. * The l2,0 coefficients of the spherical harmonics
  37461. */
  37462. l20: Vector3;
  37463. /**
  37464. * The l2,1 coefficients of the spherical harmonics
  37465. */
  37466. l21: Vector3;
  37467. /**
  37468. * The l2,2 coefficients of the spherical harmonics
  37469. */
  37470. l22: Vector3;
  37471. /**
  37472. * Adds a light to the spherical harmonics
  37473. * @param direction the direction of the light
  37474. * @param color the color of the light
  37475. * @param deltaSolidAngle the delta solid angle of the light
  37476. */
  37477. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37478. /**
  37479. * Scales the spherical harmonics by the given amount
  37480. * @param scale the amount to scale
  37481. */
  37482. scaleInPlace(scale: number): void;
  37483. /**
  37484. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37485. *
  37486. * ```
  37487. * E_lm = A_l * L_lm
  37488. * ```
  37489. *
  37490. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37491. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37492. * the scaling factors are given in equation 9.
  37493. */
  37494. convertIncidentRadianceToIrradiance(): void;
  37495. /**
  37496. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37497. *
  37498. * ```
  37499. * L = (1/pi) * E * rho
  37500. * ```
  37501. *
  37502. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37503. */
  37504. convertIrradianceToLambertianRadiance(): void;
  37505. /**
  37506. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37507. * required operations at run time.
  37508. *
  37509. * This is simply done by scaling back the SH with Ylm constants parameter.
  37510. * The trigonometric part being applied by the shader at run time.
  37511. */
  37512. preScaleForRendering(): void;
  37513. /**
  37514. * Constructs a spherical harmonics from an array.
  37515. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37516. * @returns the spherical harmonics
  37517. */
  37518. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37519. /**
  37520. * Gets the spherical harmonics from polynomial
  37521. * @param polynomial the spherical polynomial
  37522. * @returns the spherical harmonics
  37523. */
  37524. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37525. }
  37526. /**
  37527. * Class representing spherical polynomial coefficients to the 3rd degree
  37528. */
  37529. export class SphericalPolynomial {
  37530. private _harmonics;
  37531. /**
  37532. * The spherical harmonics used to create the polynomials.
  37533. */
  37534. get preScaledHarmonics(): SphericalHarmonics;
  37535. /**
  37536. * The x coefficients of the spherical polynomial
  37537. */
  37538. x: Vector3;
  37539. /**
  37540. * The y coefficients of the spherical polynomial
  37541. */
  37542. y: Vector3;
  37543. /**
  37544. * The z coefficients of the spherical polynomial
  37545. */
  37546. z: Vector3;
  37547. /**
  37548. * The xx coefficients of the spherical polynomial
  37549. */
  37550. xx: Vector3;
  37551. /**
  37552. * The yy coefficients of the spherical polynomial
  37553. */
  37554. yy: Vector3;
  37555. /**
  37556. * The zz coefficients of the spherical polynomial
  37557. */
  37558. zz: Vector3;
  37559. /**
  37560. * The xy coefficients of the spherical polynomial
  37561. */
  37562. xy: Vector3;
  37563. /**
  37564. * The yz coefficients of the spherical polynomial
  37565. */
  37566. yz: Vector3;
  37567. /**
  37568. * The zx coefficients of the spherical polynomial
  37569. */
  37570. zx: Vector3;
  37571. /**
  37572. * Adds an ambient color to the spherical polynomial
  37573. * @param color the color to add
  37574. */
  37575. addAmbient(color: Color3): void;
  37576. /**
  37577. * Scales the spherical polynomial by the given amount
  37578. * @param scale the amount to scale
  37579. */
  37580. scaleInPlace(scale: number): void;
  37581. /**
  37582. * Gets the spherical polynomial from harmonics
  37583. * @param harmonics the spherical harmonics
  37584. * @returns the spherical polynomial
  37585. */
  37586. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37587. /**
  37588. * Constructs a spherical polynomial from an array.
  37589. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37590. * @returns the spherical polynomial
  37591. */
  37592. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37593. }
  37594. }
  37595. declare module "babylonjs/Materials/Textures/internalTexture" {
  37596. import { Observable } from "babylonjs/Misc/observable";
  37597. import { Nullable, int } from "babylonjs/types";
  37598. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37600. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37601. /**
  37602. * Defines the source of the internal texture
  37603. */
  37604. export enum InternalTextureSource {
  37605. /**
  37606. * The source of the texture data is unknown
  37607. */
  37608. Unknown = 0,
  37609. /**
  37610. * Texture data comes from an URL
  37611. */
  37612. Url = 1,
  37613. /**
  37614. * Texture data is only used for temporary storage
  37615. */
  37616. Temp = 2,
  37617. /**
  37618. * Texture data comes from raw data (ArrayBuffer)
  37619. */
  37620. Raw = 3,
  37621. /**
  37622. * Texture content is dynamic (video or dynamic texture)
  37623. */
  37624. Dynamic = 4,
  37625. /**
  37626. * Texture content is generated by rendering to it
  37627. */
  37628. RenderTarget = 5,
  37629. /**
  37630. * Texture content is part of a multi render target process
  37631. */
  37632. MultiRenderTarget = 6,
  37633. /**
  37634. * Texture data comes from a cube data file
  37635. */
  37636. Cube = 7,
  37637. /**
  37638. * Texture data comes from a raw cube data
  37639. */
  37640. CubeRaw = 8,
  37641. /**
  37642. * Texture data come from a prefiltered cube data file
  37643. */
  37644. CubePrefiltered = 9,
  37645. /**
  37646. * Texture content is raw 3D data
  37647. */
  37648. Raw3D = 10,
  37649. /**
  37650. * Texture content is raw 2D array data
  37651. */
  37652. Raw2DArray = 11,
  37653. /**
  37654. * Texture content is a depth texture
  37655. */
  37656. Depth = 12,
  37657. /**
  37658. * Texture data comes from a raw cube data encoded with RGBD
  37659. */
  37660. CubeRawRGBD = 13
  37661. }
  37662. /**
  37663. * Class used to store data associated with WebGL texture data for the engine
  37664. * This class should not be used directly
  37665. */
  37666. export class InternalTexture {
  37667. /** @hidden */
  37668. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37669. /**
  37670. * Defines if the texture is ready
  37671. */
  37672. isReady: boolean;
  37673. /**
  37674. * Defines if the texture is a cube texture
  37675. */
  37676. isCube: boolean;
  37677. /**
  37678. * Defines if the texture contains 3D data
  37679. */
  37680. is3D: boolean;
  37681. /**
  37682. * Defines if the texture contains 2D array data
  37683. */
  37684. is2DArray: boolean;
  37685. /**
  37686. * Defines if the texture contains multiview data
  37687. */
  37688. isMultiview: boolean;
  37689. /**
  37690. * Gets the URL used to load this texture
  37691. */
  37692. url: string;
  37693. /**
  37694. * Gets the sampling mode of the texture
  37695. */
  37696. samplingMode: number;
  37697. /**
  37698. * Gets a boolean indicating if the texture needs mipmaps generation
  37699. */
  37700. generateMipMaps: boolean;
  37701. /**
  37702. * Gets the number of samples used by the texture (WebGL2+ only)
  37703. */
  37704. samples: number;
  37705. /**
  37706. * Gets the type of the texture (int, float...)
  37707. */
  37708. type: number;
  37709. /**
  37710. * Gets the format of the texture (RGB, RGBA...)
  37711. */
  37712. format: number;
  37713. /**
  37714. * Observable called when the texture is loaded
  37715. */
  37716. onLoadedObservable: Observable<InternalTexture>;
  37717. /**
  37718. * Gets the width of the texture
  37719. */
  37720. width: number;
  37721. /**
  37722. * Gets the height of the texture
  37723. */
  37724. height: number;
  37725. /**
  37726. * Gets the depth of the texture
  37727. */
  37728. depth: number;
  37729. /**
  37730. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37731. */
  37732. baseWidth: number;
  37733. /**
  37734. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37735. */
  37736. baseHeight: number;
  37737. /**
  37738. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37739. */
  37740. baseDepth: number;
  37741. /**
  37742. * Gets a boolean indicating if the texture is inverted on Y axis
  37743. */
  37744. invertY: boolean;
  37745. /** @hidden */
  37746. _invertVScale: boolean;
  37747. /** @hidden */
  37748. _associatedChannel: number;
  37749. /** @hidden */
  37750. _source: InternalTextureSource;
  37751. /** @hidden */
  37752. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37753. /** @hidden */
  37754. _bufferView: Nullable<ArrayBufferView>;
  37755. /** @hidden */
  37756. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37757. /** @hidden */
  37758. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37759. /** @hidden */
  37760. _size: number;
  37761. /** @hidden */
  37762. _extension: string;
  37763. /** @hidden */
  37764. _files: Nullable<string[]>;
  37765. /** @hidden */
  37766. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37767. /** @hidden */
  37768. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37769. /** @hidden */
  37770. _framebuffer: Nullable<WebGLFramebuffer>;
  37771. /** @hidden */
  37772. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37773. /** @hidden */
  37774. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37775. /** @hidden */
  37776. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37777. /** @hidden */
  37778. _attachments: Nullable<number[]>;
  37779. /** @hidden */
  37780. _textureArray: Nullable<InternalTexture[]>;
  37781. /** @hidden */
  37782. _cachedCoordinatesMode: Nullable<number>;
  37783. /** @hidden */
  37784. _cachedWrapU: Nullable<number>;
  37785. /** @hidden */
  37786. _cachedWrapV: Nullable<number>;
  37787. /** @hidden */
  37788. _cachedWrapR: Nullable<number>;
  37789. /** @hidden */
  37790. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37791. /** @hidden */
  37792. _isDisabled: boolean;
  37793. /** @hidden */
  37794. _compression: Nullable<string>;
  37795. /** @hidden */
  37796. _generateStencilBuffer: boolean;
  37797. /** @hidden */
  37798. _generateDepthBuffer: boolean;
  37799. /** @hidden */
  37800. _comparisonFunction: number;
  37801. /** @hidden */
  37802. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37803. /** @hidden */
  37804. _lodGenerationScale: number;
  37805. /** @hidden */
  37806. _lodGenerationOffset: number;
  37807. /** @hidden */
  37808. _depthStencilTexture: Nullable<InternalTexture>;
  37809. /** @hidden */
  37810. _colorTextureArray: Nullable<WebGLTexture>;
  37811. /** @hidden */
  37812. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37813. /** @hidden */
  37814. _lodTextureHigh: Nullable<BaseTexture>;
  37815. /** @hidden */
  37816. _lodTextureMid: Nullable<BaseTexture>;
  37817. /** @hidden */
  37818. _lodTextureLow: Nullable<BaseTexture>;
  37819. /** @hidden */
  37820. _isRGBD: boolean;
  37821. /** @hidden */
  37822. _linearSpecularLOD: boolean;
  37823. /** @hidden */
  37824. _irradianceTexture: Nullable<BaseTexture>;
  37825. /** @hidden */
  37826. _webGLTexture: Nullable<WebGLTexture>;
  37827. /** @hidden */
  37828. _references: number;
  37829. private _engine;
  37830. /**
  37831. * Gets the Engine the texture belongs to.
  37832. * @returns The babylon engine
  37833. */
  37834. getEngine(): ThinEngine;
  37835. /**
  37836. * Gets the data source type of the texture
  37837. */
  37838. get source(): InternalTextureSource;
  37839. /**
  37840. * Creates a new InternalTexture
  37841. * @param engine defines the engine to use
  37842. * @param source defines the type of data that will be used
  37843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37844. */
  37845. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37846. /**
  37847. * Increments the number of references (ie. the number of Texture that point to it)
  37848. */
  37849. incrementReferences(): void;
  37850. /**
  37851. * Change the size of the texture (not the size of the content)
  37852. * @param width defines the new width
  37853. * @param height defines the new height
  37854. * @param depth defines the new depth (1 by default)
  37855. */
  37856. updateSize(width: int, height: int, depth?: int): void;
  37857. /** @hidden */
  37858. _rebuild(): void;
  37859. /** @hidden */
  37860. _swapAndDie(target: InternalTexture): void;
  37861. /**
  37862. * Dispose the current allocated resources
  37863. */
  37864. dispose(): void;
  37865. }
  37866. }
  37867. declare module "babylonjs/Audio/analyser" {
  37868. import { Scene } from "babylonjs/scene";
  37869. /**
  37870. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37871. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37872. */
  37873. export class Analyser {
  37874. /**
  37875. * Gets or sets the smoothing
  37876. * @ignorenaming
  37877. */
  37878. SMOOTHING: number;
  37879. /**
  37880. * Gets or sets the FFT table size
  37881. * @ignorenaming
  37882. */
  37883. FFT_SIZE: number;
  37884. /**
  37885. * Gets or sets the bar graph amplitude
  37886. * @ignorenaming
  37887. */
  37888. BARGRAPHAMPLITUDE: number;
  37889. /**
  37890. * Gets or sets the position of the debug canvas
  37891. * @ignorenaming
  37892. */
  37893. DEBUGCANVASPOS: {
  37894. x: number;
  37895. y: number;
  37896. };
  37897. /**
  37898. * Gets or sets the debug canvas size
  37899. * @ignorenaming
  37900. */
  37901. DEBUGCANVASSIZE: {
  37902. width: number;
  37903. height: number;
  37904. };
  37905. private _byteFreqs;
  37906. private _byteTime;
  37907. private _floatFreqs;
  37908. private _webAudioAnalyser;
  37909. private _debugCanvas;
  37910. private _debugCanvasContext;
  37911. private _scene;
  37912. private _registerFunc;
  37913. private _audioEngine;
  37914. /**
  37915. * Creates a new analyser
  37916. * @param scene defines hosting scene
  37917. */
  37918. constructor(scene: Scene);
  37919. /**
  37920. * Get the number of data values you will have to play with for the visualization
  37921. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37922. * @returns a number
  37923. */
  37924. getFrequencyBinCount(): number;
  37925. /**
  37926. * Gets the current frequency data as a byte array
  37927. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37928. * @returns a Uint8Array
  37929. */
  37930. getByteFrequencyData(): Uint8Array;
  37931. /**
  37932. * Gets the current waveform as a byte array
  37933. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37934. * @returns a Uint8Array
  37935. */
  37936. getByteTimeDomainData(): Uint8Array;
  37937. /**
  37938. * Gets the current frequency data as a float array
  37939. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37940. * @returns a Float32Array
  37941. */
  37942. getFloatFrequencyData(): Float32Array;
  37943. /**
  37944. * Renders the debug canvas
  37945. */
  37946. drawDebugCanvas(): void;
  37947. /**
  37948. * Stops rendering the debug canvas and removes it
  37949. */
  37950. stopDebugCanvas(): void;
  37951. /**
  37952. * Connects two audio nodes
  37953. * @param inputAudioNode defines first node to connect
  37954. * @param outputAudioNode defines second node to connect
  37955. */
  37956. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37957. /**
  37958. * Releases all associated resources
  37959. */
  37960. dispose(): void;
  37961. }
  37962. }
  37963. declare module "babylonjs/Audio/audioEngine" {
  37964. import { IDisposable } from "babylonjs/scene";
  37965. import { Analyser } from "babylonjs/Audio/analyser";
  37966. import { Nullable } from "babylonjs/types";
  37967. import { Observable } from "babylonjs/Misc/observable";
  37968. /**
  37969. * This represents an audio engine and it is responsible
  37970. * to play, synchronize and analyse sounds throughout the application.
  37971. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37972. */
  37973. export interface IAudioEngine extends IDisposable {
  37974. /**
  37975. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37976. */
  37977. readonly canUseWebAudio: boolean;
  37978. /**
  37979. * Gets the current AudioContext if available.
  37980. */
  37981. readonly audioContext: Nullable<AudioContext>;
  37982. /**
  37983. * The master gain node defines the global audio volume of your audio engine.
  37984. */
  37985. readonly masterGain: GainNode;
  37986. /**
  37987. * Gets whether or not mp3 are supported by your browser.
  37988. */
  37989. readonly isMP3supported: boolean;
  37990. /**
  37991. * Gets whether or not ogg are supported by your browser.
  37992. */
  37993. readonly isOGGsupported: boolean;
  37994. /**
  37995. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37996. * @ignoreNaming
  37997. */
  37998. WarnedWebAudioUnsupported: boolean;
  37999. /**
  38000. * Defines if the audio engine relies on a custom unlocked button.
  38001. * In this case, the embedded button will not be displayed.
  38002. */
  38003. useCustomUnlockedButton: boolean;
  38004. /**
  38005. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38006. */
  38007. readonly unlocked: boolean;
  38008. /**
  38009. * Event raised when audio has been unlocked on the browser.
  38010. */
  38011. onAudioUnlockedObservable: Observable<AudioEngine>;
  38012. /**
  38013. * Event raised when audio has been locked on the browser.
  38014. */
  38015. onAudioLockedObservable: Observable<AudioEngine>;
  38016. /**
  38017. * Flags the audio engine in Locked state.
  38018. * This happens due to new browser policies preventing audio to autoplay.
  38019. */
  38020. lock(): void;
  38021. /**
  38022. * Unlocks the audio engine once a user action has been done on the dom.
  38023. * This is helpful to resume play once browser policies have been satisfied.
  38024. */
  38025. unlock(): void;
  38026. /**
  38027. * Gets the global volume sets on the master gain.
  38028. * @returns the global volume if set or -1 otherwise
  38029. */
  38030. getGlobalVolume(): number;
  38031. /**
  38032. * Sets the global volume of your experience (sets on the master gain).
  38033. * @param newVolume Defines the new global volume of the application
  38034. */
  38035. setGlobalVolume(newVolume: number): void;
  38036. /**
  38037. * Connect the audio engine to an audio analyser allowing some amazing
  38038. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38040. * @param analyser The analyser to connect to the engine
  38041. */
  38042. connectToAnalyser(analyser: Analyser): void;
  38043. }
  38044. /**
  38045. * This represents the default audio engine used in babylon.
  38046. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38048. */
  38049. export class AudioEngine implements IAudioEngine {
  38050. private _audioContext;
  38051. private _audioContextInitialized;
  38052. private _muteButton;
  38053. private _hostElement;
  38054. /**
  38055. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38056. */
  38057. canUseWebAudio: boolean;
  38058. /**
  38059. * The master gain node defines the global audio volume of your audio engine.
  38060. */
  38061. masterGain: GainNode;
  38062. /**
  38063. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38064. * @ignoreNaming
  38065. */
  38066. WarnedWebAudioUnsupported: boolean;
  38067. /**
  38068. * Gets whether or not mp3 are supported by your browser.
  38069. */
  38070. isMP3supported: boolean;
  38071. /**
  38072. * Gets whether or not ogg are supported by your browser.
  38073. */
  38074. isOGGsupported: boolean;
  38075. /**
  38076. * Gets whether audio has been unlocked on the device.
  38077. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38078. * a user interaction has happened.
  38079. */
  38080. unlocked: boolean;
  38081. /**
  38082. * Defines if the audio engine relies on a custom unlocked button.
  38083. * In this case, the embedded button will not be displayed.
  38084. */
  38085. useCustomUnlockedButton: boolean;
  38086. /**
  38087. * Event raised when audio has been unlocked on the browser.
  38088. */
  38089. onAudioUnlockedObservable: Observable<AudioEngine>;
  38090. /**
  38091. * Event raised when audio has been locked on the browser.
  38092. */
  38093. onAudioLockedObservable: Observable<AudioEngine>;
  38094. /**
  38095. * Gets the current AudioContext if available.
  38096. */
  38097. get audioContext(): Nullable<AudioContext>;
  38098. private _connectedAnalyser;
  38099. /**
  38100. * Instantiates a new audio engine.
  38101. *
  38102. * There should be only one per page as some browsers restrict the number
  38103. * of audio contexts you can create.
  38104. * @param hostElement defines the host element where to display the mute icon if necessary
  38105. */
  38106. constructor(hostElement?: Nullable<HTMLElement>);
  38107. /**
  38108. * Flags the audio engine in Locked state.
  38109. * This happens due to new browser policies preventing audio to autoplay.
  38110. */
  38111. lock(): void;
  38112. /**
  38113. * Unlocks the audio engine once a user action has been done on the dom.
  38114. * This is helpful to resume play once browser policies have been satisfied.
  38115. */
  38116. unlock(): void;
  38117. private _resumeAudioContext;
  38118. private _initializeAudioContext;
  38119. private _tryToRun;
  38120. private _triggerRunningState;
  38121. private _triggerSuspendedState;
  38122. private _displayMuteButton;
  38123. private _moveButtonToTopLeft;
  38124. private _onResize;
  38125. private _hideMuteButton;
  38126. /**
  38127. * Destroy and release the resources associated with the audio ccontext.
  38128. */
  38129. dispose(): void;
  38130. /**
  38131. * Gets the global volume sets on the master gain.
  38132. * @returns the global volume if set or -1 otherwise
  38133. */
  38134. getGlobalVolume(): number;
  38135. /**
  38136. * Sets the global volume of your experience (sets on the master gain).
  38137. * @param newVolume Defines the new global volume of the application
  38138. */
  38139. setGlobalVolume(newVolume: number): void;
  38140. /**
  38141. * Connect the audio engine to an audio analyser allowing some amazing
  38142. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38144. * @param analyser The analyser to connect to the engine
  38145. */
  38146. connectToAnalyser(analyser: Analyser): void;
  38147. }
  38148. }
  38149. declare module "babylonjs/Loading/loadingScreen" {
  38150. /**
  38151. * Interface used to present a loading screen while loading a scene
  38152. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38153. */
  38154. export interface ILoadingScreen {
  38155. /**
  38156. * Function called to display the loading screen
  38157. */
  38158. displayLoadingUI: () => void;
  38159. /**
  38160. * Function called to hide the loading screen
  38161. */
  38162. hideLoadingUI: () => void;
  38163. /**
  38164. * Gets or sets the color to use for the background
  38165. */
  38166. loadingUIBackgroundColor: string;
  38167. /**
  38168. * Gets or sets the text to display while loading
  38169. */
  38170. loadingUIText: string;
  38171. }
  38172. /**
  38173. * Class used for the default loading screen
  38174. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38175. */
  38176. export class DefaultLoadingScreen implements ILoadingScreen {
  38177. private _renderingCanvas;
  38178. private _loadingText;
  38179. private _loadingDivBackgroundColor;
  38180. private _loadingDiv;
  38181. private _loadingTextDiv;
  38182. /** Gets or sets the logo url to use for the default loading screen */
  38183. static DefaultLogoUrl: string;
  38184. /** Gets or sets the spinner url to use for the default loading screen */
  38185. static DefaultSpinnerUrl: string;
  38186. /**
  38187. * Creates a new default loading screen
  38188. * @param _renderingCanvas defines the canvas used to render the scene
  38189. * @param _loadingText defines the default text to display
  38190. * @param _loadingDivBackgroundColor defines the default background color
  38191. */
  38192. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38193. /**
  38194. * Function called to display the loading screen
  38195. */
  38196. displayLoadingUI(): void;
  38197. /**
  38198. * Function called to hide the loading screen
  38199. */
  38200. hideLoadingUI(): void;
  38201. /**
  38202. * Gets or sets the text to display while loading
  38203. */
  38204. set loadingUIText(text: string);
  38205. get loadingUIText(): string;
  38206. /**
  38207. * Gets or sets the color to use for the background
  38208. */
  38209. get loadingUIBackgroundColor(): string;
  38210. set loadingUIBackgroundColor(color: string);
  38211. private _resizeLoadingUI;
  38212. }
  38213. }
  38214. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38215. /**
  38216. * Interface for any object that can request an animation frame
  38217. */
  38218. export interface ICustomAnimationFrameRequester {
  38219. /**
  38220. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38221. */
  38222. renderFunction?: Function;
  38223. /**
  38224. * Called to request the next frame to render to
  38225. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38226. */
  38227. requestAnimationFrame: Function;
  38228. /**
  38229. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38230. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38231. */
  38232. requestID?: number;
  38233. }
  38234. }
  38235. declare module "babylonjs/Misc/performanceMonitor" {
  38236. /**
  38237. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38238. */
  38239. export class PerformanceMonitor {
  38240. private _enabled;
  38241. private _rollingFrameTime;
  38242. private _lastFrameTimeMs;
  38243. /**
  38244. * constructor
  38245. * @param frameSampleSize The number of samples required to saturate the sliding window
  38246. */
  38247. constructor(frameSampleSize?: number);
  38248. /**
  38249. * Samples current frame
  38250. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38251. */
  38252. sampleFrame(timeMs?: number): void;
  38253. /**
  38254. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38255. */
  38256. get averageFrameTime(): number;
  38257. /**
  38258. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38259. */
  38260. get averageFrameTimeVariance(): number;
  38261. /**
  38262. * Returns the frame time of the most recent frame
  38263. */
  38264. get instantaneousFrameTime(): number;
  38265. /**
  38266. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38267. */
  38268. get averageFPS(): number;
  38269. /**
  38270. * Returns the average framerate in frames per second using the most recent frame time
  38271. */
  38272. get instantaneousFPS(): number;
  38273. /**
  38274. * Returns true if enough samples have been taken to completely fill the sliding window
  38275. */
  38276. get isSaturated(): boolean;
  38277. /**
  38278. * Enables contributions to the sliding window sample set
  38279. */
  38280. enable(): void;
  38281. /**
  38282. * Disables contributions to the sliding window sample set
  38283. * Samples will not be interpolated over the disabled period
  38284. */
  38285. disable(): void;
  38286. /**
  38287. * Returns true if sampling is enabled
  38288. */
  38289. get isEnabled(): boolean;
  38290. /**
  38291. * Resets performance monitor
  38292. */
  38293. reset(): void;
  38294. }
  38295. /**
  38296. * RollingAverage
  38297. *
  38298. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38299. */
  38300. export class RollingAverage {
  38301. /**
  38302. * Current average
  38303. */
  38304. average: number;
  38305. /**
  38306. * Current variance
  38307. */
  38308. variance: number;
  38309. protected _samples: Array<number>;
  38310. protected _sampleCount: number;
  38311. protected _pos: number;
  38312. protected _m2: number;
  38313. /**
  38314. * constructor
  38315. * @param length The number of samples required to saturate the sliding window
  38316. */
  38317. constructor(length: number);
  38318. /**
  38319. * Adds a sample to the sample set
  38320. * @param v The sample value
  38321. */
  38322. add(v: number): void;
  38323. /**
  38324. * Returns previously added values or null if outside of history or outside the sliding window domain
  38325. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38326. * @return Value previously recorded with add() or null if outside of range
  38327. */
  38328. history(i: number): number;
  38329. /**
  38330. * Returns true if enough samples have been taken to completely fill the sliding window
  38331. * @return true if sample-set saturated
  38332. */
  38333. isSaturated(): boolean;
  38334. /**
  38335. * Resets the rolling average (equivalent to 0 samples taken so far)
  38336. */
  38337. reset(): void;
  38338. /**
  38339. * Wraps a value around the sample range boundaries
  38340. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38341. * @return Wrapped position in sample range
  38342. */
  38343. protected _wrapPosition(i: number): number;
  38344. }
  38345. }
  38346. declare module "babylonjs/Misc/perfCounter" {
  38347. /**
  38348. * This class is used to track a performance counter which is number based.
  38349. * The user has access to many properties which give statistics of different nature.
  38350. *
  38351. * The implementer can track two kinds of Performance Counter: time and count.
  38352. * 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.
  38353. * 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.
  38354. */
  38355. export class PerfCounter {
  38356. /**
  38357. * Gets or sets a global boolean to turn on and off all the counters
  38358. */
  38359. static Enabled: boolean;
  38360. /**
  38361. * Returns the smallest value ever
  38362. */
  38363. get min(): number;
  38364. /**
  38365. * Returns the biggest value ever
  38366. */
  38367. get max(): number;
  38368. /**
  38369. * Returns the average value since the performance counter is running
  38370. */
  38371. get average(): number;
  38372. /**
  38373. * Returns the average value of the last second the counter was monitored
  38374. */
  38375. get lastSecAverage(): number;
  38376. /**
  38377. * Returns the current value
  38378. */
  38379. get current(): number;
  38380. /**
  38381. * Gets the accumulated total
  38382. */
  38383. get total(): number;
  38384. /**
  38385. * Gets the total value count
  38386. */
  38387. get count(): number;
  38388. /**
  38389. * Creates a new counter
  38390. */
  38391. constructor();
  38392. /**
  38393. * Call this method to start monitoring a new frame.
  38394. * 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.
  38395. */
  38396. fetchNewFrame(): void;
  38397. /**
  38398. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38399. * @param newCount the count value to add to the monitored count
  38400. * @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.
  38401. */
  38402. addCount(newCount: number, fetchResult: boolean): void;
  38403. /**
  38404. * Start monitoring this performance counter
  38405. */
  38406. beginMonitoring(): void;
  38407. /**
  38408. * Compute the time lapsed since the previous beginMonitoring() call.
  38409. * @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
  38410. */
  38411. endMonitoring(newFrame?: boolean): void;
  38412. private _fetchResult;
  38413. private _startMonitoringTime;
  38414. private _min;
  38415. private _max;
  38416. private _average;
  38417. private _current;
  38418. private _totalValueCount;
  38419. private _totalAccumulated;
  38420. private _lastSecAverage;
  38421. private _lastSecAccumulated;
  38422. private _lastSecTime;
  38423. private _lastSecValueCount;
  38424. }
  38425. }
  38426. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38427. module "babylonjs/Engines/thinEngine" {
  38428. interface ThinEngine {
  38429. /**
  38430. * Sets alpha constants used by some alpha blending modes
  38431. * @param r defines the red component
  38432. * @param g defines the green component
  38433. * @param b defines the blue component
  38434. * @param a defines the alpha component
  38435. */
  38436. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38437. /**
  38438. * Sets the current alpha mode
  38439. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38440. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38441. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38442. */
  38443. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38444. /**
  38445. * Gets the current alpha mode
  38446. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38447. * @returns the current alpha mode
  38448. */
  38449. getAlphaMode(): number;
  38450. /**
  38451. * Sets the current alpha equation
  38452. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38453. */
  38454. setAlphaEquation(equation: number): void;
  38455. /**
  38456. * Gets the current alpha equation.
  38457. * @returns the current alpha equation
  38458. */
  38459. getAlphaEquation(): number;
  38460. }
  38461. }
  38462. }
  38463. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38465. import { Nullable } from "babylonjs/types";
  38466. module "babylonjs/Engines/thinEngine" {
  38467. interface ThinEngine {
  38468. /** @hidden */
  38469. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38470. }
  38471. }
  38472. }
  38473. declare module "babylonjs/Engines/engine" {
  38474. import { Observable } from "babylonjs/Misc/observable";
  38475. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38476. import { Scene } from "babylonjs/scene";
  38477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38478. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38479. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38480. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38481. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38482. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38483. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38484. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38485. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38486. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38487. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38488. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38489. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38490. import "babylonjs/Engines/Extensions/engine.alpha";
  38491. import "babylonjs/Engines/Extensions/engine.readTexture";
  38492. import { Material } from "babylonjs/Materials/material";
  38493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38494. /**
  38495. * Defines the interface used by display changed events
  38496. */
  38497. export interface IDisplayChangedEventArgs {
  38498. /** Gets the vrDisplay object (if any) */
  38499. vrDisplay: Nullable<any>;
  38500. /** Gets a boolean indicating if webVR is supported */
  38501. vrSupported: boolean;
  38502. }
  38503. /**
  38504. * Defines the interface used by objects containing a viewport (like a camera)
  38505. */
  38506. interface IViewportOwnerLike {
  38507. /**
  38508. * Gets or sets the viewport
  38509. */
  38510. viewport: IViewportLike;
  38511. }
  38512. /**
  38513. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38514. */
  38515. export class Engine extends ThinEngine {
  38516. /** Defines that alpha blending is disabled */
  38517. static readonly ALPHA_DISABLE: number;
  38518. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38519. static readonly ALPHA_ADD: number;
  38520. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38521. static readonly ALPHA_COMBINE: number;
  38522. /** Defines that alpha blending to DEST - SRC * DEST */
  38523. static readonly ALPHA_SUBTRACT: number;
  38524. /** Defines that alpha blending to SRC * DEST */
  38525. static readonly ALPHA_MULTIPLY: number;
  38526. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38527. static readonly ALPHA_MAXIMIZED: number;
  38528. /** Defines that alpha blending to SRC + DEST */
  38529. static readonly ALPHA_ONEONE: number;
  38530. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38531. static readonly ALPHA_PREMULTIPLIED: number;
  38532. /**
  38533. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38534. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38535. */
  38536. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38537. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38538. static readonly ALPHA_INTERPOLATE: number;
  38539. /**
  38540. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38541. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38542. */
  38543. static readonly ALPHA_SCREENMODE: number;
  38544. /** Defines that the ressource is not delayed*/
  38545. static readonly DELAYLOADSTATE_NONE: number;
  38546. /** Defines that the ressource was successfully delay loaded */
  38547. static readonly DELAYLOADSTATE_LOADED: number;
  38548. /** Defines that the ressource is currently delay loading */
  38549. static readonly DELAYLOADSTATE_LOADING: number;
  38550. /** Defines that the ressource is delayed and has not started loading */
  38551. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38552. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38553. static readonly NEVER: number;
  38554. /** 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 */
  38555. static readonly ALWAYS: number;
  38556. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38557. static readonly LESS: number;
  38558. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38559. static readonly EQUAL: number;
  38560. /** 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 */
  38561. static readonly LEQUAL: number;
  38562. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38563. static readonly GREATER: number;
  38564. /** 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 */
  38565. static readonly GEQUAL: number;
  38566. /** 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 */
  38567. static readonly NOTEQUAL: number;
  38568. /** Passed to stencilOperation to specify that stencil value must be kept */
  38569. static readonly KEEP: number;
  38570. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38571. static readonly REPLACE: number;
  38572. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38573. static readonly INCR: number;
  38574. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38575. static readonly DECR: number;
  38576. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38577. static readonly INVERT: number;
  38578. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38579. static readonly INCR_WRAP: number;
  38580. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38581. static readonly DECR_WRAP: number;
  38582. /** Texture is not repeating outside of 0..1 UVs */
  38583. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38584. /** Texture is repeating outside of 0..1 UVs */
  38585. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38586. /** Texture is repeating and mirrored */
  38587. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38588. /** ALPHA */
  38589. static readonly TEXTUREFORMAT_ALPHA: number;
  38590. /** LUMINANCE */
  38591. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38592. /** LUMINANCE_ALPHA */
  38593. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38594. /** RGB */
  38595. static readonly TEXTUREFORMAT_RGB: number;
  38596. /** RGBA */
  38597. static readonly TEXTUREFORMAT_RGBA: number;
  38598. /** RED */
  38599. static readonly TEXTUREFORMAT_RED: number;
  38600. /** RED (2nd reference) */
  38601. static readonly TEXTUREFORMAT_R: number;
  38602. /** RG */
  38603. static readonly TEXTUREFORMAT_RG: number;
  38604. /** RED_INTEGER */
  38605. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38606. /** RED_INTEGER (2nd reference) */
  38607. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38608. /** RG_INTEGER */
  38609. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38610. /** RGB_INTEGER */
  38611. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38612. /** RGBA_INTEGER */
  38613. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38614. /** UNSIGNED_BYTE */
  38615. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38616. /** UNSIGNED_BYTE (2nd reference) */
  38617. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38618. /** FLOAT */
  38619. static readonly TEXTURETYPE_FLOAT: number;
  38620. /** HALF_FLOAT */
  38621. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38622. /** BYTE */
  38623. static readonly TEXTURETYPE_BYTE: number;
  38624. /** SHORT */
  38625. static readonly TEXTURETYPE_SHORT: number;
  38626. /** UNSIGNED_SHORT */
  38627. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38628. /** INT */
  38629. static readonly TEXTURETYPE_INT: number;
  38630. /** UNSIGNED_INT */
  38631. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38632. /** UNSIGNED_SHORT_4_4_4_4 */
  38633. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38634. /** UNSIGNED_SHORT_5_5_5_1 */
  38635. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38636. /** UNSIGNED_SHORT_5_6_5 */
  38637. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38638. /** UNSIGNED_INT_2_10_10_10_REV */
  38639. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38640. /** UNSIGNED_INT_24_8 */
  38641. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38642. /** UNSIGNED_INT_10F_11F_11F_REV */
  38643. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38644. /** UNSIGNED_INT_5_9_9_9_REV */
  38645. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38646. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38647. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38648. /** nearest is mag = nearest and min = nearest and mip = linear */
  38649. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38650. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38651. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38652. /** Trilinear is mag = linear and min = linear and mip = linear */
  38653. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38654. /** nearest is mag = nearest and min = nearest and mip = linear */
  38655. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38656. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38657. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38658. /** Trilinear is mag = linear and min = linear and mip = linear */
  38659. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38660. /** mag = nearest and min = nearest and mip = nearest */
  38661. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38662. /** mag = nearest and min = linear and mip = nearest */
  38663. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38664. /** mag = nearest and min = linear and mip = linear */
  38665. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38666. /** mag = nearest and min = linear and mip = none */
  38667. static readonly TEXTURE_NEAREST_LINEAR: number;
  38668. /** mag = nearest and min = nearest and mip = none */
  38669. static readonly TEXTURE_NEAREST_NEAREST: number;
  38670. /** mag = linear and min = nearest and mip = nearest */
  38671. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38672. /** mag = linear and min = nearest and mip = linear */
  38673. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38674. /** mag = linear and min = linear and mip = none */
  38675. static readonly TEXTURE_LINEAR_LINEAR: number;
  38676. /** mag = linear and min = nearest and mip = none */
  38677. static readonly TEXTURE_LINEAR_NEAREST: number;
  38678. /** Explicit coordinates mode */
  38679. static readonly TEXTURE_EXPLICIT_MODE: number;
  38680. /** Spherical coordinates mode */
  38681. static readonly TEXTURE_SPHERICAL_MODE: number;
  38682. /** Planar coordinates mode */
  38683. static readonly TEXTURE_PLANAR_MODE: number;
  38684. /** Cubic coordinates mode */
  38685. static readonly TEXTURE_CUBIC_MODE: number;
  38686. /** Projection coordinates mode */
  38687. static readonly TEXTURE_PROJECTION_MODE: number;
  38688. /** Skybox coordinates mode */
  38689. static readonly TEXTURE_SKYBOX_MODE: number;
  38690. /** Inverse Cubic coordinates mode */
  38691. static readonly TEXTURE_INVCUBIC_MODE: number;
  38692. /** Equirectangular coordinates mode */
  38693. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38694. /** Equirectangular Fixed coordinates mode */
  38695. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38696. /** Equirectangular Fixed Mirrored coordinates mode */
  38697. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38698. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38699. static readonly SCALEMODE_FLOOR: number;
  38700. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38701. static readonly SCALEMODE_NEAREST: number;
  38702. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38703. static readonly SCALEMODE_CEILING: number;
  38704. /**
  38705. * Returns the current npm package of the sdk
  38706. */
  38707. static get NpmPackage(): string;
  38708. /**
  38709. * Returns the current version of the framework
  38710. */
  38711. static get Version(): string;
  38712. /** Gets the list of created engines */
  38713. static get Instances(): Engine[];
  38714. /**
  38715. * Gets the latest created engine
  38716. */
  38717. static get LastCreatedEngine(): Nullable<Engine>;
  38718. /**
  38719. * Gets the latest created scene
  38720. */
  38721. static get LastCreatedScene(): Nullable<Scene>;
  38722. /**
  38723. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38724. * @param flag defines which part of the materials must be marked as dirty
  38725. * @param predicate defines a predicate used to filter which materials should be affected
  38726. */
  38727. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38728. /**
  38729. * Method called to create the default loading screen.
  38730. * This can be overriden in your own app.
  38731. * @param canvas The rendering canvas element
  38732. * @returns The loading screen
  38733. */
  38734. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38735. /**
  38736. * Method called to create the default rescale post process on each engine.
  38737. */
  38738. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38739. /**
  38740. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38741. **/
  38742. enableOfflineSupport: boolean;
  38743. /**
  38744. * 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)
  38745. **/
  38746. disableManifestCheck: boolean;
  38747. /**
  38748. * Gets the list of created scenes
  38749. */
  38750. scenes: Scene[];
  38751. /**
  38752. * Event raised when a new scene is created
  38753. */
  38754. onNewSceneAddedObservable: Observable<Scene>;
  38755. /**
  38756. * Gets the list of created postprocesses
  38757. */
  38758. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38759. /**
  38760. * Gets a boolean indicating if the pointer is currently locked
  38761. */
  38762. isPointerLock: boolean;
  38763. /**
  38764. * Observable event triggered each time the rendering canvas is resized
  38765. */
  38766. onResizeObservable: Observable<Engine>;
  38767. /**
  38768. * Observable event triggered each time the canvas loses focus
  38769. */
  38770. onCanvasBlurObservable: Observable<Engine>;
  38771. /**
  38772. * Observable event triggered each time the canvas gains focus
  38773. */
  38774. onCanvasFocusObservable: Observable<Engine>;
  38775. /**
  38776. * Observable event triggered each time the canvas receives pointerout event
  38777. */
  38778. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38779. /**
  38780. * Observable raised when the engine begins a new frame
  38781. */
  38782. onBeginFrameObservable: Observable<Engine>;
  38783. /**
  38784. * If set, will be used to request the next animation frame for the render loop
  38785. */
  38786. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38787. /**
  38788. * Observable raised when the engine ends the current frame
  38789. */
  38790. onEndFrameObservable: Observable<Engine>;
  38791. /**
  38792. * Observable raised when the engine is about to compile a shader
  38793. */
  38794. onBeforeShaderCompilationObservable: Observable<Engine>;
  38795. /**
  38796. * Observable raised when the engine has jsut compiled a shader
  38797. */
  38798. onAfterShaderCompilationObservable: Observable<Engine>;
  38799. /**
  38800. * Gets the audio engine
  38801. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38802. * @ignorenaming
  38803. */
  38804. static audioEngine: IAudioEngine;
  38805. /**
  38806. * Default AudioEngine factory responsible of creating the Audio Engine.
  38807. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38808. */
  38809. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38810. /**
  38811. * Default offline support factory responsible of creating a tool used to store data locally.
  38812. * By default, this will create a Database object if the workload has been embedded.
  38813. */
  38814. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38815. private _loadingScreen;
  38816. private _pointerLockRequested;
  38817. private _rescalePostProcess;
  38818. private _deterministicLockstep;
  38819. private _lockstepMaxSteps;
  38820. private _timeStep;
  38821. protected get _supportsHardwareTextureRescaling(): boolean;
  38822. private _fps;
  38823. private _deltaTime;
  38824. /** @hidden */
  38825. _drawCalls: PerfCounter;
  38826. /** 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 */
  38827. canvasTabIndex: number;
  38828. /**
  38829. * Turn this value on if you want to pause FPS computation when in background
  38830. */
  38831. disablePerformanceMonitorInBackground: boolean;
  38832. private _performanceMonitor;
  38833. /**
  38834. * Gets the performance monitor attached to this engine
  38835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38836. */
  38837. get performanceMonitor(): PerformanceMonitor;
  38838. private _onFocus;
  38839. private _onBlur;
  38840. private _onCanvasPointerOut;
  38841. private _onCanvasBlur;
  38842. private _onCanvasFocus;
  38843. private _onFullscreenChange;
  38844. private _onPointerLockChange;
  38845. /**
  38846. * Gets the HTML element used to attach event listeners
  38847. * @returns a HTML element
  38848. */
  38849. getInputElement(): Nullable<HTMLElement>;
  38850. /**
  38851. * Creates a new engine
  38852. * @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
  38853. * @param antialias defines enable antialiasing (default: false)
  38854. * @param options defines further options to be sent to the getContext() function
  38855. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38856. */
  38857. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38858. /**
  38859. * Gets current aspect ratio
  38860. * @param viewportOwner defines the camera to use to get the aspect ratio
  38861. * @param useScreen defines if screen size must be used (or the current render target if any)
  38862. * @returns a number defining the aspect ratio
  38863. */
  38864. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38865. /**
  38866. * Gets current screen aspect ratio
  38867. * @returns a number defining the aspect ratio
  38868. */
  38869. getScreenAspectRatio(): number;
  38870. /**
  38871. * Gets the client rect of the HTML canvas attached with the current webGL context
  38872. * @returns a client rectanglee
  38873. */
  38874. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38875. /**
  38876. * Gets the client rect of the HTML element used for events
  38877. * @returns a client rectanglee
  38878. */
  38879. getInputElementClientRect(): Nullable<ClientRect>;
  38880. /**
  38881. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38883. * @returns true if engine is in deterministic lock step mode
  38884. */
  38885. isDeterministicLockStep(): boolean;
  38886. /**
  38887. * Gets the max steps when engine is running in deterministic lock step
  38888. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38889. * @returns the max steps
  38890. */
  38891. getLockstepMaxSteps(): number;
  38892. /**
  38893. * Returns the time in ms between steps when using deterministic lock step.
  38894. * @returns time step in (ms)
  38895. */
  38896. getTimeStep(): number;
  38897. /**
  38898. * Force the mipmap generation for the given render target texture
  38899. * @param texture defines the render target texture to use
  38900. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38901. */
  38902. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38903. /** States */
  38904. /**
  38905. * Set various states to the webGL context
  38906. * @param culling defines backface culling state
  38907. * @param zOffset defines the value to apply to zOffset (0 by default)
  38908. * @param force defines if states must be applied even if cache is up to date
  38909. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38910. */
  38911. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38912. /**
  38913. * Set the z offset to apply to current rendering
  38914. * @param value defines the offset to apply
  38915. */
  38916. setZOffset(value: number): void;
  38917. /**
  38918. * Gets the current value of the zOffset
  38919. * @returns the current zOffset state
  38920. */
  38921. getZOffset(): number;
  38922. /**
  38923. * Enable or disable depth buffering
  38924. * @param enable defines the state to set
  38925. */
  38926. setDepthBuffer(enable: boolean): void;
  38927. /**
  38928. * Gets a boolean indicating if depth writing is enabled
  38929. * @returns the current depth writing state
  38930. */
  38931. getDepthWrite(): boolean;
  38932. /**
  38933. * Enable or disable depth writing
  38934. * @param enable defines the state to set
  38935. */
  38936. setDepthWrite(enable: boolean): void;
  38937. /**
  38938. * Gets a boolean indicating if stencil buffer is enabled
  38939. * @returns the current stencil buffer state
  38940. */
  38941. getStencilBuffer(): boolean;
  38942. /**
  38943. * Enable or disable the stencil buffer
  38944. * @param enable defines if the stencil buffer must be enabled or disabled
  38945. */
  38946. setStencilBuffer(enable: boolean): void;
  38947. /**
  38948. * Gets the current stencil mask
  38949. * @returns a number defining the new stencil mask to use
  38950. */
  38951. getStencilMask(): number;
  38952. /**
  38953. * Sets the current stencil mask
  38954. * @param mask defines the new stencil mask to use
  38955. */
  38956. setStencilMask(mask: number): void;
  38957. /**
  38958. * Gets the current stencil function
  38959. * @returns a number defining the stencil function to use
  38960. */
  38961. getStencilFunction(): number;
  38962. /**
  38963. * Gets the current stencil reference value
  38964. * @returns a number defining the stencil reference value to use
  38965. */
  38966. getStencilFunctionReference(): number;
  38967. /**
  38968. * Gets the current stencil mask
  38969. * @returns a number defining the stencil mask to use
  38970. */
  38971. getStencilFunctionMask(): number;
  38972. /**
  38973. * Sets the current stencil function
  38974. * @param stencilFunc defines the new stencil function to use
  38975. */
  38976. setStencilFunction(stencilFunc: number): void;
  38977. /**
  38978. * Sets the current stencil reference
  38979. * @param reference defines the new stencil reference to use
  38980. */
  38981. setStencilFunctionReference(reference: number): void;
  38982. /**
  38983. * Sets the current stencil mask
  38984. * @param mask defines the new stencil mask to use
  38985. */
  38986. setStencilFunctionMask(mask: number): void;
  38987. /**
  38988. * Gets the current stencil operation when stencil fails
  38989. * @returns a number defining stencil operation to use when stencil fails
  38990. */
  38991. getStencilOperationFail(): number;
  38992. /**
  38993. * Gets the current stencil operation when depth fails
  38994. * @returns a number defining stencil operation to use when depth fails
  38995. */
  38996. getStencilOperationDepthFail(): number;
  38997. /**
  38998. * Gets the current stencil operation when stencil passes
  38999. * @returns a number defining stencil operation to use when stencil passes
  39000. */
  39001. getStencilOperationPass(): number;
  39002. /**
  39003. * Sets the stencil operation to use when stencil fails
  39004. * @param operation defines the stencil operation to use when stencil fails
  39005. */
  39006. setStencilOperationFail(operation: number): void;
  39007. /**
  39008. * Sets the stencil operation to use when depth fails
  39009. * @param operation defines the stencil operation to use when depth fails
  39010. */
  39011. setStencilOperationDepthFail(operation: number): void;
  39012. /**
  39013. * Sets the stencil operation to use when stencil passes
  39014. * @param operation defines the stencil operation to use when stencil passes
  39015. */
  39016. setStencilOperationPass(operation: number): void;
  39017. /**
  39018. * Sets a boolean indicating if the dithering state is enabled or disabled
  39019. * @param value defines the dithering state
  39020. */
  39021. setDitheringState(value: boolean): void;
  39022. /**
  39023. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39024. * @param value defines the rasterizer state
  39025. */
  39026. setRasterizerState(value: boolean): void;
  39027. /**
  39028. * Gets the current depth function
  39029. * @returns a number defining the depth function
  39030. */
  39031. getDepthFunction(): Nullable<number>;
  39032. /**
  39033. * Sets the current depth function
  39034. * @param depthFunc defines the function to use
  39035. */
  39036. setDepthFunction(depthFunc: number): void;
  39037. /**
  39038. * Sets the current depth function to GREATER
  39039. */
  39040. setDepthFunctionToGreater(): void;
  39041. /**
  39042. * Sets the current depth function to GEQUAL
  39043. */
  39044. setDepthFunctionToGreaterOrEqual(): void;
  39045. /**
  39046. * Sets the current depth function to LESS
  39047. */
  39048. setDepthFunctionToLess(): void;
  39049. /**
  39050. * Sets the current depth function to LEQUAL
  39051. */
  39052. setDepthFunctionToLessOrEqual(): void;
  39053. private _cachedStencilBuffer;
  39054. private _cachedStencilFunction;
  39055. private _cachedStencilMask;
  39056. private _cachedStencilOperationPass;
  39057. private _cachedStencilOperationFail;
  39058. private _cachedStencilOperationDepthFail;
  39059. private _cachedStencilReference;
  39060. /**
  39061. * Caches the the state of the stencil buffer
  39062. */
  39063. cacheStencilState(): void;
  39064. /**
  39065. * Restores the state of the stencil buffer
  39066. */
  39067. restoreStencilState(): void;
  39068. /**
  39069. * Directly set the WebGL Viewport
  39070. * @param x defines the x coordinate of the viewport (in screen space)
  39071. * @param y defines the y coordinate of the viewport (in screen space)
  39072. * @param width defines the width of the viewport (in screen space)
  39073. * @param height defines the height of the viewport (in screen space)
  39074. * @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
  39075. */
  39076. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39077. /**
  39078. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39079. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39080. * @param y defines the y-coordinate of the corner of the clear rectangle
  39081. * @param width defines the width of the clear rectangle
  39082. * @param height defines the height of the clear rectangle
  39083. * @param clearColor defines the clear color
  39084. */
  39085. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39086. /**
  39087. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39088. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39089. * @param y defines the y-coordinate of the corner of the clear rectangle
  39090. * @param width defines the width of the clear rectangle
  39091. * @param height defines the height of the clear rectangle
  39092. */
  39093. enableScissor(x: number, y: number, width: number, height: number): void;
  39094. /**
  39095. * Disable previously set scissor test rectangle
  39096. */
  39097. disableScissor(): void;
  39098. protected _reportDrawCall(): void;
  39099. /**
  39100. * Initializes a webVR display and starts listening to display change events
  39101. * The onVRDisplayChangedObservable will be notified upon these changes
  39102. * @returns The onVRDisplayChangedObservable
  39103. */
  39104. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39105. /** @hidden */
  39106. _prepareVRComponent(): void;
  39107. /** @hidden */
  39108. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39109. /** @hidden */
  39110. _submitVRFrame(): void;
  39111. /**
  39112. * Call this function to leave webVR mode
  39113. * Will do nothing if webVR is not supported or if there is no webVR device
  39114. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39115. */
  39116. disableVR(): void;
  39117. /**
  39118. * Gets a boolean indicating that the system is in VR mode and is presenting
  39119. * @returns true if VR mode is engaged
  39120. */
  39121. isVRPresenting(): boolean;
  39122. /** @hidden */
  39123. _requestVRFrame(): void;
  39124. /** @hidden */
  39125. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39126. /**
  39127. * Gets the source code of the vertex shader associated with a specific webGL program
  39128. * @param program defines the program to use
  39129. * @returns a string containing the source code of the vertex shader associated with the program
  39130. */
  39131. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39132. /**
  39133. * Gets the source code of the fragment shader associated with a specific webGL program
  39134. * @param program defines the program to use
  39135. * @returns a string containing the source code of the fragment shader associated with the program
  39136. */
  39137. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39138. /**
  39139. * Sets a depth stencil texture from a render target to the according uniform.
  39140. * @param channel The texture channel
  39141. * @param uniform The uniform to set
  39142. * @param texture The render target texture containing the depth stencil texture to apply
  39143. */
  39144. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39145. /**
  39146. * Sets a texture to the webGL context from a postprocess
  39147. * @param channel defines the channel to use
  39148. * @param postProcess defines the source postprocess
  39149. */
  39150. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39151. /**
  39152. * Binds the output of the passed in post process to the texture channel specified
  39153. * @param channel The channel the texture should be bound to
  39154. * @param postProcess The post process which's output should be bound
  39155. */
  39156. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39157. protected _rebuildBuffers(): void;
  39158. /** @hidden */
  39159. _renderFrame(): void;
  39160. _renderLoop(): void;
  39161. /** @hidden */
  39162. _renderViews(): boolean;
  39163. /**
  39164. * Toggle full screen mode
  39165. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39166. */
  39167. switchFullscreen(requestPointerLock: boolean): void;
  39168. /**
  39169. * Enters full screen mode
  39170. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39171. */
  39172. enterFullscreen(requestPointerLock: boolean): void;
  39173. /**
  39174. * Exits full screen mode
  39175. */
  39176. exitFullscreen(): void;
  39177. /**
  39178. * Enters Pointerlock mode
  39179. */
  39180. enterPointerlock(): void;
  39181. /**
  39182. * Exits Pointerlock mode
  39183. */
  39184. exitPointerlock(): void;
  39185. /**
  39186. * Begin a new frame
  39187. */
  39188. beginFrame(): void;
  39189. /**
  39190. * Enf the current frame
  39191. */
  39192. endFrame(): void;
  39193. resize(): void;
  39194. /**
  39195. * Force a specific size of the canvas
  39196. * @param width defines the new canvas' width
  39197. * @param height defines the new canvas' height
  39198. * @returns true if the size was changed
  39199. */
  39200. setSize(width: number, height: number): boolean;
  39201. /**
  39202. * Updates a dynamic vertex buffer.
  39203. * @param vertexBuffer the vertex buffer to update
  39204. * @param data the data used to update the vertex buffer
  39205. * @param byteOffset the byte offset of the data
  39206. * @param byteLength the byte length of the data
  39207. */
  39208. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39209. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39210. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39211. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39212. _releaseTexture(texture: InternalTexture): void;
  39213. /**
  39214. * @hidden
  39215. * Rescales a texture
  39216. * @param source input texutre
  39217. * @param destination destination texture
  39218. * @param scene scene to use to render the resize
  39219. * @param internalFormat format to use when resizing
  39220. * @param onComplete callback to be called when resize has completed
  39221. */
  39222. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39223. /**
  39224. * Gets the current framerate
  39225. * @returns a number representing the framerate
  39226. */
  39227. getFps(): number;
  39228. /**
  39229. * Gets the time spent between current and previous frame
  39230. * @returns a number representing the delta time in ms
  39231. */
  39232. getDeltaTime(): number;
  39233. private _measureFps;
  39234. /** @hidden */
  39235. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39236. /**
  39237. * Update a dynamic index buffer
  39238. * @param indexBuffer defines the target index buffer
  39239. * @param indices defines the data to update
  39240. * @param offset defines the offset in the target index buffer where update should start
  39241. */
  39242. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39243. /**
  39244. * Updates the sample count of a render target texture
  39245. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39246. * @param texture defines the texture to update
  39247. * @param samples defines the sample count to set
  39248. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39249. */
  39250. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39251. /**
  39252. * Updates a depth texture Comparison Mode and Function.
  39253. * If the comparison Function is equal to 0, the mode will be set to none.
  39254. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39255. * @param texture The texture to set the comparison function for
  39256. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39257. */
  39258. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39259. /**
  39260. * Creates a webGL buffer to use with instanciation
  39261. * @param capacity defines the size of the buffer
  39262. * @returns the webGL buffer
  39263. */
  39264. createInstancesBuffer(capacity: number): DataBuffer;
  39265. /**
  39266. * Delete a webGL buffer used with instanciation
  39267. * @param buffer defines the webGL buffer to delete
  39268. */
  39269. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39270. private _clientWaitAsync;
  39271. /** @hidden */
  39272. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39273. dispose(): void;
  39274. private _disableTouchAction;
  39275. /**
  39276. * Display the loading screen
  39277. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39278. */
  39279. displayLoadingUI(): void;
  39280. /**
  39281. * Hide the loading screen
  39282. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39283. */
  39284. hideLoadingUI(): void;
  39285. /**
  39286. * Gets the current loading screen object
  39287. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39288. */
  39289. get loadingScreen(): ILoadingScreen;
  39290. /**
  39291. * Sets the current loading screen object
  39292. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39293. */
  39294. set loadingScreen(loadingScreen: ILoadingScreen);
  39295. /**
  39296. * Sets the current loading screen text
  39297. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39298. */
  39299. set loadingUIText(text: string);
  39300. /**
  39301. * Sets the current loading screen background color
  39302. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39303. */
  39304. set loadingUIBackgroundColor(color: string);
  39305. /** Pointerlock and fullscreen */
  39306. /**
  39307. * Ask the browser to promote the current element to pointerlock mode
  39308. * @param element defines the DOM element to promote
  39309. */
  39310. static _RequestPointerlock(element: HTMLElement): void;
  39311. /**
  39312. * Asks the browser to exit pointerlock mode
  39313. */
  39314. static _ExitPointerlock(): void;
  39315. /**
  39316. * Ask the browser to promote the current element to fullscreen rendering mode
  39317. * @param element defines the DOM element to promote
  39318. */
  39319. static _RequestFullscreen(element: HTMLElement): void;
  39320. /**
  39321. * Asks the browser to exit fullscreen mode
  39322. */
  39323. static _ExitFullscreen(): void;
  39324. }
  39325. }
  39326. declare module "babylonjs/Engines/engineStore" {
  39327. import { Nullable } from "babylonjs/types";
  39328. import { Engine } from "babylonjs/Engines/engine";
  39329. import { Scene } from "babylonjs/scene";
  39330. /**
  39331. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39332. * during the life time of the application.
  39333. */
  39334. export class EngineStore {
  39335. /** Gets the list of created engines */
  39336. static Instances: import("babylonjs/Engines/engine").Engine[];
  39337. /** @hidden */
  39338. static _LastCreatedScene: Nullable<Scene>;
  39339. /**
  39340. * Gets the latest created engine
  39341. */
  39342. static get LastCreatedEngine(): Nullable<Engine>;
  39343. /**
  39344. * Gets the latest created scene
  39345. */
  39346. static get LastCreatedScene(): Nullable<Scene>;
  39347. /**
  39348. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39349. * @ignorenaming
  39350. */
  39351. static UseFallbackTexture: boolean;
  39352. /**
  39353. * Texture content used if a texture cannot loaded
  39354. * @ignorenaming
  39355. */
  39356. static FallbackTexture: string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Misc/promise" {
  39360. /**
  39361. * Helper class that provides a small promise polyfill
  39362. */
  39363. export class PromisePolyfill {
  39364. /**
  39365. * Static function used to check if the polyfill is required
  39366. * If this is the case then the function will inject the polyfill to window.Promise
  39367. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39368. */
  39369. static Apply(force?: boolean): void;
  39370. }
  39371. }
  39372. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39373. /**
  39374. * Interface for screenshot methods with describe argument called `size` as object with options
  39375. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39376. */
  39377. export interface IScreenshotSize {
  39378. /**
  39379. * number in pixels for canvas height
  39380. */
  39381. height?: number;
  39382. /**
  39383. * multiplier allowing render at a higher or lower resolution
  39384. * If value is defined then height and width will be ignored and taken from camera
  39385. */
  39386. precision?: number;
  39387. /**
  39388. * number in pixels for canvas width
  39389. */
  39390. width?: number;
  39391. }
  39392. }
  39393. declare module "babylonjs/Misc/tools" {
  39394. import { Nullable, float } from "babylonjs/types";
  39395. import { DomManagement } from "babylonjs/Misc/domManagement";
  39396. import { WebRequest } from "babylonjs/Misc/webRequest";
  39397. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39398. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39399. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39400. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39401. import { Camera } from "babylonjs/Cameras/camera";
  39402. import { Engine } from "babylonjs/Engines/engine";
  39403. interface IColor4Like {
  39404. r: float;
  39405. g: float;
  39406. b: float;
  39407. a: float;
  39408. }
  39409. /**
  39410. * Class containing a set of static utilities functions
  39411. */
  39412. export class Tools {
  39413. /**
  39414. * Gets or sets the base URL to use to load assets
  39415. */
  39416. static get BaseUrl(): string;
  39417. static set BaseUrl(value: string);
  39418. /**
  39419. * Enable/Disable Custom HTTP Request Headers globally.
  39420. * default = false
  39421. * @see CustomRequestHeaders
  39422. */
  39423. static UseCustomRequestHeaders: boolean;
  39424. /**
  39425. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39426. * i.e. when loading files, where the server/service expects an Authorization header
  39427. */
  39428. static CustomRequestHeaders: {
  39429. [key: string]: string;
  39430. };
  39431. /**
  39432. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39433. */
  39434. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39435. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39436. /**
  39437. * Default behaviour for cors in the application.
  39438. * It can be a string if the expected behavior is identical in the entire app.
  39439. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39440. */
  39441. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39442. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39443. /**
  39444. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39445. * @ignorenaming
  39446. */
  39447. static get UseFallbackTexture(): boolean;
  39448. static set UseFallbackTexture(value: boolean);
  39449. /**
  39450. * Use this object to register external classes like custom textures or material
  39451. * to allow the laoders to instantiate them
  39452. */
  39453. static get RegisteredExternalClasses(): {
  39454. [key: string]: Object;
  39455. };
  39456. static set RegisteredExternalClasses(classes: {
  39457. [key: string]: Object;
  39458. });
  39459. /**
  39460. * Texture content used if a texture cannot loaded
  39461. * @ignorenaming
  39462. */
  39463. static get fallbackTexture(): string;
  39464. static set fallbackTexture(value: string);
  39465. /**
  39466. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39467. * @param u defines the coordinate on X axis
  39468. * @param v defines the coordinate on Y axis
  39469. * @param width defines the width of the source data
  39470. * @param height defines the height of the source data
  39471. * @param pixels defines the source byte array
  39472. * @param color defines the output color
  39473. */
  39474. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39475. /**
  39476. * Interpolates between a and b via alpha
  39477. * @param a The lower value (returned when alpha = 0)
  39478. * @param b The upper value (returned when alpha = 1)
  39479. * @param alpha The interpolation-factor
  39480. * @return The mixed value
  39481. */
  39482. static Mix(a: number, b: number, alpha: number): number;
  39483. /**
  39484. * Tries to instantiate a new object from a given class name
  39485. * @param className defines the class name to instantiate
  39486. * @returns the new object or null if the system was not able to do the instantiation
  39487. */
  39488. static Instantiate(className: string): any;
  39489. /**
  39490. * Provides a slice function that will work even on IE
  39491. * @param data defines the array to slice
  39492. * @param start defines the start of the data (optional)
  39493. * @param end defines the end of the data (optional)
  39494. * @returns the new sliced array
  39495. */
  39496. static Slice<T>(data: T, start?: number, end?: number): T;
  39497. /**
  39498. * Polyfill for setImmediate
  39499. * @param action defines the action to execute after the current execution block
  39500. */
  39501. static SetImmediate(action: () => void): void;
  39502. /**
  39503. * Function indicating if a number is an exponent of 2
  39504. * @param value defines the value to test
  39505. * @returns true if the value is an exponent of 2
  39506. */
  39507. static IsExponentOfTwo(value: number): boolean;
  39508. private static _tmpFloatArray;
  39509. /**
  39510. * Returns the nearest 32-bit single precision float representation of a Number
  39511. * @param value A Number. If the parameter is of a different type, it will get converted
  39512. * to a number or to NaN if it cannot be converted
  39513. * @returns number
  39514. */
  39515. static FloatRound(value: number): number;
  39516. /**
  39517. * Extracts the filename from a path
  39518. * @param path defines the path to use
  39519. * @returns the filename
  39520. */
  39521. static GetFilename(path: string): string;
  39522. /**
  39523. * Extracts the "folder" part of a path (everything before the filename).
  39524. * @param uri The URI to extract the info from
  39525. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39526. * @returns The "folder" part of the path
  39527. */
  39528. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39529. /**
  39530. * Extracts text content from a DOM element hierarchy
  39531. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39532. */
  39533. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39534. /**
  39535. * Convert an angle in radians to degrees
  39536. * @param angle defines the angle to convert
  39537. * @returns the angle in degrees
  39538. */
  39539. static ToDegrees(angle: number): number;
  39540. /**
  39541. * Convert an angle in degrees to radians
  39542. * @param angle defines the angle to convert
  39543. * @returns the angle in radians
  39544. */
  39545. static ToRadians(angle: number): number;
  39546. /**
  39547. * Returns an array if obj is not an array
  39548. * @param obj defines the object to evaluate as an array
  39549. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39550. * @returns either obj directly if obj is an array or a new array containing obj
  39551. */
  39552. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39553. /**
  39554. * Gets the pointer prefix to use
  39555. * @param engine defines the engine we are finding the prefix for
  39556. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39557. */
  39558. static GetPointerPrefix(engine: Engine): string;
  39559. /**
  39560. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39561. * @param url define the url we are trying
  39562. * @param element define the dom element where to configure the cors policy
  39563. */
  39564. static SetCorsBehavior(url: string | string[], element: {
  39565. crossOrigin: string | null;
  39566. }): void;
  39567. /**
  39568. * Removes unwanted characters from an url
  39569. * @param url defines the url to clean
  39570. * @returns the cleaned url
  39571. */
  39572. static CleanUrl(url: string): string;
  39573. /**
  39574. * Gets or sets a function used to pre-process url before using them to load assets
  39575. */
  39576. static get PreprocessUrl(): (url: string) => string;
  39577. static set PreprocessUrl(processor: (url: string) => string);
  39578. /**
  39579. * Loads an image as an HTMLImageElement.
  39580. * @param input url string, ArrayBuffer, or Blob to load
  39581. * @param onLoad callback called when the image successfully loads
  39582. * @param onError callback called when the image fails to load
  39583. * @param offlineProvider offline provider for caching
  39584. * @param mimeType optional mime type
  39585. * @returns the HTMLImageElement of the loaded image
  39586. */
  39587. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39588. /**
  39589. * Loads a file from a url
  39590. * @param url url string, ArrayBuffer, or Blob to load
  39591. * @param onSuccess callback called when the file successfully loads
  39592. * @param onProgress callback called while file is loading (if the server supports this mode)
  39593. * @param offlineProvider defines the offline provider for caching
  39594. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39595. * @param onError callback called when the file fails to load
  39596. * @returns a file request object
  39597. */
  39598. 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;
  39599. /**
  39600. * Loads a file from a url
  39601. * @param url the file url to load
  39602. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39603. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39604. */
  39605. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39606. /**
  39607. * Load a script (identified by an url). When the url returns, the
  39608. * content of this file is added into a new script element, attached to the DOM (body element)
  39609. * @param scriptUrl defines the url of the script to laod
  39610. * @param onSuccess defines the callback called when the script is loaded
  39611. * @param onError defines the callback to call if an error occurs
  39612. * @param scriptId defines the id of the script element
  39613. */
  39614. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39615. /**
  39616. * Load an asynchronous script (identified by an url). When the url returns, the
  39617. * content of this file is added into a new script element, attached to the DOM (body element)
  39618. * @param scriptUrl defines the url of the script to laod
  39619. * @param scriptId defines the id of the script element
  39620. * @returns a promise request object
  39621. */
  39622. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39623. /**
  39624. * Loads a file from a blob
  39625. * @param fileToLoad defines the blob to use
  39626. * @param callback defines the callback to call when data is loaded
  39627. * @param progressCallback defines the callback to call during loading process
  39628. * @returns a file request object
  39629. */
  39630. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39631. /**
  39632. * Reads a file from a File object
  39633. * @param file defines the file to load
  39634. * @param onSuccess defines the callback to call when data is loaded
  39635. * @param onProgress defines the callback to call during loading process
  39636. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39637. * @param onError defines the callback to call when an error occurs
  39638. * @returns a file request object
  39639. */
  39640. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39641. /**
  39642. * Creates a data url from a given string content
  39643. * @param content defines the content to convert
  39644. * @returns the new data url link
  39645. */
  39646. static FileAsURL(content: string): string;
  39647. /**
  39648. * Format the given number to a specific decimal format
  39649. * @param value defines the number to format
  39650. * @param decimals defines the number of decimals to use
  39651. * @returns the formatted string
  39652. */
  39653. static Format(value: number, decimals?: number): string;
  39654. /**
  39655. * Tries to copy an object by duplicating every property
  39656. * @param source defines the source object
  39657. * @param destination defines the target object
  39658. * @param doNotCopyList defines a list of properties to avoid
  39659. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39660. */
  39661. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39662. /**
  39663. * Gets a boolean indicating if the given object has no own property
  39664. * @param obj defines the object to test
  39665. * @returns true if object has no own property
  39666. */
  39667. static IsEmpty(obj: any): boolean;
  39668. /**
  39669. * Function used to register events at window level
  39670. * @param windowElement defines the Window object to use
  39671. * @param events defines the events to register
  39672. */
  39673. static RegisterTopRootEvents(windowElement: Window, events: {
  39674. name: string;
  39675. handler: Nullable<(e: FocusEvent) => any>;
  39676. }[]): void;
  39677. /**
  39678. * Function used to unregister events from window level
  39679. * @param windowElement defines the Window object to use
  39680. * @param events defines the events to unregister
  39681. */
  39682. static UnregisterTopRootEvents(windowElement: Window, events: {
  39683. name: string;
  39684. handler: Nullable<(e: FocusEvent) => any>;
  39685. }[]): void;
  39686. /**
  39687. * @ignore
  39688. */
  39689. static _ScreenshotCanvas: HTMLCanvasElement;
  39690. /**
  39691. * Dumps the current bound framebuffer
  39692. * @param width defines the rendering width
  39693. * @param height defines the rendering height
  39694. * @param engine defines the hosting engine
  39695. * @param successCallback defines the callback triggered once the data are available
  39696. * @param mimeType defines the mime type of the result
  39697. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39698. */
  39699. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39700. /**
  39701. * Converts the canvas data to blob.
  39702. * This acts as a polyfill for browsers not supporting the to blob function.
  39703. * @param canvas Defines the canvas to extract the data from
  39704. * @param successCallback Defines the callback triggered once the data are available
  39705. * @param mimeType Defines the mime type of the result
  39706. */
  39707. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39708. /**
  39709. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39710. * @param successCallback defines the callback triggered once the data are available
  39711. * @param mimeType defines the mime type of the result
  39712. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39713. */
  39714. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39715. /**
  39716. * Downloads a blob in the browser
  39717. * @param blob defines the blob to download
  39718. * @param fileName defines the name of the downloaded file
  39719. */
  39720. static Download(blob: Blob, fileName: string): void;
  39721. /**
  39722. * Captures a screenshot of the current rendering
  39723. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39724. * @param engine defines the rendering engine
  39725. * @param camera defines the source camera
  39726. * @param size This parameter can be set to a single number or to an object with the
  39727. * following (optional) properties: precision, width, height. If a single number is passed,
  39728. * it will be used for both width and height. If an object is passed, the screenshot size
  39729. * will be derived from the parameters. The precision property is a multiplier allowing
  39730. * rendering at a higher or lower resolution
  39731. * @param successCallback defines the callback receives a single parameter which contains the
  39732. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39733. * src parameter of an <img> to display it
  39734. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39735. * Check your browser for supported MIME types
  39736. */
  39737. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39738. /**
  39739. * Captures a screenshot of the current rendering
  39740. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39741. * @param engine defines the rendering engine
  39742. * @param camera defines the source camera
  39743. * @param size This parameter can be set to a single number or to an object with the
  39744. * following (optional) properties: precision, width, height. If a single number is passed,
  39745. * it will be used for both width and height. If an object is passed, the screenshot size
  39746. * will be derived from the parameters. The precision property is a multiplier allowing
  39747. * rendering at a higher or lower resolution
  39748. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39749. * Check your browser for supported MIME types
  39750. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39751. * to the src parameter of an <img> to display it
  39752. */
  39753. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39754. /**
  39755. * Generates an image screenshot from the specified camera.
  39756. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39757. * @param engine The engine to use for rendering
  39758. * @param camera The camera to use for rendering
  39759. * @param size This parameter can be set to a single number or to an object with the
  39760. * following (optional) properties: precision, width, height. If a single number is passed,
  39761. * it will be used for both width and height. If an object is passed, the screenshot size
  39762. * will be derived from the parameters. The precision property is a multiplier allowing
  39763. * rendering at a higher or lower resolution
  39764. * @param successCallback The callback receives a single parameter which contains the
  39765. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39766. * src parameter of an <img> to display it
  39767. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39768. * Check your browser for supported MIME types
  39769. * @param samples Texture samples (default: 1)
  39770. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39771. * @param fileName A name for for the downloaded file.
  39772. */
  39773. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39774. /**
  39775. * Generates an image screenshot from the specified camera.
  39776. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39777. * @param engine The engine to use for rendering
  39778. * @param camera The camera to use for rendering
  39779. * @param size This parameter can be set to a single number or to an object with the
  39780. * following (optional) properties: precision, width, height. If a single number is passed,
  39781. * it will be used for both width and height. If an object is passed, the screenshot size
  39782. * will be derived from the parameters. The precision property is a multiplier allowing
  39783. * rendering at a higher or lower resolution
  39784. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39785. * Check your browser for supported MIME types
  39786. * @param samples Texture samples (default: 1)
  39787. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39788. * @param fileName A name for for the downloaded file.
  39789. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39790. * to the src parameter of an <img> to display it
  39791. */
  39792. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39793. /**
  39794. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39795. * Be aware Math.random() could cause collisions, but:
  39796. * "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"
  39797. * @returns a pseudo random id
  39798. */
  39799. static RandomId(): string;
  39800. /**
  39801. * Test if the given uri is a base64 string
  39802. * @param uri The uri to test
  39803. * @return True if the uri is a base64 string or false otherwise
  39804. */
  39805. static IsBase64(uri: string): boolean;
  39806. /**
  39807. * Decode the given base64 uri.
  39808. * @param uri The uri to decode
  39809. * @return The decoded base64 data.
  39810. */
  39811. static DecodeBase64(uri: string): ArrayBuffer;
  39812. /**
  39813. * Gets the absolute url.
  39814. * @param url the input url
  39815. * @return the absolute url
  39816. */
  39817. static GetAbsoluteUrl(url: string): string;
  39818. /**
  39819. * No log
  39820. */
  39821. static readonly NoneLogLevel: number;
  39822. /**
  39823. * Only message logs
  39824. */
  39825. static readonly MessageLogLevel: number;
  39826. /**
  39827. * Only warning logs
  39828. */
  39829. static readonly WarningLogLevel: number;
  39830. /**
  39831. * Only error logs
  39832. */
  39833. static readonly ErrorLogLevel: number;
  39834. /**
  39835. * All logs
  39836. */
  39837. static readonly AllLogLevel: number;
  39838. /**
  39839. * Gets a value indicating the number of loading errors
  39840. * @ignorenaming
  39841. */
  39842. static get errorsCount(): number;
  39843. /**
  39844. * Callback called when a new log is added
  39845. */
  39846. static OnNewCacheEntry: (entry: string) => void;
  39847. /**
  39848. * Log a message to the console
  39849. * @param message defines the message to log
  39850. */
  39851. static Log(message: string): void;
  39852. /**
  39853. * Write a warning message to the console
  39854. * @param message defines the message to log
  39855. */
  39856. static Warn(message: string): void;
  39857. /**
  39858. * Write an error message to the console
  39859. * @param message defines the message to log
  39860. */
  39861. static Error(message: string): void;
  39862. /**
  39863. * Gets current log cache (list of logs)
  39864. */
  39865. static get LogCache(): string;
  39866. /**
  39867. * Clears the log cache
  39868. */
  39869. static ClearLogCache(): void;
  39870. /**
  39871. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39872. */
  39873. static set LogLevels(level: number);
  39874. /**
  39875. * Checks if the window object exists
  39876. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39877. */
  39878. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39879. /**
  39880. * No performance log
  39881. */
  39882. static readonly PerformanceNoneLogLevel: number;
  39883. /**
  39884. * Use user marks to log performance
  39885. */
  39886. static readonly PerformanceUserMarkLogLevel: number;
  39887. /**
  39888. * Log performance to the console
  39889. */
  39890. static readonly PerformanceConsoleLogLevel: number;
  39891. private static _performance;
  39892. /**
  39893. * Sets the current performance log level
  39894. */
  39895. static set PerformanceLogLevel(level: number);
  39896. private static _StartPerformanceCounterDisabled;
  39897. private static _EndPerformanceCounterDisabled;
  39898. private static _StartUserMark;
  39899. private static _EndUserMark;
  39900. private static _StartPerformanceConsole;
  39901. private static _EndPerformanceConsole;
  39902. /**
  39903. * Starts a performance counter
  39904. */
  39905. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39906. /**
  39907. * Ends a specific performance coutner
  39908. */
  39909. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39910. /**
  39911. * Gets either window.performance.now() if supported or Date.now() else
  39912. */
  39913. static get Now(): number;
  39914. /**
  39915. * This method will return the name of the class used to create the instance of the given object.
  39916. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39917. * @param object the object to get the class name from
  39918. * @param isType defines if the object is actually a type
  39919. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39920. */
  39921. static GetClassName(object: any, isType?: boolean): string;
  39922. /**
  39923. * Gets the first element of an array satisfying a given predicate
  39924. * @param array defines the array to browse
  39925. * @param predicate defines the predicate to use
  39926. * @returns null if not found or the element
  39927. */
  39928. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39929. /**
  39930. * This method will return the name of the full name of the class, including its owning module (if any).
  39931. * 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).
  39932. * @param object the object to get the class name from
  39933. * @param isType defines if the object is actually a type
  39934. * @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.
  39935. * @ignorenaming
  39936. */
  39937. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39938. /**
  39939. * Returns a promise that resolves after the given amount of time.
  39940. * @param delay Number of milliseconds to delay
  39941. * @returns Promise that resolves after the given amount of time
  39942. */
  39943. static DelayAsync(delay: number): Promise<void>;
  39944. /**
  39945. * Utility function to detect if the current user agent is Safari
  39946. * @returns whether or not the current user agent is safari
  39947. */
  39948. static IsSafari(): boolean;
  39949. }
  39950. /**
  39951. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39952. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39953. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39954. * @param name The name of the class, case should be preserved
  39955. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39956. */
  39957. export function className(name: string, module?: string): (target: Object) => void;
  39958. /**
  39959. * An implementation of a loop for asynchronous functions.
  39960. */
  39961. export class AsyncLoop {
  39962. /**
  39963. * Defines the number of iterations for the loop
  39964. */
  39965. iterations: number;
  39966. /**
  39967. * Defines the current index of the loop.
  39968. */
  39969. index: number;
  39970. private _done;
  39971. private _fn;
  39972. private _successCallback;
  39973. /**
  39974. * Constructor.
  39975. * @param iterations the number of iterations.
  39976. * @param func the function to run each iteration
  39977. * @param successCallback the callback that will be called upon succesful execution
  39978. * @param offset starting offset.
  39979. */
  39980. constructor(
  39981. /**
  39982. * Defines the number of iterations for the loop
  39983. */
  39984. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39985. /**
  39986. * Execute the next iteration. Must be called after the last iteration was finished.
  39987. */
  39988. executeNext(): void;
  39989. /**
  39990. * Break the loop and run the success callback.
  39991. */
  39992. breakLoop(): void;
  39993. /**
  39994. * Create and run an async loop.
  39995. * @param iterations the number of iterations.
  39996. * @param fn the function to run each iteration
  39997. * @param successCallback the callback that will be called upon succesful execution
  39998. * @param offset starting offset.
  39999. * @returns the created async loop object
  40000. */
  40001. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40002. /**
  40003. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40004. * @param iterations total number of iterations
  40005. * @param syncedIterations number of synchronous iterations in each async iteration.
  40006. * @param fn the function to call each iteration.
  40007. * @param callback a success call back that will be called when iterating stops.
  40008. * @param breakFunction a break condition (optional)
  40009. * @param timeout timeout settings for the setTimeout function. default - 0.
  40010. * @returns the created async loop object
  40011. */
  40012. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40013. }
  40014. }
  40015. declare module "babylonjs/Misc/stringDictionary" {
  40016. import { Nullable } from "babylonjs/types";
  40017. /**
  40018. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40019. * The underlying implementation relies on an associative array to ensure the best performances.
  40020. * The value can be anything including 'null' but except 'undefined'
  40021. */
  40022. export class StringDictionary<T> {
  40023. /**
  40024. * This will clear this dictionary and copy the content from the 'source' one.
  40025. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40026. * @param source the dictionary to take the content from and copy to this dictionary
  40027. */
  40028. copyFrom(source: StringDictionary<T>): void;
  40029. /**
  40030. * Get a value based from its key
  40031. * @param key the given key to get the matching value from
  40032. * @return the value if found, otherwise undefined is returned
  40033. */
  40034. get(key: string): T | undefined;
  40035. /**
  40036. * Get a value from its key or add it if it doesn't exist.
  40037. * This method will ensure you that a given key/data will be present in the dictionary.
  40038. * @param key the given key to get the matching value from
  40039. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40040. * The factory will only be invoked if there's no data for the given key.
  40041. * @return the value corresponding to the key.
  40042. */
  40043. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40044. /**
  40045. * Get a value from its key if present in the dictionary otherwise add it
  40046. * @param key the key to get the value from
  40047. * @param val if there's no such key/value pair in the dictionary add it with this value
  40048. * @return the value corresponding to the key
  40049. */
  40050. getOrAdd(key: string, val: T): T;
  40051. /**
  40052. * Check if there's a given key in the dictionary
  40053. * @param key the key to check for
  40054. * @return true if the key is present, false otherwise
  40055. */
  40056. contains(key: string): boolean;
  40057. /**
  40058. * Add a new key and its corresponding value
  40059. * @param key the key to add
  40060. * @param value the value corresponding to the key
  40061. * @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
  40062. */
  40063. add(key: string, value: T): boolean;
  40064. /**
  40065. * Update a specific value associated to a key
  40066. * @param key defines the key to use
  40067. * @param value defines the value to store
  40068. * @returns true if the value was updated (or false if the key was not found)
  40069. */
  40070. set(key: string, value: T): boolean;
  40071. /**
  40072. * Get the element of the given key and remove it from the dictionary
  40073. * @param key defines the key to search
  40074. * @returns the value associated with the key or null if not found
  40075. */
  40076. getAndRemove(key: string): Nullable<T>;
  40077. /**
  40078. * Remove a key/value from the dictionary.
  40079. * @param key the key to remove
  40080. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40081. */
  40082. remove(key: string): boolean;
  40083. /**
  40084. * Clear the whole content of the dictionary
  40085. */
  40086. clear(): void;
  40087. /**
  40088. * Gets the current count
  40089. */
  40090. get count(): number;
  40091. /**
  40092. * Execute a callback on each key/val of the dictionary.
  40093. * Note that you can remove any element in this dictionary in the callback implementation
  40094. * @param callback the callback to execute on a given key/value pair
  40095. */
  40096. forEach(callback: (key: string, val: T) => void): void;
  40097. /**
  40098. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40099. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40100. * Note that you can remove any element in this dictionary in the callback implementation
  40101. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40102. * @returns the first item
  40103. */
  40104. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40105. private _count;
  40106. private _data;
  40107. }
  40108. }
  40109. declare module "babylonjs/Collisions/collisionCoordinator" {
  40110. import { Nullable } from "babylonjs/types";
  40111. import { Scene } from "babylonjs/scene";
  40112. import { Vector3 } from "babylonjs/Maths/math.vector";
  40113. import { Collider } from "babylonjs/Collisions/collider";
  40114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40115. /** @hidden */
  40116. export interface ICollisionCoordinator {
  40117. createCollider(): Collider;
  40118. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40119. init(scene: Scene): void;
  40120. }
  40121. /** @hidden */
  40122. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40123. private _scene;
  40124. private _scaledPosition;
  40125. private _scaledVelocity;
  40126. private _finalPosition;
  40127. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40128. createCollider(): Collider;
  40129. init(scene: Scene): void;
  40130. private _collideWithWorld;
  40131. }
  40132. }
  40133. declare module "babylonjs/Inputs/scene.inputManager" {
  40134. import { Nullable } from "babylonjs/types";
  40135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40136. import { Vector2 } from "babylonjs/Maths/math.vector";
  40137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40138. import { Scene } from "babylonjs/scene";
  40139. /**
  40140. * Class used to manage all inputs for the scene.
  40141. */
  40142. export class InputManager {
  40143. /** The distance in pixel that you have to move to prevent some events */
  40144. static DragMovementThreshold: number;
  40145. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40146. static LongPressDelay: number;
  40147. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40148. static DoubleClickDelay: number;
  40149. /** If you need to check double click without raising a single click at first click, enable this flag */
  40150. static ExclusiveDoubleClickMode: boolean;
  40151. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  40152. private _alreadyAttached;
  40153. private _wheelEventName;
  40154. private _onPointerMove;
  40155. private _onPointerDown;
  40156. private _onPointerUp;
  40157. private _initClickEvent;
  40158. private _initActionManager;
  40159. private _delayedSimpleClick;
  40160. private _delayedSimpleClickTimeout;
  40161. private _previousDelayedSimpleClickTimeout;
  40162. private _meshPickProceed;
  40163. private _previousButtonPressed;
  40164. private _currentPickResult;
  40165. private _previousPickResult;
  40166. private _totalPointersPressed;
  40167. private _doubleClickOccured;
  40168. private _pointerOverMesh;
  40169. private _pickedDownMesh;
  40170. private _pickedUpMesh;
  40171. private _pointerX;
  40172. private _pointerY;
  40173. private _unTranslatedPointerX;
  40174. private _unTranslatedPointerY;
  40175. private _startingPointerPosition;
  40176. private _previousStartingPointerPosition;
  40177. private _startingPointerTime;
  40178. private _previousStartingPointerTime;
  40179. private _pointerCaptures;
  40180. private _onKeyDown;
  40181. private _onKeyUp;
  40182. private _onCanvasFocusObserver;
  40183. private _onCanvasBlurObserver;
  40184. private _scene;
  40185. /**
  40186. * Creates a new InputManager
  40187. * @param scene defines the hosting scene
  40188. */
  40189. constructor(scene: Scene);
  40190. /**
  40191. * Gets the mesh that is currently under the pointer
  40192. */
  40193. get meshUnderPointer(): Nullable<AbstractMesh>;
  40194. /**
  40195. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40196. */
  40197. get unTranslatedPointer(): Vector2;
  40198. /**
  40199. * Gets or sets the current on-screen X position of the pointer
  40200. */
  40201. get pointerX(): number;
  40202. set pointerX(value: number);
  40203. /**
  40204. * Gets or sets the current on-screen Y position of the pointer
  40205. */
  40206. get pointerY(): number;
  40207. set pointerY(value: number);
  40208. private _updatePointerPosition;
  40209. private _processPointerMove;
  40210. private _setRayOnPointerInfo;
  40211. private _checkPrePointerObservable;
  40212. /**
  40213. * Use this method to simulate a pointer move on a mesh
  40214. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40215. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40216. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40217. */
  40218. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40219. /**
  40220. * Use this method to simulate a pointer down on a mesh
  40221. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40222. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40223. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40224. */
  40225. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40226. private _processPointerDown;
  40227. /** @hidden */
  40228. _isPointerSwiping(): boolean;
  40229. /**
  40230. * Use this method to simulate a pointer up on a mesh
  40231. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40232. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40233. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40234. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40235. */
  40236. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40237. private _processPointerUp;
  40238. /**
  40239. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40240. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40241. * @returns true if the pointer was captured
  40242. */
  40243. isPointerCaptured(pointerId?: number): boolean;
  40244. /**
  40245. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40246. * @param attachUp defines if you want to attach events to pointerup
  40247. * @param attachDown defines if you want to attach events to pointerdown
  40248. * @param attachMove defines if you want to attach events to pointermove
  40249. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40250. */
  40251. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40252. /**
  40253. * Detaches all event handlers
  40254. */
  40255. detachControl(): void;
  40256. /**
  40257. * Force the value of meshUnderPointer
  40258. * @param mesh defines the mesh to use
  40259. */
  40260. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40261. /**
  40262. * Gets the mesh under the pointer
  40263. * @returns a Mesh or null if no mesh is under the pointer
  40264. */
  40265. getPointerOverMesh(): Nullable<AbstractMesh>;
  40266. }
  40267. }
  40268. declare module "babylonjs/Animations/animationGroup" {
  40269. import { Animatable } from "babylonjs/Animations/animatable";
  40270. import { Animation } from "babylonjs/Animations/animation";
  40271. import { Scene, IDisposable } from "babylonjs/scene";
  40272. import { Observable } from "babylonjs/Misc/observable";
  40273. import { Nullable } from "babylonjs/types";
  40274. import "babylonjs/Animations/animatable";
  40275. /**
  40276. * This class defines the direct association between an animation and a target
  40277. */
  40278. export class TargetedAnimation {
  40279. /**
  40280. * Animation to perform
  40281. */
  40282. animation: Animation;
  40283. /**
  40284. * Target to animate
  40285. */
  40286. target: any;
  40287. /**
  40288. * Returns the string "TargetedAnimation"
  40289. * @returns "TargetedAnimation"
  40290. */
  40291. getClassName(): string;
  40292. /**
  40293. * Serialize the object
  40294. * @returns the JSON object representing the current entity
  40295. */
  40296. serialize(): any;
  40297. }
  40298. /**
  40299. * Use this class to create coordinated animations on multiple targets
  40300. */
  40301. export class AnimationGroup implements IDisposable {
  40302. /** The name of the animation group */
  40303. name: string;
  40304. private _scene;
  40305. private _targetedAnimations;
  40306. private _animatables;
  40307. private _from;
  40308. private _to;
  40309. private _isStarted;
  40310. private _isPaused;
  40311. private _speedRatio;
  40312. private _loopAnimation;
  40313. private _isAdditive;
  40314. /**
  40315. * Gets or sets the unique id of the node
  40316. */
  40317. uniqueId: number;
  40318. /**
  40319. * This observable will notify when one animation have ended
  40320. */
  40321. onAnimationEndObservable: Observable<TargetedAnimation>;
  40322. /**
  40323. * Observer raised when one animation loops
  40324. */
  40325. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40326. /**
  40327. * Observer raised when all animations have looped
  40328. */
  40329. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40330. /**
  40331. * This observable will notify when all animations have ended.
  40332. */
  40333. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40334. /**
  40335. * This observable will notify when all animations have paused.
  40336. */
  40337. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40338. /**
  40339. * This observable will notify when all animations are playing.
  40340. */
  40341. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40342. /**
  40343. * Gets the first frame
  40344. */
  40345. get from(): number;
  40346. /**
  40347. * Gets the last frame
  40348. */
  40349. get to(): number;
  40350. /**
  40351. * Define if the animations are started
  40352. */
  40353. get isStarted(): boolean;
  40354. /**
  40355. * Gets a value indicating that the current group is playing
  40356. */
  40357. get isPlaying(): boolean;
  40358. /**
  40359. * Gets or sets the speed ratio to use for all animations
  40360. */
  40361. get speedRatio(): number;
  40362. /**
  40363. * Gets or sets the speed ratio to use for all animations
  40364. */
  40365. set speedRatio(value: number);
  40366. /**
  40367. * Gets or sets if all animations should loop or not
  40368. */
  40369. get loopAnimation(): boolean;
  40370. set loopAnimation(value: boolean);
  40371. /**
  40372. * Gets or sets if all animations should be evaluated additively
  40373. */
  40374. get isAdditive(): boolean;
  40375. set isAdditive(value: boolean);
  40376. /**
  40377. * Gets the targeted animations for this animation group
  40378. */
  40379. get targetedAnimations(): Array<TargetedAnimation>;
  40380. /**
  40381. * returning the list of animatables controlled by this animation group.
  40382. */
  40383. get animatables(): Array<Animatable>;
  40384. /**
  40385. * Gets the list of target animations
  40386. */
  40387. get children(): TargetedAnimation[];
  40388. /**
  40389. * Instantiates a new Animation Group.
  40390. * This helps managing several animations at once.
  40391. * @see https://doc.babylonjs.com/how_to/group
  40392. * @param name Defines the name of the group
  40393. * @param scene Defines the scene the group belongs to
  40394. */
  40395. constructor(
  40396. /** The name of the animation group */
  40397. name: string, scene?: Nullable<Scene>);
  40398. /**
  40399. * Add an animation (with its target) in the group
  40400. * @param animation defines the animation we want to add
  40401. * @param target defines the target of the animation
  40402. * @returns the TargetedAnimation object
  40403. */
  40404. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40405. /**
  40406. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40407. * It can add constant keys at begin or end
  40408. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40409. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40410. * @returns the animation group
  40411. */
  40412. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40413. private _animationLoopCount;
  40414. private _animationLoopFlags;
  40415. private _processLoop;
  40416. /**
  40417. * Start all animations on given targets
  40418. * @param loop defines if animations must loop
  40419. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40420. * @param from defines the from key (optional)
  40421. * @param to defines the to key (optional)
  40422. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40423. * @returns the current animation group
  40424. */
  40425. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40426. /**
  40427. * Pause all animations
  40428. * @returns the animation group
  40429. */
  40430. pause(): AnimationGroup;
  40431. /**
  40432. * Play all animations to initial state
  40433. * This function will start() the animations if they were not started or will restart() them if they were paused
  40434. * @param loop defines if animations must loop
  40435. * @returns the animation group
  40436. */
  40437. play(loop?: boolean): AnimationGroup;
  40438. /**
  40439. * Reset all animations to initial state
  40440. * @returns the animation group
  40441. */
  40442. reset(): AnimationGroup;
  40443. /**
  40444. * Restart animations from key 0
  40445. * @returns the animation group
  40446. */
  40447. restart(): AnimationGroup;
  40448. /**
  40449. * Stop all animations
  40450. * @returns the animation group
  40451. */
  40452. stop(): AnimationGroup;
  40453. /**
  40454. * Set animation weight for all animatables
  40455. * @param weight defines the weight to use
  40456. * @return the animationGroup
  40457. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40458. */
  40459. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40460. /**
  40461. * Synchronize and normalize all animatables with a source animatable
  40462. * @param root defines the root animatable to synchronize with
  40463. * @return the animationGroup
  40464. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40465. */
  40466. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40467. /**
  40468. * Goes to a specific frame in this animation group
  40469. * @param frame the frame number to go to
  40470. * @return the animationGroup
  40471. */
  40472. goToFrame(frame: number): AnimationGroup;
  40473. /**
  40474. * Dispose all associated resources
  40475. */
  40476. dispose(): void;
  40477. private _checkAnimationGroupEnded;
  40478. /**
  40479. * Clone the current animation group and returns a copy
  40480. * @param newName defines the name of the new group
  40481. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40482. * @returns the new aniamtion group
  40483. */
  40484. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40485. /**
  40486. * Serializes the animationGroup to an object
  40487. * @returns Serialized object
  40488. */
  40489. serialize(): any;
  40490. /**
  40491. * Returns a new AnimationGroup object parsed from the source provided.
  40492. * @param parsedAnimationGroup defines the source
  40493. * @param scene defines the scene that will receive the animationGroup
  40494. * @returns a new AnimationGroup
  40495. */
  40496. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40497. /**
  40498. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40499. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40500. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40501. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40502. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40503. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40504. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40505. */
  40506. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40507. /**
  40508. * Returns the string "AnimationGroup"
  40509. * @returns "AnimationGroup"
  40510. */
  40511. getClassName(): string;
  40512. /**
  40513. * Creates a detailled string about the object
  40514. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40515. * @returns a string representing the object
  40516. */
  40517. toString(fullDetails?: boolean): string;
  40518. }
  40519. }
  40520. declare module "babylonjs/scene" {
  40521. import { Nullable } from "babylonjs/types";
  40522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40523. import { Observable } from "babylonjs/Misc/observable";
  40524. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40525. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40526. import { Geometry } from "babylonjs/Meshes/geometry";
  40527. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40530. import { Mesh } from "babylonjs/Meshes/mesh";
  40531. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40532. import { Bone } from "babylonjs/Bones/bone";
  40533. import { Skeleton } from "babylonjs/Bones/skeleton";
  40534. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40535. import { Camera } from "babylonjs/Cameras/camera";
  40536. import { AbstractScene } from "babylonjs/abstractScene";
  40537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40538. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40539. import { Material } from "babylonjs/Materials/material";
  40540. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40541. import { Effect } from "babylonjs/Materials/effect";
  40542. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40543. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40544. import { Light } from "babylonjs/Lights/light";
  40545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40546. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40547. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40548. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40549. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40550. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40551. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40552. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40553. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40554. import { Engine } from "babylonjs/Engines/engine";
  40555. import { Node } from "babylonjs/node";
  40556. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40557. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40558. import { WebRequest } from "babylonjs/Misc/webRequest";
  40559. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40560. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40561. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40562. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40563. import { Plane } from "babylonjs/Maths/math.plane";
  40564. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40565. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40566. import { Ray } from "babylonjs/Culling/ray";
  40567. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40568. import { Animation } from "babylonjs/Animations/animation";
  40569. import { Animatable } from "babylonjs/Animations/animatable";
  40570. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40571. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40572. import { Collider } from "babylonjs/Collisions/collider";
  40573. /**
  40574. * Define an interface for all classes that will hold resources
  40575. */
  40576. export interface IDisposable {
  40577. /**
  40578. * Releases all held resources
  40579. */
  40580. dispose(): void;
  40581. }
  40582. /** Interface defining initialization parameters for Scene class */
  40583. export interface SceneOptions {
  40584. /**
  40585. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40586. * It will improve performance when the number of geometries becomes important.
  40587. */
  40588. useGeometryUniqueIdsMap?: boolean;
  40589. /**
  40590. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40591. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40592. */
  40593. useMaterialMeshMap?: boolean;
  40594. /**
  40595. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40596. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40597. */
  40598. useClonedMeshMap?: boolean;
  40599. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40600. virtual?: boolean;
  40601. }
  40602. /**
  40603. * Represents a scene to be rendered by the engine.
  40604. * @see https://doc.babylonjs.com/features/scene
  40605. */
  40606. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40607. /** The fog is deactivated */
  40608. static readonly FOGMODE_NONE: number;
  40609. /** The fog density is following an exponential function */
  40610. static readonly FOGMODE_EXP: number;
  40611. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40612. static readonly FOGMODE_EXP2: number;
  40613. /** The fog density is following a linear function. */
  40614. static readonly FOGMODE_LINEAR: number;
  40615. /**
  40616. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40617. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40618. */
  40619. static MinDeltaTime: number;
  40620. /**
  40621. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40623. */
  40624. static MaxDeltaTime: number;
  40625. /**
  40626. * Factory used to create the default material.
  40627. * @param name The name of the material to create
  40628. * @param scene The scene to create the material for
  40629. * @returns The default material
  40630. */
  40631. static DefaultMaterialFactory(scene: Scene): Material;
  40632. /**
  40633. * Factory used to create the a collision coordinator.
  40634. * @returns The collision coordinator
  40635. */
  40636. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40637. /** @hidden */
  40638. _inputManager: InputManager;
  40639. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40640. cameraToUseForPointers: Nullable<Camera>;
  40641. /** @hidden */
  40642. readonly _isScene: boolean;
  40643. /** @hidden */
  40644. _blockEntityCollection: boolean;
  40645. /**
  40646. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40647. */
  40648. autoClear: boolean;
  40649. /**
  40650. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40651. */
  40652. autoClearDepthAndStencil: boolean;
  40653. /**
  40654. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40655. */
  40656. clearColor: Color4;
  40657. /**
  40658. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40659. */
  40660. ambientColor: Color3;
  40661. /**
  40662. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40663. * It should only be one of the following (if not the default embedded one):
  40664. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40665. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40666. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40667. * The material properties need to be setup according to the type of texture in use.
  40668. */
  40669. environmentBRDFTexture: BaseTexture;
  40670. /** @hidden */
  40671. protected _environmentTexture: Nullable<BaseTexture>;
  40672. /**
  40673. * Texture used in all pbr material as the reflection texture.
  40674. * As in the majority of the scene they are the same (exception for multi room and so on),
  40675. * this is easier to reference from here than from all the materials.
  40676. */
  40677. get environmentTexture(): Nullable<BaseTexture>;
  40678. /**
  40679. * Texture used in all pbr material as the reflection texture.
  40680. * As in the majority of the scene they are the same (exception for multi room and so on),
  40681. * this is easier to set here than in all the materials.
  40682. */
  40683. set environmentTexture(value: Nullable<BaseTexture>);
  40684. /** @hidden */
  40685. protected _environmentIntensity: number;
  40686. /**
  40687. * Intensity of the environment in all pbr material.
  40688. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40689. * As in the majority of the scene they are the same (exception for multi room and so on),
  40690. * this is easier to reference from here than from all the materials.
  40691. */
  40692. get environmentIntensity(): number;
  40693. /**
  40694. * Intensity of the environment in all pbr material.
  40695. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40696. * As in the majority of the scene they are the same (exception for multi room and so on),
  40697. * this is easier to set here than in all the materials.
  40698. */
  40699. set environmentIntensity(value: number);
  40700. /** @hidden */
  40701. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40702. /**
  40703. * Default image processing configuration used either in the rendering
  40704. * Forward main pass or through the imageProcessingPostProcess if present.
  40705. * As in the majority of the scene they are the same (exception for multi camera),
  40706. * this is easier to reference from here than from all the materials and post process.
  40707. *
  40708. * No setter as we it is a shared configuration, you can set the values instead.
  40709. */
  40710. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40711. private _forceWireframe;
  40712. /**
  40713. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40714. */
  40715. set forceWireframe(value: boolean);
  40716. get forceWireframe(): boolean;
  40717. private _skipFrustumClipping;
  40718. /**
  40719. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40720. */
  40721. set skipFrustumClipping(value: boolean);
  40722. get skipFrustumClipping(): boolean;
  40723. private _forcePointsCloud;
  40724. /**
  40725. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40726. */
  40727. set forcePointsCloud(value: boolean);
  40728. get forcePointsCloud(): boolean;
  40729. /**
  40730. * Gets or sets the active clipplane 1
  40731. */
  40732. clipPlane: Nullable<Plane>;
  40733. /**
  40734. * Gets or sets the active clipplane 2
  40735. */
  40736. clipPlane2: Nullable<Plane>;
  40737. /**
  40738. * Gets or sets the active clipplane 3
  40739. */
  40740. clipPlane3: Nullable<Plane>;
  40741. /**
  40742. * Gets or sets the active clipplane 4
  40743. */
  40744. clipPlane4: Nullable<Plane>;
  40745. /**
  40746. * Gets or sets the active clipplane 5
  40747. */
  40748. clipPlane5: Nullable<Plane>;
  40749. /**
  40750. * Gets or sets the active clipplane 6
  40751. */
  40752. clipPlane6: Nullable<Plane>;
  40753. /**
  40754. * Gets or sets a boolean indicating if animations are enabled
  40755. */
  40756. animationsEnabled: boolean;
  40757. private _animationPropertiesOverride;
  40758. /**
  40759. * Gets or sets the animation properties override
  40760. */
  40761. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40762. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40763. /**
  40764. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40765. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40766. */
  40767. useConstantAnimationDeltaTime: boolean;
  40768. /**
  40769. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40770. * Please note that it requires to run a ray cast through the scene on every frame
  40771. */
  40772. constantlyUpdateMeshUnderPointer: boolean;
  40773. /**
  40774. * Defines the HTML cursor to use when hovering over interactive elements
  40775. */
  40776. hoverCursor: string;
  40777. /**
  40778. * Defines the HTML default cursor to use (empty by default)
  40779. */
  40780. defaultCursor: string;
  40781. /**
  40782. * Defines whether cursors are handled by the scene.
  40783. */
  40784. doNotHandleCursors: boolean;
  40785. /**
  40786. * This is used to call preventDefault() on pointer down
  40787. * in order to block unwanted artifacts like system double clicks
  40788. */
  40789. preventDefaultOnPointerDown: boolean;
  40790. /**
  40791. * This is used to call preventDefault() on pointer up
  40792. * in order to block unwanted artifacts like system double clicks
  40793. */
  40794. preventDefaultOnPointerUp: boolean;
  40795. /**
  40796. * Gets or sets user defined metadata
  40797. */
  40798. metadata: any;
  40799. /**
  40800. * For internal use only. Please do not use.
  40801. */
  40802. reservedDataStore: any;
  40803. /**
  40804. * Gets the name of the plugin used to load this scene (null by default)
  40805. */
  40806. loadingPluginName: string;
  40807. /**
  40808. * Use this array to add regular expressions used to disable offline support for specific urls
  40809. */
  40810. disableOfflineSupportExceptionRules: RegExp[];
  40811. /**
  40812. * An event triggered when the scene is disposed.
  40813. */
  40814. onDisposeObservable: Observable<Scene>;
  40815. private _onDisposeObserver;
  40816. /** Sets a function to be executed when this scene is disposed. */
  40817. set onDispose(callback: () => void);
  40818. /**
  40819. * An event triggered before rendering the scene (right after animations and physics)
  40820. */
  40821. onBeforeRenderObservable: Observable<Scene>;
  40822. private _onBeforeRenderObserver;
  40823. /** Sets a function to be executed before rendering this scene */
  40824. set beforeRender(callback: Nullable<() => void>);
  40825. /**
  40826. * An event triggered after rendering the scene
  40827. */
  40828. onAfterRenderObservable: Observable<Scene>;
  40829. /**
  40830. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40831. */
  40832. onAfterRenderCameraObservable: Observable<Camera>;
  40833. private _onAfterRenderObserver;
  40834. /** Sets a function to be executed after rendering this scene */
  40835. set afterRender(callback: Nullable<() => void>);
  40836. /**
  40837. * An event triggered before animating the scene
  40838. */
  40839. onBeforeAnimationsObservable: Observable<Scene>;
  40840. /**
  40841. * An event triggered after animations processing
  40842. */
  40843. onAfterAnimationsObservable: Observable<Scene>;
  40844. /**
  40845. * An event triggered before draw calls are ready to be sent
  40846. */
  40847. onBeforeDrawPhaseObservable: Observable<Scene>;
  40848. /**
  40849. * An event triggered after draw calls have been sent
  40850. */
  40851. onAfterDrawPhaseObservable: Observable<Scene>;
  40852. /**
  40853. * An event triggered when the scene is ready
  40854. */
  40855. onReadyObservable: Observable<Scene>;
  40856. /**
  40857. * An event triggered before rendering a camera
  40858. */
  40859. onBeforeCameraRenderObservable: Observable<Camera>;
  40860. private _onBeforeCameraRenderObserver;
  40861. /** Sets a function to be executed before rendering a camera*/
  40862. set beforeCameraRender(callback: () => void);
  40863. /**
  40864. * An event triggered after rendering a camera
  40865. */
  40866. onAfterCameraRenderObservable: Observable<Camera>;
  40867. private _onAfterCameraRenderObserver;
  40868. /** Sets a function to be executed after rendering a camera*/
  40869. set afterCameraRender(callback: () => void);
  40870. /**
  40871. * An event triggered when active meshes evaluation is about to start
  40872. */
  40873. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40874. /**
  40875. * An event triggered when active meshes evaluation is done
  40876. */
  40877. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40878. /**
  40879. * An event triggered when particles rendering is about to start
  40880. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40881. */
  40882. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40883. /**
  40884. * An event triggered when particles rendering is done
  40885. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40886. */
  40887. onAfterParticlesRenderingObservable: Observable<Scene>;
  40888. /**
  40889. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40890. */
  40891. onDataLoadedObservable: Observable<Scene>;
  40892. /**
  40893. * An event triggered when a camera is created
  40894. */
  40895. onNewCameraAddedObservable: Observable<Camera>;
  40896. /**
  40897. * An event triggered when a camera is removed
  40898. */
  40899. onCameraRemovedObservable: Observable<Camera>;
  40900. /**
  40901. * An event triggered when a light is created
  40902. */
  40903. onNewLightAddedObservable: Observable<Light>;
  40904. /**
  40905. * An event triggered when a light is removed
  40906. */
  40907. onLightRemovedObservable: Observable<Light>;
  40908. /**
  40909. * An event triggered when a geometry is created
  40910. */
  40911. onNewGeometryAddedObservable: Observable<Geometry>;
  40912. /**
  40913. * An event triggered when a geometry is removed
  40914. */
  40915. onGeometryRemovedObservable: Observable<Geometry>;
  40916. /**
  40917. * An event triggered when a transform node is created
  40918. */
  40919. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40920. /**
  40921. * An event triggered when a transform node is removed
  40922. */
  40923. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40924. /**
  40925. * An event triggered when a mesh is created
  40926. */
  40927. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40928. /**
  40929. * An event triggered when a mesh is removed
  40930. */
  40931. onMeshRemovedObservable: Observable<AbstractMesh>;
  40932. /**
  40933. * An event triggered when a skeleton is created
  40934. */
  40935. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40936. /**
  40937. * An event triggered when a skeleton is removed
  40938. */
  40939. onSkeletonRemovedObservable: Observable<Skeleton>;
  40940. /**
  40941. * An event triggered when a material is created
  40942. */
  40943. onNewMaterialAddedObservable: Observable<Material>;
  40944. /**
  40945. * An event triggered when a material is removed
  40946. */
  40947. onMaterialRemovedObservable: Observable<Material>;
  40948. /**
  40949. * An event triggered when a texture is created
  40950. */
  40951. onNewTextureAddedObservable: Observable<BaseTexture>;
  40952. /**
  40953. * An event triggered when a texture is removed
  40954. */
  40955. onTextureRemovedObservable: Observable<BaseTexture>;
  40956. /**
  40957. * An event triggered when render targets are about to be rendered
  40958. * Can happen multiple times per frame.
  40959. */
  40960. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40961. /**
  40962. * An event triggered when render targets were rendered.
  40963. * Can happen multiple times per frame.
  40964. */
  40965. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40966. /**
  40967. * An event triggered before calculating deterministic simulation step
  40968. */
  40969. onBeforeStepObservable: Observable<Scene>;
  40970. /**
  40971. * An event triggered after calculating deterministic simulation step
  40972. */
  40973. onAfterStepObservable: Observable<Scene>;
  40974. /**
  40975. * An event triggered when the activeCamera property is updated
  40976. */
  40977. onActiveCameraChanged: Observable<Scene>;
  40978. /**
  40979. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40980. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40981. * 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)
  40982. */
  40983. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40984. /**
  40985. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40986. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40987. * 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)
  40988. */
  40989. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40990. /**
  40991. * This Observable will when a mesh has been imported into the scene.
  40992. */
  40993. onMeshImportedObservable: Observable<AbstractMesh>;
  40994. /**
  40995. * This Observable will when an animation file has been imported into the scene.
  40996. */
  40997. onAnimationFileImportedObservable: Observable<Scene>;
  40998. /**
  40999. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41000. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41001. */
  41002. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41003. /** @hidden */
  41004. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41005. /**
  41006. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41007. */
  41008. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41009. /**
  41010. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41011. */
  41012. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41013. /**
  41014. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41015. */
  41016. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41017. /** Callback called when a pointer move is detected */
  41018. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41019. /** Callback called when a pointer down is detected */
  41020. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41021. /** Callback called when a pointer up is detected */
  41022. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41023. /** Callback called when a pointer pick is detected */
  41024. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41025. /**
  41026. * 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).
  41027. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41028. */
  41029. onPrePointerObservable: Observable<PointerInfoPre>;
  41030. /**
  41031. * Observable event triggered each time an input event is received from the rendering canvas
  41032. */
  41033. onPointerObservable: Observable<PointerInfo>;
  41034. /**
  41035. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41036. */
  41037. get unTranslatedPointer(): Vector2;
  41038. /**
  41039. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41040. */
  41041. static get DragMovementThreshold(): number;
  41042. static set DragMovementThreshold(value: number);
  41043. /**
  41044. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41045. */
  41046. static get LongPressDelay(): number;
  41047. static set LongPressDelay(value: number);
  41048. /**
  41049. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41050. */
  41051. static get DoubleClickDelay(): number;
  41052. static set DoubleClickDelay(value: number);
  41053. /** If you need to check double click without raising a single click at first click, enable this flag */
  41054. static get ExclusiveDoubleClickMode(): boolean;
  41055. static set ExclusiveDoubleClickMode(value: boolean);
  41056. /** @hidden */
  41057. _mirroredCameraPosition: Nullable<Vector3>;
  41058. /**
  41059. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41060. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41061. */
  41062. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41063. /**
  41064. * Observable event triggered each time an keyboard event is received from the hosting window
  41065. */
  41066. onKeyboardObservable: Observable<KeyboardInfo>;
  41067. private _useRightHandedSystem;
  41068. /**
  41069. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41070. */
  41071. set useRightHandedSystem(value: boolean);
  41072. get useRightHandedSystem(): boolean;
  41073. private _timeAccumulator;
  41074. private _currentStepId;
  41075. private _currentInternalStep;
  41076. /**
  41077. * Sets the step Id used by deterministic lock step
  41078. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41079. * @param newStepId defines the step Id
  41080. */
  41081. setStepId(newStepId: number): void;
  41082. /**
  41083. * Gets the step Id used by deterministic lock step
  41084. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41085. * @returns the step Id
  41086. */
  41087. getStepId(): number;
  41088. /**
  41089. * Gets the internal step used by deterministic lock step
  41090. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41091. * @returns the internal step
  41092. */
  41093. getInternalStep(): number;
  41094. private _fogEnabled;
  41095. /**
  41096. * Gets or sets a boolean indicating if fog is enabled on this scene
  41097. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41098. * (Default is true)
  41099. */
  41100. set fogEnabled(value: boolean);
  41101. get fogEnabled(): boolean;
  41102. private _fogMode;
  41103. /**
  41104. * Gets or sets the fog mode to use
  41105. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41106. * | mode | value |
  41107. * | --- | --- |
  41108. * | FOGMODE_NONE | 0 |
  41109. * | FOGMODE_EXP | 1 |
  41110. * | FOGMODE_EXP2 | 2 |
  41111. * | FOGMODE_LINEAR | 3 |
  41112. */
  41113. set fogMode(value: number);
  41114. get fogMode(): number;
  41115. /**
  41116. * Gets or sets the fog color to use
  41117. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41118. * (Default is Color3(0.2, 0.2, 0.3))
  41119. */
  41120. fogColor: Color3;
  41121. /**
  41122. * Gets or sets the fog density to use
  41123. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41124. * (Default is 0.1)
  41125. */
  41126. fogDensity: number;
  41127. /**
  41128. * Gets or sets the fog start distance to use
  41129. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41130. * (Default is 0)
  41131. */
  41132. fogStart: number;
  41133. /**
  41134. * Gets or sets the fog end distance to use
  41135. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41136. * (Default is 1000)
  41137. */
  41138. fogEnd: number;
  41139. /**
  41140. * Flag indicating that the frame buffer binding is handled by another component
  41141. */
  41142. prePass: boolean;
  41143. private _shadowsEnabled;
  41144. /**
  41145. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41146. */
  41147. set shadowsEnabled(value: boolean);
  41148. get shadowsEnabled(): boolean;
  41149. private _lightsEnabled;
  41150. /**
  41151. * Gets or sets a boolean indicating if lights are enabled on this scene
  41152. */
  41153. set lightsEnabled(value: boolean);
  41154. get lightsEnabled(): boolean;
  41155. /** All of the active cameras added to this scene. */
  41156. activeCameras: Camera[];
  41157. /** @hidden */
  41158. _activeCamera: Nullable<Camera>;
  41159. /** Gets or sets the current active camera */
  41160. get activeCamera(): Nullable<Camera>;
  41161. set activeCamera(value: Nullable<Camera>);
  41162. private _defaultMaterial;
  41163. /** The default material used on meshes when no material is affected */
  41164. get defaultMaterial(): Material;
  41165. /** The default material used on meshes when no material is affected */
  41166. set defaultMaterial(value: Material);
  41167. private _texturesEnabled;
  41168. /**
  41169. * Gets or sets a boolean indicating if textures are enabled on this scene
  41170. */
  41171. set texturesEnabled(value: boolean);
  41172. get texturesEnabled(): boolean;
  41173. /**
  41174. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41175. */
  41176. physicsEnabled: boolean;
  41177. /**
  41178. * Gets or sets a boolean indicating if particles are enabled on this scene
  41179. */
  41180. particlesEnabled: boolean;
  41181. /**
  41182. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41183. */
  41184. spritesEnabled: boolean;
  41185. private _skeletonsEnabled;
  41186. /**
  41187. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41188. */
  41189. set skeletonsEnabled(value: boolean);
  41190. get skeletonsEnabled(): boolean;
  41191. /**
  41192. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41193. */
  41194. lensFlaresEnabled: boolean;
  41195. /**
  41196. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41197. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41198. */
  41199. collisionsEnabled: boolean;
  41200. private _collisionCoordinator;
  41201. /** @hidden */
  41202. get collisionCoordinator(): ICollisionCoordinator;
  41203. /**
  41204. * Defines the gravity applied to this scene (used only for collisions)
  41205. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41206. */
  41207. gravity: Vector3;
  41208. /**
  41209. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41210. */
  41211. postProcessesEnabled: boolean;
  41212. /**
  41213. * The list of postprocesses added to the scene
  41214. */
  41215. postProcesses: PostProcess[];
  41216. /**
  41217. * Gets the current postprocess manager
  41218. */
  41219. postProcessManager: PostProcessManager;
  41220. /**
  41221. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41222. */
  41223. renderTargetsEnabled: boolean;
  41224. /**
  41225. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41226. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41227. */
  41228. dumpNextRenderTargets: boolean;
  41229. /**
  41230. * The list of user defined render targets added to the scene
  41231. */
  41232. customRenderTargets: RenderTargetTexture[];
  41233. /**
  41234. * Defines if texture loading must be delayed
  41235. * If true, textures will only be loaded when they need to be rendered
  41236. */
  41237. useDelayedTextureLoading: boolean;
  41238. /**
  41239. * Gets the list of meshes imported to the scene through SceneLoader
  41240. */
  41241. importedMeshesFiles: String[];
  41242. /**
  41243. * Gets or sets a boolean indicating if probes are enabled on this scene
  41244. */
  41245. probesEnabled: boolean;
  41246. /**
  41247. * Gets or sets the current offline provider to use to store scene data
  41248. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41249. */
  41250. offlineProvider: IOfflineProvider;
  41251. /**
  41252. * Gets or sets the action manager associated with the scene
  41253. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41254. */
  41255. actionManager: AbstractActionManager;
  41256. private _meshesForIntersections;
  41257. /**
  41258. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41259. */
  41260. proceduralTexturesEnabled: boolean;
  41261. private _engine;
  41262. private _totalVertices;
  41263. /** @hidden */
  41264. _activeIndices: PerfCounter;
  41265. /** @hidden */
  41266. _activeParticles: PerfCounter;
  41267. /** @hidden */
  41268. _activeBones: PerfCounter;
  41269. private _animationRatio;
  41270. /** @hidden */
  41271. _animationTimeLast: number;
  41272. /** @hidden */
  41273. _animationTime: number;
  41274. /**
  41275. * Gets or sets a general scale for animation speed
  41276. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41277. */
  41278. animationTimeScale: number;
  41279. /** @hidden */
  41280. _cachedMaterial: Nullable<Material>;
  41281. /** @hidden */
  41282. _cachedEffect: Nullable<Effect>;
  41283. /** @hidden */
  41284. _cachedVisibility: Nullable<number>;
  41285. private _renderId;
  41286. private _frameId;
  41287. private _executeWhenReadyTimeoutId;
  41288. private _intermediateRendering;
  41289. private _viewUpdateFlag;
  41290. private _projectionUpdateFlag;
  41291. /** @hidden */
  41292. _toBeDisposed: Nullable<IDisposable>[];
  41293. private _activeRequests;
  41294. /** @hidden */
  41295. _pendingData: any[];
  41296. private _isDisposed;
  41297. /**
  41298. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41299. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41300. */
  41301. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41302. private _activeMeshes;
  41303. private _processedMaterials;
  41304. private _renderTargets;
  41305. /** @hidden */
  41306. _activeParticleSystems: SmartArray<IParticleSystem>;
  41307. private _activeSkeletons;
  41308. private _softwareSkinnedMeshes;
  41309. private _renderingManager;
  41310. /** @hidden */
  41311. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41312. private _transformMatrix;
  41313. private _sceneUbo;
  41314. /** @hidden */
  41315. _viewMatrix: Matrix;
  41316. private _projectionMatrix;
  41317. /** @hidden */
  41318. _forcedViewPosition: Nullable<Vector3>;
  41319. /** @hidden */
  41320. _frustumPlanes: Plane[];
  41321. /**
  41322. * Gets the list of frustum planes (built from the active camera)
  41323. */
  41324. get frustumPlanes(): Plane[];
  41325. /**
  41326. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41327. * This is useful if there are more lights that the maximum simulteanous authorized
  41328. */
  41329. requireLightSorting: boolean;
  41330. /** @hidden */
  41331. readonly useMaterialMeshMap: boolean;
  41332. /** @hidden */
  41333. readonly useClonedMeshMap: boolean;
  41334. private _externalData;
  41335. private _uid;
  41336. /**
  41337. * @hidden
  41338. * Backing store of defined scene components.
  41339. */
  41340. _components: ISceneComponent[];
  41341. /**
  41342. * @hidden
  41343. * Backing store of defined scene components.
  41344. */
  41345. _serializableComponents: ISceneSerializableComponent[];
  41346. /**
  41347. * List of components to register on the next registration step.
  41348. */
  41349. private _transientComponents;
  41350. /**
  41351. * Registers the transient components if needed.
  41352. */
  41353. private _registerTransientComponents;
  41354. /**
  41355. * @hidden
  41356. * Add a component to the scene.
  41357. * Note that the ccomponent could be registered on th next frame if this is called after
  41358. * the register component stage.
  41359. * @param component Defines the component to add to the scene
  41360. */
  41361. _addComponent(component: ISceneComponent): void;
  41362. /**
  41363. * @hidden
  41364. * Gets a component from the scene.
  41365. * @param name defines the name of the component to retrieve
  41366. * @returns the component or null if not present
  41367. */
  41368. _getComponent(name: string): Nullable<ISceneComponent>;
  41369. /**
  41370. * @hidden
  41371. * Defines the actions happening before camera updates.
  41372. */
  41373. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41374. /**
  41375. * @hidden
  41376. * Defines the actions happening before clear the canvas.
  41377. */
  41378. _beforeClearStage: Stage<SimpleStageAction>;
  41379. /**
  41380. * @hidden
  41381. * Defines the actions when collecting render targets for the frame.
  41382. */
  41383. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41384. /**
  41385. * @hidden
  41386. * Defines the actions happening for one camera in the frame.
  41387. */
  41388. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41389. /**
  41390. * @hidden
  41391. * Defines the actions happening during the per mesh ready checks.
  41392. */
  41393. _isReadyForMeshStage: Stage<MeshStageAction>;
  41394. /**
  41395. * @hidden
  41396. * Defines the actions happening before evaluate active mesh checks.
  41397. */
  41398. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41399. /**
  41400. * @hidden
  41401. * Defines the actions happening during the evaluate sub mesh checks.
  41402. */
  41403. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41404. /**
  41405. * @hidden
  41406. * Defines the actions happening during the active mesh stage.
  41407. */
  41408. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41409. /**
  41410. * @hidden
  41411. * Defines the actions happening during the per camera render target step.
  41412. */
  41413. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41414. /**
  41415. * @hidden
  41416. * Defines the actions happening just before the active camera is drawing.
  41417. */
  41418. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41419. /**
  41420. * @hidden
  41421. * Defines the actions happening just before a render target is drawing.
  41422. */
  41423. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41424. /**
  41425. * @hidden
  41426. * Defines the actions happening just before a rendering group is drawing.
  41427. */
  41428. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41429. /**
  41430. * @hidden
  41431. * Defines the actions happening just before a mesh is drawing.
  41432. */
  41433. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41434. /**
  41435. * @hidden
  41436. * Defines the actions happening just after a mesh has been drawn.
  41437. */
  41438. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41439. /**
  41440. * @hidden
  41441. * Defines the actions happening just after a rendering group has been drawn.
  41442. */
  41443. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41444. /**
  41445. * @hidden
  41446. * Defines the actions happening just after the active camera has been drawn.
  41447. */
  41448. _afterCameraDrawStage: Stage<CameraStageAction>;
  41449. /**
  41450. * @hidden
  41451. * Defines the actions happening just after a render target has been drawn.
  41452. */
  41453. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41454. /**
  41455. * @hidden
  41456. * Defines the actions happening just after rendering all cameras and computing intersections.
  41457. */
  41458. _afterRenderStage: Stage<SimpleStageAction>;
  41459. /**
  41460. * @hidden
  41461. * Defines the actions happening when a pointer move event happens.
  41462. */
  41463. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41464. /**
  41465. * @hidden
  41466. * Defines the actions happening when a pointer down event happens.
  41467. */
  41468. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41469. /**
  41470. * @hidden
  41471. * Defines the actions happening when a pointer up event happens.
  41472. */
  41473. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41474. /**
  41475. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41476. */
  41477. private geometriesByUniqueId;
  41478. /**
  41479. * Creates a new Scene
  41480. * @param engine defines the engine to use to render this scene
  41481. * @param options defines the scene options
  41482. */
  41483. constructor(engine: Engine, options?: SceneOptions);
  41484. /**
  41485. * Gets a string idenfifying the name of the class
  41486. * @returns "Scene" string
  41487. */
  41488. getClassName(): string;
  41489. private _defaultMeshCandidates;
  41490. /**
  41491. * @hidden
  41492. */
  41493. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41494. private _defaultSubMeshCandidates;
  41495. /**
  41496. * @hidden
  41497. */
  41498. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41499. /**
  41500. * Sets the default candidate providers for the scene.
  41501. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41502. * and getCollidingSubMeshCandidates to their default function
  41503. */
  41504. setDefaultCandidateProviders(): void;
  41505. /**
  41506. * Gets the mesh that is currently under the pointer
  41507. */
  41508. get meshUnderPointer(): Nullable<AbstractMesh>;
  41509. /**
  41510. * Gets or sets the current on-screen X position of the pointer
  41511. */
  41512. get pointerX(): number;
  41513. set pointerX(value: number);
  41514. /**
  41515. * Gets or sets the current on-screen Y position of the pointer
  41516. */
  41517. get pointerY(): number;
  41518. set pointerY(value: number);
  41519. /**
  41520. * Gets the cached material (ie. the latest rendered one)
  41521. * @returns the cached material
  41522. */
  41523. getCachedMaterial(): Nullable<Material>;
  41524. /**
  41525. * Gets the cached effect (ie. the latest rendered one)
  41526. * @returns the cached effect
  41527. */
  41528. getCachedEffect(): Nullable<Effect>;
  41529. /**
  41530. * Gets the cached visibility state (ie. the latest rendered one)
  41531. * @returns the cached visibility state
  41532. */
  41533. getCachedVisibility(): Nullable<number>;
  41534. /**
  41535. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41536. * @param material defines the current material
  41537. * @param effect defines the current effect
  41538. * @param visibility defines the current visibility state
  41539. * @returns true if one parameter is not cached
  41540. */
  41541. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41542. /**
  41543. * Gets the engine associated with the scene
  41544. * @returns an Engine
  41545. */
  41546. getEngine(): Engine;
  41547. /**
  41548. * Gets the total number of vertices rendered per frame
  41549. * @returns the total number of vertices rendered per frame
  41550. */
  41551. getTotalVertices(): number;
  41552. /**
  41553. * Gets the performance counter for total vertices
  41554. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41555. */
  41556. get totalVerticesPerfCounter(): PerfCounter;
  41557. /**
  41558. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41559. * @returns the total number of active indices rendered per frame
  41560. */
  41561. getActiveIndices(): number;
  41562. /**
  41563. * Gets the performance counter for active indices
  41564. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41565. */
  41566. get totalActiveIndicesPerfCounter(): PerfCounter;
  41567. /**
  41568. * Gets the total number of active particles rendered per frame
  41569. * @returns the total number of active particles rendered per frame
  41570. */
  41571. getActiveParticles(): number;
  41572. /**
  41573. * Gets the performance counter for active particles
  41574. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41575. */
  41576. get activeParticlesPerfCounter(): PerfCounter;
  41577. /**
  41578. * Gets the total number of active bones rendered per frame
  41579. * @returns the total number of active bones rendered per frame
  41580. */
  41581. getActiveBones(): number;
  41582. /**
  41583. * Gets the performance counter for active bones
  41584. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41585. */
  41586. get activeBonesPerfCounter(): PerfCounter;
  41587. /**
  41588. * Gets the array of active meshes
  41589. * @returns an array of AbstractMesh
  41590. */
  41591. getActiveMeshes(): SmartArray<AbstractMesh>;
  41592. /**
  41593. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41594. * @returns a number
  41595. */
  41596. getAnimationRatio(): number;
  41597. /**
  41598. * Gets an unique Id for the current render phase
  41599. * @returns a number
  41600. */
  41601. getRenderId(): number;
  41602. /**
  41603. * Gets an unique Id for the current frame
  41604. * @returns a number
  41605. */
  41606. getFrameId(): number;
  41607. /** Call this function if you want to manually increment the render Id*/
  41608. incrementRenderId(): void;
  41609. private _createUbo;
  41610. /**
  41611. * Use this method to simulate a pointer move on a mesh
  41612. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41613. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41614. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41615. * @returns the current scene
  41616. */
  41617. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41618. /**
  41619. * Use this method to simulate a pointer down on a mesh
  41620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41623. * @returns the current scene
  41624. */
  41625. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41626. /**
  41627. * Use this method to simulate a pointer up on a mesh
  41628. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41629. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41630. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41631. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41632. * @returns the current scene
  41633. */
  41634. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41635. /**
  41636. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41637. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41638. * @returns true if the pointer was captured
  41639. */
  41640. isPointerCaptured(pointerId?: number): boolean;
  41641. /**
  41642. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41643. * @param attachUp defines if you want to attach events to pointerup
  41644. * @param attachDown defines if you want to attach events to pointerdown
  41645. * @param attachMove defines if you want to attach events to pointermove
  41646. */
  41647. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41648. /** Detaches all event handlers*/
  41649. detachControl(): void;
  41650. /**
  41651. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41652. * Delay loaded resources are not taking in account
  41653. * @return true if all required resources are ready
  41654. */
  41655. isReady(): boolean;
  41656. /** Resets all cached information relative to material (including effect and visibility) */
  41657. resetCachedMaterial(): void;
  41658. /**
  41659. * Registers a function to be called before every frame render
  41660. * @param func defines the function to register
  41661. */
  41662. registerBeforeRender(func: () => void): void;
  41663. /**
  41664. * Unregisters a function called before every frame render
  41665. * @param func defines the function to unregister
  41666. */
  41667. unregisterBeforeRender(func: () => void): void;
  41668. /**
  41669. * Registers a function to be called after every frame render
  41670. * @param func defines the function to register
  41671. */
  41672. registerAfterRender(func: () => void): void;
  41673. /**
  41674. * Unregisters a function called after every frame render
  41675. * @param func defines the function to unregister
  41676. */
  41677. unregisterAfterRender(func: () => void): void;
  41678. private _executeOnceBeforeRender;
  41679. /**
  41680. * The provided function will run before render once and will be disposed afterwards.
  41681. * A timeout delay can be provided so that the function will be executed in N ms.
  41682. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41683. * @param func The function to be executed.
  41684. * @param timeout optional delay in ms
  41685. */
  41686. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41687. /** @hidden */
  41688. _addPendingData(data: any): void;
  41689. /** @hidden */
  41690. _removePendingData(data: any): void;
  41691. /**
  41692. * Returns the number of items waiting to be loaded
  41693. * @returns the number of items waiting to be loaded
  41694. */
  41695. getWaitingItemsCount(): number;
  41696. /**
  41697. * Returns a boolean indicating if the scene is still loading data
  41698. */
  41699. get isLoading(): boolean;
  41700. /**
  41701. * Registers a function to be executed when the scene is ready
  41702. * @param {Function} func - the function to be executed
  41703. */
  41704. executeWhenReady(func: () => void): void;
  41705. /**
  41706. * Returns a promise that resolves when the scene is ready
  41707. * @returns A promise that resolves when the scene is ready
  41708. */
  41709. whenReadyAsync(): Promise<void>;
  41710. /** @hidden */
  41711. _checkIsReady(): void;
  41712. /**
  41713. * Gets all animatable attached to the scene
  41714. */
  41715. get animatables(): Animatable[];
  41716. /**
  41717. * Resets the last animation time frame.
  41718. * Useful to override when animations start running when loading a scene for the first time.
  41719. */
  41720. resetLastAnimationTimeFrame(): void;
  41721. /**
  41722. * Gets the current view matrix
  41723. * @returns a Matrix
  41724. */
  41725. getViewMatrix(): Matrix;
  41726. /**
  41727. * Gets the current projection matrix
  41728. * @returns a Matrix
  41729. */
  41730. getProjectionMatrix(): Matrix;
  41731. /**
  41732. * Gets the current transform matrix
  41733. * @returns a Matrix made of View * Projection
  41734. */
  41735. getTransformMatrix(): Matrix;
  41736. /**
  41737. * Sets the current transform matrix
  41738. * @param viewL defines the View matrix to use
  41739. * @param projectionL defines the Projection matrix to use
  41740. * @param viewR defines the right View matrix to use (if provided)
  41741. * @param projectionR defines the right Projection matrix to use (if provided)
  41742. */
  41743. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41744. /**
  41745. * Gets the uniform buffer used to store scene data
  41746. * @returns a UniformBuffer
  41747. */
  41748. getSceneUniformBuffer(): UniformBuffer;
  41749. /**
  41750. * Gets an unique (relatively to the current scene) Id
  41751. * @returns an unique number for the scene
  41752. */
  41753. getUniqueId(): number;
  41754. /**
  41755. * Add a mesh to the list of scene's meshes
  41756. * @param newMesh defines the mesh to add
  41757. * @param recursive if all child meshes should also be added to the scene
  41758. */
  41759. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41760. /**
  41761. * Remove a mesh for the list of scene's meshes
  41762. * @param toRemove defines the mesh to remove
  41763. * @param recursive if all child meshes should also be removed from the scene
  41764. * @returns the index where the mesh was in the mesh list
  41765. */
  41766. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41767. /**
  41768. * Add a transform node to the list of scene's transform nodes
  41769. * @param newTransformNode defines the transform node to add
  41770. */
  41771. addTransformNode(newTransformNode: TransformNode): void;
  41772. /**
  41773. * Remove a transform node for the list of scene's transform nodes
  41774. * @param toRemove defines the transform node to remove
  41775. * @returns the index where the transform node was in the transform node list
  41776. */
  41777. removeTransformNode(toRemove: TransformNode): number;
  41778. /**
  41779. * Remove a skeleton for the list of scene's skeletons
  41780. * @param toRemove defines the skeleton to remove
  41781. * @returns the index where the skeleton was in the skeleton list
  41782. */
  41783. removeSkeleton(toRemove: Skeleton): number;
  41784. /**
  41785. * Remove a morph target for the list of scene's morph targets
  41786. * @param toRemove defines the morph target to remove
  41787. * @returns the index where the morph target was in the morph target list
  41788. */
  41789. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41790. /**
  41791. * Remove a light for the list of scene's lights
  41792. * @param toRemove defines the light to remove
  41793. * @returns the index where the light was in the light list
  41794. */
  41795. removeLight(toRemove: Light): number;
  41796. /**
  41797. * Remove a camera for the list of scene's cameras
  41798. * @param toRemove defines the camera to remove
  41799. * @returns the index where the camera was in the camera list
  41800. */
  41801. removeCamera(toRemove: Camera): number;
  41802. /**
  41803. * Remove a particle system for the list of scene's particle systems
  41804. * @param toRemove defines the particle system to remove
  41805. * @returns the index where the particle system was in the particle system list
  41806. */
  41807. removeParticleSystem(toRemove: IParticleSystem): number;
  41808. /**
  41809. * Remove a animation for the list of scene's animations
  41810. * @param toRemove defines the animation to remove
  41811. * @returns the index where the animation was in the animation list
  41812. */
  41813. removeAnimation(toRemove: Animation): number;
  41814. /**
  41815. * Will stop the animation of the given target
  41816. * @param target - the target
  41817. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41818. * @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)
  41819. */
  41820. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41821. /**
  41822. * Removes the given animation group from this scene.
  41823. * @param toRemove The animation group to remove
  41824. * @returns The index of the removed animation group
  41825. */
  41826. removeAnimationGroup(toRemove: AnimationGroup): number;
  41827. /**
  41828. * Removes the given multi-material from this scene.
  41829. * @param toRemove The multi-material to remove
  41830. * @returns The index of the removed multi-material
  41831. */
  41832. removeMultiMaterial(toRemove: MultiMaterial): number;
  41833. /**
  41834. * Removes the given material from this scene.
  41835. * @param toRemove The material to remove
  41836. * @returns The index of the removed material
  41837. */
  41838. removeMaterial(toRemove: Material): number;
  41839. /**
  41840. * Removes the given action manager from this scene.
  41841. * @param toRemove The action manager to remove
  41842. * @returns The index of the removed action manager
  41843. */
  41844. removeActionManager(toRemove: AbstractActionManager): number;
  41845. /**
  41846. * Removes the given texture from this scene.
  41847. * @param toRemove The texture to remove
  41848. * @returns The index of the removed texture
  41849. */
  41850. removeTexture(toRemove: BaseTexture): number;
  41851. /**
  41852. * Adds the given light to this scene
  41853. * @param newLight The light to add
  41854. */
  41855. addLight(newLight: Light): void;
  41856. /**
  41857. * Sorts the list list based on light priorities
  41858. */
  41859. sortLightsByPriority(): void;
  41860. /**
  41861. * Adds the given camera to this scene
  41862. * @param newCamera The camera to add
  41863. */
  41864. addCamera(newCamera: Camera): void;
  41865. /**
  41866. * Adds the given skeleton to this scene
  41867. * @param newSkeleton The skeleton to add
  41868. */
  41869. addSkeleton(newSkeleton: Skeleton): void;
  41870. /**
  41871. * Adds the given particle system to this scene
  41872. * @param newParticleSystem The particle system to add
  41873. */
  41874. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41875. /**
  41876. * Adds the given animation to this scene
  41877. * @param newAnimation The animation to add
  41878. */
  41879. addAnimation(newAnimation: Animation): void;
  41880. /**
  41881. * Adds the given animation group to this scene.
  41882. * @param newAnimationGroup The animation group to add
  41883. */
  41884. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41885. /**
  41886. * Adds the given multi-material to this scene
  41887. * @param newMultiMaterial The multi-material to add
  41888. */
  41889. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41890. /**
  41891. * Adds the given material to this scene
  41892. * @param newMaterial The material to add
  41893. */
  41894. addMaterial(newMaterial: Material): void;
  41895. /**
  41896. * Adds the given morph target to this scene
  41897. * @param newMorphTargetManager The morph target to add
  41898. */
  41899. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41900. /**
  41901. * Adds the given geometry to this scene
  41902. * @param newGeometry The geometry to add
  41903. */
  41904. addGeometry(newGeometry: Geometry): void;
  41905. /**
  41906. * Adds the given action manager to this scene
  41907. * @param newActionManager The action manager to add
  41908. */
  41909. addActionManager(newActionManager: AbstractActionManager): void;
  41910. /**
  41911. * Adds the given texture to this scene.
  41912. * @param newTexture The texture to add
  41913. */
  41914. addTexture(newTexture: BaseTexture): void;
  41915. /**
  41916. * Switch active camera
  41917. * @param newCamera defines the new active camera
  41918. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41919. */
  41920. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41921. /**
  41922. * sets the active camera of the scene using its ID
  41923. * @param id defines the camera's ID
  41924. * @return the new active camera or null if none found.
  41925. */
  41926. setActiveCameraByID(id: string): Nullable<Camera>;
  41927. /**
  41928. * sets the active camera of the scene using its name
  41929. * @param name defines the camera's name
  41930. * @returns the new active camera or null if none found.
  41931. */
  41932. setActiveCameraByName(name: string): Nullable<Camera>;
  41933. /**
  41934. * get an animation group using its name
  41935. * @param name defines the material's name
  41936. * @return the animation group or null if none found.
  41937. */
  41938. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41939. /**
  41940. * Get a material using its unique id
  41941. * @param uniqueId defines the material's unique id
  41942. * @return the material or null if none found.
  41943. */
  41944. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41945. /**
  41946. * get a material using its id
  41947. * @param id defines the material's ID
  41948. * @return the material or null if none found.
  41949. */
  41950. getMaterialByID(id: string): Nullable<Material>;
  41951. /**
  41952. * Gets a the last added material using a given id
  41953. * @param id defines the material's ID
  41954. * @return the last material with the given id or null if none found.
  41955. */
  41956. getLastMaterialByID(id: string): Nullable<Material>;
  41957. /**
  41958. * Gets a material using its name
  41959. * @param name defines the material's name
  41960. * @return the material or null if none found.
  41961. */
  41962. getMaterialByName(name: string): Nullable<Material>;
  41963. /**
  41964. * Get a texture using its unique id
  41965. * @param uniqueId defines the texture's unique id
  41966. * @return the texture or null if none found.
  41967. */
  41968. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41969. /**
  41970. * Gets a camera using its id
  41971. * @param id defines the id to look for
  41972. * @returns the camera or null if not found
  41973. */
  41974. getCameraByID(id: string): Nullable<Camera>;
  41975. /**
  41976. * Gets a camera using its unique id
  41977. * @param uniqueId defines the unique id to look for
  41978. * @returns the camera or null if not found
  41979. */
  41980. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41981. /**
  41982. * Gets a camera using its name
  41983. * @param name defines the camera's name
  41984. * @return the camera or null if none found.
  41985. */
  41986. getCameraByName(name: string): Nullable<Camera>;
  41987. /**
  41988. * Gets a bone using its id
  41989. * @param id defines the bone's id
  41990. * @return the bone or null if not found
  41991. */
  41992. getBoneByID(id: string): Nullable<Bone>;
  41993. /**
  41994. * Gets a bone using its id
  41995. * @param name defines the bone's name
  41996. * @return the bone or null if not found
  41997. */
  41998. getBoneByName(name: string): Nullable<Bone>;
  41999. /**
  42000. * Gets a light node using its name
  42001. * @param name defines the the light's name
  42002. * @return the light or null if none found.
  42003. */
  42004. getLightByName(name: string): Nullable<Light>;
  42005. /**
  42006. * Gets a light node using its id
  42007. * @param id defines the light's id
  42008. * @return the light or null if none found.
  42009. */
  42010. getLightByID(id: string): Nullable<Light>;
  42011. /**
  42012. * Gets a light node using its scene-generated unique ID
  42013. * @param uniqueId defines the light's unique id
  42014. * @return the light or null if none found.
  42015. */
  42016. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42017. /**
  42018. * Gets a particle system by id
  42019. * @param id defines the particle system id
  42020. * @return the corresponding system or null if none found
  42021. */
  42022. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42023. /**
  42024. * Gets a geometry using its ID
  42025. * @param id defines the geometry's id
  42026. * @return the geometry or null if none found.
  42027. */
  42028. getGeometryByID(id: string): Nullable<Geometry>;
  42029. private _getGeometryByUniqueID;
  42030. /**
  42031. * Add a new geometry to this scene
  42032. * @param geometry defines the geometry to be added to the scene.
  42033. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42034. * @return a boolean defining if the geometry was added or not
  42035. */
  42036. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42037. /**
  42038. * Removes an existing geometry
  42039. * @param geometry defines the geometry to be removed from the scene
  42040. * @return a boolean defining if the geometry was removed or not
  42041. */
  42042. removeGeometry(geometry: Geometry): boolean;
  42043. /**
  42044. * Gets the list of geometries attached to the scene
  42045. * @returns an array of Geometry
  42046. */
  42047. getGeometries(): Geometry[];
  42048. /**
  42049. * Gets the first added mesh found of a given ID
  42050. * @param id defines the id to search for
  42051. * @return the mesh found or null if not found at all
  42052. */
  42053. getMeshByID(id: string): Nullable<AbstractMesh>;
  42054. /**
  42055. * Gets a list of meshes using their id
  42056. * @param id defines the id to search for
  42057. * @returns a list of meshes
  42058. */
  42059. getMeshesByID(id: string): Array<AbstractMesh>;
  42060. /**
  42061. * Gets the first added transform node found of a given ID
  42062. * @param id defines the id to search for
  42063. * @return the found transform node or null if not found at all.
  42064. */
  42065. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42066. /**
  42067. * Gets a transform node with its auto-generated unique id
  42068. * @param uniqueId efines the unique id to search for
  42069. * @return the found transform node or null if not found at all.
  42070. */
  42071. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42072. /**
  42073. * Gets a list of transform nodes using their id
  42074. * @param id defines the id to search for
  42075. * @returns a list of transform nodes
  42076. */
  42077. getTransformNodesByID(id: string): Array<TransformNode>;
  42078. /**
  42079. * Gets a mesh with its auto-generated unique id
  42080. * @param uniqueId defines the unique id to search for
  42081. * @return the found mesh or null if not found at all.
  42082. */
  42083. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42084. /**
  42085. * Gets a the last added mesh using a given id
  42086. * @param id defines the id to search for
  42087. * @return the found mesh or null if not found at all.
  42088. */
  42089. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42090. /**
  42091. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42092. * @param id defines the id to search for
  42093. * @return the found node or null if not found at all
  42094. */
  42095. getLastEntryByID(id: string): Nullable<Node>;
  42096. /**
  42097. * Gets a node (Mesh, Camera, Light) using a given id
  42098. * @param id defines the id to search for
  42099. * @return the found node or null if not found at all
  42100. */
  42101. getNodeByID(id: string): Nullable<Node>;
  42102. /**
  42103. * Gets a node (Mesh, Camera, Light) using a given name
  42104. * @param name defines the name to search for
  42105. * @return the found node or null if not found at all.
  42106. */
  42107. getNodeByName(name: string): Nullable<Node>;
  42108. /**
  42109. * Gets a mesh using a given name
  42110. * @param name defines the name to search for
  42111. * @return the found mesh or null if not found at all.
  42112. */
  42113. getMeshByName(name: string): Nullable<AbstractMesh>;
  42114. /**
  42115. * Gets a transform node using a given name
  42116. * @param name defines the name to search for
  42117. * @return the found transform node or null if not found at all.
  42118. */
  42119. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42120. /**
  42121. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42122. * @param id defines the id to search for
  42123. * @return the found skeleton or null if not found at all.
  42124. */
  42125. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42126. /**
  42127. * Gets a skeleton using a given auto generated unique id
  42128. * @param uniqueId defines the unique id to search for
  42129. * @return the found skeleton or null if not found at all.
  42130. */
  42131. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42132. /**
  42133. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42134. * @param id defines the id to search for
  42135. * @return the found skeleton or null if not found at all.
  42136. */
  42137. getSkeletonById(id: string): Nullable<Skeleton>;
  42138. /**
  42139. * Gets a skeleton using a given name
  42140. * @param name defines the name to search for
  42141. * @return the found skeleton or null if not found at all.
  42142. */
  42143. getSkeletonByName(name: string): Nullable<Skeleton>;
  42144. /**
  42145. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42146. * @param id defines the id to search for
  42147. * @return the found morph target manager or null if not found at all.
  42148. */
  42149. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42150. /**
  42151. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42152. * @param id defines the id to search for
  42153. * @return the found morph target or null if not found at all.
  42154. */
  42155. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42156. /**
  42157. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42158. * @param name defines the name to search for
  42159. * @return the found morph target or null if not found at all.
  42160. */
  42161. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42162. /**
  42163. * Gets a boolean indicating if the given mesh is active
  42164. * @param mesh defines the mesh to look for
  42165. * @returns true if the mesh is in the active list
  42166. */
  42167. isActiveMesh(mesh: AbstractMesh): boolean;
  42168. /**
  42169. * Return a unique id as a string which can serve as an identifier for the scene
  42170. */
  42171. get uid(): string;
  42172. /**
  42173. * Add an externaly attached data from its key.
  42174. * This method call will fail and return false, if such key already exists.
  42175. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42176. * @param key the unique key that identifies the data
  42177. * @param data the data object to associate to the key for this Engine instance
  42178. * @return true if no such key were already present and the data was added successfully, false otherwise
  42179. */
  42180. addExternalData<T>(key: string, data: T): boolean;
  42181. /**
  42182. * Get an externaly attached data from its key
  42183. * @param key the unique key that identifies the data
  42184. * @return the associated data, if present (can be null), or undefined if not present
  42185. */
  42186. getExternalData<T>(key: string): Nullable<T>;
  42187. /**
  42188. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42189. * @param key the unique key that identifies the data
  42190. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42191. * @return the associated data, can be null if the factory returned null.
  42192. */
  42193. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42194. /**
  42195. * Remove an externaly attached data from the Engine instance
  42196. * @param key the unique key that identifies the data
  42197. * @return true if the data was successfully removed, false if it doesn't exist
  42198. */
  42199. removeExternalData(key: string): boolean;
  42200. private _evaluateSubMesh;
  42201. /**
  42202. * Clear the processed materials smart array preventing retention point in material dispose.
  42203. */
  42204. freeProcessedMaterials(): void;
  42205. private _preventFreeActiveMeshesAndRenderingGroups;
  42206. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42207. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42208. * when disposing several meshes in a row or a hierarchy of meshes.
  42209. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42210. */
  42211. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42212. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42213. /**
  42214. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42215. */
  42216. freeActiveMeshes(): void;
  42217. /**
  42218. * Clear the info related to rendering groups preventing retention points during dispose.
  42219. */
  42220. freeRenderingGroups(): void;
  42221. /** @hidden */
  42222. _isInIntermediateRendering(): boolean;
  42223. /**
  42224. * Lambda returning the list of potentially active meshes.
  42225. */
  42226. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42227. /**
  42228. * Lambda returning the list of potentially active sub meshes.
  42229. */
  42230. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42231. /**
  42232. * Lambda returning the list of potentially intersecting sub meshes.
  42233. */
  42234. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42235. /**
  42236. * Lambda returning the list of potentially colliding sub meshes.
  42237. */
  42238. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42239. private _activeMeshesFrozen;
  42240. private _skipEvaluateActiveMeshesCompletely;
  42241. /**
  42242. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42243. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42244. * @returns the current scene
  42245. */
  42246. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42247. /**
  42248. * Use this function to restart evaluating active meshes on every frame
  42249. * @returns the current scene
  42250. */
  42251. unfreezeActiveMeshes(): Scene;
  42252. private _evaluateActiveMeshes;
  42253. private _activeMesh;
  42254. /**
  42255. * Update the transform matrix to update from the current active camera
  42256. * @param force defines a boolean used to force the update even if cache is up to date
  42257. */
  42258. updateTransformMatrix(force?: boolean): void;
  42259. private _bindFrameBuffer;
  42260. /** @hidden */
  42261. _allowPostProcessClearColor: boolean;
  42262. /** @hidden */
  42263. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42264. private _processSubCameras;
  42265. private _checkIntersections;
  42266. /** @hidden */
  42267. _advancePhysicsEngineStep(step: number): void;
  42268. /**
  42269. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42270. */
  42271. getDeterministicFrameTime: () => number;
  42272. /** @hidden */
  42273. _animate(): void;
  42274. /** Execute all animations (for a frame) */
  42275. animate(): void;
  42276. /**
  42277. * Render the scene
  42278. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42279. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42280. */
  42281. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42282. /**
  42283. * Freeze all materials
  42284. * A frozen material will not be updatable but should be faster to render
  42285. */
  42286. freezeMaterials(): void;
  42287. /**
  42288. * Unfreeze all materials
  42289. * A frozen material will not be updatable but should be faster to render
  42290. */
  42291. unfreezeMaterials(): void;
  42292. /**
  42293. * Releases all held ressources
  42294. */
  42295. dispose(): void;
  42296. /**
  42297. * Gets if the scene is already disposed
  42298. */
  42299. get isDisposed(): boolean;
  42300. /**
  42301. * Call this function to reduce memory footprint of the scene.
  42302. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42303. */
  42304. clearCachedVertexData(): void;
  42305. /**
  42306. * This function will remove the local cached buffer data from texture.
  42307. * It will save memory but will prevent the texture from being rebuilt
  42308. */
  42309. cleanCachedTextureBuffer(): void;
  42310. /**
  42311. * Get the world extend vectors with an optional filter
  42312. *
  42313. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42314. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42315. */
  42316. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42317. min: Vector3;
  42318. max: Vector3;
  42319. };
  42320. /**
  42321. * Creates a ray that can be used to pick in the scene
  42322. * @param x defines the x coordinate of the origin (on-screen)
  42323. * @param y defines the y coordinate of the origin (on-screen)
  42324. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42325. * @param camera defines the camera to use for the picking
  42326. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42327. * @returns a Ray
  42328. */
  42329. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42330. /**
  42331. * Creates a ray that can be used to pick in the scene
  42332. * @param x defines the x coordinate of the origin (on-screen)
  42333. * @param y defines the y coordinate of the origin (on-screen)
  42334. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42335. * @param result defines the ray where to store the picking ray
  42336. * @param camera defines the camera to use for the picking
  42337. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42338. * @returns the current scene
  42339. */
  42340. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42341. /**
  42342. * Creates a ray that can be used to pick in the scene
  42343. * @param x defines the x coordinate of the origin (on-screen)
  42344. * @param y defines the y coordinate of the origin (on-screen)
  42345. * @param camera defines the camera to use for the picking
  42346. * @returns a Ray
  42347. */
  42348. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42349. /**
  42350. * Creates a ray that can be used to pick in the scene
  42351. * @param x defines the x coordinate of the origin (on-screen)
  42352. * @param y defines the y coordinate of the origin (on-screen)
  42353. * @param result defines the ray where to store the picking ray
  42354. * @param camera defines the camera to use for the picking
  42355. * @returns the current scene
  42356. */
  42357. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42358. /** Launch a ray to try to pick a mesh in the scene
  42359. * @param x position on screen
  42360. * @param y position on screen
  42361. * @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
  42362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42363. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42364. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42365. * @returns a PickingInfo
  42366. */
  42367. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42368. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42369. * @param x position on screen
  42370. * @param y position on screen
  42371. * @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
  42372. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42373. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42374. * @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)
  42375. */
  42376. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42377. /** Use the given ray to pick a mesh in the scene
  42378. * @param ray The ray to use to pick meshes
  42379. * @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
  42380. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42382. * @returns a PickingInfo
  42383. */
  42384. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42385. /**
  42386. * Launch a ray to try to pick a mesh in the scene
  42387. * @param x X position on screen
  42388. * @param y Y position on screen
  42389. * @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
  42390. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42392. * @returns an array of PickingInfo
  42393. */
  42394. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42395. /**
  42396. * Launch a ray to try to pick a mesh in the scene
  42397. * @param ray Ray to use
  42398. * @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
  42399. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42400. * @returns an array of PickingInfo
  42401. */
  42402. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42403. /**
  42404. * Force the value of meshUnderPointer
  42405. * @param mesh defines the mesh to use
  42406. */
  42407. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42408. /**
  42409. * Gets the mesh under the pointer
  42410. * @returns a Mesh or null if no mesh is under the pointer
  42411. */
  42412. getPointerOverMesh(): Nullable<AbstractMesh>;
  42413. /** @hidden */
  42414. _rebuildGeometries(): void;
  42415. /** @hidden */
  42416. _rebuildTextures(): void;
  42417. private _getByTags;
  42418. /**
  42419. * Get a list of meshes by tags
  42420. * @param tagsQuery defines the tags query to use
  42421. * @param forEach defines a predicate used to filter results
  42422. * @returns an array of Mesh
  42423. */
  42424. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42425. /**
  42426. * Get a list of cameras by tags
  42427. * @param tagsQuery defines the tags query to use
  42428. * @param forEach defines a predicate used to filter results
  42429. * @returns an array of Camera
  42430. */
  42431. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42432. /**
  42433. * Get a list of lights by tags
  42434. * @param tagsQuery defines the tags query to use
  42435. * @param forEach defines a predicate used to filter results
  42436. * @returns an array of Light
  42437. */
  42438. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42439. /**
  42440. * Get a list of materials by tags
  42441. * @param tagsQuery defines the tags query to use
  42442. * @param forEach defines a predicate used to filter results
  42443. * @returns an array of Material
  42444. */
  42445. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42446. /**
  42447. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42448. * This allowed control for front to back rendering or reversly depending of the special needs.
  42449. *
  42450. * @param renderingGroupId The rendering group id corresponding to its index
  42451. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42452. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42453. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42454. */
  42455. 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;
  42456. /**
  42457. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42458. *
  42459. * @param renderingGroupId The rendering group id corresponding to its index
  42460. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42461. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42462. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42463. */
  42464. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42465. /**
  42466. * Gets the current auto clear configuration for one rendering group of the rendering
  42467. * manager.
  42468. * @param index the rendering group index to get the information for
  42469. * @returns The auto clear setup for the requested rendering group
  42470. */
  42471. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42472. private _blockMaterialDirtyMechanism;
  42473. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42474. get blockMaterialDirtyMechanism(): boolean;
  42475. set blockMaterialDirtyMechanism(value: boolean);
  42476. /**
  42477. * Will flag all materials as dirty to trigger new shader compilation
  42478. * @param flag defines the flag used to specify which material part must be marked as dirty
  42479. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42480. */
  42481. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42482. /** @hidden */
  42483. _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;
  42484. /** @hidden */
  42485. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42486. /** @hidden */
  42487. _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;
  42488. /** @hidden */
  42489. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42490. /** @hidden */
  42491. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42492. /** @hidden */
  42493. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42494. }
  42495. }
  42496. declare module "babylonjs/assetContainer" {
  42497. import { AbstractScene } from "babylonjs/abstractScene";
  42498. import { Scene } from "babylonjs/scene";
  42499. import { Mesh } from "babylonjs/Meshes/mesh";
  42500. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42501. import { Skeleton } from "babylonjs/Bones/skeleton";
  42502. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42503. import { Animatable } from "babylonjs/Animations/animatable";
  42504. import { Nullable } from "babylonjs/types";
  42505. import { Node } from "babylonjs/node";
  42506. /**
  42507. * Set of assets to keep when moving a scene into an asset container.
  42508. */
  42509. export class KeepAssets extends AbstractScene {
  42510. }
  42511. /**
  42512. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42513. */
  42514. export class InstantiatedEntries {
  42515. /**
  42516. * List of new root nodes (eg. nodes with no parent)
  42517. */
  42518. rootNodes: TransformNode[];
  42519. /**
  42520. * List of new skeletons
  42521. */
  42522. skeletons: Skeleton[];
  42523. /**
  42524. * List of new animation groups
  42525. */
  42526. animationGroups: AnimationGroup[];
  42527. }
  42528. /**
  42529. * Container with a set of assets that can be added or removed from a scene.
  42530. */
  42531. export class AssetContainer extends AbstractScene {
  42532. private _wasAddedToScene;
  42533. /**
  42534. * The scene the AssetContainer belongs to.
  42535. */
  42536. scene: Scene;
  42537. /**
  42538. * Instantiates an AssetContainer.
  42539. * @param scene The scene the AssetContainer belongs to.
  42540. */
  42541. constructor(scene: Scene);
  42542. /**
  42543. * Instantiate or clone all meshes and add the new ones to the scene.
  42544. * Skeletons and animation groups will all be cloned
  42545. * @param nameFunction defines an optional function used to get new names for clones
  42546. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42547. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42548. */
  42549. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42550. /**
  42551. * Adds all the assets from the container to the scene.
  42552. */
  42553. addAllToScene(): void;
  42554. /**
  42555. * Removes all the assets in the container from the scene
  42556. */
  42557. removeAllFromScene(): void;
  42558. /**
  42559. * Disposes all the assets in the container
  42560. */
  42561. dispose(): void;
  42562. private _moveAssets;
  42563. /**
  42564. * Removes all the assets contained in the scene and adds them to the container.
  42565. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42566. */
  42567. moveAllFromScene(keepAssets?: KeepAssets): void;
  42568. /**
  42569. * 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.
  42570. * @returns the root mesh
  42571. */
  42572. createRootMesh(): Mesh;
  42573. /**
  42574. * Merge animations (direct and animation groups) from this asset container into a scene
  42575. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42576. * @param animatables set of animatables to retarget to a node from the scene
  42577. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42578. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42579. */
  42580. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42581. }
  42582. }
  42583. declare module "babylonjs/abstractScene" {
  42584. import { Scene } from "babylonjs/scene";
  42585. import { Nullable } from "babylonjs/types";
  42586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42588. import { Geometry } from "babylonjs/Meshes/geometry";
  42589. import { Skeleton } from "babylonjs/Bones/skeleton";
  42590. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42591. import { AssetContainer } from "babylonjs/assetContainer";
  42592. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42593. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42595. import { Material } from "babylonjs/Materials/material";
  42596. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42597. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42598. import { Camera } from "babylonjs/Cameras/camera";
  42599. import { Light } from "babylonjs/Lights/light";
  42600. import { Node } from "babylonjs/node";
  42601. import { Animation } from "babylonjs/Animations/animation";
  42602. /**
  42603. * Defines how the parser contract is defined.
  42604. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42605. */
  42606. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42607. /**
  42608. * Defines how the individual parser contract is defined.
  42609. * These parser can parse an individual asset
  42610. */
  42611. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42612. /**
  42613. * Base class of the scene acting as a container for the different elements composing a scene.
  42614. * This class is dynamically extended by the different components of the scene increasing
  42615. * flexibility and reducing coupling
  42616. */
  42617. export abstract class AbstractScene {
  42618. /**
  42619. * Stores the list of available parsers in the application.
  42620. */
  42621. private static _BabylonFileParsers;
  42622. /**
  42623. * Stores the list of available individual parsers in the application.
  42624. */
  42625. private static _IndividualBabylonFileParsers;
  42626. /**
  42627. * Adds a parser in the list of available ones
  42628. * @param name Defines the name of the parser
  42629. * @param parser Defines the parser to add
  42630. */
  42631. static AddParser(name: string, parser: BabylonFileParser): void;
  42632. /**
  42633. * Gets a general parser from the list of avaialble ones
  42634. * @param name Defines the name of the parser
  42635. * @returns the requested parser or null
  42636. */
  42637. static GetParser(name: string): Nullable<BabylonFileParser>;
  42638. /**
  42639. * Adds n individual parser in the list of available ones
  42640. * @param name Defines the name of the parser
  42641. * @param parser Defines the parser to add
  42642. */
  42643. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42644. /**
  42645. * Gets an individual parser from the list of avaialble ones
  42646. * @param name Defines the name of the parser
  42647. * @returns the requested parser or null
  42648. */
  42649. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42650. /**
  42651. * Parser json data and populate both a scene and its associated container object
  42652. * @param jsonData Defines the data to parse
  42653. * @param scene Defines the scene to parse the data for
  42654. * @param container Defines the container attached to the parsing sequence
  42655. * @param rootUrl Defines the root url of the data
  42656. */
  42657. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42658. /**
  42659. * Gets the list of root nodes (ie. nodes with no parent)
  42660. */
  42661. rootNodes: Node[];
  42662. /** All of the cameras added to this scene
  42663. * @see https://doc.babylonjs.com/babylon101/cameras
  42664. */
  42665. cameras: Camera[];
  42666. /**
  42667. * All of the lights added to this scene
  42668. * @see https://doc.babylonjs.com/babylon101/lights
  42669. */
  42670. lights: Light[];
  42671. /**
  42672. * All of the (abstract) meshes added to this scene
  42673. */
  42674. meshes: AbstractMesh[];
  42675. /**
  42676. * The list of skeletons added to the scene
  42677. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42678. */
  42679. skeletons: Skeleton[];
  42680. /**
  42681. * All of the particle systems added to this scene
  42682. * @see https://doc.babylonjs.com/babylon101/particles
  42683. */
  42684. particleSystems: IParticleSystem[];
  42685. /**
  42686. * Gets a list of Animations associated with the scene
  42687. */
  42688. animations: Animation[];
  42689. /**
  42690. * All of the animation groups added to this scene
  42691. * @see https://doc.babylonjs.com/how_to/group
  42692. */
  42693. animationGroups: AnimationGroup[];
  42694. /**
  42695. * All of the multi-materials added to this scene
  42696. * @see https://doc.babylonjs.com/how_to/multi_materials
  42697. */
  42698. multiMaterials: MultiMaterial[];
  42699. /**
  42700. * All of the materials added to this scene
  42701. * In the context of a Scene, it is not supposed to be modified manually.
  42702. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42703. * Note also that the order of the Material within the array is not significant and might change.
  42704. * @see https://doc.babylonjs.com/babylon101/materials
  42705. */
  42706. materials: Material[];
  42707. /**
  42708. * The list of morph target managers added to the scene
  42709. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42710. */
  42711. morphTargetManagers: MorphTargetManager[];
  42712. /**
  42713. * The list of geometries used in the scene.
  42714. */
  42715. geometries: Geometry[];
  42716. /**
  42717. * All of the tranform nodes added to this scene
  42718. * In the context of a Scene, it is not supposed to be modified manually.
  42719. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42720. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42721. * @see https://doc.babylonjs.com/how_to/transformnode
  42722. */
  42723. transformNodes: TransformNode[];
  42724. /**
  42725. * ActionManagers available on the scene.
  42726. */
  42727. actionManagers: AbstractActionManager[];
  42728. /**
  42729. * Textures to keep.
  42730. */
  42731. textures: BaseTexture[];
  42732. /**
  42733. * Environment texture for the scene
  42734. */
  42735. environmentTexture: Nullable<BaseTexture>;
  42736. /**
  42737. * @returns all meshes, lights, cameras, transformNodes and bones
  42738. */
  42739. getNodes(): Array<Node>;
  42740. }
  42741. }
  42742. declare module "babylonjs/Audio/sound" {
  42743. import { Observable } from "babylonjs/Misc/observable";
  42744. import { Vector3 } from "babylonjs/Maths/math.vector";
  42745. import { Nullable } from "babylonjs/types";
  42746. import { Scene } from "babylonjs/scene";
  42747. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42748. /**
  42749. * Interface used to define options for Sound class
  42750. */
  42751. export interface ISoundOptions {
  42752. /**
  42753. * Does the sound autoplay once loaded.
  42754. */
  42755. autoplay?: boolean;
  42756. /**
  42757. * Does the sound loop after it finishes playing once.
  42758. */
  42759. loop?: boolean;
  42760. /**
  42761. * Sound's volume
  42762. */
  42763. volume?: number;
  42764. /**
  42765. * Is it a spatial sound?
  42766. */
  42767. spatialSound?: boolean;
  42768. /**
  42769. * Maximum distance to hear that sound
  42770. */
  42771. maxDistance?: number;
  42772. /**
  42773. * Uses user defined attenuation function
  42774. */
  42775. useCustomAttenuation?: boolean;
  42776. /**
  42777. * Define the roll off factor of spatial sounds.
  42778. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42779. */
  42780. rolloffFactor?: number;
  42781. /**
  42782. * Define the reference distance the sound should be heard perfectly.
  42783. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42784. */
  42785. refDistance?: number;
  42786. /**
  42787. * Define the distance attenuation model the sound will follow.
  42788. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42789. */
  42790. distanceModel?: string;
  42791. /**
  42792. * Defines the playback speed (1 by default)
  42793. */
  42794. playbackRate?: number;
  42795. /**
  42796. * Defines if the sound is from a streaming source
  42797. */
  42798. streaming?: boolean;
  42799. /**
  42800. * Defines an optional length (in seconds) inside the sound file
  42801. */
  42802. length?: number;
  42803. /**
  42804. * Defines an optional offset (in seconds) inside the sound file
  42805. */
  42806. offset?: number;
  42807. /**
  42808. * If true, URLs will not be required to state the audio file codec to use.
  42809. */
  42810. skipCodecCheck?: boolean;
  42811. }
  42812. /**
  42813. * Defines a sound that can be played in the application.
  42814. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42816. */
  42817. export class Sound {
  42818. /**
  42819. * The name of the sound in the scene.
  42820. */
  42821. name: string;
  42822. /**
  42823. * Does the sound autoplay once loaded.
  42824. */
  42825. autoplay: boolean;
  42826. /**
  42827. * Does the sound loop after it finishes playing once.
  42828. */
  42829. loop: boolean;
  42830. /**
  42831. * Does the sound use a custom attenuation curve to simulate the falloff
  42832. * happening when the source gets further away from the camera.
  42833. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42834. */
  42835. useCustomAttenuation: boolean;
  42836. /**
  42837. * The sound track id this sound belongs to.
  42838. */
  42839. soundTrackId: number;
  42840. /**
  42841. * Is this sound currently played.
  42842. */
  42843. isPlaying: boolean;
  42844. /**
  42845. * Is this sound currently paused.
  42846. */
  42847. isPaused: boolean;
  42848. /**
  42849. * Does this sound enables spatial sound.
  42850. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42851. */
  42852. spatialSound: boolean;
  42853. /**
  42854. * Define the reference distance the sound should be heard perfectly.
  42855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42856. */
  42857. refDistance: number;
  42858. /**
  42859. * Define the roll off factor of spatial sounds.
  42860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42861. */
  42862. rolloffFactor: number;
  42863. /**
  42864. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42865. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42866. */
  42867. maxDistance: number;
  42868. /**
  42869. * Define the distance attenuation model the sound will follow.
  42870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42871. */
  42872. distanceModel: string;
  42873. /**
  42874. * @hidden
  42875. * Back Compat
  42876. **/
  42877. onended: () => any;
  42878. /**
  42879. * Gets or sets an object used to store user defined information for the sound.
  42880. */
  42881. metadata: any;
  42882. /**
  42883. * Observable event when the current playing sound finishes.
  42884. */
  42885. onEndedObservable: Observable<Sound>;
  42886. private _panningModel;
  42887. private _playbackRate;
  42888. private _streaming;
  42889. private _startTime;
  42890. private _startOffset;
  42891. private _position;
  42892. /** @hidden */
  42893. _positionInEmitterSpace: boolean;
  42894. private _localDirection;
  42895. private _volume;
  42896. private _isReadyToPlay;
  42897. private _isDirectional;
  42898. private _readyToPlayCallback;
  42899. private _audioBuffer;
  42900. private _soundSource;
  42901. private _streamingSource;
  42902. private _soundPanner;
  42903. private _soundGain;
  42904. private _inputAudioNode;
  42905. private _outputAudioNode;
  42906. private _coneInnerAngle;
  42907. private _coneOuterAngle;
  42908. private _coneOuterGain;
  42909. private _scene;
  42910. private _connectedTransformNode;
  42911. private _customAttenuationFunction;
  42912. private _registerFunc;
  42913. private _isOutputConnected;
  42914. private _htmlAudioElement;
  42915. private _urlType;
  42916. private _length?;
  42917. private _offset?;
  42918. /** @hidden */
  42919. static _SceneComponentInitialization: (scene: Scene) => void;
  42920. /**
  42921. * Create a sound and attach it to a scene
  42922. * @param name Name of your sound
  42923. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42924. * @param scene defines the scene the sound belongs to
  42925. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42926. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42927. */
  42928. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42929. /**
  42930. * Release the sound and its associated resources
  42931. */
  42932. dispose(): void;
  42933. /**
  42934. * Gets if the sounds is ready to be played or not.
  42935. * @returns true if ready, otherwise false
  42936. */
  42937. isReady(): boolean;
  42938. private _soundLoaded;
  42939. /**
  42940. * Sets the data of the sound from an audiobuffer
  42941. * @param audioBuffer The audioBuffer containing the data
  42942. */
  42943. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42944. /**
  42945. * Updates the current sounds options such as maxdistance, loop...
  42946. * @param options A JSON object containing values named as the object properties
  42947. */
  42948. updateOptions(options: ISoundOptions): void;
  42949. private _createSpatialParameters;
  42950. private _updateSpatialParameters;
  42951. /**
  42952. * Switch the panning model to HRTF:
  42953. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42955. */
  42956. switchPanningModelToHRTF(): void;
  42957. /**
  42958. * Switch the panning model to Equal Power:
  42959. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42961. */
  42962. switchPanningModelToEqualPower(): void;
  42963. private _switchPanningModel;
  42964. /**
  42965. * Connect this sound to a sound track audio node like gain...
  42966. * @param soundTrackAudioNode the sound track audio node to connect to
  42967. */
  42968. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42969. /**
  42970. * Transform this sound into a directional source
  42971. * @param coneInnerAngle Size of the inner cone in degree
  42972. * @param coneOuterAngle Size of the outer cone in degree
  42973. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42974. */
  42975. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42976. /**
  42977. * Gets or sets the inner angle for the directional cone.
  42978. */
  42979. get directionalConeInnerAngle(): number;
  42980. /**
  42981. * Gets or sets the inner angle for the directional cone.
  42982. */
  42983. set directionalConeInnerAngle(value: number);
  42984. /**
  42985. * Gets or sets the outer angle for the directional cone.
  42986. */
  42987. get directionalConeOuterAngle(): number;
  42988. /**
  42989. * Gets or sets the outer angle for the directional cone.
  42990. */
  42991. set directionalConeOuterAngle(value: number);
  42992. /**
  42993. * Sets the position of the emitter if spatial sound is enabled
  42994. * @param newPosition Defines the new posisiton
  42995. */
  42996. setPosition(newPosition: Vector3): void;
  42997. /**
  42998. * Sets the local direction of the emitter if spatial sound is enabled
  42999. * @param newLocalDirection Defines the new local direction
  43000. */
  43001. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43002. private _updateDirection;
  43003. /** @hidden */
  43004. updateDistanceFromListener(): void;
  43005. /**
  43006. * Sets a new custom attenuation function for the sound.
  43007. * @param callback Defines the function used for the attenuation
  43008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43009. */
  43010. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43011. /**
  43012. * Play the sound
  43013. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43014. * @param offset (optional) Start the sound at a specific time in seconds
  43015. * @param length (optional) Sound duration (in seconds)
  43016. */
  43017. play(time?: number, offset?: number, length?: number): void;
  43018. private _onended;
  43019. /**
  43020. * Stop the sound
  43021. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43022. */
  43023. stop(time?: number): void;
  43024. /**
  43025. * Put the sound in pause
  43026. */
  43027. pause(): void;
  43028. /**
  43029. * Sets a dedicated volume for this sounds
  43030. * @param newVolume Define the new volume of the sound
  43031. * @param time Define time for gradual change to new volume
  43032. */
  43033. setVolume(newVolume: number, time?: number): void;
  43034. /**
  43035. * Set the sound play back rate
  43036. * @param newPlaybackRate Define the playback rate the sound should be played at
  43037. */
  43038. setPlaybackRate(newPlaybackRate: number): void;
  43039. /**
  43040. * Gets the volume of the sound.
  43041. * @returns the volume of the sound
  43042. */
  43043. getVolume(): number;
  43044. /**
  43045. * Attach the sound to a dedicated mesh
  43046. * @param transformNode The transform node to connect the sound with
  43047. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43048. */
  43049. attachToMesh(transformNode: TransformNode): void;
  43050. /**
  43051. * Detach the sound from the previously attached mesh
  43052. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43053. */
  43054. detachFromMesh(): void;
  43055. private _onRegisterAfterWorldMatrixUpdate;
  43056. /**
  43057. * Clone the current sound in the scene.
  43058. * @returns the new sound clone
  43059. */
  43060. clone(): Nullable<Sound>;
  43061. /**
  43062. * Gets the current underlying audio buffer containing the data
  43063. * @returns the audio buffer
  43064. */
  43065. getAudioBuffer(): Nullable<AudioBuffer>;
  43066. /**
  43067. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43068. * @returns the source node
  43069. */
  43070. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43071. /**
  43072. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43073. * @returns the gain node
  43074. */
  43075. getSoundGain(): Nullable<GainNode>;
  43076. /**
  43077. * Serializes the Sound in a JSON representation
  43078. * @returns the JSON representation of the sound
  43079. */
  43080. serialize(): any;
  43081. /**
  43082. * Parse a JSON representation of a sound to innstantiate in a given scene
  43083. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43084. * @param scene Define the scene the new parsed sound should be created in
  43085. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43086. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43087. * @returns the newly parsed sound
  43088. */
  43089. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43090. }
  43091. }
  43092. declare module "babylonjs/Actions/directAudioActions" {
  43093. import { Action } from "babylonjs/Actions/action";
  43094. import { Condition } from "babylonjs/Actions/condition";
  43095. import { Sound } from "babylonjs/Audio/sound";
  43096. /**
  43097. * This defines an action helpful to play a defined sound on a triggered action.
  43098. */
  43099. export class PlaySoundAction extends Action {
  43100. private _sound;
  43101. /**
  43102. * Instantiate the action
  43103. * @param triggerOptions defines the trigger options
  43104. * @param sound defines the sound to play
  43105. * @param condition defines the trigger related conditions
  43106. */
  43107. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43108. /** @hidden */
  43109. _prepare(): void;
  43110. /**
  43111. * Execute the action and play the sound.
  43112. */
  43113. execute(): void;
  43114. /**
  43115. * Serializes the actions and its related information.
  43116. * @param parent defines the object to serialize in
  43117. * @returns the serialized object
  43118. */
  43119. serialize(parent: any): any;
  43120. }
  43121. /**
  43122. * This defines an action helpful to stop a defined sound on a triggered action.
  43123. */
  43124. export class StopSoundAction extends Action {
  43125. private _sound;
  43126. /**
  43127. * Instantiate the action
  43128. * @param triggerOptions defines the trigger options
  43129. * @param sound defines the sound to stop
  43130. * @param condition defines the trigger related conditions
  43131. */
  43132. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43133. /** @hidden */
  43134. _prepare(): void;
  43135. /**
  43136. * Execute the action and stop the sound.
  43137. */
  43138. execute(): void;
  43139. /**
  43140. * Serializes the actions and its related information.
  43141. * @param parent defines the object to serialize in
  43142. * @returns the serialized object
  43143. */
  43144. serialize(parent: any): any;
  43145. }
  43146. }
  43147. declare module "babylonjs/Actions/interpolateValueAction" {
  43148. import { Action } from "babylonjs/Actions/action";
  43149. import { Condition } from "babylonjs/Actions/condition";
  43150. import { Observable } from "babylonjs/Misc/observable";
  43151. /**
  43152. * This defines an action responsible to change the value of a property
  43153. * by interpolating between its current value and the newly set one once triggered.
  43154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43155. */
  43156. export class InterpolateValueAction extends Action {
  43157. /**
  43158. * Defines the path of the property where the value should be interpolated
  43159. */
  43160. propertyPath: string;
  43161. /**
  43162. * Defines the target value at the end of the interpolation.
  43163. */
  43164. value: any;
  43165. /**
  43166. * Defines the time it will take for the property to interpolate to the value.
  43167. */
  43168. duration: number;
  43169. /**
  43170. * Defines if the other scene animations should be stopped when the action has been triggered
  43171. */
  43172. stopOtherAnimations?: boolean;
  43173. /**
  43174. * Defines a callback raised once the interpolation animation has been done.
  43175. */
  43176. onInterpolationDone?: () => void;
  43177. /**
  43178. * Observable triggered once the interpolation animation has been done.
  43179. */
  43180. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43181. private _target;
  43182. private _effectiveTarget;
  43183. private _property;
  43184. /**
  43185. * Instantiate the action
  43186. * @param triggerOptions defines the trigger options
  43187. * @param target defines the object containing the value to interpolate
  43188. * @param propertyPath defines the path to the property in the target object
  43189. * @param value defines the target value at the end of the interpolation
  43190. * @param duration deines the time it will take for the property to interpolate to the value.
  43191. * @param condition defines the trigger related conditions
  43192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43194. */
  43195. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43196. /** @hidden */
  43197. _prepare(): void;
  43198. /**
  43199. * Execute the action starts the value interpolation.
  43200. */
  43201. execute(): void;
  43202. /**
  43203. * Serializes the actions and its related information.
  43204. * @param parent defines the object to serialize in
  43205. * @returns the serialized object
  43206. */
  43207. serialize(parent: any): any;
  43208. }
  43209. }
  43210. declare module "babylonjs/Actions/index" {
  43211. export * from "babylonjs/Actions/abstractActionManager";
  43212. export * from "babylonjs/Actions/action";
  43213. export * from "babylonjs/Actions/actionEvent";
  43214. export * from "babylonjs/Actions/actionManager";
  43215. export * from "babylonjs/Actions/condition";
  43216. export * from "babylonjs/Actions/directActions";
  43217. export * from "babylonjs/Actions/directAudioActions";
  43218. export * from "babylonjs/Actions/interpolateValueAction";
  43219. }
  43220. declare module "babylonjs/Animations/index" {
  43221. export * from "babylonjs/Animations/animatable";
  43222. export * from "babylonjs/Animations/animation";
  43223. export * from "babylonjs/Animations/animationGroup";
  43224. export * from "babylonjs/Animations/animationPropertiesOverride";
  43225. export * from "babylonjs/Animations/easing";
  43226. export * from "babylonjs/Animations/runtimeAnimation";
  43227. export * from "babylonjs/Animations/animationEvent";
  43228. export * from "babylonjs/Animations/animationGroup";
  43229. export * from "babylonjs/Animations/animationKey";
  43230. export * from "babylonjs/Animations/animationRange";
  43231. export * from "babylonjs/Animations/animatable.interface";
  43232. }
  43233. declare module "babylonjs/Audio/soundTrack" {
  43234. import { Sound } from "babylonjs/Audio/sound";
  43235. import { Analyser } from "babylonjs/Audio/analyser";
  43236. import { Scene } from "babylonjs/scene";
  43237. /**
  43238. * Options allowed during the creation of a sound track.
  43239. */
  43240. export interface ISoundTrackOptions {
  43241. /**
  43242. * The volume the sound track should take during creation
  43243. */
  43244. volume?: number;
  43245. /**
  43246. * Define if the sound track is the main sound track of the scene
  43247. */
  43248. mainTrack?: boolean;
  43249. }
  43250. /**
  43251. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43252. * It will be also used in a future release to apply effects on a specific track.
  43253. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43254. */
  43255. export class SoundTrack {
  43256. /**
  43257. * The unique identifier of the sound track in the scene.
  43258. */
  43259. id: number;
  43260. /**
  43261. * The list of sounds included in the sound track.
  43262. */
  43263. soundCollection: Array<Sound>;
  43264. private _outputAudioNode;
  43265. private _scene;
  43266. private _connectedAnalyser;
  43267. private _options;
  43268. private _isInitialized;
  43269. /**
  43270. * Creates a new sound track.
  43271. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43272. * @param scene Define the scene the sound track belongs to
  43273. * @param options
  43274. */
  43275. constructor(scene: Scene, options?: ISoundTrackOptions);
  43276. private _initializeSoundTrackAudioGraph;
  43277. /**
  43278. * Release the sound track and its associated resources
  43279. */
  43280. dispose(): void;
  43281. /**
  43282. * Adds a sound to this sound track
  43283. * @param sound define the cound to add
  43284. * @ignoreNaming
  43285. */
  43286. AddSound(sound: Sound): void;
  43287. /**
  43288. * Removes a sound to this sound track
  43289. * @param sound define the cound to remove
  43290. * @ignoreNaming
  43291. */
  43292. RemoveSound(sound: Sound): void;
  43293. /**
  43294. * Set a global volume for the full sound track.
  43295. * @param newVolume Define the new volume of the sound track
  43296. */
  43297. setVolume(newVolume: number): void;
  43298. /**
  43299. * Switch the panning model to HRTF:
  43300. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43301. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43302. */
  43303. switchPanningModelToHRTF(): void;
  43304. /**
  43305. * Switch the panning model to Equal Power:
  43306. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43308. */
  43309. switchPanningModelToEqualPower(): void;
  43310. /**
  43311. * Connect the sound track to an audio analyser allowing some amazing
  43312. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43313. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43314. * @param analyser The analyser to connect to the engine
  43315. */
  43316. connectToAnalyser(analyser: Analyser): void;
  43317. }
  43318. }
  43319. declare module "babylonjs/Audio/audioSceneComponent" {
  43320. import { Sound } from "babylonjs/Audio/sound";
  43321. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43322. import { Nullable } from "babylonjs/types";
  43323. import { Vector3 } from "babylonjs/Maths/math.vector";
  43324. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43325. import { Scene } from "babylonjs/scene";
  43326. import { AbstractScene } from "babylonjs/abstractScene";
  43327. import "babylonjs/Audio/audioEngine";
  43328. module "babylonjs/abstractScene" {
  43329. interface AbstractScene {
  43330. /**
  43331. * The list of sounds used in the scene.
  43332. */
  43333. sounds: Nullable<Array<Sound>>;
  43334. }
  43335. }
  43336. module "babylonjs/scene" {
  43337. interface Scene {
  43338. /**
  43339. * @hidden
  43340. * Backing field
  43341. */
  43342. _mainSoundTrack: SoundTrack;
  43343. /**
  43344. * The main sound track played by the scene.
  43345. * It cotains your primary collection of sounds.
  43346. */
  43347. mainSoundTrack: SoundTrack;
  43348. /**
  43349. * The list of sound tracks added to the scene
  43350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43351. */
  43352. soundTracks: Nullable<Array<SoundTrack>>;
  43353. /**
  43354. * Gets a sound using a given name
  43355. * @param name defines the name to search for
  43356. * @return the found sound or null if not found at all.
  43357. */
  43358. getSoundByName(name: string): Nullable<Sound>;
  43359. /**
  43360. * Gets or sets if audio support is enabled
  43361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43362. */
  43363. audioEnabled: boolean;
  43364. /**
  43365. * Gets or sets if audio will be output to headphones
  43366. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43367. */
  43368. headphone: boolean;
  43369. /**
  43370. * Gets or sets custom audio listener position provider
  43371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43372. */
  43373. audioListenerPositionProvider: Nullable<() => Vector3>;
  43374. /**
  43375. * Gets or sets a refresh rate when using 3D audio positioning
  43376. */
  43377. audioPositioningRefreshRate: number;
  43378. }
  43379. }
  43380. /**
  43381. * Defines the sound scene component responsible to manage any sounds
  43382. * in a given scene.
  43383. */
  43384. export class AudioSceneComponent implements ISceneSerializableComponent {
  43385. /**
  43386. * The component name helpfull to identify the component in the list of scene components.
  43387. */
  43388. readonly name: string;
  43389. /**
  43390. * The scene the component belongs to.
  43391. */
  43392. scene: Scene;
  43393. private _audioEnabled;
  43394. /**
  43395. * Gets whether audio is enabled or not.
  43396. * Please use related enable/disable method to switch state.
  43397. */
  43398. get audioEnabled(): boolean;
  43399. private _headphone;
  43400. /**
  43401. * Gets whether audio is outputing to headphone or not.
  43402. * Please use the according Switch methods to change output.
  43403. */
  43404. get headphone(): boolean;
  43405. /**
  43406. * Gets or sets a refresh rate when using 3D audio positioning
  43407. */
  43408. audioPositioningRefreshRate: number;
  43409. private _audioListenerPositionProvider;
  43410. /**
  43411. * Gets the current audio listener position provider
  43412. */
  43413. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43414. /**
  43415. * Sets a custom listener position for all sounds in the scene
  43416. * By default, this is the position of the first active camera
  43417. */
  43418. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43419. /**
  43420. * Creates a new instance of the component for the given scene
  43421. * @param scene Defines the scene to register the component in
  43422. */
  43423. constructor(scene: Scene);
  43424. /**
  43425. * Registers the component in a given scene
  43426. */
  43427. register(): void;
  43428. /**
  43429. * Rebuilds the elements related to this component in case of
  43430. * context lost for instance.
  43431. */
  43432. rebuild(): void;
  43433. /**
  43434. * Serializes the component data to the specified json object
  43435. * @param serializationObject The object to serialize to
  43436. */
  43437. serialize(serializationObject: any): void;
  43438. /**
  43439. * Adds all the elements from the container to the scene
  43440. * @param container the container holding the elements
  43441. */
  43442. addFromContainer(container: AbstractScene): void;
  43443. /**
  43444. * Removes all the elements in the container from the scene
  43445. * @param container contains the elements to remove
  43446. * @param dispose if the removed element should be disposed (default: false)
  43447. */
  43448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43449. /**
  43450. * Disposes the component and the associated ressources.
  43451. */
  43452. dispose(): void;
  43453. /**
  43454. * Disables audio in the associated scene.
  43455. */
  43456. disableAudio(): void;
  43457. /**
  43458. * Enables audio in the associated scene.
  43459. */
  43460. enableAudio(): void;
  43461. /**
  43462. * Switch audio to headphone output.
  43463. */
  43464. switchAudioModeForHeadphones(): void;
  43465. /**
  43466. * Switch audio to normal speakers.
  43467. */
  43468. switchAudioModeForNormalSpeakers(): void;
  43469. private _cachedCameraDirection;
  43470. private _cachedCameraPosition;
  43471. private _lastCheck;
  43472. private _afterRender;
  43473. }
  43474. }
  43475. declare module "babylonjs/Audio/weightedsound" {
  43476. import { Sound } from "babylonjs/Audio/sound";
  43477. /**
  43478. * Wraps one or more Sound objects and selects one with random weight for playback.
  43479. */
  43480. export class WeightedSound {
  43481. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43482. loop: boolean;
  43483. private _coneInnerAngle;
  43484. private _coneOuterAngle;
  43485. private _volume;
  43486. /** A Sound is currently playing. */
  43487. isPlaying: boolean;
  43488. /** A Sound is currently paused. */
  43489. isPaused: boolean;
  43490. private _sounds;
  43491. private _weights;
  43492. private _currentIndex?;
  43493. /**
  43494. * Creates a new WeightedSound from the list of sounds given.
  43495. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43496. * @param sounds Array of Sounds that will be selected from.
  43497. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43498. */
  43499. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43500. /**
  43501. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43502. */
  43503. get directionalConeInnerAngle(): number;
  43504. /**
  43505. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43506. */
  43507. set directionalConeInnerAngle(value: number);
  43508. /**
  43509. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43510. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43511. */
  43512. get directionalConeOuterAngle(): number;
  43513. /**
  43514. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43515. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43516. */
  43517. set directionalConeOuterAngle(value: number);
  43518. /**
  43519. * Playback volume.
  43520. */
  43521. get volume(): number;
  43522. /**
  43523. * Playback volume.
  43524. */
  43525. set volume(value: number);
  43526. private _onended;
  43527. /**
  43528. * Suspend playback
  43529. */
  43530. pause(): void;
  43531. /**
  43532. * Stop playback
  43533. */
  43534. stop(): void;
  43535. /**
  43536. * Start playback.
  43537. * @param startOffset Position the clip head at a specific time in seconds.
  43538. */
  43539. play(startOffset?: number): void;
  43540. }
  43541. }
  43542. declare module "babylonjs/Audio/index" {
  43543. export * from "babylonjs/Audio/analyser";
  43544. export * from "babylonjs/Audio/audioEngine";
  43545. export * from "babylonjs/Audio/audioSceneComponent";
  43546. export * from "babylonjs/Audio/sound";
  43547. export * from "babylonjs/Audio/soundTrack";
  43548. export * from "babylonjs/Audio/weightedsound";
  43549. }
  43550. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43551. import { Behavior } from "babylonjs/Behaviors/behavior";
  43552. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43553. import { BackEase } from "babylonjs/Animations/easing";
  43554. /**
  43555. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43556. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43557. */
  43558. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43559. /**
  43560. * Gets the name of the behavior.
  43561. */
  43562. get name(): string;
  43563. /**
  43564. * The easing function used by animations
  43565. */
  43566. static EasingFunction: BackEase;
  43567. /**
  43568. * The easing mode used by animations
  43569. */
  43570. static EasingMode: number;
  43571. /**
  43572. * The duration of the animation, in milliseconds
  43573. */
  43574. transitionDuration: number;
  43575. /**
  43576. * Length of the distance animated by the transition when lower radius is reached
  43577. */
  43578. lowerRadiusTransitionRange: number;
  43579. /**
  43580. * Length of the distance animated by the transition when upper radius is reached
  43581. */
  43582. upperRadiusTransitionRange: number;
  43583. private _autoTransitionRange;
  43584. /**
  43585. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43586. */
  43587. get autoTransitionRange(): boolean;
  43588. /**
  43589. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43590. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43591. */
  43592. set autoTransitionRange(value: boolean);
  43593. private _attachedCamera;
  43594. private _onAfterCheckInputsObserver;
  43595. private _onMeshTargetChangedObserver;
  43596. /**
  43597. * Initializes the behavior.
  43598. */
  43599. init(): void;
  43600. /**
  43601. * Attaches the behavior to its arc rotate camera.
  43602. * @param camera Defines the camera to attach the behavior to
  43603. */
  43604. attach(camera: ArcRotateCamera): void;
  43605. /**
  43606. * Detaches the behavior from its current arc rotate camera.
  43607. */
  43608. detach(): void;
  43609. private _radiusIsAnimating;
  43610. private _radiusBounceTransition;
  43611. private _animatables;
  43612. private _cachedWheelPrecision;
  43613. /**
  43614. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43615. * @param radiusLimit The limit to check against.
  43616. * @return Bool to indicate if at limit.
  43617. */
  43618. private _isRadiusAtLimit;
  43619. /**
  43620. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43621. * @param radiusDelta The delta by which to animate to. Can be negative.
  43622. */
  43623. private _applyBoundRadiusAnimation;
  43624. /**
  43625. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43626. */
  43627. protected _clearAnimationLocks(): void;
  43628. /**
  43629. * Stops and removes all animations that have been applied to the camera
  43630. */
  43631. stopAllAnimations(): void;
  43632. }
  43633. }
  43634. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43635. import { Behavior } from "babylonjs/Behaviors/behavior";
  43636. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43637. import { ExponentialEase } from "babylonjs/Animations/easing";
  43638. import { Nullable } from "babylonjs/types";
  43639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43640. import { Vector3 } from "babylonjs/Maths/math.vector";
  43641. /**
  43642. * 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.
  43643. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43644. */
  43645. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43646. /**
  43647. * Gets the name of the behavior.
  43648. */
  43649. get name(): string;
  43650. private _mode;
  43651. private _radiusScale;
  43652. private _positionScale;
  43653. private _defaultElevation;
  43654. private _elevationReturnTime;
  43655. private _elevationReturnWaitTime;
  43656. private _zoomStopsAnimation;
  43657. private _framingTime;
  43658. /**
  43659. * The easing function used by animations
  43660. */
  43661. static EasingFunction: ExponentialEase;
  43662. /**
  43663. * The easing mode used by animations
  43664. */
  43665. static EasingMode: number;
  43666. /**
  43667. * Sets the current mode used by the behavior
  43668. */
  43669. set mode(mode: number);
  43670. /**
  43671. * Gets current mode used by the behavior.
  43672. */
  43673. get mode(): number;
  43674. /**
  43675. * Sets the scale applied to the radius (1 by default)
  43676. */
  43677. set radiusScale(radius: number);
  43678. /**
  43679. * Gets the scale applied to the radius
  43680. */
  43681. get radiusScale(): number;
  43682. /**
  43683. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43684. */
  43685. set positionScale(scale: number);
  43686. /**
  43687. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43688. */
  43689. get positionScale(): number;
  43690. /**
  43691. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43692. * behaviour is triggered, in radians.
  43693. */
  43694. set defaultElevation(elevation: number);
  43695. /**
  43696. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43697. * behaviour is triggered, in radians.
  43698. */
  43699. get defaultElevation(): number;
  43700. /**
  43701. * Sets the time (in milliseconds) taken to return to the default beta position.
  43702. * Negative value indicates camera should not return to default.
  43703. */
  43704. set elevationReturnTime(speed: number);
  43705. /**
  43706. * Gets the time (in milliseconds) taken to return to the default beta position.
  43707. * Negative value indicates camera should not return to default.
  43708. */
  43709. get elevationReturnTime(): number;
  43710. /**
  43711. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43712. */
  43713. set elevationReturnWaitTime(time: number);
  43714. /**
  43715. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43716. */
  43717. get elevationReturnWaitTime(): number;
  43718. /**
  43719. * Sets the flag that indicates if user zooming should stop animation.
  43720. */
  43721. set zoomStopsAnimation(flag: boolean);
  43722. /**
  43723. * Gets the flag that indicates if user zooming should stop animation.
  43724. */
  43725. get zoomStopsAnimation(): boolean;
  43726. /**
  43727. * Sets the transition time when framing the mesh, in milliseconds
  43728. */
  43729. set framingTime(time: number);
  43730. /**
  43731. * Gets the transition time when framing the mesh, in milliseconds
  43732. */
  43733. get framingTime(): number;
  43734. /**
  43735. * Define if the behavior should automatically change the configured
  43736. * camera limits and sensibilities.
  43737. */
  43738. autoCorrectCameraLimitsAndSensibility: boolean;
  43739. private _onPrePointerObservableObserver;
  43740. private _onAfterCheckInputsObserver;
  43741. private _onMeshTargetChangedObserver;
  43742. private _attachedCamera;
  43743. private _isPointerDown;
  43744. private _lastInteractionTime;
  43745. /**
  43746. * Initializes the behavior.
  43747. */
  43748. init(): void;
  43749. /**
  43750. * Attaches the behavior to its arc rotate camera.
  43751. * @param camera Defines the camera to attach the behavior to
  43752. */
  43753. attach(camera: ArcRotateCamera): void;
  43754. /**
  43755. * Detaches the behavior from its current arc rotate camera.
  43756. */
  43757. detach(): void;
  43758. private _animatables;
  43759. private _betaIsAnimating;
  43760. private _betaTransition;
  43761. private _radiusTransition;
  43762. private _vectorTransition;
  43763. /**
  43764. * Targets the given mesh and updates zoom level accordingly.
  43765. * @param mesh The mesh to target.
  43766. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43767. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43768. */
  43769. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43770. /**
  43771. * Targets the given mesh with its children and updates zoom level accordingly.
  43772. * @param mesh The mesh to target.
  43773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43775. */
  43776. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43777. /**
  43778. * Targets the given meshes with their children and updates zoom level accordingly.
  43779. * @param meshes The mesh to target.
  43780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43782. */
  43783. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43784. /**
  43785. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43786. * @param minimumWorld Determines the smaller position of the bounding box extend
  43787. * @param maximumWorld Determines the bigger position of the bounding box extend
  43788. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43789. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43790. */
  43791. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43792. /**
  43793. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43794. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43795. * frustum width.
  43796. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43797. * to fully enclose the mesh in the viewing frustum.
  43798. */
  43799. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43800. /**
  43801. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43802. * is automatically returned to its default position (expected to be above ground plane).
  43803. */
  43804. private _maintainCameraAboveGround;
  43805. /**
  43806. * Returns the frustum slope based on the canvas ratio and camera FOV
  43807. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43808. */
  43809. private _getFrustumSlope;
  43810. /**
  43811. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43812. */
  43813. private _clearAnimationLocks;
  43814. /**
  43815. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43816. */
  43817. private _applyUserInteraction;
  43818. /**
  43819. * Stops and removes all animations that have been applied to the camera
  43820. */
  43821. stopAllAnimations(): void;
  43822. /**
  43823. * Gets a value indicating if the user is moving the camera
  43824. */
  43825. get isUserIsMoving(): boolean;
  43826. /**
  43827. * The camera can move all the way towards the mesh.
  43828. */
  43829. static IgnoreBoundsSizeMode: number;
  43830. /**
  43831. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43832. */
  43833. static FitFrustumSidesMode: number;
  43834. }
  43835. }
  43836. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43837. import { Nullable } from "babylonjs/types";
  43838. import { Camera } from "babylonjs/Cameras/camera";
  43839. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43840. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43841. /**
  43842. * Base class for Camera Pointer Inputs.
  43843. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43844. * for example usage.
  43845. */
  43846. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43847. /**
  43848. * Defines the camera the input is attached to.
  43849. */
  43850. abstract camera: Camera;
  43851. /**
  43852. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43853. */
  43854. protected _altKey: boolean;
  43855. protected _ctrlKey: boolean;
  43856. protected _metaKey: boolean;
  43857. protected _shiftKey: boolean;
  43858. /**
  43859. * Which mouse buttons were pressed at time of last mouse event.
  43860. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43861. */
  43862. protected _buttonsPressed: number;
  43863. /**
  43864. * Defines the buttons associated with the input to handle camera move.
  43865. */
  43866. buttons: number[];
  43867. /**
  43868. * Attach the input controls to a specific dom element to get the input from.
  43869. * @param element Defines the element the controls should be listened from
  43870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43871. */
  43872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43873. /**
  43874. * Detach the current controls from the specified dom element.
  43875. * @param element Defines the element to stop listening the inputs from
  43876. */
  43877. detachControl(element: Nullable<HTMLElement>): void;
  43878. /**
  43879. * Gets the class name of the current input.
  43880. * @returns the class name
  43881. */
  43882. getClassName(): string;
  43883. /**
  43884. * Get the friendly name associated with the input class.
  43885. * @returns the input friendly name
  43886. */
  43887. getSimpleName(): string;
  43888. /**
  43889. * Called on pointer POINTERDOUBLETAP event.
  43890. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43891. */
  43892. protected onDoubleTap(type: string): void;
  43893. /**
  43894. * Called on pointer POINTERMOVE event if only a single touch is active.
  43895. * Override this method to provide functionality.
  43896. */
  43897. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43898. /**
  43899. * Called on pointer POINTERMOVE event if multiple touches are active.
  43900. * Override this method to provide functionality.
  43901. */
  43902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43903. /**
  43904. * Called on JS contextmenu event.
  43905. * Override this method to provide functionality.
  43906. */
  43907. protected onContextMenu(evt: PointerEvent): void;
  43908. /**
  43909. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43910. * press.
  43911. * Override this method to provide functionality.
  43912. */
  43913. protected onButtonDown(evt: PointerEvent): void;
  43914. /**
  43915. * Called each time a new POINTERUP event occurs. Ie, for each button
  43916. * release.
  43917. * Override this method to provide functionality.
  43918. */
  43919. protected onButtonUp(evt: PointerEvent): void;
  43920. /**
  43921. * Called when window becomes inactive.
  43922. * Override this method to provide functionality.
  43923. */
  43924. protected onLostFocus(): void;
  43925. private _pointerInput;
  43926. private _observer;
  43927. private _onLostFocus;
  43928. private pointA;
  43929. private pointB;
  43930. }
  43931. }
  43932. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43933. import { Nullable } from "babylonjs/types";
  43934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43935. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43936. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43937. /**
  43938. * Manage the pointers inputs to control an arc rotate camera.
  43939. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43940. */
  43941. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43942. /**
  43943. * Defines the camera the input is attached to.
  43944. */
  43945. camera: ArcRotateCamera;
  43946. /**
  43947. * Gets the class name of the current input.
  43948. * @returns the class name
  43949. */
  43950. getClassName(): string;
  43951. /**
  43952. * Defines the buttons associated with the input to handle camera move.
  43953. */
  43954. buttons: number[];
  43955. /**
  43956. * Defines the pointer angular sensibility along the X axis or how fast is
  43957. * the camera rotating.
  43958. */
  43959. angularSensibilityX: number;
  43960. /**
  43961. * Defines the pointer angular sensibility along the Y axis or how fast is
  43962. * the camera rotating.
  43963. */
  43964. angularSensibilityY: number;
  43965. /**
  43966. * Defines the pointer pinch precision or how fast is the camera zooming.
  43967. */
  43968. pinchPrecision: number;
  43969. /**
  43970. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43971. * from 0.
  43972. * It defines the percentage of current camera.radius to use as delta when
  43973. * pinch zoom is used.
  43974. */
  43975. pinchDeltaPercentage: number;
  43976. /**
  43977. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43978. * that any object in the plane at the camera's target point will scale
  43979. * perfectly with finger motion.
  43980. * Overrides pinchDeltaPercentage and pinchPrecision.
  43981. */
  43982. useNaturalPinchZoom: boolean;
  43983. /**
  43984. * Defines the pointer panning sensibility or how fast is the camera moving.
  43985. */
  43986. panningSensibility: number;
  43987. /**
  43988. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43989. */
  43990. multiTouchPanning: boolean;
  43991. /**
  43992. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43993. * zoom (pinch) through multitouch.
  43994. */
  43995. multiTouchPanAndZoom: boolean;
  43996. /**
  43997. * Revers pinch action direction.
  43998. */
  43999. pinchInwards: boolean;
  44000. private _isPanClick;
  44001. private _twoFingerActivityCount;
  44002. private _isPinching;
  44003. /**
  44004. * Called on pointer POINTERMOVE event if only a single touch is active.
  44005. */
  44006. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44007. /**
  44008. * Called on pointer POINTERDOUBLETAP event.
  44009. */
  44010. protected onDoubleTap(type: string): void;
  44011. /**
  44012. * Called on pointer POINTERMOVE event if multiple touches are active.
  44013. */
  44014. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44015. /**
  44016. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44017. * press.
  44018. */
  44019. protected onButtonDown(evt: PointerEvent): void;
  44020. /**
  44021. * Called each time a new POINTERUP event occurs. Ie, for each button
  44022. * release.
  44023. */
  44024. protected onButtonUp(evt: PointerEvent): void;
  44025. /**
  44026. * Called when window becomes inactive.
  44027. */
  44028. protected onLostFocus(): void;
  44029. }
  44030. }
  44031. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44032. import { Nullable } from "babylonjs/types";
  44033. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44035. /**
  44036. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44038. */
  44039. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44040. /**
  44041. * Defines the camera the input is attached to.
  44042. */
  44043. camera: ArcRotateCamera;
  44044. /**
  44045. * Defines the list of key codes associated with the up action (increase alpha)
  44046. */
  44047. keysUp: number[];
  44048. /**
  44049. * Defines the list of key codes associated with the down action (decrease alpha)
  44050. */
  44051. keysDown: number[];
  44052. /**
  44053. * Defines the list of key codes associated with the left action (increase beta)
  44054. */
  44055. keysLeft: number[];
  44056. /**
  44057. * Defines the list of key codes associated with the right action (decrease beta)
  44058. */
  44059. keysRight: number[];
  44060. /**
  44061. * Defines the list of key codes associated with the reset action.
  44062. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44063. */
  44064. keysReset: number[];
  44065. /**
  44066. * Defines the panning sensibility of the inputs.
  44067. * (How fast is the camera panning)
  44068. */
  44069. panningSensibility: number;
  44070. /**
  44071. * Defines the zooming sensibility of the inputs.
  44072. * (How fast is the camera zooming)
  44073. */
  44074. zoomingSensibility: number;
  44075. /**
  44076. * Defines whether maintaining the alt key down switch the movement mode from
  44077. * orientation to zoom.
  44078. */
  44079. useAltToZoom: boolean;
  44080. /**
  44081. * Rotation speed of the camera
  44082. */
  44083. angularSpeed: number;
  44084. private _keys;
  44085. private _ctrlPressed;
  44086. private _altPressed;
  44087. private _onCanvasBlurObserver;
  44088. private _onKeyboardObserver;
  44089. private _engine;
  44090. private _scene;
  44091. /**
  44092. * Attach the input controls to a specific dom element to get the input from.
  44093. * @param element Defines the element the controls should be listened from
  44094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44095. */
  44096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44097. /**
  44098. * Detach the current controls from the specified dom element.
  44099. * @param element Defines the element to stop listening the inputs from
  44100. */
  44101. detachControl(element: Nullable<HTMLElement>): void;
  44102. /**
  44103. * Update the current camera state depending on the inputs that have been used this frame.
  44104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44105. */
  44106. checkInputs(): void;
  44107. /**
  44108. * Gets the class name of the current intput.
  44109. * @returns the class name
  44110. */
  44111. getClassName(): string;
  44112. /**
  44113. * Get the friendly name associated with the input class.
  44114. * @returns the input friendly name
  44115. */
  44116. getSimpleName(): string;
  44117. }
  44118. }
  44119. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44120. import { Nullable } from "babylonjs/types";
  44121. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44123. /**
  44124. * Manage the mouse wheel inputs to control an arc rotate camera.
  44125. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44126. */
  44127. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44128. /**
  44129. * Defines the camera the input is attached to.
  44130. */
  44131. camera: ArcRotateCamera;
  44132. /**
  44133. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44134. */
  44135. wheelPrecision: number;
  44136. /**
  44137. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44138. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44139. */
  44140. wheelDeltaPercentage: number;
  44141. private _wheel;
  44142. private _observer;
  44143. private computeDeltaFromMouseWheelLegacyEvent;
  44144. /**
  44145. * Attach the input controls to a specific dom element to get the input from.
  44146. * @param element Defines the element the controls should be listened from
  44147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44148. */
  44149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44150. /**
  44151. * Detach the current controls from the specified dom element.
  44152. * @param element Defines the element to stop listening the inputs from
  44153. */
  44154. detachControl(element: Nullable<HTMLElement>): void;
  44155. /**
  44156. * Gets the class name of the current intput.
  44157. * @returns the class name
  44158. */
  44159. getClassName(): string;
  44160. /**
  44161. * Get the friendly name associated with the input class.
  44162. * @returns the input friendly name
  44163. */
  44164. getSimpleName(): string;
  44165. }
  44166. }
  44167. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44168. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44170. /**
  44171. * Default Inputs manager for the ArcRotateCamera.
  44172. * It groups all the default supported inputs for ease of use.
  44173. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44174. */
  44175. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44176. /**
  44177. * Instantiates a new ArcRotateCameraInputsManager.
  44178. * @param camera Defines the camera the inputs belong to
  44179. */
  44180. constructor(camera: ArcRotateCamera);
  44181. /**
  44182. * Add mouse wheel input support to the input manager.
  44183. * @returns the current input manager
  44184. */
  44185. addMouseWheel(): ArcRotateCameraInputsManager;
  44186. /**
  44187. * Add pointers input support to the input manager.
  44188. * @returns the current input manager
  44189. */
  44190. addPointers(): ArcRotateCameraInputsManager;
  44191. /**
  44192. * Add keyboard input support to the input manager.
  44193. * @returns the current input manager
  44194. */
  44195. addKeyboard(): ArcRotateCameraInputsManager;
  44196. }
  44197. }
  44198. declare module "babylonjs/Cameras/arcRotateCamera" {
  44199. import { Observable } from "babylonjs/Misc/observable";
  44200. import { Nullable } from "babylonjs/types";
  44201. import { Scene } from "babylonjs/scene";
  44202. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44204. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44205. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44206. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44207. import { Camera } from "babylonjs/Cameras/camera";
  44208. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44209. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44210. import { Collider } from "babylonjs/Collisions/collider";
  44211. /**
  44212. * This represents an orbital type of camera.
  44213. *
  44214. * 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.
  44215. * 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.
  44216. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44217. */
  44218. export class ArcRotateCamera extends TargetCamera {
  44219. /**
  44220. * Defines the rotation angle of the camera along the longitudinal axis.
  44221. */
  44222. alpha: number;
  44223. /**
  44224. * Defines the rotation angle of the camera along the latitudinal axis.
  44225. */
  44226. beta: number;
  44227. /**
  44228. * Defines the radius of the camera from it s target point.
  44229. */
  44230. radius: number;
  44231. protected _target: Vector3;
  44232. protected _targetHost: Nullable<AbstractMesh>;
  44233. /**
  44234. * Defines the target point of the camera.
  44235. * The camera looks towards it form the radius distance.
  44236. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44237. */
  44238. get target(): Vector3;
  44239. set target(value: Vector3);
  44240. /**
  44241. * Define the current local position of the camera in the scene
  44242. */
  44243. get position(): Vector3;
  44244. set position(newPosition: Vector3);
  44245. protected _upVector: Vector3;
  44246. protected _upToYMatrix: Matrix;
  44247. protected _YToUpMatrix: Matrix;
  44248. /**
  44249. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44250. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44251. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44252. */
  44253. set upVector(vec: Vector3);
  44254. get upVector(): Vector3;
  44255. /**
  44256. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44257. */
  44258. setMatUp(): void;
  44259. /**
  44260. * Current inertia value on the longitudinal axis.
  44261. * The bigger this number the longer it will take for the camera to stop.
  44262. */
  44263. inertialAlphaOffset: number;
  44264. /**
  44265. * Current inertia value on the latitudinal axis.
  44266. * The bigger this number the longer it will take for the camera to stop.
  44267. */
  44268. inertialBetaOffset: number;
  44269. /**
  44270. * Current inertia value on the radius axis.
  44271. * The bigger this number the longer it will take for the camera to stop.
  44272. */
  44273. inertialRadiusOffset: number;
  44274. /**
  44275. * Minimum allowed angle on the longitudinal axis.
  44276. * This can help limiting how the Camera is able to move in the scene.
  44277. */
  44278. lowerAlphaLimit: Nullable<number>;
  44279. /**
  44280. * Maximum allowed angle on the longitudinal axis.
  44281. * This can help limiting how the Camera is able to move in the scene.
  44282. */
  44283. upperAlphaLimit: Nullable<number>;
  44284. /**
  44285. * Minimum allowed angle on the latitudinal axis.
  44286. * This can help limiting how the Camera is able to move in the scene.
  44287. */
  44288. lowerBetaLimit: number;
  44289. /**
  44290. * Maximum allowed angle on the latitudinal axis.
  44291. * This can help limiting how the Camera is able to move in the scene.
  44292. */
  44293. upperBetaLimit: number;
  44294. /**
  44295. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44296. * This can help limiting how the Camera is able to move in the scene.
  44297. */
  44298. lowerRadiusLimit: Nullable<number>;
  44299. /**
  44300. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44301. * This can help limiting how the Camera is able to move in the scene.
  44302. */
  44303. upperRadiusLimit: Nullable<number>;
  44304. /**
  44305. * Defines the current inertia value used during panning of the camera along the X axis.
  44306. */
  44307. inertialPanningX: number;
  44308. /**
  44309. * Defines the current inertia value used during panning of the camera along the Y axis.
  44310. */
  44311. inertialPanningY: number;
  44312. /**
  44313. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44314. * Basically if your fingers moves away from more than this distance you will be considered
  44315. * in pinch mode.
  44316. */
  44317. pinchToPanMaxDistance: number;
  44318. /**
  44319. * Defines the maximum distance the camera can pan.
  44320. * This could help keeping the cammera always in your scene.
  44321. */
  44322. panningDistanceLimit: Nullable<number>;
  44323. /**
  44324. * Defines the target of the camera before paning.
  44325. */
  44326. panningOriginTarget: Vector3;
  44327. /**
  44328. * Defines the value of the inertia used during panning.
  44329. * 0 would mean stop inertia and one would mean no decelleration at all.
  44330. */
  44331. panningInertia: number;
  44332. /**
  44333. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44334. */
  44335. get angularSensibilityX(): number;
  44336. set angularSensibilityX(value: number);
  44337. /**
  44338. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44339. */
  44340. get angularSensibilityY(): number;
  44341. set angularSensibilityY(value: number);
  44342. /**
  44343. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44344. */
  44345. get pinchPrecision(): number;
  44346. set pinchPrecision(value: number);
  44347. /**
  44348. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44349. * It will be used instead of pinchDeltaPrecision if different from 0.
  44350. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44351. */
  44352. get pinchDeltaPercentage(): number;
  44353. set pinchDeltaPercentage(value: number);
  44354. /**
  44355. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44356. * and pinch delta percentage.
  44357. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44358. * that any object in the plane at the camera's target point will scale
  44359. * perfectly with finger motion.
  44360. */
  44361. get useNaturalPinchZoom(): boolean;
  44362. set useNaturalPinchZoom(value: boolean);
  44363. /**
  44364. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44365. */
  44366. get panningSensibility(): number;
  44367. set panningSensibility(value: number);
  44368. /**
  44369. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44370. */
  44371. get keysUp(): number[];
  44372. set keysUp(value: number[]);
  44373. /**
  44374. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44375. */
  44376. get keysDown(): number[];
  44377. set keysDown(value: number[]);
  44378. /**
  44379. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44380. */
  44381. get keysLeft(): number[];
  44382. set keysLeft(value: number[]);
  44383. /**
  44384. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44385. */
  44386. get keysRight(): number[];
  44387. set keysRight(value: number[]);
  44388. /**
  44389. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44390. */
  44391. get wheelPrecision(): number;
  44392. set wheelPrecision(value: number);
  44393. /**
  44394. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44395. * It will be used instead of pinchDeltaPrecision if different from 0.
  44396. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44397. */
  44398. get wheelDeltaPercentage(): number;
  44399. set wheelDeltaPercentage(value: number);
  44400. /**
  44401. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44402. */
  44403. zoomOnFactor: number;
  44404. /**
  44405. * Defines a screen offset for the camera position.
  44406. */
  44407. targetScreenOffset: Vector2;
  44408. /**
  44409. * Allows the camera to be completely reversed.
  44410. * If false the camera can not arrive upside down.
  44411. */
  44412. allowUpsideDown: boolean;
  44413. /**
  44414. * Define if double tap/click is used to restore the previously saved state of the camera.
  44415. */
  44416. useInputToRestoreState: boolean;
  44417. /** @hidden */
  44418. _viewMatrix: Matrix;
  44419. /** @hidden */
  44420. _useCtrlForPanning: boolean;
  44421. /** @hidden */
  44422. _panningMouseButton: number;
  44423. /**
  44424. * Defines the input associated to the camera.
  44425. */
  44426. inputs: ArcRotateCameraInputsManager;
  44427. /** @hidden */
  44428. _reset: () => void;
  44429. /**
  44430. * Defines the allowed panning axis.
  44431. */
  44432. panningAxis: Vector3;
  44433. protected _localDirection: Vector3;
  44434. protected _transformedDirection: Vector3;
  44435. private _bouncingBehavior;
  44436. /**
  44437. * Gets the bouncing behavior of the camera if it has been enabled.
  44438. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44439. */
  44440. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44441. /**
  44442. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44443. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44444. */
  44445. get useBouncingBehavior(): boolean;
  44446. set useBouncingBehavior(value: boolean);
  44447. private _framingBehavior;
  44448. /**
  44449. * Gets the framing behavior of the camera if it has been enabled.
  44450. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44451. */
  44452. get framingBehavior(): Nullable<FramingBehavior>;
  44453. /**
  44454. * Defines if the framing behavior of the camera is enabled on the camera.
  44455. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44456. */
  44457. get useFramingBehavior(): boolean;
  44458. set useFramingBehavior(value: boolean);
  44459. private _autoRotationBehavior;
  44460. /**
  44461. * Gets the auto rotation behavior of the camera if it has been enabled.
  44462. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44463. */
  44464. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44465. /**
  44466. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44467. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44468. */
  44469. get useAutoRotationBehavior(): boolean;
  44470. set useAutoRotationBehavior(value: boolean);
  44471. /**
  44472. * Observable triggered when the mesh target has been changed on the camera.
  44473. */
  44474. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44475. /**
  44476. * Event raised when the camera is colliding with a mesh.
  44477. */
  44478. onCollide: (collidedMesh: AbstractMesh) => void;
  44479. /**
  44480. * Defines whether the camera should check collision with the objects oh the scene.
  44481. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44482. */
  44483. checkCollisions: boolean;
  44484. /**
  44485. * Defines the collision radius of the camera.
  44486. * This simulates a sphere around the camera.
  44487. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44488. */
  44489. collisionRadius: Vector3;
  44490. protected _collider: Collider;
  44491. protected _previousPosition: Vector3;
  44492. protected _collisionVelocity: Vector3;
  44493. protected _newPosition: Vector3;
  44494. protected _previousAlpha: number;
  44495. protected _previousBeta: number;
  44496. protected _previousRadius: number;
  44497. protected _collisionTriggered: boolean;
  44498. protected _targetBoundingCenter: Nullable<Vector3>;
  44499. private _computationVector;
  44500. /**
  44501. * Instantiates a new ArcRotateCamera in a given scene
  44502. * @param name Defines the name of the camera
  44503. * @param alpha Defines the camera rotation along the logitudinal axis
  44504. * @param beta Defines the camera rotation along the latitudinal axis
  44505. * @param radius Defines the camera distance from its target
  44506. * @param target Defines the camera target
  44507. * @param scene Defines the scene the camera belongs to
  44508. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44509. */
  44510. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44511. /** @hidden */
  44512. _initCache(): void;
  44513. /** @hidden */
  44514. _updateCache(ignoreParentClass?: boolean): void;
  44515. protected _getTargetPosition(): Vector3;
  44516. private _storedAlpha;
  44517. private _storedBeta;
  44518. private _storedRadius;
  44519. private _storedTarget;
  44520. private _storedTargetScreenOffset;
  44521. /**
  44522. * Stores the current state of the camera (alpha, beta, radius and target)
  44523. * @returns the camera itself
  44524. */
  44525. storeState(): Camera;
  44526. /**
  44527. * @hidden
  44528. * Restored camera state. You must call storeState() first
  44529. */
  44530. _restoreStateValues(): boolean;
  44531. /** @hidden */
  44532. _isSynchronizedViewMatrix(): boolean;
  44533. /**
  44534. * Attached controls to the current camera.
  44535. * @param element Defines the element the controls should be listened from
  44536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44537. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44538. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44539. */
  44540. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44541. /**
  44542. * Detach the current controls from the camera.
  44543. * The camera will stop reacting to inputs.
  44544. * @param element Defines the element to stop listening the inputs from
  44545. */
  44546. detachControl(element: HTMLElement): void;
  44547. /** @hidden */
  44548. _checkInputs(): void;
  44549. protected _checkLimits(): void;
  44550. /**
  44551. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44552. */
  44553. rebuildAnglesAndRadius(): void;
  44554. /**
  44555. * Use a position to define the current camera related information like alpha, beta and radius
  44556. * @param position Defines the position to set the camera at
  44557. */
  44558. setPosition(position: Vector3): void;
  44559. /**
  44560. * Defines the target the camera should look at.
  44561. * This will automatically adapt alpha beta and radius to fit within the new target.
  44562. * @param target Defines the new target as a Vector or a mesh
  44563. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44564. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44565. */
  44566. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44567. /** @hidden */
  44568. _getViewMatrix(): Matrix;
  44569. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44570. /**
  44571. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44572. * @param meshes Defines the mesh to zoom on
  44573. * @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)
  44574. */
  44575. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44576. /**
  44577. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44578. * The target will be changed but the radius
  44579. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44580. * @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)
  44581. */
  44582. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44583. min: Vector3;
  44584. max: Vector3;
  44585. distance: number;
  44586. }, doNotUpdateMaxZ?: boolean): void;
  44587. /**
  44588. * @override
  44589. * Override Camera.createRigCamera
  44590. */
  44591. createRigCamera(name: string, cameraIndex: number): Camera;
  44592. /**
  44593. * @hidden
  44594. * @override
  44595. * Override Camera._updateRigCameras
  44596. */
  44597. _updateRigCameras(): void;
  44598. /**
  44599. * Destroy the camera and release the current resources hold by it.
  44600. */
  44601. dispose(): void;
  44602. /**
  44603. * Gets the current object class name.
  44604. * @return the class name
  44605. */
  44606. getClassName(): string;
  44607. }
  44608. }
  44609. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44610. import { Behavior } from "babylonjs/Behaviors/behavior";
  44611. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44612. /**
  44613. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44614. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44615. */
  44616. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44617. /**
  44618. * Gets the name of the behavior.
  44619. */
  44620. get name(): string;
  44621. private _zoomStopsAnimation;
  44622. private _idleRotationSpeed;
  44623. private _idleRotationWaitTime;
  44624. private _idleRotationSpinupTime;
  44625. /**
  44626. * Sets the flag that indicates if user zooming should stop animation.
  44627. */
  44628. set zoomStopsAnimation(flag: boolean);
  44629. /**
  44630. * Gets the flag that indicates if user zooming should stop animation.
  44631. */
  44632. get zoomStopsAnimation(): boolean;
  44633. /**
  44634. * Sets the default speed at which the camera rotates around the model.
  44635. */
  44636. set idleRotationSpeed(speed: number);
  44637. /**
  44638. * Gets the default speed at which the camera rotates around the model.
  44639. */
  44640. get idleRotationSpeed(): number;
  44641. /**
  44642. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44643. */
  44644. set idleRotationWaitTime(time: number);
  44645. /**
  44646. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44647. */
  44648. get idleRotationWaitTime(): number;
  44649. /**
  44650. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44651. */
  44652. set idleRotationSpinupTime(time: number);
  44653. /**
  44654. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44655. */
  44656. get idleRotationSpinupTime(): number;
  44657. /**
  44658. * Gets a value indicating if the camera is currently rotating because of this behavior
  44659. */
  44660. get rotationInProgress(): boolean;
  44661. private _onPrePointerObservableObserver;
  44662. private _onAfterCheckInputsObserver;
  44663. private _attachedCamera;
  44664. private _isPointerDown;
  44665. private _lastFrameTime;
  44666. private _lastInteractionTime;
  44667. private _cameraRotationSpeed;
  44668. /**
  44669. * Initializes the behavior.
  44670. */
  44671. init(): void;
  44672. /**
  44673. * Attaches the behavior to its arc rotate camera.
  44674. * @param camera Defines the camera to attach the behavior to
  44675. */
  44676. attach(camera: ArcRotateCamera): void;
  44677. /**
  44678. * Detaches the behavior from its current arc rotate camera.
  44679. */
  44680. detach(): void;
  44681. /**
  44682. * Returns true if user is scrolling.
  44683. * @return true if user is scrolling.
  44684. */
  44685. private _userIsZooming;
  44686. private _lastFrameRadius;
  44687. private _shouldAnimationStopForInteraction;
  44688. /**
  44689. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44690. */
  44691. private _applyUserInteraction;
  44692. private _userIsMoving;
  44693. }
  44694. }
  44695. declare module "babylonjs/Behaviors/Cameras/index" {
  44696. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44697. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44698. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44699. }
  44700. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44701. import { Mesh } from "babylonjs/Meshes/mesh";
  44702. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44703. import { Behavior } from "babylonjs/Behaviors/behavior";
  44704. /**
  44705. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44706. */
  44707. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44708. private ui;
  44709. /**
  44710. * The name of the behavior
  44711. */
  44712. name: string;
  44713. /**
  44714. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44715. */
  44716. distanceAwayFromFace: number;
  44717. /**
  44718. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44719. */
  44720. distanceAwayFromBottomOfFace: number;
  44721. private _faceVectors;
  44722. private _target;
  44723. private _scene;
  44724. private _onRenderObserver;
  44725. private _tmpMatrix;
  44726. private _tmpVector;
  44727. /**
  44728. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44729. * @param ui The transform node that should be attched to the mesh
  44730. */
  44731. constructor(ui: TransformNode);
  44732. /**
  44733. * Initializes the behavior
  44734. */
  44735. init(): void;
  44736. private _closestFace;
  44737. private _zeroVector;
  44738. private _lookAtTmpMatrix;
  44739. private _lookAtToRef;
  44740. /**
  44741. * Attaches the AttachToBoxBehavior to the passed in mesh
  44742. * @param target The mesh that the specified node will be attached to
  44743. */
  44744. attach(target: Mesh): void;
  44745. /**
  44746. * Detaches the behavior from the mesh
  44747. */
  44748. detach(): void;
  44749. }
  44750. }
  44751. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44752. import { Behavior } from "babylonjs/Behaviors/behavior";
  44753. import { Mesh } from "babylonjs/Meshes/mesh";
  44754. /**
  44755. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44756. */
  44757. export class FadeInOutBehavior implements Behavior<Mesh> {
  44758. /**
  44759. * Time in milliseconds to delay before fading in (Default: 0)
  44760. */
  44761. delay: number;
  44762. /**
  44763. * Time in milliseconds for the mesh to fade in (Default: 300)
  44764. */
  44765. fadeInTime: number;
  44766. private _millisecondsPerFrame;
  44767. private _hovered;
  44768. private _hoverValue;
  44769. private _ownerNode;
  44770. /**
  44771. * Instatiates the FadeInOutBehavior
  44772. */
  44773. constructor();
  44774. /**
  44775. * The name of the behavior
  44776. */
  44777. get name(): string;
  44778. /**
  44779. * Initializes the behavior
  44780. */
  44781. init(): void;
  44782. /**
  44783. * Attaches the fade behavior on the passed in mesh
  44784. * @param ownerNode The mesh that will be faded in/out once attached
  44785. */
  44786. attach(ownerNode: Mesh): void;
  44787. /**
  44788. * Detaches the behavior from the mesh
  44789. */
  44790. detach(): void;
  44791. /**
  44792. * Triggers the mesh to begin fading in or out
  44793. * @param value if the object should fade in or out (true to fade in)
  44794. */
  44795. fadeIn(value: boolean): void;
  44796. private _update;
  44797. private _setAllVisibility;
  44798. }
  44799. }
  44800. declare module "babylonjs/Misc/pivotTools" {
  44801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44802. /**
  44803. * Class containing a set of static utilities functions for managing Pivots
  44804. * @hidden
  44805. */
  44806. export class PivotTools {
  44807. private static _PivotCached;
  44808. private static _OldPivotPoint;
  44809. private static _PivotTranslation;
  44810. private static _PivotTmpVector;
  44811. /** @hidden */
  44812. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44813. /** @hidden */
  44814. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44815. }
  44816. }
  44817. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44818. import { Scene } from "babylonjs/scene";
  44819. import { Vector4 } from "babylonjs/Maths/math.vector";
  44820. import { Mesh } from "babylonjs/Meshes/mesh";
  44821. import { Nullable } from "babylonjs/types";
  44822. import { Plane } from "babylonjs/Maths/math.plane";
  44823. /**
  44824. * Class containing static functions to help procedurally build meshes
  44825. */
  44826. export class PlaneBuilder {
  44827. /**
  44828. * Creates a plane mesh
  44829. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44830. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44831. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44835. * @param name defines the name of the mesh
  44836. * @param options defines the options used to create the mesh
  44837. * @param scene defines the hosting scene
  44838. * @returns the plane mesh
  44839. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44840. */
  44841. static CreatePlane(name: string, options: {
  44842. size?: number;
  44843. width?: number;
  44844. height?: number;
  44845. sideOrientation?: number;
  44846. frontUVs?: Vector4;
  44847. backUVs?: Vector4;
  44848. updatable?: boolean;
  44849. sourcePlane?: Plane;
  44850. }, scene?: Nullable<Scene>): Mesh;
  44851. }
  44852. }
  44853. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44854. import { Behavior } from "babylonjs/Behaviors/behavior";
  44855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44856. import { Observable } from "babylonjs/Misc/observable";
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Ray } from "babylonjs/Culling/ray";
  44859. import "babylonjs/Meshes/Builders/planeBuilder";
  44860. /**
  44861. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44862. */
  44863. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44864. private static _AnyMouseID;
  44865. /**
  44866. * Abstract mesh the behavior is set on
  44867. */
  44868. attachedNode: AbstractMesh;
  44869. private _dragPlane;
  44870. private _scene;
  44871. private _pointerObserver;
  44872. private _beforeRenderObserver;
  44873. private static _planeScene;
  44874. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44875. /**
  44876. * 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)
  44877. */
  44878. maxDragAngle: number;
  44879. /**
  44880. * @hidden
  44881. */
  44882. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44883. /**
  44884. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44885. */
  44886. currentDraggingPointerID: number;
  44887. /**
  44888. * The last position where the pointer hit the drag plane in world space
  44889. */
  44890. lastDragPosition: Vector3;
  44891. /**
  44892. * If the behavior is currently in a dragging state
  44893. */
  44894. dragging: boolean;
  44895. /**
  44896. * 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)
  44897. */
  44898. dragDeltaRatio: number;
  44899. /**
  44900. * If the drag plane orientation should be updated during the dragging (Default: true)
  44901. */
  44902. updateDragPlane: boolean;
  44903. private _debugMode;
  44904. private _moving;
  44905. /**
  44906. * Fires each time the attached mesh is dragged with the pointer
  44907. * * delta between last drag position and current drag position in world space
  44908. * * dragDistance along the drag axis
  44909. * * dragPlaneNormal normal of the current drag plane used during the drag
  44910. * * dragPlanePoint in world space where the drag intersects the drag plane
  44911. */
  44912. onDragObservable: Observable<{
  44913. delta: Vector3;
  44914. dragPlanePoint: Vector3;
  44915. dragPlaneNormal: Vector3;
  44916. dragDistance: number;
  44917. pointerId: number;
  44918. }>;
  44919. /**
  44920. * Fires each time a drag begins (eg. mouse down on mesh)
  44921. */
  44922. onDragStartObservable: Observable<{
  44923. dragPlanePoint: Vector3;
  44924. pointerId: number;
  44925. }>;
  44926. /**
  44927. * Fires each time a drag ends (eg. mouse release after drag)
  44928. */
  44929. onDragEndObservable: Observable<{
  44930. dragPlanePoint: Vector3;
  44931. pointerId: number;
  44932. }>;
  44933. /**
  44934. * If the attached mesh should be moved when dragged
  44935. */
  44936. moveAttached: boolean;
  44937. /**
  44938. * If the drag behavior will react to drag events (Default: true)
  44939. */
  44940. enabled: boolean;
  44941. /**
  44942. * If pointer events should start and release the drag (Default: true)
  44943. */
  44944. startAndReleaseDragOnPointerEvents: boolean;
  44945. /**
  44946. * If camera controls should be detached during the drag
  44947. */
  44948. detachCameraControls: boolean;
  44949. /**
  44950. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44951. */
  44952. useObjectOrientationForDragging: boolean;
  44953. private _options;
  44954. /**
  44955. * Gets the options used by the behavior
  44956. */
  44957. get options(): {
  44958. dragAxis?: Vector3;
  44959. dragPlaneNormal?: Vector3;
  44960. };
  44961. /**
  44962. * Sets the options used by the behavior
  44963. */
  44964. set options(options: {
  44965. dragAxis?: Vector3;
  44966. dragPlaneNormal?: Vector3;
  44967. });
  44968. /**
  44969. * Creates a pointer drag behavior that can be attached to a mesh
  44970. * @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)
  44971. */
  44972. constructor(options?: {
  44973. dragAxis?: Vector3;
  44974. dragPlaneNormal?: Vector3;
  44975. });
  44976. /**
  44977. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44978. */
  44979. validateDrag: (targetPosition: Vector3) => boolean;
  44980. /**
  44981. * The name of the behavior
  44982. */
  44983. get name(): string;
  44984. /**
  44985. * Initializes the behavior
  44986. */
  44987. init(): void;
  44988. private _tmpVector;
  44989. private _alternatePickedPoint;
  44990. private _worldDragAxis;
  44991. private _targetPosition;
  44992. private _attachedElement;
  44993. /**
  44994. * Attaches the drag behavior the passed in mesh
  44995. * @param ownerNode The mesh that will be dragged around once attached
  44996. * @param predicate Predicate to use for pick filtering
  44997. */
  44998. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44999. /**
  45000. * Force relase the drag action by code.
  45001. */
  45002. releaseDrag(): void;
  45003. private _startDragRay;
  45004. private _lastPointerRay;
  45005. /**
  45006. * Simulates the start of a pointer drag event on the behavior
  45007. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45008. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45009. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45010. */
  45011. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45012. private _startDrag;
  45013. private _dragDelta;
  45014. private _moveDrag;
  45015. private _pickWithRayOnDragPlane;
  45016. private _pointA;
  45017. private _pointC;
  45018. private _localAxis;
  45019. private _lookAt;
  45020. private _updateDragPlanePosition;
  45021. /**
  45022. * Detaches the behavior from the mesh
  45023. */
  45024. detach(): void;
  45025. }
  45026. }
  45027. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45028. import { Mesh } from "babylonjs/Meshes/mesh";
  45029. import { Behavior } from "babylonjs/Behaviors/behavior";
  45030. /**
  45031. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45032. */
  45033. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45034. private _dragBehaviorA;
  45035. private _dragBehaviorB;
  45036. private _startDistance;
  45037. private _initialScale;
  45038. private _targetScale;
  45039. private _ownerNode;
  45040. private _sceneRenderObserver;
  45041. /**
  45042. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45043. */
  45044. constructor();
  45045. /**
  45046. * The name of the behavior
  45047. */
  45048. get name(): string;
  45049. /**
  45050. * Initializes the behavior
  45051. */
  45052. init(): void;
  45053. private _getCurrentDistance;
  45054. /**
  45055. * Attaches the scale behavior the passed in mesh
  45056. * @param ownerNode The mesh that will be scaled around once attached
  45057. */
  45058. attach(ownerNode: Mesh): void;
  45059. /**
  45060. * Detaches the behavior from the mesh
  45061. */
  45062. detach(): void;
  45063. }
  45064. }
  45065. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45066. import { Behavior } from "babylonjs/Behaviors/behavior";
  45067. import { Mesh } from "babylonjs/Meshes/mesh";
  45068. import { Observable } from "babylonjs/Misc/observable";
  45069. /**
  45070. * 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
  45071. */
  45072. export class SixDofDragBehavior implements Behavior<Mesh> {
  45073. private static _virtualScene;
  45074. private _ownerNode;
  45075. private _sceneRenderObserver;
  45076. private _scene;
  45077. private _targetPosition;
  45078. private _virtualOriginMesh;
  45079. private _virtualDragMesh;
  45080. private _pointerObserver;
  45081. private _moving;
  45082. private _startingOrientation;
  45083. private _attachedElement;
  45084. /**
  45085. * 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)
  45086. */
  45087. private zDragFactor;
  45088. /**
  45089. * If the object should rotate to face the drag origin
  45090. */
  45091. rotateDraggedObject: boolean;
  45092. /**
  45093. * If the behavior is currently in a dragging state
  45094. */
  45095. dragging: boolean;
  45096. /**
  45097. * 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)
  45098. */
  45099. dragDeltaRatio: number;
  45100. /**
  45101. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45102. */
  45103. currentDraggingPointerID: number;
  45104. /**
  45105. * If camera controls should be detached during the drag
  45106. */
  45107. detachCameraControls: boolean;
  45108. /**
  45109. * Fires each time a drag starts
  45110. */
  45111. onDragStartObservable: Observable<{}>;
  45112. /**
  45113. * Fires each time a drag ends (eg. mouse release after drag)
  45114. */
  45115. onDragEndObservable: Observable<{}>;
  45116. /**
  45117. * 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
  45118. */
  45119. constructor();
  45120. /**
  45121. * The name of the behavior
  45122. */
  45123. get name(): string;
  45124. /**
  45125. * Initializes the behavior
  45126. */
  45127. init(): void;
  45128. /**
  45129. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45130. */
  45131. private get _pointerCamera();
  45132. /**
  45133. * Attaches the scale behavior the passed in mesh
  45134. * @param ownerNode The mesh that will be scaled around once attached
  45135. */
  45136. attach(ownerNode: Mesh): void;
  45137. /**
  45138. * Detaches the behavior from the mesh
  45139. */
  45140. detach(): void;
  45141. }
  45142. }
  45143. declare module "babylonjs/Behaviors/Meshes/index" {
  45144. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45145. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45146. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45147. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45148. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45149. }
  45150. declare module "babylonjs/Behaviors/index" {
  45151. export * from "babylonjs/Behaviors/behavior";
  45152. export * from "babylonjs/Behaviors/Cameras/index";
  45153. export * from "babylonjs/Behaviors/Meshes/index";
  45154. }
  45155. declare module "babylonjs/Bones/boneIKController" {
  45156. import { Bone } from "babylonjs/Bones/bone";
  45157. import { Vector3 } from "babylonjs/Maths/math.vector";
  45158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45159. import { Nullable } from "babylonjs/types";
  45160. /**
  45161. * Class used to apply inverse kinematics to bones
  45162. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45163. */
  45164. export class BoneIKController {
  45165. private static _tmpVecs;
  45166. private static _tmpQuat;
  45167. private static _tmpMats;
  45168. /**
  45169. * Gets or sets the target mesh
  45170. */
  45171. targetMesh: AbstractMesh;
  45172. /** Gets or sets the mesh used as pole */
  45173. poleTargetMesh: AbstractMesh;
  45174. /**
  45175. * Gets or sets the bone used as pole
  45176. */
  45177. poleTargetBone: Nullable<Bone>;
  45178. /**
  45179. * Gets or sets the target position
  45180. */
  45181. targetPosition: Vector3;
  45182. /**
  45183. * Gets or sets the pole target position
  45184. */
  45185. poleTargetPosition: Vector3;
  45186. /**
  45187. * Gets or sets the pole target local offset
  45188. */
  45189. poleTargetLocalOffset: Vector3;
  45190. /**
  45191. * Gets or sets the pole angle
  45192. */
  45193. poleAngle: number;
  45194. /**
  45195. * Gets or sets the mesh associated with the controller
  45196. */
  45197. mesh: AbstractMesh;
  45198. /**
  45199. * 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)
  45200. */
  45201. slerpAmount: number;
  45202. private _bone1Quat;
  45203. private _bone1Mat;
  45204. private _bone2Ang;
  45205. private _bone1;
  45206. private _bone2;
  45207. private _bone1Length;
  45208. private _bone2Length;
  45209. private _maxAngle;
  45210. private _maxReach;
  45211. private _rightHandedSystem;
  45212. private _bendAxis;
  45213. private _slerping;
  45214. private _adjustRoll;
  45215. /**
  45216. * Gets or sets maximum allowed angle
  45217. */
  45218. get maxAngle(): number;
  45219. set maxAngle(value: number);
  45220. /**
  45221. * Creates a new BoneIKController
  45222. * @param mesh defines the mesh to control
  45223. * @param bone defines the bone to control
  45224. * @param options defines options to set up the controller
  45225. */
  45226. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45227. targetMesh?: AbstractMesh;
  45228. poleTargetMesh?: AbstractMesh;
  45229. poleTargetBone?: Bone;
  45230. poleTargetLocalOffset?: Vector3;
  45231. poleAngle?: number;
  45232. bendAxis?: Vector3;
  45233. maxAngle?: number;
  45234. slerpAmount?: number;
  45235. });
  45236. private _setMaxAngle;
  45237. /**
  45238. * Force the controller to update the bones
  45239. */
  45240. update(): void;
  45241. }
  45242. }
  45243. declare module "babylonjs/Bones/boneLookController" {
  45244. import { Vector3 } from "babylonjs/Maths/math.vector";
  45245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45246. import { Bone } from "babylonjs/Bones/bone";
  45247. import { Space } from "babylonjs/Maths/math.axis";
  45248. /**
  45249. * Class used to make a bone look toward a point in space
  45250. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45251. */
  45252. export class BoneLookController {
  45253. private static _tmpVecs;
  45254. private static _tmpQuat;
  45255. private static _tmpMats;
  45256. /**
  45257. * The target Vector3 that the bone will look at
  45258. */
  45259. target: Vector3;
  45260. /**
  45261. * The mesh that the bone is attached to
  45262. */
  45263. mesh: AbstractMesh;
  45264. /**
  45265. * The bone that will be looking to the target
  45266. */
  45267. bone: Bone;
  45268. /**
  45269. * The up axis of the coordinate system that is used when the bone is rotated
  45270. */
  45271. upAxis: Vector3;
  45272. /**
  45273. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45274. */
  45275. upAxisSpace: Space;
  45276. /**
  45277. * Used to make an adjustment to the yaw of the bone
  45278. */
  45279. adjustYaw: number;
  45280. /**
  45281. * Used to make an adjustment to the pitch of the bone
  45282. */
  45283. adjustPitch: number;
  45284. /**
  45285. * Used to make an adjustment to the roll of the bone
  45286. */
  45287. adjustRoll: number;
  45288. /**
  45289. * 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)
  45290. */
  45291. slerpAmount: number;
  45292. private _minYaw;
  45293. private _maxYaw;
  45294. private _minPitch;
  45295. private _maxPitch;
  45296. private _minYawSin;
  45297. private _minYawCos;
  45298. private _maxYawSin;
  45299. private _maxYawCos;
  45300. private _midYawConstraint;
  45301. private _minPitchTan;
  45302. private _maxPitchTan;
  45303. private _boneQuat;
  45304. private _slerping;
  45305. private _transformYawPitch;
  45306. private _transformYawPitchInv;
  45307. private _firstFrameSkipped;
  45308. private _yawRange;
  45309. private _fowardAxis;
  45310. /**
  45311. * Gets or sets the minimum yaw angle that the bone can look to
  45312. */
  45313. get minYaw(): number;
  45314. set minYaw(value: number);
  45315. /**
  45316. * Gets or sets the maximum yaw angle that the bone can look to
  45317. */
  45318. get maxYaw(): number;
  45319. set maxYaw(value: number);
  45320. /**
  45321. * Gets or sets the minimum pitch angle that the bone can look to
  45322. */
  45323. get minPitch(): number;
  45324. set minPitch(value: number);
  45325. /**
  45326. * Gets or sets the maximum pitch angle that the bone can look to
  45327. */
  45328. get maxPitch(): number;
  45329. set maxPitch(value: number);
  45330. /**
  45331. * Create a BoneLookController
  45332. * @param mesh the mesh that the bone belongs to
  45333. * @param bone the bone that will be looking to the target
  45334. * @param target the target Vector3 to look at
  45335. * @param options optional settings:
  45336. * * maxYaw: the maximum angle the bone will yaw to
  45337. * * minYaw: the minimum angle the bone will yaw to
  45338. * * maxPitch: the maximum angle the bone will pitch to
  45339. * * minPitch: the minimum angle the bone will yaw to
  45340. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45341. * * upAxis: the up axis of the coordinate system
  45342. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45343. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45344. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45345. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45346. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45347. * * adjustRoll: used to make an adjustment to the roll of the bone
  45348. **/
  45349. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45350. maxYaw?: number;
  45351. minYaw?: number;
  45352. maxPitch?: number;
  45353. minPitch?: number;
  45354. slerpAmount?: number;
  45355. upAxis?: Vector3;
  45356. upAxisSpace?: Space;
  45357. yawAxis?: Vector3;
  45358. pitchAxis?: Vector3;
  45359. adjustYaw?: number;
  45360. adjustPitch?: number;
  45361. adjustRoll?: number;
  45362. });
  45363. /**
  45364. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45365. */
  45366. update(): void;
  45367. private _getAngleDiff;
  45368. private _getAngleBetween;
  45369. private _isAngleBetween;
  45370. }
  45371. }
  45372. declare module "babylonjs/Bones/index" {
  45373. export * from "babylonjs/Bones/bone";
  45374. export * from "babylonjs/Bones/boneIKController";
  45375. export * from "babylonjs/Bones/boneLookController";
  45376. export * from "babylonjs/Bones/skeleton";
  45377. }
  45378. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45379. import { Nullable } from "babylonjs/types";
  45380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45381. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45382. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45383. /**
  45384. * Manage the gamepad inputs to control an arc rotate camera.
  45385. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45386. */
  45387. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45388. /**
  45389. * Defines the camera the input is attached to.
  45390. */
  45391. camera: ArcRotateCamera;
  45392. /**
  45393. * Defines the gamepad the input is gathering event from.
  45394. */
  45395. gamepad: Nullable<Gamepad>;
  45396. /**
  45397. * Defines the gamepad rotation sensiblity.
  45398. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45399. */
  45400. gamepadRotationSensibility: number;
  45401. /**
  45402. * Defines the gamepad move sensiblity.
  45403. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45404. */
  45405. gamepadMoveSensibility: number;
  45406. private _yAxisScale;
  45407. /**
  45408. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45409. */
  45410. get invertYAxis(): boolean;
  45411. set invertYAxis(value: boolean);
  45412. private _onGamepadConnectedObserver;
  45413. private _onGamepadDisconnectedObserver;
  45414. /**
  45415. * Attach the input controls to a specific dom element to get the input from.
  45416. * @param element Defines the element the controls should be listened from
  45417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45418. */
  45419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45420. /**
  45421. * Detach the current controls from the specified dom element.
  45422. * @param element Defines the element to stop listening the inputs from
  45423. */
  45424. detachControl(element: Nullable<HTMLElement>): void;
  45425. /**
  45426. * Update the current camera state depending on the inputs that have been used this frame.
  45427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45428. */
  45429. checkInputs(): void;
  45430. /**
  45431. * Gets the class name of the current intput.
  45432. * @returns the class name
  45433. */
  45434. getClassName(): string;
  45435. /**
  45436. * Get the friendly name associated with the input class.
  45437. * @returns the input friendly name
  45438. */
  45439. getSimpleName(): string;
  45440. }
  45441. }
  45442. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45443. import { Nullable } from "babylonjs/types";
  45444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45445. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45446. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45447. interface ArcRotateCameraInputsManager {
  45448. /**
  45449. * Add orientation input support to the input manager.
  45450. * @returns the current input manager
  45451. */
  45452. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45453. }
  45454. }
  45455. /**
  45456. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45458. */
  45459. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45460. /**
  45461. * Defines the camera the input is attached to.
  45462. */
  45463. camera: ArcRotateCamera;
  45464. /**
  45465. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45466. */
  45467. alphaCorrection: number;
  45468. /**
  45469. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45470. */
  45471. gammaCorrection: number;
  45472. private _alpha;
  45473. private _gamma;
  45474. private _dirty;
  45475. private _deviceOrientationHandler;
  45476. /**
  45477. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45478. */
  45479. constructor();
  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. /** @hidden */
  45487. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45488. /**
  45489. * Update the current camera state depending on the inputs that have been used this frame.
  45490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45491. */
  45492. checkInputs(): void;
  45493. /**
  45494. * Detach the current controls from the specified dom element.
  45495. * @param element Defines the element to stop listening the inputs from
  45496. */
  45497. detachControl(element: Nullable<HTMLElement>): 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/flyCameraMouseInput" {
  45511. import { Nullable } from "babylonjs/types";
  45512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45513. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45514. /**
  45515. * Listen to mouse events to control the camera.
  45516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45517. */
  45518. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45519. /**
  45520. * Defines the camera the input is attached to.
  45521. */
  45522. camera: FlyCamera;
  45523. /**
  45524. * Defines if touch is enabled. (Default is true.)
  45525. */
  45526. touchEnabled: boolean;
  45527. /**
  45528. * Defines the buttons associated with the input to handle camera rotation.
  45529. */
  45530. buttons: number[];
  45531. /**
  45532. * Assign buttons for Yaw control.
  45533. */
  45534. buttonsYaw: number[];
  45535. /**
  45536. * Assign buttons for Pitch control.
  45537. */
  45538. buttonsPitch: number[];
  45539. /**
  45540. * Assign buttons for Roll control.
  45541. */
  45542. buttonsRoll: number[];
  45543. /**
  45544. * Detect if any button is being pressed while mouse is moved.
  45545. * -1 = Mouse locked.
  45546. * 0 = Left button.
  45547. * 1 = Middle Button.
  45548. * 2 = Right Button.
  45549. */
  45550. activeButton: number;
  45551. /**
  45552. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45553. * Higher values reduce its sensitivity.
  45554. */
  45555. angularSensibility: number;
  45556. private _mousemoveCallback;
  45557. private _observer;
  45558. private _rollObserver;
  45559. private previousPosition;
  45560. private noPreventDefault;
  45561. private element;
  45562. /**
  45563. * Listen to mouse events to control the camera.
  45564. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45565. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45566. */
  45567. constructor(touchEnabled?: boolean);
  45568. /**
  45569. * Attach the mouse control to the HTML DOM element.
  45570. * @param element Defines the element that listens to the input events.
  45571. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45572. */
  45573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45574. /**
  45575. * Detach the current controls from the specified dom element.
  45576. * @param element Defines the element to stop listening the inputs from
  45577. */
  45578. detachControl(element: Nullable<HTMLElement>): void;
  45579. /**
  45580. * Gets the class name of the current input.
  45581. * @returns the class name.
  45582. */
  45583. getClassName(): string;
  45584. /**
  45585. * Get the friendly name associated with the input class.
  45586. * @returns the input's friendly name.
  45587. */
  45588. getSimpleName(): string;
  45589. private _pointerInput;
  45590. private _onMouseMove;
  45591. /**
  45592. * Rotate camera by mouse offset.
  45593. */
  45594. private rotateCamera;
  45595. }
  45596. }
  45597. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45598. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45599. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45600. /**
  45601. * Default Inputs manager for the FlyCamera.
  45602. * It groups all the default supported inputs for ease of use.
  45603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45604. */
  45605. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45606. /**
  45607. * Instantiates a new FlyCameraInputsManager.
  45608. * @param camera Defines the camera the inputs belong to.
  45609. */
  45610. constructor(camera: FlyCamera);
  45611. /**
  45612. * Add keyboard input support to the input manager.
  45613. * @returns the new FlyCameraKeyboardMoveInput().
  45614. */
  45615. addKeyboard(): FlyCameraInputsManager;
  45616. /**
  45617. * Add mouse input support to the input manager.
  45618. * @param touchEnabled Enable touch screen support.
  45619. * @returns the new FlyCameraMouseInput().
  45620. */
  45621. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45622. }
  45623. }
  45624. declare module "babylonjs/Cameras/flyCamera" {
  45625. import { Scene } from "babylonjs/scene";
  45626. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45628. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45629. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45630. /**
  45631. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45632. * such as in a 3D Space Shooter or a Flight Simulator.
  45633. */
  45634. export class FlyCamera extends TargetCamera {
  45635. /**
  45636. * Define the collision ellipsoid of the camera.
  45637. * This is helpful for simulating a camera body, like a player's body.
  45638. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45639. */
  45640. ellipsoid: Vector3;
  45641. /**
  45642. * Define an offset for the position of the ellipsoid around the camera.
  45643. * This can be helpful if the camera is attached away from the player's body center,
  45644. * such as at its head.
  45645. */
  45646. ellipsoidOffset: Vector3;
  45647. /**
  45648. * Enable or disable collisions of the camera with the rest of the scene objects.
  45649. */
  45650. checkCollisions: boolean;
  45651. /**
  45652. * Enable or disable gravity on the camera.
  45653. */
  45654. applyGravity: boolean;
  45655. /**
  45656. * Define the current direction the camera is moving to.
  45657. */
  45658. cameraDirection: Vector3;
  45659. /**
  45660. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45661. * This overrides and empties cameraRotation.
  45662. */
  45663. rotationQuaternion: Quaternion;
  45664. /**
  45665. * Track Roll to maintain the wanted Rolling when looking around.
  45666. */
  45667. _trackRoll: number;
  45668. /**
  45669. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45670. */
  45671. rollCorrect: number;
  45672. /**
  45673. * Mimic a banked turn, Rolling the camera when Yawing.
  45674. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45675. */
  45676. bankedTurn: boolean;
  45677. /**
  45678. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45679. */
  45680. bankedTurnLimit: number;
  45681. /**
  45682. * Value of 0 disables the banked Roll.
  45683. * Value of 1 is equal to the Yaw angle in radians.
  45684. */
  45685. bankedTurnMultiplier: number;
  45686. /**
  45687. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45688. */
  45689. inputs: FlyCameraInputsManager;
  45690. /**
  45691. * Gets the input sensibility for mouse input.
  45692. * Higher values reduce sensitivity.
  45693. */
  45694. get angularSensibility(): number;
  45695. /**
  45696. * Sets the input sensibility for a mouse input.
  45697. * Higher values reduce sensitivity.
  45698. */
  45699. set angularSensibility(value: number);
  45700. /**
  45701. * Get the keys for camera movement forward.
  45702. */
  45703. get keysForward(): number[];
  45704. /**
  45705. * Set the keys for camera movement forward.
  45706. */
  45707. set keysForward(value: number[]);
  45708. /**
  45709. * Get the keys for camera movement backward.
  45710. */
  45711. get keysBackward(): number[];
  45712. set keysBackward(value: number[]);
  45713. /**
  45714. * Get the keys for camera movement up.
  45715. */
  45716. get keysUp(): number[];
  45717. /**
  45718. * Set the keys for camera movement up.
  45719. */
  45720. set keysUp(value: number[]);
  45721. /**
  45722. * Get the keys for camera movement down.
  45723. */
  45724. get keysDown(): number[];
  45725. /**
  45726. * Set the keys for camera movement down.
  45727. */
  45728. set keysDown(value: number[]);
  45729. /**
  45730. * Get the keys for camera movement left.
  45731. */
  45732. get keysLeft(): number[];
  45733. /**
  45734. * Set the keys for camera movement left.
  45735. */
  45736. set keysLeft(value: number[]);
  45737. /**
  45738. * Set the keys for camera movement right.
  45739. */
  45740. get keysRight(): number[];
  45741. /**
  45742. * Set the keys for camera movement right.
  45743. */
  45744. set keysRight(value: number[]);
  45745. /**
  45746. * Event raised when the camera collides with a mesh in the scene.
  45747. */
  45748. onCollide: (collidedMesh: AbstractMesh) => void;
  45749. private _collider;
  45750. private _needMoveForGravity;
  45751. private _oldPosition;
  45752. private _diffPosition;
  45753. private _newPosition;
  45754. /** @hidden */
  45755. _localDirection: Vector3;
  45756. /** @hidden */
  45757. _transformedDirection: Vector3;
  45758. /**
  45759. * Instantiates a FlyCamera.
  45760. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45761. * such as in a 3D Space Shooter or a Flight Simulator.
  45762. * @param name Define the name of the camera in the scene.
  45763. * @param position Define the starting position of the camera in the scene.
  45764. * @param scene Define the scene the camera belongs to.
  45765. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45766. */
  45767. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45768. /**
  45769. * Attach a control to the HTML DOM element.
  45770. * @param element Defines the element that listens to the input events.
  45771. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45772. */
  45773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45774. /**
  45775. * Detach a control from the HTML DOM element.
  45776. * The camera will stop reacting to that input.
  45777. * @param element Defines the element that listens to the input events.
  45778. */
  45779. detachControl(element: HTMLElement): void;
  45780. private _collisionMask;
  45781. /**
  45782. * Get the mask that the camera ignores in collision events.
  45783. */
  45784. get collisionMask(): number;
  45785. /**
  45786. * Set the mask that the camera ignores in collision events.
  45787. */
  45788. set collisionMask(mask: number);
  45789. /** @hidden */
  45790. _collideWithWorld(displacement: Vector3): void;
  45791. /** @hidden */
  45792. private _onCollisionPositionChange;
  45793. /** @hidden */
  45794. _checkInputs(): void;
  45795. /** @hidden */
  45796. _decideIfNeedsToMove(): boolean;
  45797. /** @hidden */
  45798. _updatePosition(): void;
  45799. /**
  45800. * Restore the Roll to its target value at the rate specified.
  45801. * @param rate - Higher means slower restoring.
  45802. * @hidden
  45803. */
  45804. restoreRoll(rate: number): void;
  45805. /**
  45806. * Destroy the camera and release the current resources held by it.
  45807. */
  45808. dispose(): void;
  45809. /**
  45810. * Get the current object class name.
  45811. * @returns the class name.
  45812. */
  45813. getClassName(): string;
  45814. }
  45815. }
  45816. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45817. import { Nullable } from "babylonjs/types";
  45818. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45819. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45820. /**
  45821. * Listen to keyboard events to control the camera.
  45822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45823. */
  45824. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45825. /**
  45826. * Defines the camera the input is attached to.
  45827. */
  45828. camera: FlyCamera;
  45829. /**
  45830. * The list of keyboard keys used to control the forward move of the camera.
  45831. */
  45832. keysForward: number[];
  45833. /**
  45834. * The list of keyboard keys used to control the backward move of the camera.
  45835. */
  45836. keysBackward: number[];
  45837. /**
  45838. * The list of keyboard keys used to control the forward move of the camera.
  45839. */
  45840. keysUp: number[];
  45841. /**
  45842. * The list of keyboard keys used to control the backward move of the camera.
  45843. */
  45844. keysDown: number[];
  45845. /**
  45846. * The list of keyboard keys used to control the right strafe move of the camera.
  45847. */
  45848. keysRight: number[];
  45849. /**
  45850. * The list of keyboard keys used to control the left strafe move of the camera.
  45851. */
  45852. keysLeft: number[];
  45853. private _keys;
  45854. private _onCanvasBlurObserver;
  45855. private _onKeyboardObserver;
  45856. private _engine;
  45857. private _scene;
  45858. /**
  45859. * Attach the input controls to a specific dom element to get the input from.
  45860. * @param element Defines the element the controls should be listened from
  45861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45862. */
  45863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45864. /**
  45865. * Detach the current controls from the specified dom element.
  45866. * @param element Defines the element to stop listening the inputs from
  45867. */
  45868. detachControl(element: Nullable<HTMLElement>): void;
  45869. /**
  45870. * Gets the class name of the current intput.
  45871. * @returns the class name
  45872. */
  45873. getClassName(): string;
  45874. /** @hidden */
  45875. _onLostFocus(e: FocusEvent): void;
  45876. /**
  45877. * Get the friendly name associated with the input class.
  45878. * @returns the input friendly name
  45879. */
  45880. getSimpleName(): string;
  45881. /**
  45882. * Update the current camera state depending on the inputs that have been used this frame.
  45883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45884. */
  45885. checkInputs(): void;
  45886. }
  45887. }
  45888. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45889. import { Nullable } from "babylonjs/types";
  45890. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45892. /**
  45893. * Manage the mouse wheel inputs to control a follow camera.
  45894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45895. */
  45896. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45897. /**
  45898. * Defines the camera the input is attached to.
  45899. */
  45900. camera: FollowCamera;
  45901. /**
  45902. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45903. */
  45904. axisControlRadius: boolean;
  45905. /**
  45906. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45907. */
  45908. axisControlHeight: boolean;
  45909. /**
  45910. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45911. */
  45912. axisControlRotation: boolean;
  45913. /**
  45914. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45915. * relation to mouseWheel events.
  45916. */
  45917. wheelPrecision: number;
  45918. /**
  45919. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45920. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45921. */
  45922. wheelDeltaPercentage: number;
  45923. private _wheel;
  45924. private _observer;
  45925. /**
  45926. * Attach the input controls to a specific dom element to get the input from.
  45927. * @param element Defines the element the controls should be listened from
  45928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45929. */
  45930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45931. /**
  45932. * Detach the current controls from the specified dom element.
  45933. * @param element Defines the element to stop listening the inputs from
  45934. */
  45935. detachControl(element: Nullable<HTMLElement>): void;
  45936. /**
  45937. * Gets the class name of the current intput.
  45938. * @returns the class name
  45939. */
  45940. getClassName(): string;
  45941. /**
  45942. * Get the friendly name associated with the input class.
  45943. * @returns the input friendly name
  45944. */
  45945. getSimpleName(): string;
  45946. }
  45947. }
  45948. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45949. import { Nullable } from "babylonjs/types";
  45950. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45951. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45953. /**
  45954. * Manage the pointers inputs to control an follow camera.
  45955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45956. */
  45957. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45958. /**
  45959. * Defines the camera the input is attached to.
  45960. */
  45961. camera: FollowCamera;
  45962. /**
  45963. * Gets the class name of the current input.
  45964. * @returns the class name
  45965. */
  45966. getClassName(): string;
  45967. /**
  45968. * Defines the pointer angular sensibility along the X axis or how fast is
  45969. * the camera rotating.
  45970. * A negative number will reverse the axis direction.
  45971. */
  45972. angularSensibilityX: number;
  45973. /**
  45974. * Defines the pointer angular sensibility along the Y axis or how fast is
  45975. * the camera rotating.
  45976. * A negative number will reverse the axis direction.
  45977. */
  45978. angularSensibilityY: number;
  45979. /**
  45980. * Defines the pointer pinch precision or how fast is the camera zooming.
  45981. * A negative number will reverse the axis direction.
  45982. */
  45983. pinchPrecision: number;
  45984. /**
  45985. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45986. * from 0.
  45987. * It defines the percentage of current camera.radius to use as delta when
  45988. * pinch zoom is used.
  45989. */
  45990. pinchDeltaPercentage: number;
  45991. /**
  45992. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45993. */
  45994. axisXControlRadius: boolean;
  45995. /**
  45996. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45997. */
  45998. axisXControlHeight: boolean;
  45999. /**
  46000. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46001. */
  46002. axisXControlRotation: boolean;
  46003. /**
  46004. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46005. */
  46006. axisYControlRadius: boolean;
  46007. /**
  46008. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46009. */
  46010. axisYControlHeight: boolean;
  46011. /**
  46012. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46013. */
  46014. axisYControlRotation: boolean;
  46015. /**
  46016. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46017. */
  46018. axisPinchControlRadius: boolean;
  46019. /**
  46020. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46021. */
  46022. axisPinchControlHeight: boolean;
  46023. /**
  46024. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46025. */
  46026. axisPinchControlRotation: boolean;
  46027. /**
  46028. * Log error messages if basic misconfiguration has occurred.
  46029. */
  46030. warningEnable: boolean;
  46031. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46032. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46033. private _warningCounter;
  46034. private _warning;
  46035. }
  46036. }
  46037. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46038. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46039. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46040. /**
  46041. * Default Inputs manager for the FollowCamera.
  46042. * It groups all the default supported inputs for ease of use.
  46043. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46044. */
  46045. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46046. /**
  46047. * Instantiates a new FollowCameraInputsManager.
  46048. * @param camera Defines the camera the inputs belong to
  46049. */
  46050. constructor(camera: FollowCamera);
  46051. /**
  46052. * Add keyboard input support to the input manager.
  46053. * @returns the current input manager
  46054. */
  46055. addKeyboard(): FollowCameraInputsManager;
  46056. /**
  46057. * Add mouse wheel input support to the input manager.
  46058. * @returns the current input manager
  46059. */
  46060. addMouseWheel(): FollowCameraInputsManager;
  46061. /**
  46062. * Add pointers input support to the input manager.
  46063. * @returns the current input manager
  46064. */
  46065. addPointers(): FollowCameraInputsManager;
  46066. /**
  46067. * Add orientation input support to the input manager.
  46068. * @returns the current input manager
  46069. */
  46070. addVRDeviceOrientation(): FollowCameraInputsManager;
  46071. }
  46072. }
  46073. declare module "babylonjs/Cameras/followCamera" {
  46074. import { Nullable } from "babylonjs/types";
  46075. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46076. import { Scene } from "babylonjs/scene";
  46077. import { Vector3 } from "babylonjs/Maths/math.vector";
  46078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46079. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46080. /**
  46081. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46082. * an arc rotate version arcFollowCamera are available.
  46083. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46084. */
  46085. export class FollowCamera extends TargetCamera {
  46086. /**
  46087. * Distance the follow camera should follow an object at
  46088. */
  46089. radius: number;
  46090. /**
  46091. * Minimum allowed distance of the camera to the axis of rotation
  46092. * (The camera can not get closer).
  46093. * This can help limiting how the Camera is able to move in the scene.
  46094. */
  46095. lowerRadiusLimit: Nullable<number>;
  46096. /**
  46097. * Maximum allowed distance of the camera to the axis of rotation
  46098. * (The camera can not get further).
  46099. * This can help limiting how the Camera is able to move in the scene.
  46100. */
  46101. upperRadiusLimit: Nullable<number>;
  46102. /**
  46103. * Define a rotation offset between the camera and the object it follows
  46104. */
  46105. rotationOffset: number;
  46106. /**
  46107. * Minimum allowed angle to camera position relative to target object.
  46108. * This can help limiting how the Camera is able to move in the scene.
  46109. */
  46110. lowerRotationOffsetLimit: Nullable<number>;
  46111. /**
  46112. * Maximum allowed angle to camera position relative to target object.
  46113. * This can help limiting how the Camera is able to move in the scene.
  46114. */
  46115. upperRotationOffsetLimit: Nullable<number>;
  46116. /**
  46117. * Define a height offset between the camera and the object it follows.
  46118. * It can help following an object from the top (like a car chaing a plane)
  46119. */
  46120. heightOffset: number;
  46121. /**
  46122. * Minimum allowed height of camera position relative to target object.
  46123. * This can help limiting how the Camera is able to move in the scene.
  46124. */
  46125. lowerHeightOffsetLimit: Nullable<number>;
  46126. /**
  46127. * Maximum allowed height of camera position relative to target object.
  46128. * This can help limiting how the Camera is able to move in the scene.
  46129. */
  46130. upperHeightOffsetLimit: Nullable<number>;
  46131. /**
  46132. * Define how fast the camera can accelerate to follow it s target.
  46133. */
  46134. cameraAcceleration: number;
  46135. /**
  46136. * Define the speed limit of the camera following an object.
  46137. */
  46138. maxCameraSpeed: number;
  46139. /**
  46140. * Define the target of the camera.
  46141. */
  46142. lockedTarget: Nullable<AbstractMesh>;
  46143. /**
  46144. * Defines the input associated with the camera.
  46145. */
  46146. inputs: FollowCameraInputsManager;
  46147. /**
  46148. * Instantiates the follow camera.
  46149. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46150. * @param name Define the name of the camera in the scene
  46151. * @param position Define the position of the camera
  46152. * @param scene Define the scene the camera belong to
  46153. * @param lockedTarget Define the target of the camera
  46154. */
  46155. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46156. private _follow;
  46157. /**
  46158. * Attached controls to the current camera.
  46159. * @param element Defines the element the controls should be listened from
  46160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46161. */
  46162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46163. /**
  46164. * Detach the current controls from the camera.
  46165. * The camera will stop reacting to inputs.
  46166. * @param element Defines the element to stop listening the inputs from
  46167. */
  46168. detachControl(element: HTMLElement): void;
  46169. /** @hidden */
  46170. _checkInputs(): void;
  46171. private _checkLimits;
  46172. /**
  46173. * Gets the camera class name.
  46174. * @returns the class name
  46175. */
  46176. getClassName(): string;
  46177. }
  46178. /**
  46179. * Arc Rotate version of the follow camera.
  46180. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46181. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46182. */
  46183. export class ArcFollowCamera extends TargetCamera {
  46184. /** The longitudinal angle of the camera */
  46185. alpha: number;
  46186. /** The latitudinal angle of the camera */
  46187. beta: number;
  46188. /** The radius of the camera from its target */
  46189. radius: number;
  46190. private _cartesianCoordinates;
  46191. /** Define the camera target (the mesh it should follow) */
  46192. private _meshTarget;
  46193. /**
  46194. * Instantiates a new ArcFollowCamera
  46195. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46196. * @param name Define the name of the camera
  46197. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46198. * @param beta Define the rotation angle of the camera around the elevation axis
  46199. * @param radius Define the radius of the camera from its target point
  46200. * @param target Define the target of the camera
  46201. * @param scene Define the scene the camera belongs to
  46202. */
  46203. constructor(name: string,
  46204. /** The longitudinal angle of the camera */
  46205. alpha: number,
  46206. /** The latitudinal angle of the camera */
  46207. beta: number,
  46208. /** The radius of the camera from its target */
  46209. radius: number,
  46210. /** Define the camera target (the mesh it should follow) */
  46211. target: Nullable<AbstractMesh>, scene: Scene);
  46212. private _follow;
  46213. /** @hidden */
  46214. _checkInputs(): void;
  46215. /**
  46216. * Returns the class name of the object.
  46217. * It is mostly used internally for serialization purposes.
  46218. */
  46219. getClassName(): string;
  46220. }
  46221. }
  46222. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46223. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46224. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46225. import { Nullable } from "babylonjs/types";
  46226. /**
  46227. * Manage the keyboard inputs to control the movement of a follow camera.
  46228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46229. */
  46230. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46231. /**
  46232. * Defines the camera the input is attached to.
  46233. */
  46234. camera: FollowCamera;
  46235. /**
  46236. * Defines the list of key codes associated with the up action (increase heightOffset)
  46237. */
  46238. keysHeightOffsetIncr: number[];
  46239. /**
  46240. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46241. */
  46242. keysHeightOffsetDecr: number[];
  46243. /**
  46244. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46245. */
  46246. keysHeightOffsetModifierAlt: boolean;
  46247. /**
  46248. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46249. */
  46250. keysHeightOffsetModifierCtrl: boolean;
  46251. /**
  46252. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46253. */
  46254. keysHeightOffsetModifierShift: boolean;
  46255. /**
  46256. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46257. */
  46258. keysRotationOffsetIncr: number[];
  46259. /**
  46260. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46261. */
  46262. keysRotationOffsetDecr: number[];
  46263. /**
  46264. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46265. */
  46266. keysRotationOffsetModifierAlt: boolean;
  46267. /**
  46268. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46269. */
  46270. keysRotationOffsetModifierCtrl: boolean;
  46271. /**
  46272. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46273. */
  46274. keysRotationOffsetModifierShift: boolean;
  46275. /**
  46276. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46277. */
  46278. keysRadiusIncr: number[];
  46279. /**
  46280. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46281. */
  46282. keysRadiusDecr: number[];
  46283. /**
  46284. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46285. */
  46286. keysRadiusModifierAlt: boolean;
  46287. /**
  46288. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46289. */
  46290. keysRadiusModifierCtrl: boolean;
  46291. /**
  46292. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46293. */
  46294. keysRadiusModifierShift: boolean;
  46295. /**
  46296. * Defines the rate of change of heightOffset.
  46297. */
  46298. heightSensibility: number;
  46299. /**
  46300. * Defines the rate of change of rotationOffset.
  46301. */
  46302. rotationSensibility: number;
  46303. /**
  46304. * Defines the rate of change of radius.
  46305. */
  46306. radiusSensibility: number;
  46307. private _keys;
  46308. private _ctrlPressed;
  46309. private _altPressed;
  46310. private _shiftPressed;
  46311. private _onCanvasBlurObserver;
  46312. private _onKeyboardObserver;
  46313. private _engine;
  46314. private _scene;
  46315. /**
  46316. * Attach the input controls to a specific dom element to get the input from.
  46317. * @param element Defines the element the controls should be listened from
  46318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46319. */
  46320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46321. /**
  46322. * Detach the current controls from the specified dom element.
  46323. * @param element Defines the element to stop listening the inputs from
  46324. */
  46325. detachControl(element: Nullable<HTMLElement>): void;
  46326. /**
  46327. * Update the current camera state depending on the inputs that have been used this frame.
  46328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46329. */
  46330. checkInputs(): void;
  46331. /**
  46332. * Gets the class name of the current input.
  46333. * @returns the class name
  46334. */
  46335. getClassName(): string;
  46336. /**
  46337. * Get the friendly name associated with the input class.
  46338. * @returns the input friendly name
  46339. */
  46340. getSimpleName(): string;
  46341. /**
  46342. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46343. * allow modification of the heightOffset value.
  46344. */
  46345. private _modifierHeightOffset;
  46346. /**
  46347. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46348. * allow modification of the rotationOffset value.
  46349. */
  46350. private _modifierRotationOffset;
  46351. /**
  46352. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46353. * allow modification of the radius value.
  46354. */
  46355. private _modifierRadius;
  46356. }
  46357. }
  46358. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46359. import { Nullable } from "babylonjs/types";
  46360. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46361. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46362. import { Observable } from "babylonjs/Misc/observable";
  46363. module "babylonjs/Cameras/freeCameraInputsManager" {
  46364. interface FreeCameraInputsManager {
  46365. /**
  46366. * @hidden
  46367. */
  46368. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46369. /**
  46370. * Add orientation input support to the input manager.
  46371. * @returns the current input manager
  46372. */
  46373. addDeviceOrientation(): FreeCameraInputsManager;
  46374. }
  46375. }
  46376. /**
  46377. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46378. * Screen rotation is taken into account.
  46379. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46380. */
  46381. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46382. private _camera;
  46383. private _screenOrientationAngle;
  46384. private _constantTranform;
  46385. private _screenQuaternion;
  46386. private _alpha;
  46387. private _beta;
  46388. private _gamma;
  46389. /**
  46390. * Can be used to detect if a device orientation sensor is available on a device
  46391. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46392. * @returns a promise that will resolve on orientation change
  46393. */
  46394. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46395. /**
  46396. * @hidden
  46397. */
  46398. _onDeviceOrientationChangedObservable: Observable<void>;
  46399. /**
  46400. * Instantiates a new input
  46401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46402. */
  46403. constructor();
  46404. /**
  46405. * Define the camera controlled by the input.
  46406. */
  46407. get camera(): FreeCamera;
  46408. set camera(camera: FreeCamera);
  46409. /**
  46410. * Attach the input controls to a specific dom element to get the input from.
  46411. * @param element Defines the element the controls should be listened from
  46412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46413. */
  46414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46415. private _orientationChanged;
  46416. private _deviceOrientation;
  46417. /**
  46418. * Detach the current controls from the specified dom element.
  46419. * @param element Defines the element to stop listening the inputs from
  46420. */
  46421. detachControl(element: Nullable<HTMLElement>): void;
  46422. /**
  46423. * Update the current camera state depending on the inputs that have been used this frame.
  46424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46425. */
  46426. checkInputs(): void;
  46427. /**
  46428. * Gets the class name of the current intput.
  46429. * @returns the class name
  46430. */
  46431. getClassName(): string;
  46432. /**
  46433. * Get the friendly name associated with the input class.
  46434. * @returns the input friendly name
  46435. */
  46436. getSimpleName(): string;
  46437. }
  46438. }
  46439. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46440. import { Nullable } from "babylonjs/types";
  46441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46442. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46443. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46444. /**
  46445. * Manage the gamepad inputs to control a free camera.
  46446. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46447. */
  46448. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46449. /**
  46450. * Define the camera the input is attached to.
  46451. */
  46452. camera: FreeCamera;
  46453. /**
  46454. * Define the Gamepad controlling the input
  46455. */
  46456. gamepad: Nullable<Gamepad>;
  46457. /**
  46458. * Defines the gamepad rotation sensiblity.
  46459. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46460. */
  46461. gamepadAngularSensibility: number;
  46462. /**
  46463. * Defines the gamepad move sensiblity.
  46464. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46465. */
  46466. gamepadMoveSensibility: number;
  46467. private _yAxisScale;
  46468. /**
  46469. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46470. */
  46471. get invertYAxis(): boolean;
  46472. set invertYAxis(value: boolean);
  46473. private _onGamepadConnectedObserver;
  46474. private _onGamepadDisconnectedObserver;
  46475. private _cameraTransform;
  46476. private _deltaTransform;
  46477. private _vector3;
  46478. private _vector2;
  46479. /**
  46480. * Attach the input controls to a specific dom element to get the input from.
  46481. * @param element Defines the element the controls should be listened from
  46482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46483. */
  46484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46485. /**
  46486. * Detach the current controls from the specified dom element.
  46487. * @param element Defines the element to stop listening the inputs from
  46488. */
  46489. detachControl(element: Nullable<HTMLElement>): void;
  46490. /**
  46491. * Update the current camera state depending on the inputs that have been used this frame.
  46492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46493. */
  46494. checkInputs(): void;
  46495. /**
  46496. * Gets the class name of the current intput.
  46497. * @returns the class name
  46498. */
  46499. getClassName(): string;
  46500. /**
  46501. * Get the friendly name associated with the input class.
  46502. * @returns the input friendly name
  46503. */
  46504. getSimpleName(): string;
  46505. }
  46506. }
  46507. declare module "babylonjs/Misc/virtualJoystick" {
  46508. import { Nullable } from "babylonjs/types";
  46509. import { Vector3 } from "babylonjs/Maths/math.vector";
  46510. /**
  46511. * Defines the potential axis of a Joystick
  46512. */
  46513. export enum JoystickAxis {
  46514. /** X axis */
  46515. X = 0,
  46516. /** Y axis */
  46517. Y = 1,
  46518. /** Z axis */
  46519. Z = 2
  46520. }
  46521. /**
  46522. * Represents the different customization options available
  46523. * for VirtualJoystick
  46524. */
  46525. interface VirtualJoystickCustomizations {
  46526. /**
  46527. * Size of the joystick's puck
  46528. */
  46529. puckSize: number;
  46530. /**
  46531. * Size of the joystick's container
  46532. */
  46533. containerSize: number;
  46534. /**
  46535. * Color of the joystick && puck
  46536. */
  46537. color: string;
  46538. /**
  46539. * Image URL for the joystick's puck
  46540. */
  46541. puckImage?: string;
  46542. /**
  46543. * Image URL for the joystick's container
  46544. */
  46545. containerImage?: string;
  46546. /**
  46547. * Defines the unmoving position of the joystick container
  46548. */
  46549. position?: {
  46550. x: number;
  46551. y: number;
  46552. };
  46553. /**
  46554. * Defines whether or not the joystick container is always visible
  46555. */
  46556. alwaysVisible: boolean;
  46557. /**
  46558. * Defines whether or not to limit the movement of the puck to the joystick's container
  46559. */
  46560. limitToContainer: boolean;
  46561. }
  46562. /**
  46563. * Class used to define virtual joystick (used in touch mode)
  46564. */
  46565. export class VirtualJoystick {
  46566. /**
  46567. * Gets or sets a boolean indicating that left and right values must be inverted
  46568. */
  46569. reverseLeftRight: boolean;
  46570. /**
  46571. * Gets or sets a boolean indicating that up and down values must be inverted
  46572. */
  46573. reverseUpDown: boolean;
  46574. /**
  46575. * Gets the offset value for the position (ie. the change of the position value)
  46576. */
  46577. deltaPosition: Vector3;
  46578. /**
  46579. * Gets a boolean indicating if the virtual joystick was pressed
  46580. */
  46581. pressed: boolean;
  46582. /**
  46583. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46584. */
  46585. static Canvas: Nullable<HTMLCanvasElement>;
  46586. /**
  46587. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46588. */
  46589. limitToContainer: boolean;
  46590. private static _globalJoystickIndex;
  46591. private static _alwaysVisibleSticks;
  46592. private static vjCanvasContext;
  46593. private static vjCanvasWidth;
  46594. private static vjCanvasHeight;
  46595. private static halfWidth;
  46596. private static _GetDefaultOptions;
  46597. private _action;
  46598. private _axisTargetedByLeftAndRight;
  46599. private _axisTargetedByUpAndDown;
  46600. private _joystickSensibility;
  46601. private _inversedSensibility;
  46602. private _joystickPointerID;
  46603. private _joystickColor;
  46604. private _joystickPointerPos;
  46605. private _joystickPreviousPointerPos;
  46606. private _joystickPointerStartPos;
  46607. private _deltaJoystickVector;
  46608. private _leftJoystick;
  46609. private _touches;
  46610. private _joystickPosition;
  46611. private _alwaysVisible;
  46612. private _puckImage;
  46613. private _containerImage;
  46614. private _joystickPuckSize;
  46615. private _joystickContainerSize;
  46616. private _clearPuckSize;
  46617. private _clearContainerSize;
  46618. private _clearPuckSizeOffset;
  46619. private _clearContainerSizeOffset;
  46620. private _onPointerDownHandlerRef;
  46621. private _onPointerMoveHandlerRef;
  46622. private _onPointerUpHandlerRef;
  46623. private _onResize;
  46624. /**
  46625. * Creates a new virtual joystick
  46626. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46627. * @param customizations Defines the options we want to customize the VirtualJoystick
  46628. */
  46629. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46630. /**
  46631. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46632. * @param newJoystickSensibility defines the new sensibility
  46633. */
  46634. setJoystickSensibility(newJoystickSensibility: number): void;
  46635. private _onPointerDown;
  46636. private _onPointerMove;
  46637. private _onPointerUp;
  46638. /**
  46639. * Change the color of the virtual joystick
  46640. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46641. */
  46642. setJoystickColor(newColor: string): void;
  46643. /**
  46644. * Size of the joystick's container
  46645. */
  46646. set containerSize(newSize: number);
  46647. get containerSize(): number;
  46648. /**
  46649. * Size of the joystick's puck
  46650. */
  46651. set puckSize(newSize: number);
  46652. get puckSize(): number;
  46653. /**
  46654. * Clears the set position of the joystick
  46655. */
  46656. clearPosition(): void;
  46657. /**
  46658. * Defines whether or not the joystick container is always visible
  46659. */
  46660. set alwaysVisible(value: boolean);
  46661. get alwaysVisible(): boolean;
  46662. /**
  46663. * Sets the constant position of the Joystick container
  46664. * @param x X axis coordinate
  46665. * @param y Y axis coordinate
  46666. */
  46667. setPosition(x: number, y: number): void;
  46668. /**
  46669. * Defines a callback to call when the joystick is touched
  46670. * @param action defines the callback
  46671. */
  46672. setActionOnTouch(action: () => any): void;
  46673. /**
  46674. * Defines which axis you'd like to control for left & right
  46675. * @param axis defines the axis to use
  46676. */
  46677. setAxisForLeftRight(axis: JoystickAxis): void;
  46678. /**
  46679. * Defines which axis you'd like to control for up & down
  46680. * @param axis defines the axis to use
  46681. */
  46682. setAxisForUpDown(axis: JoystickAxis): void;
  46683. /**
  46684. * Clears the canvas from the previous puck / container draw
  46685. */
  46686. private _clearPreviousDraw;
  46687. /**
  46688. * Loads `urlPath` to be used for the container's image
  46689. * @param urlPath defines the urlPath of an image to use
  46690. */
  46691. setContainerImage(urlPath: string): void;
  46692. /**
  46693. * Loads `urlPath` to be used for the puck's image
  46694. * @param urlPath defines the urlPath of an image to use
  46695. */
  46696. setPuckImage(urlPath: string): void;
  46697. /**
  46698. * Draws the Virtual Joystick's container
  46699. */
  46700. private _drawContainer;
  46701. /**
  46702. * Draws the Virtual Joystick's puck
  46703. */
  46704. private _drawPuck;
  46705. private _drawVirtualJoystick;
  46706. /**
  46707. * Release internal HTML canvas
  46708. */
  46709. releaseCanvas(): void;
  46710. }
  46711. }
  46712. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46713. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46714. import { Nullable } from "babylonjs/types";
  46715. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46716. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46717. module "babylonjs/Cameras/freeCameraInputsManager" {
  46718. interface FreeCameraInputsManager {
  46719. /**
  46720. * Add virtual joystick input support to the input manager.
  46721. * @returns the current input manager
  46722. */
  46723. addVirtualJoystick(): FreeCameraInputsManager;
  46724. }
  46725. }
  46726. /**
  46727. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46728. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46729. */
  46730. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46731. /**
  46732. * Defines the camera the input is attached to.
  46733. */
  46734. camera: FreeCamera;
  46735. private _leftjoystick;
  46736. private _rightjoystick;
  46737. /**
  46738. * Gets the left stick of the virtual joystick.
  46739. * @returns The virtual Joystick
  46740. */
  46741. getLeftJoystick(): VirtualJoystick;
  46742. /**
  46743. * Gets the right stick of the virtual joystick.
  46744. * @returns The virtual Joystick
  46745. */
  46746. getRightJoystick(): VirtualJoystick;
  46747. /**
  46748. * Update the current camera state depending on the inputs that have been used this frame.
  46749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46750. */
  46751. checkInputs(): void;
  46752. /**
  46753. * Attach the input controls to a specific dom element to get the input from.
  46754. * @param element Defines the element the controls should be listened from
  46755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46756. */
  46757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46758. /**
  46759. * Detach the current controls from the specified dom element.
  46760. * @param element Defines the element to stop listening the inputs from
  46761. */
  46762. detachControl(element: Nullable<HTMLElement>): void;
  46763. /**
  46764. * Gets the class name of the current intput.
  46765. * @returns the class name
  46766. */
  46767. getClassName(): string;
  46768. /**
  46769. * Get the friendly name associated with the input class.
  46770. * @returns the input friendly name
  46771. */
  46772. getSimpleName(): string;
  46773. }
  46774. }
  46775. declare module "babylonjs/Cameras/Inputs/index" {
  46776. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46777. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46778. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46779. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46780. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46781. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46782. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46783. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46784. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46785. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46786. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46787. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46788. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46789. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46790. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46791. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46792. }
  46793. declare module "babylonjs/Cameras/touchCamera" {
  46794. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46795. import { Scene } from "babylonjs/scene";
  46796. import { Vector3 } from "babylonjs/Maths/math.vector";
  46797. /**
  46798. * This represents a FPS type of camera controlled by touch.
  46799. * This is like a universal camera minus the Gamepad controls.
  46800. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46801. */
  46802. export class TouchCamera extends FreeCamera {
  46803. /**
  46804. * Defines the touch sensibility for rotation.
  46805. * The higher the faster.
  46806. */
  46807. get touchAngularSensibility(): number;
  46808. set touchAngularSensibility(value: number);
  46809. /**
  46810. * Defines the touch sensibility for move.
  46811. * The higher the faster.
  46812. */
  46813. get touchMoveSensibility(): number;
  46814. set touchMoveSensibility(value: number);
  46815. /**
  46816. * Instantiates a new touch camera.
  46817. * This represents a FPS type of camera controlled by touch.
  46818. * This is like a universal camera minus the Gamepad controls.
  46819. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46820. * @param name Define the name of the camera in the scene
  46821. * @param position Define the start position of the camera in the scene
  46822. * @param scene Define the scene the camera belongs to
  46823. */
  46824. constructor(name: string, position: Vector3, scene: Scene);
  46825. /**
  46826. * Gets the current object class name.
  46827. * @return the class name
  46828. */
  46829. getClassName(): string;
  46830. /** @hidden */
  46831. _setupInputs(): void;
  46832. }
  46833. }
  46834. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46835. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46836. import { Scene } from "babylonjs/scene";
  46837. import { Vector3 } from "babylonjs/Maths/math.vector";
  46838. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46839. import { Axis } from "babylonjs/Maths/math.axis";
  46840. /**
  46841. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46842. * being tilted forward or back and left or right.
  46843. */
  46844. export class DeviceOrientationCamera extends FreeCamera {
  46845. private _initialQuaternion;
  46846. private _quaternionCache;
  46847. private _tmpDragQuaternion;
  46848. private _disablePointerInputWhenUsingDeviceOrientation;
  46849. /**
  46850. * Creates a new device orientation camera
  46851. * @param name The name of the camera
  46852. * @param position The start position camera
  46853. * @param scene The scene the camera belongs to
  46854. */
  46855. constructor(name: string, position: Vector3, scene: Scene);
  46856. /**
  46857. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46858. */
  46859. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46860. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46861. private _dragFactor;
  46862. /**
  46863. * Enabled turning on the y axis when the orientation sensor is active
  46864. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46865. */
  46866. enableHorizontalDragging(dragFactor?: number): void;
  46867. /**
  46868. * Gets the current instance class name ("DeviceOrientationCamera").
  46869. * This helps avoiding instanceof at run time.
  46870. * @returns the class name
  46871. */
  46872. getClassName(): string;
  46873. /**
  46874. * @hidden
  46875. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46876. */
  46877. _checkInputs(): void;
  46878. /**
  46879. * Reset the camera to its default orientation on the specified axis only.
  46880. * @param axis The axis to reset
  46881. */
  46882. resetToCurrentRotation(axis?: Axis): void;
  46883. }
  46884. }
  46885. declare module "babylonjs/Gamepads/xboxGamepad" {
  46886. import { Observable } from "babylonjs/Misc/observable";
  46887. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46888. /**
  46889. * Defines supported buttons for XBox360 compatible gamepads
  46890. */
  46891. export enum Xbox360Button {
  46892. /** A */
  46893. A = 0,
  46894. /** B */
  46895. B = 1,
  46896. /** X */
  46897. X = 2,
  46898. /** Y */
  46899. Y = 3,
  46900. /** Left button */
  46901. LB = 4,
  46902. /** Right button */
  46903. RB = 5,
  46904. /** Back */
  46905. Back = 8,
  46906. /** Start */
  46907. Start = 9,
  46908. /** Left stick */
  46909. LeftStick = 10,
  46910. /** Right stick */
  46911. RightStick = 11
  46912. }
  46913. /** Defines values for XBox360 DPad */
  46914. export enum Xbox360Dpad {
  46915. /** Up */
  46916. Up = 12,
  46917. /** Down */
  46918. Down = 13,
  46919. /** Left */
  46920. Left = 14,
  46921. /** Right */
  46922. Right = 15
  46923. }
  46924. /**
  46925. * Defines a XBox360 gamepad
  46926. */
  46927. export class Xbox360Pad extends Gamepad {
  46928. private _leftTrigger;
  46929. private _rightTrigger;
  46930. private _onlefttriggerchanged;
  46931. private _onrighttriggerchanged;
  46932. private _onbuttondown;
  46933. private _onbuttonup;
  46934. private _ondpaddown;
  46935. private _ondpadup;
  46936. /** Observable raised when a button is pressed */
  46937. onButtonDownObservable: Observable<Xbox360Button>;
  46938. /** Observable raised when a button is released */
  46939. onButtonUpObservable: Observable<Xbox360Button>;
  46940. /** Observable raised when a pad is pressed */
  46941. onPadDownObservable: Observable<Xbox360Dpad>;
  46942. /** Observable raised when a pad is released */
  46943. onPadUpObservable: Observable<Xbox360Dpad>;
  46944. private _buttonA;
  46945. private _buttonB;
  46946. private _buttonX;
  46947. private _buttonY;
  46948. private _buttonBack;
  46949. private _buttonStart;
  46950. private _buttonLB;
  46951. private _buttonRB;
  46952. private _buttonLeftStick;
  46953. private _buttonRightStick;
  46954. private _dPadUp;
  46955. private _dPadDown;
  46956. private _dPadLeft;
  46957. private _dPadRight;
  46958. private _isXboxOnePad;
  46959. /**
  46960. * Creates a new XBox360 gamepad object
  46961. * @param id defines the id of this gamepad
  46962. * @param index defines its index
  46963. * @param gamepad defines the internal HTML gamepad object
  46964. * @param xboxOne defines if it is a XBox One gamepad
  46965. */
  46966. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46967. /**
  46968. * Defines the callback to call when left trigger is pressed
  46969. * @param callback defines the callback to use
  46970. */
  46971. onlefttriggerchanged(callback: (value: number) => void): void;
  46972. /**
  46973. * Defines the callback to call when right trigger is pressed
  46974. * @param callback defines the callback to use
  46975. */
  46976. onrighttriggerchanged(callback: (value: number) => void): void;
  46977. /**
  46978. * Gets the left trigger value
  46979. */
  46980. get leftTrigger(): number;
  46981. /**
  46982. * Sets the left trigger value
  46983. */
  46984. set leftTrigger(newValue: number);
  46985. /**
  46986. * Gets the right trigger value
  46987. */
  46988. get rightTrigger(): number;
  46989. /**
  46990. * Sets the right trigger value
  46991. */
  46992. set rightTrigger(newValue: number);
  46993. /**
  46994. * Defines the callback to call when a button is pressed
  46995. * @param callback defines the callback to use
  46996. */
  46997. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46998. /**
  46999. * Defines the callback to call when a button is released
  47000. * @param callback defines the callback to use
  47001. */
  47002. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47003. /**
  47004. * Defines the callback to call when a pad is pressed
  47005. * @param callback defines the callback to use
  47006. */
  47007. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47008. /**
  47009. * Defines the callback to call when a pad is released
  47010. * @param callback defines the callback to use
  47011. */
  47012. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47013. private _setButtonValue;
  47014. private _setDPadValue;
  47015. /**
  47016. * Gets the value of the `A` button
  47017. */
  47018. get buttonA(): number;
  47019. /**
  47020. * Sets the value of the `A` button
  47021. */
  47022. set buttonA(value: number);
  47023. /**
  47024. * Gets the value of the `B` button
  47025. */
  47026. get buttonB(): number;
  47027. /**
  47028. * Sets the value of the `B` button
  47029. */
  47030. set buttonB(value: number);
  47031. /**
  47032. * Gets the value of the `X` button
  47033. */
  47034. get buttonX(): number;
  47035. /**
  47036. * Sets the value of the `X` button
  47037. */
  47038. set buttonX(value: number);
  47039. /**
  47040. * Gets the value of the `Y` button
  47041. */
  47042. get buttonY(): number;
  47043. /**
  47044. * Sets the value of the `Y` button
  47045. */
  47046. set buttonY(value: number);
  47047. /**
  47048. * Gets the value of the `Start` button
  47049. */
  47050. get buttonStart(): number;
  47051. /**
  47052. * Sets the value of the `Start` button
  47053. */
  47054. set buttonStart(value: number);
  47055. /**
  47056. * Gets the value of the `Back` button
  47057. */
  47058. get buttonBack(): number;
  47059. /**
  47060. * Sets the value of the `Back` button
  47061. */
  47062. set buttonBack(value: number);
  47063. /**
  47064. * Gets the value of the `Left` button
  47065. */
  47066. get buttonLB(): number;
  47067. /**
  47068. * Sets the value of the `Left` button
  47069. */
  47070. set buttonLB(value: number);
  47071. /**
  47072. * Gets the value of the `Right` button
  47073. */
  47074. get buttonRB(): number;
  47075. /**
  47076. * Sets the value of the `Right` button
  47077. */
  47078. set buttonRB(value: number);
  47079. /**
  47080. * Gets the value of the Left joystick
  47081. */
  47082. get buttonLeftStick(): number;
  47083. /**
  47084. * Sets the value of the Left joystick
  47085. */
  47086. set buttonLeftStick(value: number);
  47087. /**
  47088. * Gets the value of the Right joystick
  47089. */
  47090. get buttonRightStick(): number;
  47091. /**
  47092. * Sets the value of the Right joystick
  47093. */
  47094. set buttonRightStick(value: number);
  47095. /**
  47096. * Gets the value of D-pad up
  47097. */
  47098. get dPadUp(): number;
  47099. /**
  47100. * Sets the value of D-pad up
  47101. */
  47102. set dPadUp(value: number);
  47103. /**
  47104. * Gets the value of D-pad down
  47105. */
  47106. get dPadDown(): number;
  47107. /**
  47108. * Sets the value of D-pad down
  47109. */
  47110. set dPadDown(value: number);
  47111. /**
  47112. * Gets the value of D-pad left
  47113. */
  47114. get dPadLeft(): number;
  47115. /**
  47116. * Sets the value of D-pad left
  47117. */
  47118. set dPadLeft(value: number);
  47119. /**
  47120. * Gets the value of D-pad right
  47121. */
  47122. get dPadRight(): number;
  47123. /**
  47124. * Sets the value of D-pad right
  47125. */
  47126. set dPadRight(value: number);
  47127. /**
  47128. * Force the gamepad to synchronize with device values
  47129. */
  47130. update(): void;
  47131. /**
  47132. * Disposes the gamepad
  47133. */
  47134. dispose(): void;
  47135. }
  47136. }
  47137. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47138. import { Observable } from "babylonjs/Misc/observable";
  47139. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47140. /**
  47141. * Defines supported buttons for DualShock compatible gamepads
  47142. */
  47143. export enum DualShockButton {
  47144. /** Cross */
  47145. Cross = 0,
  47146. /** Circle */
  47147. Circle = 1,
  47148. /** Square */
  47149. Square = 2,
  47150. /** Triangle */
  47151. Triangle = 3,
  47152. /** L1 */
  47153. L1 = 4,
  47154. /** R1 */
  47155. R1 = 5,
  47156. /** Share */
  47157. Share = 8,
  47158. /** Options */
  47159. Options = 9,
  47160. /** Left stick */
  47161. LeftStick = 10,
  47162. /** Right stick */
  47163. RightStick = 11
  47164. }
  47165. /** Defines values for DualShock DPad */
  47166. export enum DualShockDpad {
  47167. /** Up */
  47168. Up = 12,
  47169. /** Down */
  47170. Down = 13,
  47171. /** Left */
  47172. Left = 14,
  47173. /** Right */
  47174. Right = 15
  47175. }
  47176. /**
  47177. * Defines a DualShock gamepad
  47178. */
  47179. export class DualShockPad extends Gamepad {
  47180. private _leftTrigger;
  47181. private _rightTrigger;
  47182. private _onlefttriggerchanged;
  47183. private _onrighttriggerchanged;
  47184. private _onbuttondown;
  47185. private _onbuttonup;
  47186. private _ondpaddown;
  47187. private _ondpadup;
  47188. /** Observable raised when a button is pressed */
  47189. onButtonDownObservable: Observable<DualShockButton>;
  47190. /** Observable raised when a button is released */
  47191. onButtonUpObservable: Observable<DualShockButton>;
  47192. /** Observable raised when a pad is pressed */
  47193. onPadDownObservable: Observable<DualShockDpad>;
  47194. /** Observable raised when a pad is released */
  47195. onPadUpObservable: Observable<DualShockDpad>;
  47196. private _buttonCross;
  47197. private _buttonCircle;
  47198. private _buttonSquare;
  47199. private _buttonTriangle;
  47200. private _buttonShare;
  47201. private _buttonOptions;
  47202. private _buttonL1;
  47203. private _buttonR1;
  47204. private _buttonLeftStick;
  47205. private _buttonRightStick;
  47206. private _dPadUp;
  47207. private _dPadDown;
  47208. private _dPadLeft;
  47209. private _dPadRight;
  47210. /**
  47211. * Creates a new DualShock gamepad object
  47212. * @param id defines the id of this gamepad
  47213. * @param index defines its index
  47214. * @param gamepad defines the internal HTML gamepad object
  47215. */
  47216. constructor(id: string, index: number, gamepad: any);
  47217. /**
  47218. * Defines the callback to call when left trigger is pressed
  47219. * @param callback defines the callback to use
  47220. */
  47221. onlefttriggerchanged(callback: (value: number) => void): void;
  47222. /**
  47223. * Defines the callback to call when right trigger is pressed
  47224. * @param callback defines the callback to use
  47225. */
  47226. onrighttriggerchanged(callback: (value: number) => void): void;
  47227. /**
  47228. * Gets the left trigger value
  47229. */
  47230. get leftTrigger(): number;
  47231. /**
  47232. * Sets the left trigger value
  47233. */
  47234. set leftTrigger(newValue: number);
  47235. /**
  47236. * Gets the right trigger value
  47237. */
  47238. get rightTrigger(): number;
  47239. /**
  47240. * Sets the right trigger value
  47241. */
  47242. set rightTrigger(newValue: number);
  47243. /**
  47244. * Defines the callback to call when a button is pressed
  47245. * @param callback defines the callback to use
  47246. */
  47247. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47248. /**
  47249. * Defines the callback to call when a button is released
  47250. * @param callback defines the callback to use
  47251. */
  47252. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47253. /**
  47254. * Defines the callback to call when a pad is pressed
  47255. * @param callback defines the callback to use
  47256. */
  47257. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47258. /**
  47259. * Defines the callback to call when a pad is released
  47260. * @param callback defines the callback to use
  47261. */
  47262. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47263. private _setButtonValue;
  47264. private _setDPadValue;
  47265. /**
  47266. * Gets the value of the `Cross` button
  47267. */
  47268. get buttonCross(): number;
  47269. /**
  47270. * Sets the value of the `Cross` button
  47271. */
  47272. set buttonCross(value: number);
  47273. /**
  47274. * Gets the value of the `Circle` button
  47275. */
  47276. get buttonCircle(): number;
  47277. /**
  47278. * Sets the value of the `Circle` button
  47279. */
  47280. set buttonCircle(value: number);
  47281. /**
  47282. * Gets the value of the `Square` button
  47283. */
  47284. get buttonSquare(): number;
  47285. /**
  47286. * Sets the value of the `Square` button
  47287. */
  47288. set buttonSquare(value: number);
  47289. /**
  47290. * Gets the value of the `Triangle` button
  47291. */
  47292. get buttonTriangle(): number;
  47293. /**
  47294. * Sets the value of the `Triangle` button
  47295. */
  47296. set buttonTriangle(value: number);
  47297. /**
  47298. * Gets the value of the `Options` button
  47299. */
  47300. get buttonOptions(): number;
  47301. /**
  47302. * Sets the value of the `Options` button
  47303. */
  47304. set buttonOptions(value: number);
  47305. /**
  47306. * Gets the value of the `Share` button
  47307. */
  47308. get buttonShare(): number;
  47309. /**
  47310. * Sets the value of the `Share` button
  47311. */
  47312. set buttonShare(value: number);
  47313. /**
  47314. * Gets the value of the `L1` button
  47315. */
  47316. get buttonL1(): number;
  47317. /**
  47318. * Sets the value of the `L1` button
  47319. */
  47320. set buttonL1(value: number);
  47321. /**
  47322. * Gets the value of the `R1` button
  47323. */
  47324. get buttonR1(): number;
  47325. /**
  47326. * Sets the value of the `R1` button
  47327. */
  47328. set buttonR1(value: number);
  47329. /**
  47330. * Gets the value of the Left joystick
  47331. */
  47332. get buttonLeftStick(): number;
  47333. /**
  47334. * Sets the value of the Left joystick
  47335. */
  47336. set buttonLeftStick(value: number);
  47337. /**
  47338. * Gets the value of the Right joystick
  47339. */
  47340. get buttonRightStick(): number;
  47341. /**
  47342. * Sets the value of the Right joystick
  47343. */
  47344. set buttonRightStick(value: number);
  47345. /**
  47346. * Gets the value of D-pad up
  47347. */
  47348. get dPadUp(): number;
  47349. /**
  47350. * Sets the value of D-pad up
  47351. */
  47352. set dPadUp(value: number);
  47353. /**
  47354. * Gets the value of D-pad down
  47355. */
  47356. get dPadDown(): number;
  47357. /**
  47358. * Sets the value of D-pad down
  47359. */
  47360. set dPadDown(value: number);
  47361. /**
  47362. * Gets the value of D-pad left
  47363. */
  47364. get dPadLeft(): number;
  47365. /**
  47366. * Sets the value of D-pad left
  47367. */
  47368. set dPadLeft(value: number);
  47369. /**
  47370. * Gets the value of D-pad right
  47371. */
  47372. get dPadRight(): number;
  47373. /**
  47374. * Sets the value of D-pad right
  47375. */
  47376. set dPadRight(value: number);
  47377. /**
  47378. * Force the gamepad to synchronize with device values
  47379. */
  47380. update(): void;
  47381. /**
  47382. * Disposes the gamepad
  47383. */
  47384. dispose(): void;
  47385. }
  47386. }
  47387. declare module "babylonjs/Gamepads/gamepadManager" {
  47388. import { Observable } from "babylonjs/Misc/observable";
  47389. import { Nullable } from "babylonjs/types";
  47390. import { Scene } from "babylonjs/scene";
  47391. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47392. /**
  47393. * Manager for handling gamepads
  47394. */
  47395. export class GamepadManager {
  47396. private _scene?;
  47397. private _babylonGamepads;
  47398. private _oneGamepadConnected;
  47399. /** @hidden */
  47400. _isMonitoring: boolean;
  47401. private _gamepadEventSupported;
  47402. private _gamepadSupport?;
  47403. /**
  47404. * observable to be triggered when the gamepad controller has been connected
  47405. */
  47406. onGamepadConnectedObservable: Observable<Gamepad>;
  47407. /**
  47408. * observable to be triggered when the gamepad controller has been disconnected
  47409. */
  47410. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47411. private _onGamepadConnectedEvent;
  47412. private _onGamepadDisconnectedEvent;
  47413. /**
  47414. * Initializes the gamepad manager
  47415. * @param _scene BabylonJS scene
  47416. */
  47417. constructor(_scene?: Scene | undefined);
  47418. /**
  47419. * The gamepads in the game pad manager
  47420. */
  47421. get gamepads(): Gamepad[];
  47422. /**
  47423. * Get the gamepad controllers based on type
  47424. * @param type The type of gamepad controller
  47425. * @returns Nullable gamepad
  47426. */
  47427. getGamepadByType(type?: number): Nullable<Gamepad>;
  47428. /**
  47429. * Disposes the gamepad manager
  47430. */
  47431. dispose(): void;
  47432. private _addNewGamepad;
  47433. private _startMonitoringGamepads;
  47434. private _stopMonitoringGamepads;
  47435. /** @hidden */
  47436. _checkGamepadsStatus(): void;
  47437. private _updateGamepadObjects;
  47438. }
  47439. }
  47440. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47441. import { Nullable } from "babylonjs/types";
  47442. import { Scene } from "babylonjs/scene";
  47443. import { ISceneComponent } from "babylonjs/sceneComponent";
  47444. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47445. module "babylonjs/scene" {
  47446. interface Scene {
  47447. /** @hidden */
  47448. _gamepadManager: Nullable<GamepadManager>;
  47449. /**
  47450. * Gets the gamepad manager associated with the scene
  47451. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47452. */
  47453. gamepadManager: GamepadManager;
  47454. }
  47455. }
  47456. module "babylonjs/Cameras/freeCameraInputsManager" {
  47457. /**
  47458. * Interface representing a free camera inputs manager
  47459. */
  47460. interface FreeCameraInputsManager {
  47461. /**
  47462. * Adds gamepad input support to the FreeCameraInputsManager.
  47463. * @returns the FreeCameraInputsManager
  47464. */
  47465. addGamepad(): FreeCameraInputsManager;
  47466. }
  47467. }
  47468. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47469. /**
  47470. * Interface representing an arc rotate camera inputs manager
  47471. */
  47472. interface ArcRotateCameraInputsManager {
  47473. /**
  47474. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47475. * @returns the camera inputs manager
  47476. */
  47477. addGamepad(): ArcRotateCameraInputsManager;
  47478. }
  47479. }
  47480. /**
  47481. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47482. */
  47483. export class GamepadSystemSceneComponent implements ISceneComponent {
  47484. /**
  47485. * The component name helpfull to identify the component in the list of scene components.
  47486. */
  47487. readonly name: string;
  47488. /**
  47489. * The scene the component belongs to.
  47490. */
  47491. scene: Scene;
  47492. /**
  47493. * Creates a new instance of the component for the given scene
  47494. * @param scene Defines the scene to register the component in
  47495. */
  47496. constructor(scene: Scene);
  47497. /**
  47498. * Registers the component in a given scene
  47499. */
  47500. register(): void;
  47501. /**
  47502. * Rebuilds the elements related to this component in case of
  47503. * context lost for instance.
  47504. */
  47505. rebuild(): void;
  47506. /**
  47507. * Disposes the component and the associated ressources
  47508. */
  47509. dispose(): void;
  47510. private _beforeCameraUpdate;
  47511. }
  47512. }
  47513. declare module "babylonjs/Cameras/universalCamera" {
  47514. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47515. import { Scene } from "babylonjs/scene";
  47516. import { Vector3 } from "babylonjs/Maths/math.vector";
  47517. import "babylonjs/Gamepads/gamepadSceneComponent";
  47518. /**
  47519. * 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,
  47520. * which still works and will still be found in many Playgrounds.
  47521. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47522. */
  47523. export class UniversalCamera extends TouchCamera {
  47524. /**
  47525. * Defines the gamepad rotation sensiblity.
  47526. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47527. */
  47528. get gamepadAngularSensibility(): number;
  47529. set gamepadAngularSensibility(value: number);
  47530. /**
  47531. * Defines the gamepad move sensiblity.
  47532. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47533. */
  47534. get gamepadMoveSensibility(): number;
  47535. set gamepadMoveSensibility(value: number);
  47536. /**
  47537. * 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,
  47538. * which still works and will still be found in many Playgrounds.
  47539. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47540. * @param name Define the name of the camera in the scene
  47541. * @param position Define the start position of the camera in the scene
  47542. * @param scene Define the scene the camera belongs to
  47543. */
  47544. constructor(name: string, position: Vector3, scene: Scene);
  47545. /**
  47546. * Gets the current object class name.
  47547. * @return the class name
  47548. */
  47549. getClassName(): string;
  47550. }
  47551. }
  47552. declare module "babylonjs/Cameras/gamepadCamera" {
  47553. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47554. import { Scene } from "babylonjs/scene";
  47555. import { Vector3 } from "babylonjs/Maths/math.vector";
  47556. /**
  47557. * This represents a FPS type of camera. This is only here for back compat purpose.
  47558. * Please use the UniversalCamera instead as both are identical.
  47559. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47560. */
  47561. export class GamepadCamera extends UniversalCamera {
  47562. /**
  47563. * Instantiates a new Gamepad Camera
  47564. * This represents a FPS type of camera. This is only here for back compat purpose.
  47565. * Please use the UniversalCamera instead as both are identical.
  47566. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47567. * @param name Define the name of the camera in the scene
  47568. * @param position Define the start position of the camera in the scene
  47569. * @param scene Define the scene the camera belongs to
  47570. */
  47571. constructor(name: string, position: Vector3, scene: Scene);
  47572. /**
  47573. * Gets the current object class name.
  47574. * @return the class name
  47575. */
  47576. getClassName(): string;
  47577. }
  47578. }
  47579. declare module "babylonjs/Shaders/pass.fragment" {
  47580. /** @hidden */
  47581. export var passPixelShader: {
  47582. name: string;
  47583. shader: string;
  47584. };
  47585. }
  47586. declare module "babylonjs/Shaders/passCube.fragment" {
  47587. /** @hidden */
  47588. export var passCubePixelShader: {
  47589. name: string;
  47590. shader: string;
  47591. };
  47592. }
  47593. declare module "babylonjs/PostProcesses/passPostProcess" {
  47594. import { Nullable } from "babylonjs/types";
  47595. import { Camera } from "babylonjs/Cameras/camera";
  47596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47597. import { Engine } from "babylonjs/Engines/engine";
  47598. import "babylonjs/Shaders/pass.fragment";
  47599. import "babylonjs/Shaders/passCube.fragment";
  47600. /**
  47601. * PassPostProcess which produces an output the same as it's input
  47602. */
  47603. export class PassPostProcess extends PostProcess {
  47604. /**
  47605. * Creates the PassPostProcess
  47606. * @param name The name of the effect.
  47607. * @param options The required width/height ratio to downsize to before computing the render pass.
  47608. * @param camera The camera to apply the render pass to.
  47609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47610. * @param engine The engine which the post process will be applied. (default: current engine)
  47611. * @param reusable If the post process can be reused on the same frame. (default: false)
  47612. * @param textureType The type of texture to be used when performing the post processing.
  47613. * @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)
  47614. */
  47615. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47616. }
  47617. /**
  47618. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47619. */
  47620. export class PassCubePostProcess extends PostProcess {
  47621. private _face;
  47622. /**
  47623. * Gets or sets the cube face to display.
  47624. * * 0 is +X
  47625. * * 1 is -X
  47626. * * 2 is +Y
  47627. * * 3 is -Y
  47628. * * 4 is +Z
  47629. * * 5 is -Z
  47630. */
  47631. get face(): number;
  47632. set face(value: number);
  47633. /**
  47634. * Creates the PassCubePostProcess
  47635. * @param name The name of the effect.
  47636. * @param options The required width/height ratio to downsize to before computing the render pass.
  47637. * @param camera The camera to apply the render pass to.
  47638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47639. * @param engine The engine which the post process will be applied. (default: current engine)
  47640. * @param reusable If the post process can be reused on the same frame. (default: false)
  47641. * @param textureType The type of texture to be used when performing the post processing.
  47642. * @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)
  47643. */
  47644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47645. }
  47646. }
  47647. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47648. /** @hidden */
  47649. export var anaglyphPixelShader: {
  47650. name: string;
  47651. shader: string;
  47652. };
  47653. }
  47654. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47655. import { Engine } from "babylonjs/Engines/engine";
  47656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47657. import { Camera } from "babylonjs/Cameras/camera";
  47658. import "babylonjs/Shaders/anaglyph.fragment";
  47659. /**
  47660. * Postprocess used to generate anaglyphic rendering
  47661. */
  47662. export class AnaglyphPostProcess extends PostProcess {
  47663. private _passedProcess;
  47664. /**
  47665. * Creates a new AnaglyphPostProcess
  47666. * @param name defines postprocess name
  47667. * @param options defines creation options or target ratio scale
  47668. * @param rigCameras defines cameras using this postprocess
  47669. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47670. * @param engine defines hosting engine
  47671. * @param reusable defines if the postprocess will be reused multiple times per frame
  47672. */
  47673. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47674. }
  47675. }
  47676. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47677. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47679. import { Scene } from "babylonjs/scene";
  47680. import { Vector3 } from "babylonjs/Maths/math.vector";
  47681. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47682. /**
  47683. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47684. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47685. */
  47686. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47687. /**
  47688. * Creates a new AnaglyphArcRotateCamera
  47689. * @param name defines camera name
  47690. * @param alpha defines alpha angle (in radians)
  47691. * @param beta defines beta angle (in radians)
  47692. * @param radius defines radius
  47693. * @param target defines camera target
  47694. * @param interaxialDistance defines distance between each color axis
  47695. * @param scene defines the hosting scene
  47696. */
  47697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47698. /**
  47699. * Gets camera class name
  47700. * @returns AnaglyphArcRotateCamera
  47701. */
  47702. getClassName(): string;
  47703. }
  47704. }
  47705. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47706. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47707. import { Scene } from "babylonjs/scene";
  47708. import { Vector3 } from "babylonjs/Maths/math.vector";
  47709. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47710. /**
  47711. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47712. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47713. */
  47714. export class AnaglyphFreeCamera extends FreeCamera {
  47715. /**
  47716. * Creates a new AnaglyphFreeCamera
  47717. * @param name defines camera name
  47718. * @param position defines initial position
  47719. * @param interaxialDistance defines distance between each color axis
  47720. * @param scene defines the hosting scene
  47721. */
  47722. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47723. /**
  47724. * Gets camera class name
  47725. * @returns AnaglyphFreeCamera
  47726. */
  47727. getClassName(): string;
  47728. }
  47729. }
  47730. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47731. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47732. import { Scene } from "babylonjs/scene";
  47733. import { Vector3 } from "babylonjs/Maths/math.vector";
  47734. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47735. /**
  47736. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47737. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47738. */
  47739. export class AnaglyphGamepadCamera extends GamepadCamera {
  47740. /**
  47741. * Creates a new AnaglyphGamepadCamera
  47742. * @param name defines camera name
  47743. * @param position defines initial position
  47744. * @param interaxialDistance defines distance between each color axis
  47745. * @param scene defines the hosting scene
  47746. */
  47747. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47748. /**
  47749. * Gets camera class name
  47750. * @returns AnaglyphGamepadCamera
  47751. */
  47752. getClassName(): string;
  47753. }
  47754. }
  47755. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47756. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47757. import { Scene } from "babylonjs/scene";
  47758. import { Vector3 } from "babylonjs/Maths/math.vector";
  47759. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47760. /**
  47761. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47762. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47763. */
  47764. export class AnaglyphUniversalCamera extends UniversalCamera {
  47765. /**
  47766. * Creates a new AnaglyphUniversalCamera
  47767. * @param name defines camera name
  47768. * @param position defines initial position
  47769. * @param interaxialDistance defines distance between each color axis
  47770. * @param scene defines the hosting scene
  47771. */
  47772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47773. /**
  47774. * Gets camera class name
  47775. * @returns AnaglyphUniversalCamera
  47776. */
  47777. getClassName(): string;
  47778. }
  47779. }
  47780. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47781. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47782. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47783. import { Scene } from "babylonjs/scene";
  47784. import { Vector3 } from "babylonjs/Maths/math.vector";
  47785. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47786. /**
  47787. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47788. * @see https://doc.babylonjs.com/features/cameras
  47789. */
  47790. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47791. /**
  47792. * Creates a new StereoscopicArcRotateCamera
  47793. * @param name defines camera name
  47794. * @param alpha defines alpha angle (in radians)
  47795. * @param beta defines beta angle (in radians)
  47796. * @param radius defines radius
  47797. * @param target defines camera target
  47798. * @param interaxialDistance defines distance between each color axis
  47799. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47800. * @param scene defines the hosting scene
  47801. */
  47802. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47803. /**
  47804. * Gets camera class name
  47805. * @returns StereoscopicArcRotateCamera
  47806. */
  47807. getClassName(): string;
  47808. }
  47809. }
  47810. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47811. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47812. import { Scene } from "babylonjs/scene";
  47813. import { Vector3 } from "babylonjs/Maths/math.vector";
  47814. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47815. /**
  47816. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47817. * @see https://doc.babylonjs.com/features/cameras
  47818. */
  47819. export class StereoscopicFreeCamera extends FreeCamera {
  47820. /**
  47821. * Creates a new StereoscopicFreeCamera
  47822. * @param name defines camera name
  47823. * @param position defines initial position
  47824. * @param interaxialDistance defines distance between each color axis
  47825. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47826. * @param scene defines the hosting scene
  47827. */
  47828. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47829. /**
  47830. * Gets camera class name
  47831. * @returns StereoscopicFreeCamera
  47832. */
  47833. getClassName(): string;
  47834. }
  47835. }
  47836. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47837. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47838. import { Scene } from "babylonjs/scene";
  47839. import { Vector3 } from "babylonjs/Maths/math.vector";
  47840. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47841. /**
  47842. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47843. * @see https://doc.babylonjs.com/features/cameras
  47844. */
  47845. export class StereoscopicGamepadCamera extends GamepadCamera {
  47846. /**
  47847. * Creates a new StereoscopicGamepadCamera
  47848. * @param name defines camera name
  47849. * @param position defines initial position
  47850. * @param interaxialDistance defines distance between each color axis
  47851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47852. * @param scene defines the hosting scene
  47853. */
  47854. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47855. /**
  47856. * Gets camera class name
  47857. * @returns StereoscopicGamepadCamera
  47858. */
  47859. getClassName(): string;
  47860. }
  47861. }
  47862. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47863. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47864. import { Scene } from "babylonjs/scene";
  47865. import { Vector3 } from "babylonjs/Maths/math.vector";
  47866. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47867. /**
  47868. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47869. * @see https://doc.babylonjs.com/features/cameras
  47870. */
  47871. export class StereoscopicUniversalCamera extends UniversalCamera {
  47872. /**
  47873. * Creates a new StereoscopicUniversalCamera
  47874. * @param name defines camera name
  47875. * @param position defines initial position
  47876. * @param interaxialDistance defines distance between each color axis
  47877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47878. * @param scene defines the hosting scene
  47879. */
  47880. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47881. /**
  47882. * Gets camera class name
  47883. * @returns StereoscopicUniversalCamera
  47884. */
  47885. getClassName(): string;
  47886. }
  47887. }
  47888. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47889. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47890. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47891. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47892. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47893. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47894. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47895. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47896. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47897. }
  47898. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47900. import { Scene } from "babylonjs/scene";
  47901. import { Vector3 } from "babylonjs/Maths/math.vector";
  47902. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47903. /**
  47904. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47905. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47906. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47907. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47908. */
  47909. export class VirtualJoysticksCamera extends FreeCamera {
  47910. /**
  47911. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47912. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47913. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47914. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47915. * @param name Define the name of the camera in the scene
  47916. * @param position Define the start position of the camera in the scene
  47917. * @param scene Define the scene the camera belongs to
  47918. */
  47919. constructor(name: string, position: Vector3, scene: Scene);
  47920. /**
  47921. * Gets the current object class name.
  47922. * @return the class name
  47923. */
  47924. getClassName(): string;
  47925. }
  47926. }
  47927. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47928. import { Matrix } from "babylonjs/Maths/math.vector";
  47929. /**
  47930. * This represents all the required metrics to create a VR camera.
  47931. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47932. */
  47933. export class VRCameraMetrics {
  47934. /**
  47935. * Define the horizontal resolution off the screen.
  47936. */
  47937. hResolution: number;
  47938. /**
  47939. * Define the vertical resolution off the screen.
  47940. */
  47941. vResolution: number;
  47942. /**
  47943. * Define the horizontal screen size.
  47944. */
  47945. hScreenSize: number;
  47946. /**
  47947. * Define the vertical screen size.
  47948. */
  47949. vScreenSize: number;
  47950. /**
  47951. * Define the vertical screen center position.
  47952. */
  47953. vScreenCenter: number;
  47954. /**
  47955. * Define the distance of the eyes to the screen.
  47956. */
  47957. eyeToScreenDistance: number;
  47958. /**
  47959. * Define the distance between both lenses
  47960. */
  47961. lensSeparationDistance: number;
  47962. /**
  47963. * Define the distance between both viewer's eyes.
  47964. */
  47965. interpupillaryDistance: number;
  47966. /**
  47967. * Define the distortion factor of the VR postprocess.
  47968. * Please, touch with care.
  47969. */
  47970. distortionK: number[];
  47971. /**
  47972. * Define the chromatic aberration correction factors for the VR post process.
  47973. */
  47974. chromaAbCorrection: number[];
  47975. /**
  47976. * Define the scale factor of the post process.
  47977. * The smaller the better but the slower.
  47978. */
  47979. postProcessScaleFactor: number;
  47980. /**
  47981. * Define an offset for the lens center.
  47982. */
  47983. lensCenterOffset: number;
  47984. /**
  47985. * Define if the current vr camera should compensate the distortion of the lense or not.
  47986. */
  47987. compensateDistortion: boolean;
  47988. /**
  47989. * Defines if multiview should be enabled when rendering (Default: false)
  47990. */
  47991. multiviewEnabled: boolean;
  47992. /**
  47993. * Gets the rendering aspect ratio based on the provided resolutions.
  47994. */
  47995. get aspectRatio(): number;
  47996. /**
  47997. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47998. */
  47999. get aspectRatioFov(): number;
  48000. /**
  48001. * @hidden
  48002. */
  48003. get leftHMatrix(): Matrix;
  48004. /**
  48005. * @hidden
  48006. */
  48007. get rightHMatrix(): Matrix;
  48008. /**
  48009. * @hidden
  48010. */
  48011. get leftPreViewMatrix(): Matrix;
  48012. /**
  48013. * @hidden
  48014. */
  48015. get rightPreViewMatrix(): Matrix;
  48016. /**
  48017. * Get the default VRMetrics based on the most generic setup.
  48018. * @returns the default vr metrics
  48019. */
  48020. static GetDefault(): VRCameraMetrics;
  48021. }
  48022. }
  48023. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48024. /** @hidden */
  48025. export var vrDistortionCorrectionPixelShader: {
  48026. name: string;
  48027. shader: string;
  48028. };
  48029. }
  48030. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48031. import { Camera } from "babylonjs/Cameras/camera";
  48032. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48034. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48035. /**
  48036. * VRDistortionCorrectionPostProcess used for mobile VR
  48037. */
  48038. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48039. private _isRightEye;
  48040. private _distortionFactors;
  48041. private _postProcessScaleFactor;
  48042. private _lensCenterOffset;
  48043. private _scaleIn;
  48044. private _scaleFactor;
  48045. private _lensCenter;
  48046. /**
  48047. * Initializes the VRDistortionCorrectionPostProcess
  48048. * @param name The name of the effect.
  48049. * @param camera The camera to apply the render pass to.
  48050. * @param isRightEye If this is for the right eye distortion
  48051. * @param vrMetrics All the required metrics for the VR camera
  48052. */
  48053. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48054. }
  48055. }
  48056. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48057. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48058. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48059. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48060. import { Scene } from "babylonjs/scene";
  48061. import { Vector3 } from "babylonjs/Maths/math.vector";
  48062. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48063. import "babylonjs/Cameras/RigModes/vrRigMode";
  48064. /**
  48065. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48066. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48067. */
  48068. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48069. /**
  48070. * Creates a new VRDeviceOrientationArcRotateCamera
  48071. * @param name defines camera name
  48072. * @param alpha defines the camera rotation along the logitudinal axis
  48073. * @param beta defines the camera rotation along the latitudinal axis
  48074. * @param radius defines the camera distance from its target
  48075. * @param target defines the camera target
  48076. * @param scene defines the scene the camera belongs to
  48077. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48078. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48079. */
  48080. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48081. /**
  48082. * Gets camera class name
  48083. * @returns VRDeviceOrientationArcRotateCamera
  48084. */
  48085. getClassName(): string;
  48086. }
  48087. }
  48088. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48089. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48090. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48091. import { Scene } from "babylonjs/scene";
  48092. import { Vector3 } from "babylonjs/Maths/math.vector";
  48093. import "babylonjs/Cameras/RigModes/vrRigMode";
  48094. /**
  48095. * Camera used to simulate VR rendering (based on FreeCamera)
  48096. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48097. */
  48098. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48099. /**
  48100. * Creates a new VRDeviceOrientationFreeCamera
  48101. * @param name defines camera name
  48102. * @param position defines the start position of the camera
  48103. * @param scene defines the scene the camera belongs to
  48104. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48105. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48106. */
  48107. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48108. /**
  48109. * Gets camera class name
  48110. * @returns VRDeviceOrientationFreeCamera
  48111. */
  48112. getClassName(): string;
  48113. }
  48114. }
  48115. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48116. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48117. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48118. import { Scene } from "babylonjs/scene";
  48119. import { Vector3 } from "babylonjs/Maths/math.vector";
  48120. import "babylonjs/Gamepads/gamepadSceneComponent";
  48121. /**
  48122. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48123. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48124. */
  48125. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48126. /**
  48127. * Creates a new VRDeviceOrientationGamepadCamera
  48128. * @param name defines camera name
  48129. * @param position defines the start position of the camera
  48130. * @param scene defines the scene the camera belongs to
  48131. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48132. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48133. */
  48134. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48135. /**
  48136. * Gets camera class name
  48137. * @returns VRDeviceOrientationGamepadCamera
  48138. */
  48139. getClassName(): string;
  48140. }
  48141. }
  48142. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48143. import { Scene } from "babylonjs/scene";
  48144. import { Texture } from "babylonjs/Materials/Textures/texture";
  48145. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48146. /**
  48147. * A class extending Texture allowing drawing on a texture
  48148. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48149. */
  48150. export class DynamicTexture extends Texture {
  48151. private _generateMipMaps;
  48152. private _canvas;
  48153. private _context;
  48154. /**
  48155. * Creates a DynamicTexture
  48156. * @param name defines the name of the texture
  48157. * @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
  48158. * @param scene defines the scene where you want the texture
  48159. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48160. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48161. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48162. */
  48163. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48164. /**
  48165. * Get the current class name of the texture useful for serialization or dynamic coding.
  48166. * @returns "DynamicTexture"
  48167. */
  48168. getClassName(): string;
  48169. /**
  48170. * Gets the current state of canRescale
  48171. */
  48172. get canRescale(): boolean;
  48173. private _recreate;
  48174. /**
  48175. * Scales the texture
  48176. * @param ratio the scale factor to apply to both width and height
  48177. */
  48178. scale(ratio: number): void;
  48179. /**
  48180. * Resizes the texture
  48181. * @param width the new width
  48182. * @param height the new height
  48183. */
  48184. scaleTo(width: number, height: number): void;
  48185. /**
  48186. * Gets the context of the canvas used by the texture
  48187. * @returns the canvas context of the dynamic texture
  48188. */
  48189. getContext(): CanvasRenderingContext2D;
  48190. /**
  48191. * Clears the texture
  48192. */
  48193. clear(): void;
  48194. /**
  48195. * Updates the texture
  48196. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48197. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48198. */
  48199. update(invertY?: boolean, premulAlpha?: boolean): void;
  48200. /**
  48201. * Draws text onto the texture
  48202. * @param text defines the text to be drawn
  48203. * @param x defines the placement of the text from the left
  48204. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48205. * @param font defines the font to be used with font-style, font-size, font-name
  48206. * @param color defines the color used for the text
  48207. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48208. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48209. * @param update defines whether texture is immediately update (default is true)
  48210. */
  48211. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48212. /**
  48213. * Clones the texture
  48214. * @returns the clone of the texture.
  48215. */
  48216. clone(): DynamicTexture;
  48217. /**
  48218. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48219. * @returns a serialized dynamic texture object
  48220. */
  48221. serialize(): any;
  48222. private _IsCanvasElement;
  48223. /** @hidden */
  48224. _rebuild(): void;
  48225. }
  48226. }
  48227. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48228. import { Scene } from "babylonjs/scene";
  48229. import { Color3 } from "babylonjs/Maths/math.color";
  48230. import { Mesh } from "babylonjs/Meshes/mesh";
  48231. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48232. import { Nullable } from "babylonjs/types";
  48233. /**
  48234. * Class containing static functions to help procedurally build meshes
  48235. */
  48236. export class GroundBuilder {
  48237. /**
  48238. * Creates a ground mesh
  48239. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48240. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48242. * @param name defines the name of the mesh
  48243. * @param options defines the options used to create the mesh
  48244. * @param scene defines the hosting scene
  48245. * @returns the ground mesh
  48246. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48247. */
  48248. static CreateGround(name: string, options: {
  48249. width?: number;
  48250. height?: number;
  48251. subdivisions?: number;
  48252. subdivisionsX?: number;
  48253. subdivisionsY?: number;
  48254. updatable?: boolean;
  48255. }, scene: any): Mesh;
  48256. /**
  48257. * Creates a tiled ground mesh
  48258. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48259. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48260. * * 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
  48261. * * 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
  48262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48263. * @param name defines the name of the mesh
  48264. * @param options defines the options used to create the mesh
  48265. * @param scene defines the hosting scene
  48266. * @returns the tiled ground mesh
  48267. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48268. */
  48269. static CreateTiledGround(name: string, options: {
  48270. xmin: number;
  48271. zmin: number;
  48272. xmax: number;
  48273. zmax: number;
  48274. subdivisions?: {
  48275. w: number;
  48276. h: number;
  48277. };
  48278. precision?: {
  48279. w: number;
  48280. h: number;
  48281. };
  48282. updatable?: boolean;
  48283. }, scene?: Nullable<Scene>): Mesh;
  48284. /**
  48285. * Creates a ground mesh from a height map
  48286. * * The parameter `url` sets the URL of the height map image resource.
  48287. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48288. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48289. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48290. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48291. * * 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.
  48292. * * 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).
  48293. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48295. * @param name defines the name of the mesh
  48296. * @param url defines the url to the height map
  48297. * @param options defines the options used to create the mesh
  48298. * @param scene defines the hosting scene
  48299. * @returns the ground mesh
  48300. * @see https://doc.babylonjs.com/babylon101/height_map
  48301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48302. */
  48303. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48304. width?: number;
  48305. height?: number;
  48306. subdivisions?: number;
  48307. minHeight?: number;
  48308. maxHeight?: number;
  48309. colorFilter?: Color3;
  48310. alphaFilter?: number;
  48311. updatable?: boolean;
  48312. onReady?: (mesh: GroundMesh) => void;
  48313. }, scene?: Nullable<Scene>): GroundMesh;
  48314. }
  48315. }
  48316. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48317. import { Vector4 } from "babylonjs/Maths/math.vector";
  48318. import { Mesh } from "babylonjs/Meshes/mesh";
  48319. /**
  48320. * Class containing static functions to help procedurally build meshes
  48321. */
  48322. export class TorusBuilder {
  48323. /**
  48324. * Creates a torus mesh
  48325. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48326. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48327. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48331. * @param name defines the name of the mesh
  48332. * @param options defines the options used to create the mesh
  48333. * @param scene defines the hosting scene
  48334. * @returns the torus mesh
  48335. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48336. */
  48337. static CreateTorus(name: string, options: {
  48338. diameter?: number;
  48339. thickness?: number;
  48340. tessellation?: number;
  48341. updatable?: boolean;
  48342. sideOrientation?: number;
  48343. frontUVs?: Vector4;
  48344. backUVs?: Vector4;
  48345. }, scene: any): Mesh;
  48346. }
  48347. }
  48348. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48349. import { Vector4 } from "babylonjs/Maths/math.vector";
  48350. import { Color4 } from "babylonjs/Maths/math.color";
  48351. import { Mesh } from "babylonjs/Meshes/mesh";
  48352. /**
  48353. * Class containing static functions to help procedurally build meshes
  48354. */
  48355. export class CylinderBuilder {
  48356. /**
  48357. * Creates a cylinder or a cone mesh
  48358. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48359. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48360. * * 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.
  48361. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48362. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48363. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48364. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48365. * * 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).
  48366. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48367. * * 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).
  48368. * * 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
  48369. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48370. * * 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
  48371. * * 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.
  48372. * * If `enclose` is false, a ring surface is one element.
  48373. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48374. * * 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
  48375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48378. * @param name defines the name of the mesh
  48379. * @param options defines the options used to create the mesh
  48380. * @param scene defines the hosting scene
  48381. * @returns the cylinder mesh
  48382. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48383. */
  48384. static CreateCylinder(name: string, options: {
  48385. height?: number;
  48386. diameterTop?: number;
  48387. diameterBottom?: number;
  48388. diameter?: number;
  48389. tessellation?: number;
  48390. subdivisions?: number;
  48391. arc?: number;
  48392. faceColors?: Color4[];
  48393. faceUV?: Vector4[];
  48394. updatable?: boolean;
  48395. hasRings?: boolean;
  48396. enclose?: boolean;
  48397. cap?: number;
  48398. sideOrientation?: number;
  48399. frontUVs?: Vector4;
  48400. backUVs?: Vector4;
  48401. }, scene: any): Mesh;
  48402. }
  48403. }
  48404. declare module "babylonjs/XR/webXRTypes" {
  48405. import { Nullable } from "babylonjs/types";
  48406. import { IDisposable } from "babylonjs/scene";
  48407. /**
  48408. * States of the webXR experience
  48409. */
  48410. export enum WebXRState {
  48411. /**
  48412. * Transitioning to being in XR mode
  48413. */
  48414. ENTERING_XR = 0,
  48415. /**
  48416. * Transitioning to non XR mode
  48417. */
  48418. EXITING_XR = 1,
  48419. /**
  48420. * In XR mode and presenting
  48421. */
  48422. IN_XR = 2,
  48423. /**
  48424. * Not entered XR mode
  48425. */
  48426. NOT_IN_XR = 3
  48427. }
  48428. /**
  48429. * Abstraction of the XR render target
  48430. */
  48431. export interface WebXRRenderTarget extends IDisposable {
  48432. /**
  48433. * xrpresent context of the canvas which can be used to display/mirror xr content
  48434. */
  48435. canvasContext: WebGLRenderingContext;
  48436. /**
  48437. * xr layer for the canvas
  48438. */
  48439. xrLayer: Nullable<XRWebGLLayer>;
  48440. /**
  48441. * Initializes the xr layer for the session
  48442. * @param xrSession xr session
  48443. * @returns a promise that will resolve once the XR Layer has been created
  48444. */
  48445. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48446. }
  48447. }
  48448. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48449. import { Nullable } from "babylonjs/types";
  48450. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48451. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48452. import { Observable } from "babylonjs/Misc/observable";
  48453. /**
  48454. * COnfiguration object for WebXR output canvas
  48455. */
  48456. export class WebXRManagedOutputCanvasOptions {
  48457. /**
  48458. * An optional canvas in case you wish to create it yourself and provide it here.
  48459. * If not provided, a new canvas will be created
  48460. */
  48461. canvasElement?: HTMLCanvasElement;
  48462. /**
  48463. * Options for this XR Layer output
  48464. */
  48465. canvasOptions?: XRWebGLLayerOptions;
  48466. /**
  48467. * CSS styling for a newly created canvas (if not provided)
  48468. */
  48469. newCanvasCssStyle?: string;
  48470. /**
  48471. * Get the default values of the configuration object
  48472. * @returns default values of this configuration object
  48473. */
  48474. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48475. }
  48476. /**
  48477. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48478. */
  48479. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48480. private _options;
  48481. private _canvas;
  48482. private _engine;
  48483. private _originalCanvasSize;
  48484. /**
  48485. * Rendering context of the canvas which can be used to display/mirror xr content
  48486. */
  48487. canvasContext: WebGLRenderingContext;
  48488. /**
  48489. * xr layer for the canvas
  48490. */
  48491. xrLayer: Nullable<XRWebGLLayer>;
  48492. /**
  48493. * Obseervers registered here will be triggered when the xr layer was initialized
  48494. */
  48495. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48496. /**
  48497. * Initializes the canvas to be added/removed upon entering/exiting xr
  48498. * @param _xrSessionManager The XR Session manager
  48499. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48500. */
  48501. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48502. /**
  48503. * Disposes of the object
  48504. */
  48505. dispose(): void;
  48506. /**
  48507. * Initializes the xr layer for the session
  48508. * @param xrSession xr session
  48509. * @returns a promise that will resolve once the XR Layer has been created
  48510. */
  48511. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48512. private _addCanvas;
  48513. private _removeCanvas;
  48514. private _setCanvasSize;
  48515. private _setManagedOutputCanvas;
  48516. }
  48517. }
  48518. declare module "babylonjs/XR/webXRSessionManager" {
  48519. import { Observable } from "babylonjs/Misc/observable";
  48520. import { Nullable } from "babylonjs/types";
  48521. import { IDisposable, Scene } from "babylonjs/scene";
  48522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48523. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48524. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48525. /**
  48526. * Manages an XRSession to work with Babylon's engine
  48527. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48528. */
  48529. export class WebXRSessionManager implements IDisposable {
  48530. /** The scene which the session should be created for */
  48531. scene: Scene;
  48532. private _referenceSpace;
  48533. private _rttProvider;
  48534. private _sessionEnded;
  48535. private _xrNavigator;
  48536. private baseLayer;
  48537. /**
  48538. * The base reference space from which the session started. good if you want to reset your
  48539. * reference space
  48540. */
  48541. baseReferenceSpace: XRReferenceSpace;
  48542. /**
  48543. * Current XR frame
  48544. */
  48545. currentFrame: Nullable<XRFrame>;
  48546. /** WebXR timestamp updated every frame */
  48547. currentTimestamp: number;
  48548. /**
  48549. * Used just in case of a failure to initialize an immersive session.
  48550. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48551. */
  48552. defaultHeightCompensation: number;
  48553. /**
  48554. * Fires every time a new xrFrame arrives which can be used to update the camera
  48555. */
  48556. onXRFrameObservable: Observable<XRFrame>;
  48557. /**
  48558. * Fires when the reference space changed
  48559. */
  48560. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48561. /**
  48562. * Fires when the xr session is ended either by the device or manually done
  48563. */
  48564. onXRSessionEnded: Observable<any>;
  48565. /**
  48566. * Fires when the xr session is ended either by the device or manually done
  48567. */
  48568. onXRSessionInit: Observable<XRSession>;
  48569. /**
  48570. * Underlying xr session
  48571. */
  48572. session: XRSession;
  48573. /**
  48574. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48575. * or get the offset the player is currently at.
  48576. */
  48577. viewerReferenceSpace: XRReferenceSpace;
  48578. /**
  48579. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48580. * @param scene The scene which the session should be created for
  48581. */
  48582. constructor(
  48583. /** The scene which the session should be created for */
  48584. scene: Scene);
  48585. /**
  48586. * The current reference space used in this session. This reference space can constantly change!
  48587. * It is mainly used to offset the camera's position.
  48588. */
  48589. get referenceSpace(): XRReferenceSpace;
  48590. /**
  48591. * Set a new reference space and triggers the observable
  48592. */
  48593. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48594. /**
  48595. * Disposes of the session manager
  48596. */
  48597. dispose(): void;
  48598. /**
  48599. * Stops the xrSession and restores the render loop
  48600. * @returns Promise which resolves after it exits XR
  48601. */
  48602. exitXRAsync(): Promise<void>;
  48603. /**
  48604. * Gets the correct render target texture to be rendered this frame for this eye
  48605. * @param eye the eye for which to get the render target
  48606. * @returns the render target for the specified eye
  48607. */
  48608. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48609. /**
  48610. * Creates a WebXRRenderTarget object for the XR session
  48611. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48612. * @param options optional options to provide when creating a new render target
  48613. * @returns a WebXR render target to which the session can render
  48614. */
  48615. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48616. /**
  48617. * Initializes the manager
  48618. * After initialization enterXR can be called to start an XR session
  48619. * @returns Promise which resolves after it is initialized
  48620. */
  48621. initializeAsync(): Promise<void>;
  48622. /**
  48623. * Initializes an xr session
  48624. * @param xrSessionMode mode to initialize
  48625. * @param xrSessionInit defines optional and required values to pass to the session builder
  48626. * @returns a promise which will resolve once the session has been initialized
  48627. */
  48628. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48629. /**
  48630. * Checks if a session would be supported for the creation options specified
  48631. * @param sessionMode session mode to check if supported eg. immersive-vr
  48632. * @returns A Promise that resolves to true if supported and false if not
  48633. */
  48634. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48635. /**
  48636. * Resets the reference space to the one started the session
  48637. */
  48638. resetReferenceSpace(): void;
  48639. /**
  48640. * Starts rendering to the xr layer
  48641. */
  48642. runXRRenderLoop(): void;
  48643. /**
  48644. * Sets the reference space on the xr session
  48645. * @param referenceSpaceType space to set
  48646. * @returns a promise that will resolve once the reference space has been set
  48647. */
  48648. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48649. /**
  48650. * Updates the render state of the session
  48651. * @param state state to set
  48652. * @returns a promise that resolves once the render state has been updated
  48653. */
  48654. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48655. /**
  48656. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48657. * @param sessionMode defines the session to test
  48658. * @returns a promise with boolean as final value
  48659. */
  48660. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48661. private _createRenderTargetTexture;
  48662. }
  48663. }
  48664. declare module "babylonjs/XR/webXRCamera" {
  48665. import { Vector3 } from "babylonjs/Maths/math.vector";
  48666. import { Scene } from "babylonjs/scene";
  48667. import { Camera } from "babylonjs/Cameras/camera";
  48668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48669. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48670. import { Observable } from "babylonjs/Misc/observable";
  48671. /**
  48672. * WebXR Camera which holds the views for the xrSession
  48673. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48674. */
  48675. export class WebXRCamera extends FreeCamera {
  48676. private _xrSessionManager;
  48677. private _firstFrame;
  48678. private _referenceQuaternion;
  48679. private _referencedPosition;
  48680. private _xrInvPositionCache;
  48681. private _xrInvQuaternionCache;
  48682. /**
  48683. * Observable raised before camera teleportation
  48684. */
  48685. onBeforeCameraTeleport: Observable<Vector3>;
  48686. /**
  48687. * Observable raised after camera teleportation
  48688. */
  48689. onAfterCameraTeleport: Observable<Vector3>;
  48690. /**
  48691. * Should position compensation execute on first frame.
  48692. * This is used when copying the position from a native (non XR) camera
  48693. */
  48694. compensateOnFirstFrame: boolean;
  48695. /**
  48696. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48697. * @param name the name of the camera
  48698. * @param scene the scene to add the camera to
  48699. * @param _xrSessionManager a constructed xr session manager
  48700. */
  48701. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48702. /**
  48703. * Return the user's height, unrelated to the current ground.
  48704. * This will be the y position of this camera, when ground level is 0.
  48705. */
  48706. get realWorldHeight(): number;
  48707. /** @hidden */
  48708. _updateForDualEyeDebugging(): void;
  48709. /**
  48710. * Sets this camera's transformation based on a non-vr camera
  48711. * @param otherCamera the non-vr camera to copy the transformation from
  48712. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48713. */
  48714. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48715. /**
  48716. * Gets the current instance class name ("WebXRCamera").
  48717. * @returns the class name
  48718. */
  48719. getClassName(): string;
  48720. private _rotate180;
  48721. private _updateFromXRSession;
  48722. private _updateNumberOfRigCameras;
  48723. private _updateReferenceSpace;
  48724. private _updateReferenceSpaceOffset;
  48725. }
  48726. }
  48727. declare module "babylonjs/XR/webXRFeaturesManager" {
  48728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48729. import { IDisposable } from "babylonjs/scene";
  48730. /**
  48731. * Defining the interface required for a (webxr) feature
  48732. */
  48733. export interface IWebXRFeature extends IDisposable {
  48734. /**
  48735. * Is this feature attached
  48736. */
  48737. attached: boolean;
  48738. /**
  48739. * Should auto-attach be disabled?
  48740. */
  48741. disableAutoAttach: boolean;
  48742. /**
  48743. * Attach the feature to the session
  48744. * Will usually be called by the features manager
  48745. *
  48746. * @param force should attachment be forced (even when already attached)
  48747. * @returns true if successful.
  48748. */
  48749. attach(force?: boolean): boolean;
  48750. /**
  48751. * Detach the feature from the session
  48752. * Will usually be called by the features manager
  48753. *
  48754. * @returns true if successful.
  48755. */
  48756. detach(): boolean;
  48757. /**
  48758. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48759. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48760. *
  48761. * @returns whether or not the feature is compatible in this environment
  48762. */
  48763. isCompatible(): boolean;
  48764. /**
  48765. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48766. */
  48767. xrNativeFeatureName?: string;
  48768. }
  48769. /**
  48770. * A list of the currently available features without referencing them
  48771. */
  48772. export class WebXRFeatureName {
  48773. /**
  48774. * The name of the anchor system feature
  48775. */
  48776. static ANCHOR_SYSTEM: string;
  48777. /**
  48778. * The name of the background remover feature
  48779. */
  48780. static BACKGROUND_REMOVER: string;
  48781. /**
  48782. * The name of the hit test feature
  48783. */
  48784. static HIT_TEST: string;
  48785. /**
  48786. * physics impostors for xr controllers feature
  48787. */
  48788. static PHYSICS_CONTROLLERS: string;
  48789. /**
  48790. * The name of the plane detection feature
  48791. */
  48792. static PLANE_DETECTION: string;
  48793. /**
  48794. * The name of the pointer selection feature
  48795. */
  48796. static POINTER_SELECTION: string;
  48797. /**
  48798. * The name of the teleportation feature
  48799. */
  48800. static TELEPORTATION: string;
  48801. }
  48802. /**
  48803. * Defining the constructor of a feature. Used to register the modules.
  48804. */
  48805. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48806. /**
  48807. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48808. * It is mainly used in AR sessions.
  48809. *
  48810. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48811. */
  48812. export class WebXRFeaturesManager implements IDisposable {
  48813. private _xrSessionManager;
  48814. private static readonly _AvailableFeatures;
  48815. private _features;
  48816. /**
  48817. * constructs a new features manages.
  48818. *
  48819. * @param _xrSessionManager an instance of WebXRSessionManager
  48820. */
  48821. constructor(_xrSessionManager: WebXRSessionManager);
  48822. /**
  48823. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48824. * Mainly used internally.
  48825. *
  48826. * @param featureName the name of the feature to register
  48827. * @param constructorFunction the function used to construct the module
  48828. * @param version the (babylon) version of the module
  48829. * @param stable is that a stable version of this module
  48830. */
  48831. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48832. /**
  48833. * Returns a constructor of a specific feature.
  48834. *
  48835. * @param featureName the name of the feature to construct
  48836. * @param version the version of the feature to load
  48837. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48838. * @param options optional options provided to the module.
  48839. * @returns a function that, when called, will return a new instance of this feature
  48840. */
  48841. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48842. /**
  48843. * Can be used to return the list of features currently registered
  48844. *
  48845. * @returns an Array of available features
  48846. */
  48847. static GetAvailableFeatures(): string[];
  48848. /**
  48849. * Gets the versions available for a specific feature
  48850. * @param featureName the name of the feature
  48851. * @returns an array with the available versions
  48852. */
  48853. static GetAvailableVersions(featureName: string): string[];
  48854. /**
  48855. * Return the latest unstable version of this feature
  48856. * @param featureName the name of the feature to search
  48857. * @returns the version number. if not found will return -1
  48858. */
  48859. static GetLatestVersionOfFeature(featureName: string): number;
  48860. /**
  48861. * Return the latest stable version of this feature
  48862. * @param featureName the name of the feature to search
  48863. * @returns the version number. if not found will return -1
  48864. */
  48865. static GetStableVersionOfFeature(featureName: string): number;
  48866. /**
  48867. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48868. * Can be used during a session to start a feature
  48869. * @param featureName the name of feature to attach
  48870. */
  48871. attachFeature(featureName: string): void;
  48872. /**
  48873. * Can be used inside a session or when the session ends to detach a specific feature
  48874. * @param featureName the name of the feature to detach
  48875. */
  48876. detachFeature(featureName: string): void;
  48877. /**
  48878. * Used to disable an already-enabled feature
  48879. * The feature will be disposed and will be recreated once enabled.
  48880. * @param featureName the feature to disable
  48881. * @returns true if disable was successful
  48882. */
  48883. disableFeature(featureName: string | {
  48884. Name: string;
  48885. }): boolean;
  48886. /**
  48887. * dispose this features manager
  48888. */
  48889. dispose(): void;
  48890. /**
  48891. * 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.
  48892. * 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.
  48893. *
  48894. * @param featureName the name of the feature to load or the class of the feature
  48895. * @param version optional version to load. if not provided the latest version will be enabled
  48896. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48897. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48898. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48899. * @returns a new constructed feature or throws an error if feature not found.
  48900. */
  48901. enableFeature(featureName: string | {
  48902. Name: string;
  48903. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48904. /**
  48905. * get the implementation of an enabled feature.
  48906. * @param featureName the name of the feature to load
  48907. * @returns the feature class, if found
  48908. */
  48909. getEnabledFeature(featureName: string): IWebXRFeature;
  48910. /**
  48911. * Get the list of enabled features
  48912. * @returns an array of enabled features
  48913. */
  48914. getEnabledFeatures(): string[];
  48915. /**
  48916. * This function will exten the session creation configuration object with enabled features.
  48917. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48918. * according to the defined "required" variable, provided during enableFeature call
  48919. * @param xrSessionInit the xr Session init object to extend
  48920. *
  48921. * @returns an extended XRSessionInit object
  48922. */
  48923. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48924. }
  48925. }
  48926. declare module "babylonjs/XR/webXRExperienceHelper" {
  48927. import { Observable } from "babylonjs/Misc/observable";
  48928. import { IDisposable, Scene } from "babylonjs/scene";
  48929. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48930. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48931. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48932. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48933. /**
  48934. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48935. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48936. */
  48937. export class WebXRExperienceHelper implements IDisposable {
  48938. private scene;
  48939. private _nonVRCamera;
  48940. private _originalSceneAutoClear;
  48941. private _supported;
  48942. /**
  48943. * Camera used to render xr content
  48944. */
  48945. camera: WebXRCamera;
  48946. /** A features manager for this xr session */
  48947. featuresManager: WebXRFeaturesManager;
  48948. /**
  48949. * Observers registered here will be triggered after the camera's initial transformation is set
  48950. * This can be used to set a different ground level or an extra rotation.
  48951. *
  48952. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48953. * to the position set after this observable is done executing.
  48954. */
  48955. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48956. /**
  48957. * Fires when the state of the experience helper has changed
  48958. */
  48959. onStateChangedObservable: Observable<WebXRState>;
  48960. /** Session manager used to keep track of xr session */
  48961. sessionManager: WebXRSessionManager;
  48962. /**
  48963. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48964. */
  48965. state: WebXRState;
  48966. /**
  48967. * Creates a WebXRExperienceHelper
  48968. * @param scene The scene the helper should be created in
  48969. */
  48970. private constructor();
  48971. /**
  48972. * Creates the experience helper
  48973. * @param scene the scene to attach the experience helper to
  48974. * @returns a promise for the experience helper
  48975. */
  48976. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48977. /**
  48978. * Disposes of the experience helper
  48979. */
  48980. dispose(): void;
  48981. /**
  48982. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48983. * @param sessionMode options for the XR session
  48984. * @param referenceSpaceType frame of reference of the XR session
  48985. * @param renderTarget the output canvas that will be used to enter XR mode
  48986. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48987. * @returns promise that resolves after xr mode has entered
  48988. */
  48989. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48990. /**
  48991. * Exits XR mode and returns the scene to its original state
  48992. * @returns promise that resolves after xr mode has exited
  48993. */
  48994. exitXRAsync(): Promise<void>;
  48995. private _nonXRToXRCamera;
  48996. private _setState;
  48997. }
  48998. }
  48999. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49000. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49001. import { Observable } from "babylonjs/Misc/observable";
  49002. import { IDisposable } from "babylonjs/scene";
  49003. /**
  49004. * X-Y values for axes in WebXR
  49005. */
  49006. export interface IWebXRMotionControllerAxesValue {
  49007. /**
  49008. * The value of the x axis
  49009. */
  49010. x: number;
  49011. /**
  49012. * The value of the y-axis
  49013. */
  49014. y: number;
  49015. }
  49016. /**
  49017. * changed / previous values for the values of this component
  49018. */
  49019. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49020. /**
  49021. * current (this frame) value
  49022. */
  49023. current: T;
  49024. /**
  49025. * previous (last change) value
  49026. */
  49027. previous: T;
  49028. }
  49029. /**
  49030. * Represents changes in the component between current frame and last values recorded
  49031. */
  49032. export interface IWebXRMotionControllerComponentChanges {
  49033. /**
  49034. * will be populated with previous and current values if axes changed
  49035. */
  49036. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49037. /**
  49038. * will be populated with previous and current values if pressed changed
  49039. */
  49040. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49041. /**
  49042. * will be populated with previous and current values if touched changed
  49043. */
  49044. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49045. /**
  49046. * will be populated with previous and current values if value changed
  49047. */
  49048. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49049. }
  49050. /**
  49051. * This class represents a single component (for example button or thumbstick) of a motion controller
  49052. */
  49053. export class WebXRControllerComponent implements IDisposable {
  49054. /**
  49055. * the id of this component
  49056. */
  49057. id: string;
  49058. /**
  49059. * the type of the component
  49060. */
  49061. type: MotionControllerComponentType;
  49062. private _buttonIndex;
  49063. private _axesIndices;
  49064. private _axes;
  49065. private _changes;
  49066. private _currentValue;
  49067. private _hasChanges;
  49068. private _pressed;
  49069. private _touched;
  49070. /**
  49071. * button component type
  49072. */
  49073. static BUTTON_TYPE: MotionControllerComponentType;
  49074. /**
  49075. * squeeze component type
  49076. */
  49077. static SQUEEZE_TYPE: MotionControllerComponentType;
  49078. /**
  49079. * Thumbstick component type
  49080. */
  49081. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49082. /**
  49083. * Touchpad component type
  49084. */
  49085. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49086. /**
  49087. * trigger component type
  49088. */
  49089. static TRIGGER_TYPE: MotionControllerComponentType;
  49090. /**
  49091. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49092. * the axes data changes
  49093. */
  49094. onAxisValueChangedObservable: Observable<{
  49095. x: number;
  49096. y: number;
  49097. }>;
  49098. /**
  49099. * Observers registered here will be triggered when the state of a button changes
  49100. * State change is either pressed / touched / value
  49101. */
  49102. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49103. /**
  49104. * Creates a new component for a motion controller.
  49105. * It is created by the motion controller itself
  49106. *
  49107. * @param id the id of this component
  49108. * @param type the type of the component
  49109. * @param _buttonIndex index in the buttons array of the gamepad
  49110. * @param _axesIndices indices of the values in the axes array of the gamepad
  49111. */
  49112. constructor(
  49113. /**
  49114. * the id of this component
  49115. */
  49116. id: string,
  49117. /**
  49118. * the type of the component
  49119. */
  49120. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49121. /**
  49122. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49123. */
  49124. get axes(): IWebXRMotionControllerAxesValue;
  49125. /**
  49126. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49127. */
  49128. get changes(): IWebXRMotionControllerComponentChanges;
  49129. /**
  49130. * Return whether or not the component changed the last frame
  49131. */
  49132. get hasChanges(): boolean;
  49133. /**
  49134. * is the button currently pressed
  49135. */
  49136. get pressed(): boolean;
  49137. /**
  49138. * is the button currently touched
  49139. */
  49140. get touched(): boolean;
  49141. /**
  49142. * Get the current value of this component
  49143. */
  49144. get value(): number;
  49145. /**
  49146. * Dispose this component
  49147. */
  49148. dispose(): void;
  49149. /**
  49150. * Are there axes correlating to this component
  49151. * @return true is axes data is available
  49152. */
  49153. isAxes(): boolean;
  49154. /**
  49155. * Is this component a button (hence - pressable)
  49156. * @returns true if can be pressed
  49157. */
  49158. isButton(): boolean;
  49159. /**
  49160. * update this component using the gamepad object it is in. Called on every frame
  49161. * @param nativeController the native gamepad controller object
  49162. */
  49163. update(nativeController: IMinimalMotionControllerObject): void;
  49164. }
  49165. }
  49166. declare module "babylonjs/Loading/sceneLoader" {
  49167. import { Observable } from "babylonjs/Misc/observable";
  49168. import { Nullable } from "babylonjs/types";
  49169. import { Scene } from "babylonjs/scene";
  49170. import { Engine } from "babylonjs/Engines/engine";
  49171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49172. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49173. import { AssetContainer } from "babylonjs/assetContainer";
  49174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49175. import { Skeleton } from "babylonjs/Bones/skeleton";
  49176. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49177. import { WebRequest } from "babylonjs/Misc/webRequest";
  49178. /**
  49179. * Interface used to represent data loading progression
  49180. */
  49181. export interface ISceneLoaderProgressEvent {
  49182. /**
  49183. * Defines if data length to load can be evaluated
  49184. */
  49185. readonly lengthComputable: boolean;
  49186. /**
  49187. * Defines the loaded data length
  49188. */
  49189. readonly loaded: number;
  49190. /**
  49191. * Defines the data length to load
  49192. */
  49193. readonly total: number;
  49194. }
  49195. /**
  49196. * Interface used by SceneLoader plugins to define supported file extensions
  49197. */
  49198. export interface ISceneLoaderPluginExtensions {
  49199. /**
  49200. * Defines the list of supported extensions
  49201. */
  49202. [extension: string]: {
  49203. isBinary: boolean;
  49204. };
  49205. }
  49206. /**
  49207. * Interface used by SceneLoader plugin factory
  49208. */
  49209. export interface ISceneLoaderPluginFactory {
  49210. /**
  49211. * Defines the name of the factory
  49212. */
  49213. name: string;
  49214. /**
  49215. * Function called to create a new plugin
  49216. * @return the new plugin
  49217. */
  49218. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49219. /**
  49220. * The callback that returns true if the data can be directly loaded.
  49221. * @param data string containing the file data
  49222. * @returns if the data can be loaded directly
  49223. */
  49224. canDirectLoad?(data: string): boolean;
  49225. }
  49226. /**
  49227. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49228. */
  49229. export interface ISceneLoaderPluginBase {
  49230. /**
  49231. * The friendly name of this plugin.
  49232. */
  49233. name: string;
  49234. /**
  49235. * The file extensions supported by this plugin.
  49236. */
  49237. extensions: string | ISceneLoaderPluginExtensions;
  49238. /**
  49239. * The callback called when loading from a url.
  49240. * @param scene scene loading this url
  49241. * @param url url to load
  49242. * @param onSuccess callback called when the file successfully loads
  49243. * @param onProgress callback called while file is loading (if the server supports this mode)
  49244. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49245. * @param onError callback called when the file fails to load
  49246. * @returns a file request object
  49247. */
  49248. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49249. /**
  49250. * The callback called when loading from a file object.
  49251. * @param scene scene loading this file
  49252. * @param file defines the file to load
  49253. * @param onSuccess defines the callback to call when data is loaded
  49254. * @param onProgress defines the callback to call during loading process
  49255. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49256. * @param onError defines the callback to call when an error occurs
  49257. * @returns a file request object
  49258. */
  49259. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49260. /**
  49261. * The callback that returns true if the data can be directly loaded.
  49262. * @param data string containing the file data
  49263. * @returns if the data can be loaded directly
  49264. */
  49265. canDirectLoad?(data: string): boolean;
  49266. /**
  49267. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49268. * @param scene scene loading this data
  49269. * @param data string containing the data
  49270. * @returns data to pass to the plugin
  49271. */
  49272. directLoad?(scene: Scene, data: string): any;
  49273. /**
  49274. * The callback that allows custom handling of the root url based on the response url.
  49275. * @param rootUrl the original root url
  49276. * @param responseURL the response url if available
  49277. * @returns the new root url
  49278. */
  49279. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49280. }
  49281. /**
  49282. * Interface used to define a SceneLoader plugin
  49283. */
  49284. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49285. /**
  49286. * Import meshes into a scene.
  49287. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49288. * @param scene The scene to import into
  49289. * @param data The data to import
  49290. * @param rootUrl The root url for scene and resources
  49291. * @param meshes The meshes array to import into
  49292. * @param particleSystems The particle systems array to import into
  49293. * @param skeletons The skeletons array to import into
  49294. * @param onError The callback when import fails
  49295. * @returns True if successful or false otherwise
  49296. */
  49297. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49298. /**
  49299. * Load into a scene.
  49300. * @param scene The scene to load into
  49301. * @param data The data to import
  49302. * @param rootUrl The root url for scene and resources
  49303. * @param onError The callback when import fails
  49304. * @returns True if successful or false otherwise
  49305. */
  49306. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49307. /**
  49308. * Load into an asset container.
  49309. * @param scene The scene to load into
  49310. * @param data The data to import
  49311. * @param rootUrl The root url for scene and resources
  49312. * @param onError The callback when import fails
  49313. * @returns The loaded asset container
  49314. */
  49315. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49316. }
  49317. /**
  49318. * Interface used to define an async SceneLoader plugin
  49319. */
  49320. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49321. /**
  49322. * Import meshes into a scene.
  49323. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49324. * @param scene The scene to import into
  49325. * @param data The data to import
  49326. * @param rootUrl The root url for scene and resources
  49327. * @param onProgress The callback when the load progresses
  49328. * @param fileName Defines the name of the file to load
  49329. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49330. */
  49331. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49332. meshes: AbstractMesh[];
  49333. particleSystems: IParticleSystem[];
  49334. skeletons: Skeleton[];
  49335. animationGroups: AnimationGroup[];
  49336. }>;
  49337. /**
  49338. * Load into a scene.
  49339. * @param scene The scene to load into
  49340. * @param data The data to import
  49341. * @param rootUrl The root url for scene and resources
  49342. * @param onProgress The callback when the load progresses
  49343. * @param fileName Defines the name of the file to load
  49344. * @returns Nothing
  49345. */
  49346. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49347. /**
  49348. * Load into an asset container.
  49349. * @param scene The scene to load into
  49350. * @param data The data to import
  49351. * @param rootUrl The root url for scene and resources
  49352. * @param onProgress The callback when the load progresses
  49353. * @param fileName Defines the name of the file to load
  49354. * @returns The loaded asset container
  49355. */
  49356. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49357. }
  49358. /**
  49359. * Mode that determines how to handle old animation groups before loading new ones.
  49360. */
  49361. export enum SceneLoaderAnimationGroupLoadingMode {
  49362. /**
  49363. * Reset all old animations to initial state then dispose them.
  49364. */
  49365. Clean = 0,
  49366. /**
  49367. * Stop all old animations.
  49368. */
  49369. Stop = 1,
  49370. /**
  49371. * Restart old animations from first frame.
  49372. */
  49373. Sync = 2,
  49374. /**
  49375. * Old animations remains untouched.
  49376. */
  49377. NoSync = 3
  49378. }
  49379. /**
  49380. * Defines a plugin registered by the SceneLoader
  49381. */
  49382. interface IRegisteredPlugin {
  49383. /**
  49384. * Defines the plugin to use
  49385. */
  49386. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49387. /**
  49388. * Defines if the plugin supports binary data
  49389. */
  49390. isBinary: boolean;
  49391. }
  49392. /**
  49393. * Class used to load scene from various file formats using registered plugins
  49394. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49395. */
  49396. export class SceneLoader {
  49397. /**
  49398. * No logging while loading
  49399. */
  49400. static readonly NO_LOGGING: number;
  49401. /**
  49402. * Minimal logging while loading
  49403. */
  49404. static readonly MINIMAL_LOGGING: number;
  49405. /**
  49406. * Summary logging while loading
  49407. */
  49408. static readonly SUMMARY_LOGGING: number;
  49409. /**
  49410. * Detailled logging while loading
  49411. */
  49412. static readonly DETAILED_LOGGING: number;
  49413. /**
  49414. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49415. */
  49416. static get ForceFullSceneLoadingForIncremental(): boolean;
  49417. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49418. /**
  49419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49420. */
  49421. static get ShowLoadingScreen(): boolean;
  49422. static set ShowLoadingScreen(value: boolean);
  49423. /**
  49424. * Defines the current logging level (while loading the scene)
  49425. * @ignorenaming
  49426. */
  49427. static get loggingLevel(): number;
  49428. static set loggingLevel(value: number);
  49429. /**
  49430. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49431. */
  49432. static get CleanBoneMatrixWeights(): boolean;
  49433. static set CleanBoneMatrixWeights(value: boolean);
  49434. /**
  49435. * Event raised when a plugin is used to load a scene
  49436. */
  49437. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49438. private static _registeredPlugins;
  49439. private static _showingLoadingScreen;
  49440. /**
  49441. * Gets the default plugin (used to load Babylon files)
  49442. * @returns the .babylon plugin
  49443. */
  49444. static GetDefaultPlugin(): IRegisteredPlugin;
  49445. private static _GetPluginForExtension;
  49446. private static _GetPluginForDirectLoad;
  49447. private static _GetPluginForFilename;
  49448. private static _GetDirectLoad;
  49449. private static _LoadData;
  49450. private static _GetFileInfo;
  49451. /**
  49452. * Gets a plugin that can load the given extension
  49453. * @param extension defines the extension to load
  49454. * @returns a plugin or null if none works
  49455. */
  49456. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49457. /**
  49458. * Gets a boolean indicating that the given extension can be loaded
  49459. * @param extension defines the extension to load
  49460. * @returns true if the extension is supported
  49461. */
  49462. static IsPluginForExtensionAvailable(extension: string): boolean;
  49463. /**
  49464. * Adds a new plugin to the list of registered plugins
  49465. * @param plugin defines the plugin to add
  49466. */
  49467. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49468. /**
  49469. * Import meshes into a scene
  49470. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49471. * @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)
  49472. * @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)
  49473. * @param scene the instance of BABYLON.Scene to append to
  49474. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49475. * @param onProgress a callback with a progress event for each file being loaded
  49476. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49477. * @param pluginExtension the extension used to determine the plugin
  49478. * @returns The loaded plugin
  49479. */
  49480. 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>;
  49481. /**
  49482. * Import meshes into a scene
  49483. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49484. * @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)
  49485. * @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)
  49486. * @param scene the instance of BABYLON.Scene to append to
  49487. * @param onProgress a callback with a progress event for each file being loaded
  49488. * @param pluginExtension the extension used to determine the plugin
  49489. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49490. */
  49491. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49492. meshes: AbstractMesh[];
  49493. particleSystems: IParticleSystem[];
  49494. skeletons: Skeleton[];
  49495. animationGroups: AnimationGroup[];
  49496. }>;
  49497. /**
  49498. * Load a scene
  49499. * @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)
  49500. * @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)
  49501. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49502. * @param onSuccess a callback with the scene when import succeeds
  49503. * @param onProgress a callback with a progress event for each file being loaded
  49504. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49505. * @param pluginExtension the extension used to determine the plugin
  49506. * @returns The loaded plugin
  49507. */
  49508. 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>;
  49509. /**
  49510. * Load a scene
  49511. * @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)
  49512. * @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)
  49513. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49514. * @param onProgress a callback with a progress event for each file being loaded
  49515. * @param pluginExtension the extension used to determine the plugin
  49516. * @returns The loaded scene
  49517. */
  49518. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49519. /**
  49520. * Append a scene
  49521. * @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)
  49522. * @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)
  49523. * @param scene is the instance of BABYLON.Scene to append to
  49524. * @param onSuccess a callback with the scene when import succeeds
  49525. * @param onProgress a callback with a progress event for each file being loaded
  49526. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49527. * @param pluginExtension the extension used to determine the plugin
  49528. * @returns The loaded plugin
  49529. */
  49530. 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>;
  49531. /**
  49532. * Append a scene
  49533. * @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)
  49534. * @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)
  49535. * @param scene is the instance of BABYLON.Scene to append to
  49536. * @param onProgress a callback with a progress event for each file being loaded
  49537. * @param pluginExtension the extension used to determine the plugin
  49538. * @returns The given scene
  49539. */
  49540. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49541. /**
  49542. * Load a scene into an asset container
  49543. * @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)
  49544. * @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)
  49545. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49546. * @param onSuccess a callback with the scene when import succeeds
  49547. * @param onProgress a callback with a progress event for each file being loaded
  49548. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49549. * @param pluginExtension the extension used to determine the plugin
  49550. * @returns The loaded plugin
  49551. */
  49552. 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>;
  49553. /**
  49554. * Load a scene into an asset container
  49555. * @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)
  49556. * @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)
  49557. * @param scene is the instance of Scene to append to
  49558. * @param onProgress a callback with a progress event for each file being loaded
  49559. * @param pluginExtension the extension used to determine the plugin
  49560. * @returns The loaded asset container
  49561. */
  49562. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49563. /**
  49564. * Import animations from a file into a scene
  49565. * @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)
  49566. * @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)
  49567. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49568. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49569. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49570. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49571. * @param onSuccess a callback with the scene when import succeeds
  49572. * @param onProgress a callback with a progress event for each file being loaded
  49573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49574. * @param pluginExtension the extension used to determine the plugin
  49575. */
  49576. 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;
  49577. /**
  49578. * Import animations from a file into a scene
  49579. * @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)
  49580. * @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)
  49581. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49582. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49583. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49584. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49585. * @param onSuccess a callback with the scene when import succeeds
  49586. * @param onProgress a callback with a progress event for each file being loaded
  49587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49588. * @param pluginExtension the extension used to determine the plugin
  49589. * @returns the updated scene with imported animations
  49590. */
  49591. 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>;
  49592. }
  49593. }
  49594. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49595. import { IDisposable, Scene } from "babylonjs/scene";
  49596. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49597. import { Observable } from "babylonjs/Misc/observable";
  49598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49599. import { Nullable } from "babylonjs/types";
  49600. /**
  49601. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49602. */
  49603. export type MotionControllerHandedness = "none" | "left" | "right";
  49604. /**
  49605. * The type of components available in motion controllers.
  49606. * This is not the name of the component.
  49607. */
  49608. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49609. /**
  49610. * The state of a controller component
  49611. */
  49612. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49613. /**
  49614. * The schema of motion controller layout.
  49615. * No object will be initialized using this interface
  49616. * This is used just to define the profile.
  49617. */
  49618. export interface IMotionControllerLayout {
  49619. /**
  49620. * Path to load the assets. Usually relative to the base path
  49621. */
  49622. assetPath: string;
  49623. /**
  49624. * Available components (unsorted)
  49625. */
  49626. components: {
  49627. /**
  49628. * A map of component Ids
  49629. */
  49630. [componentId: string]: {
  49631. /**
  49632. * The type of input the component outputs
  49633. */
  49634. type: MotionControllerComponentType;
  49635. /**
  49636. * The indices of this component in the gamepad object
  49637. */
  49638. gamepadIndices: {
  49639. /**
  49640. * Index of button
  49641. */
  49642. button?: number;
  49643. /**
  49644. * If available, index of x-axis
  49645. */
  49646. xAxis?: number;
  49647. /**
  49648. * If available, index of y-axis
  49649. */
  49650. yAxis?: number;
  49651. };
  49652. /**
  49653. * The mesh's root node name
  49654. */
  49655. rootNodeName: string;
  49656. /**
  49657. * Animation definitions for this model
  49658. */
  49659. visualResponses: {
  49660. [stateKey: string]: {
  49661. /**
  49662. * What property will be animated
  49663. */
  49664. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49665. /**
  49666. * What states influence this visual response
  49667. */
  49668. states: MotionControllerComponentStateType[];
  49669. /**
  49670. * Type of animation - movement or visibility
  49671. */
  49672. valueNodeProperty: "transform" | "visibility";
  49673. /**
  49674. * Base node name to move. Its position will be calculated according to the min and max nodes
  49675. */
  49676. valueNodeName?: string;
  49677. /**
  49678. * Minimum movement node
  49679. */
  49680. minNodeName?: string;
  49681. /**
  49682. * Max movement node
  49683. */
  49684. maxNodeName?: string;
  49685. };
  49686. };
  49687. /**
  49688. * If touch enabled, what is the name of node to display user feedback
  49689. */
  49690. touchPointNodeName?: string;
  49691. };
  49692. };
  49693. /**
  49694. * Is it xr standard mapping or not
  49695. */
  49696. gamepadMapping: "" | "xr-standard";
  49697. /**
  49698. * Base root node of this entire model
  49699. */
  49700. rootNodeName: string;
  49701. /**
  49702. * Defines the main button component id
  49703. */
  49704. selectComponentId: string;
  49705. }
  49706. /**
  49707. * A definition for the layout map in the input profile
  49708. */
  49709. export interface IMotionControllerLayoutMap {
  49710. /**
  49711. * Layouts with handedness type as a key
  49712. */
  49713. [handedness: string]: IMotionControllerLayout;
  49714. }
  49715. /**
  49716. * The XR Input profile schema
  49717. * Profiles can be found here:
  49718. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49719. */
  49720. export interface IMotionControllerProfile {
  49721. /**
  49722. * fallback profiles for this profileId
  49723. */
  49724. fallbackProfileIds: string[];
  49725. /**
  49726. * The layout map, with handedness as key
  49727. */
  49728. layouts: IMotionControllerLayoutMap;
  49729. /**
  49730. * The id of this profile
  49731. * correlates to the profile(s) in the xrInput.profiles array
  49732. */
  49733. profileId: string;
  49734. }
  49735. /**
  49736. * A helper-interface for the 3 meshes needed for controller button animation
  49737. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49738. */
  49739. export interface IMotionControllerButtonMeshMap {
  49740. /**
  49741. * the mesh that defines the pressed value mesh position.
  49742. * This is used to find the max-position of this button
  49743. */
  49744. pressedMesh: AbstractMesh;
  49745. /**
  49746. * the mesh that defines the unpressed value mesh position.
  49747. * This is used to find the min (or initial) position of this button
  49748. */
  49749. unpressedMesh: AbstractMesh;
  49750. /**
  49751. * The mesh that will be changed when value changes
  49752. */
  49753. valueMesh: AbstractMesh;
  49754. }
  49755. /**
  49756. * A helper-interface for the 3 meshes needed for controller axis animation.
  49757. * This will be expanded when touchpad animations are fully supported
  49758. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49759. */
  49760. export interface IMotionControllerMeshMap {
  49761. /**
  49762. * the mesh that defines the maximum value mesh position.
  49763. */
  49764. maxMesh?: AbstractMesh;
  49765. /**
  49766. * the mesh that defines the minimum value mesh position.
  49767. */
  49768. minMesh?: AbstractMesh;
  49769. /**
  49770. * The mesh that will be changed when axis value changes
  49771. */
  49772. valueMesh: AbstractMesh;
  49773. }
  49774. /**
  49775. * The elements needed for change-detection of the gamepad objects in motion controllers
  49776. */
  49777. export interface IMinimalMotionControllerObject {
  49778. /**
  49779. * Available axes of this controller
  49780. */
  49781. axes: number[];
  49782. /**
  49783. * An array of available buttons
  49784. */
  49785. buttons: Array<{
  49786. /**
  49787. * Value of the button/trigger
  49788. */
  49789. value: number;
  49790. /**
  49791. * If the button/trigger is currently touched
  49792. */
  49793. touched: boolean;
  49794. /**
  49795. * If the button/trigger is currently pressed
  49796. */
  49797. pressed: boolean;
  49798. }>;
  49799. /**
  49800. * EXPERIMENTAL haptic support.
  49801. */
  49802. hapticActuators?: Array<{
  49803. pulse: (value: number, duration: number) => Promise<boolean>;
  49804. }>;
  49805. }
  49806. /**
  49807. * An Abstract Motion controller
  49808. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49809. * Each component has an observable to check for changes in value and state
  49810. */
  49811. export abstract class WebXRAbstractMotionController implements IDisposable {
  49812. protected scene: Scene;
  49813. protected layout: IMotionControllerLayout;
  49814. /**
  49815. * The gamepad object correlating to this controller
  49816. */
  49817. gamepadObject: IMinimalMotionControllerObject;
  49818. /**
  49819. * handedness (left/right/none) of this controller
  49820. */
  49821. handedness: MotionControllerHandedness;
  49822. private _initComponent;
  49823. private _modelReady;
  49824. /**
  49825. * A map of components (WebXRControllerComponent) in this motion controller
  49826. * Components have a ComponentType and can also have both button and axis definitions
  49827. */
  49828. readonly components: {
  49829. [id: string]: WebXRControllerComponent;
  49830. };
  49831. /**
  49832. * Disable the model's animation. Can be set at any time.
  49833. */
  49834. disableAnimation: boolean;
  49835. /**
  49836. * Observers registered here will be triggered when the model of this controller is done loading
  49837. */
  49838. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49839. /**
  49840. * The profile id of this motion controller
  49841. */
  49842. abstract profileId: string;
  49843. /**
  49844. * The root mesh of the model. It is null if the model was not yet initialized
  49845. */
  49846. rootMesh: Nullable<AbstractMesh>;
  49847. /**
  49848. * constructs a new abstract motion controller
  49849. * @param scene the scene to which the model of the controller will be added
  49850. * @param layout The profile layout to load
  49851. * @param gamepadObject The gamepad object correlating to this controller
  49852. * @param handedness handedness (left/right/none) of this controller
  49853. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49854. */
  49855. constructor(scene: Scene, layout: IMotionControllerLayout,
  49856. /**
  49857. * The gamepad object correlating to this controller
  49858. */
  49859. gamepadObject: IMinimalMotionControllerObject,
  49860. /**
  49861. * handedness (left/right/none) of this controller
  49862. */
  49863. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49864. /**
  49865. * Dispose this controller, the model mesh and all its components
  49866. */
  49867. dispose(): void;
  49868. /**
  49869. * Returns all components of specific type
  49870. * @param type the type to search for
  49871. * @return an array of components with this type
  49872. */
  49873. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49874. /**
  49875. * get a component based an its component id as defined in layout.components
  49876. * @param id the id of the component
  49877. * @returns the component correlates to the id or undefined if not found
  49878. */
  49879. getComponent(id: string): WebXRControllerComponent;
  49880. /**
  49881. * Get the list of components available in this motion controller
  49882. * @returns an array of strings correlating to available components
  49883. */
  49884. getComponentIds(): string[];
  49885. /**
  49886. * Get the first component of specific type
  49887. * @param type type of component to find
  49888. * @return a controller component or null if not found
  49889. */
  49890. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49891. /**
  49892. * Get the main (Select) component of this controller as defined in the layout
  49893. * @returns the main component of this controller
  49894. */
  49895. getMainComponent(): WebXRControllerComponent;
  49896. /**
  49897. * Loads the model correlating to this controller
  49898. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49899. * @returns A promise fulfilled with the result of the model loading
  49900. */
  49901. loadModel(): Promise<boolean>;
  49902. /**
  49903. * Update this model using the current XRFrame
  49904. * @param xrFrame the current xr frame to use and update the model
  49905. */
  49906. updateFromXRFrame(xrFrame: XRFrame): void;
  49907. /**
  49908. * Backwards compatibility due to a deeply-integrated typo
  49909. */
  49910. get handness(): XREye;
  49911. /**
  49912. * Pulse (vibrate) this controller
  49913. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49914. * Consecutive calls to this function will cancel the last pulse call
  49915. *
  49916. * @param value the strength of the pulse in 0.0...1.0 range
  49917. * @param duration Duration of the pulse in milliseconds
  49918. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49919. * @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
  49920. */
  49921. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49922. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49923. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49924. /**
  49925. * Moves the axis on the controller mesh based on its current state
  49926. * @param axis the index of the axis
  49927. * @param axisValue the value of the axis which determines the meshes new position
  49928. * @hidden
  49929. */
  49930. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49931. /**
  49932. * Update the model itself with the current frame data
  49933. * @param xrFrame the frame to use for updating the model mesh
  49934. */
  49935. protected updateModel(xrFrame: XRFrame): void;
  49936. /**
  49937. * Get the filename and path for this controller's model
  49938. * @returns a map of filename and path
  49939. */
  49940. protected abstract _getFilenameAndPath(): {
  49941. filename: string;
  49942. path: string;
  49943. };
  49944. /**
  49945. * This function is called before the mesh is loaded. It checks for loading constraints.
  49946. * For example, this function can check if the GLB loader is available
  49947. * If this function returns false, the generic controller will be loaded instead
  49948. * @returns Is the client ready to load the mesh
  49949. */
  49950. protected abstract _getModelLoadingConstraints(): boolean;
  49951. /**
  49952. * This function will be called after the model was successfully loaded and can be used
  49953. * for mesh transformations before it is available for the user
  49954. * @param meshes the loaded meshes
  49955. */
  49956. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49957. /**
  49958. * Set the root mesh for this controller. Important for the WebXR controller class
  49959. * @param meshes the loaded meshes
  49960. */
  49961. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49962. /**
  49963. * A function executed each frame that updates the mesh (if needed)
  49964. * @param xrFrame the current xrFrame
  49965. */
  49966. protected abstract _updateModel(xrFrame: XRFrame): void;
  49967. private _getGenericFilenameAndPath;
  49968. private _getGenericParentMesh;
  49969. }
  49970. }
  49971. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49972. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49974. import { Scene } from "babylonjs/scene";
  49975. /**
  49976. * A generic trigger-only motion controller for WebXR
  49977. */
  49978. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49979. /**
  49980. * Static version of the profile id of this controller
  49981. */
  49982. static ProfileId: string;
  49983. profileId: string;
  49984. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49985. protected _getFilenameAndPath(): {
  49986. filename: string;
  49987. path: string;
  49988. };
  49989. protected _getModelLoadingConstraints(): boolean;
  49990. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49991. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49992. protected _updateModel(): void;
  49993. }
  49994. }
  49995. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49996. import { Vector4 } from "babylonjs/Maths/math.vector";
  49997. import { Mesh } from "babylonjs/Meshes/mesh";
  49998. import { Scene } from "babylonjs/scene";
  49999. import { Nullable } from "babylonjs/types";
  50000. /**
  50001. * Class containing static functions to help procedurally build meshes
  50002. */
  50003. export class SphereBuilder {
  50004. /**
  50005. * Creates a sphere mesh
  50006. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50007. * * 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`)
  50008. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50009. * * 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
  50010. * * 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)
  50011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50014. * @param name defines the name of the mesh
  50015. * @param options defines the options used to create the mesh
  50016. * @param scene defines the hosting scene
  50017. * @returns the sphere mesh
  50018. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50019. */
  50020. static CreateSphere(name: string, options: {
  50021. segments?: number;
  50022. diameter?: number;
  50023. diameterX?: number;
  50024. diameterY?: number;
  50025. diameterZ?: number;
  50026. arc?: number;
  50027. slice?: number;
  50028. sideOrientation?: number;
  50029. frontUVs?: Vector4;
  50030. backUVs?: Vector4;
  50031. updatable?: boolean;
  50032. }, scene?: Nullable<Scene>): Mesh;
  50033. }
  50034. }
  50035. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50037. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50038. import { Scene } from "babylonjs/scene";
  50039. /**
  50040. * A profiled motion controller has its profile loaded from an online repository.
  50041. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50042. */
  50043. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50044. private _repositoryUrl;
  50045. private _buttonMeshMapping;
  50046. private _touchDots;
  50047. /**
  50048. * The profile ID of this controller. Will be populated when the controller initializes.
  50049. */
  50050. profileId: string;
  50051. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50052. dispose(): void;
  50053. protected _getFilenameAndPath(): {
  50054. filename: string;
  50055. path: string;
  50056. };
  50057. protected _getModelLoadingConstraints(): boolean;
  50058. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50059. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50060. protected _updateModel(_xrFrame: XRFrame): void;
  50061. }
  50062. }
  50063. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50064. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50065. import { Scene } from "babylonjs/scene";
  50066. /**
  50067. * A construction function type to create a new controller based on an xrInput object
  50068. */
  50069. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50070. /**
  50071. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50072. *
  50073. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50074. * it should be replaced with auto-loaded controllers.
  50075. *
  50076. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50077. */
  50078. export class WebXRMotionControllerManager {
  50079. private static _AvailableControllers;
  50080. private static _Fallbacks;
  50081. private static _ProfileLoadingPromises;
  50082. private static _ProfilesList;
  50083. /**
  50084. * The base URL of the online controller repository. Can be changed at any time.
  50085. */
  50086. static BaseRepositoryUrl: string;
  50087. /**
  50088. * Which repository gets priority - local or online
  50089. */
  50090. static PrioritizeOnlineRepository: boolean;
  50091. /**
  50092. * Use the online repository, or use only locally-defined controllers
  50093. */
  50094. static UseOnlineRepository: boolean;
  50095. /**
  50096. * Clear the cache used for profile loading and reload when requested again
  50097. */
  50098. static ClearProfilesCache(): void;
  50099. /**
  50100. * Register the default fallbacks.
  50101. * This function is called automatically when this file is imported.
  50102. */
  50103. static DefaultFallbacks(): void;
  50104. /**
  50105. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50106. * @param profileId the profile to which a fallback needs to be found
  50107. * @return an array with corresponding fallback profiles
  50108. */
  50109. static FindFallbackWithProfileId(profileId: string): string[];
  50110. /**
  50111. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50112. * The order of search:
  50113. *
  50114. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50115. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50116. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50117. * 4) return the generic trigger controller if none were found
  50118. *
  50119. * @param xrInput the xrInput to which a new controller is initialized
  50120. * @param scene the scene to which the model will be added
  50121. * @param forceProfile force a certain profile for this controller
  50122. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50123. */
  50124. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50125. /**
  50126. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50127. *
  50128. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50129. *
  50130. * @param type the profile type to register
  50131. * @param constructFunction the function to be called when loading this profile
  50132. */
  50133. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50134. /**
  50135. * Register a fallback to a specific profile.
  50136. * @param profileId the profileId that will receive the fallbacks
  50137. * @param fallbacks A list of fallback profiles
  50138. */
  50139. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50140. /**
  50141. * Will update the list of profiles available in the repository
  50142. * @return a promise that resolves to a map of profiles available online
  50143. */
  50144. static UpdateProfilesList(): Promise<{
  50145. [profile: string]: string;
  50146. }>;
  50147. private static _LoadProfileFromRepository;
  50148. private static _LoadProfilesFromAvailableControllers;
  50149. }
  50150. }
  50151. declare module "babylonjs/XR/webXRInputSource" {
  50152. import { Observable } from "babylonjs/Misc/observable";
  50153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50154. import { Ray } from "babylonjs/Culling/ray";
  50155. import { Scene } from "babylonjs/scene";
  50156. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50157. /**
  50158. * Configuration options for the WebXR controller creation
  50159. */
  50160. export interface IWebXRControllerOptions {
  50161. /**
  50162. * Should the controller mesh be animated when a user interacts with it
  50163. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50164. */
  50165. disableMotionControllerAnimation?: boolean;
  50166. /**
  50167. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50168. */
  50169. doNotLoadControllerMesh?: boolean;
  50170. /**
  50171. * Force a specific controller type for this controller.
  50172. * This can be used when creating your own profile or when testing different controllers
  50173. */
  50174. forceControllerProfile?: string;
  50175. /**
  50176. * Defines a rendering group ID for meshes that will be loaded.
  50177. * This is for the default controllers only.
  50178. */
  50179. renderingGroupId?: number;
  50180. }
  50181. /**
  50182. * Represents an XR controller
  50183. */
  50184. export class WebXRInputSource {
  50185. private _scene;
  50186. /** The underlying input source for the controller */
  50187. inputSource: XRInputSource;
  50188. private _options;
  50189. private _tmpVector;
  50190. private _uniqueId;
  50191. /**
  50192. * 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
  50193. */
  50194. grip?: AbstractMesh;
  50195. /**
  50196. * If available, this is the gamepad object related to this controller.
  50197. * Using this object it is possible to get click events and trackpad changes of the
  50198. * webxr controller that is currently being used.
  50199. */
  50200. motionController?: WebXRAbstractMotionController;
  50201. /**
  50202. * Event that fires when the controller is removed/disposed.
  50203. * The object provided as event data is this controller, after associated assets were disposed.
  50204. * uniqueId is still available.
  50205. */
  50206. onDisposeObservable: Observable<WebXRInputSource>;
  50207. /**
  50208. * Will be triggered when the mesh associated with the motion controller is done loading.
  50209. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50210. * A shortened version of controller -> motion controller -> on mesh loaded.
  50211. */
  50212. onMeshLoadedObservable: Observable<AbstractMesh>;
  50213. /**
  50214. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50215. */
  50216. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50217. /**
  50218. * Pointer which can be used to select objects or attach a visible laser to
  50219. */
  50220. pointer: AbstractMesh;
  50221. /**
  50222. * Creates the input source object
  50223. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50224. * @param _scene the scene which the controller should be associated to
  50225. * @param inputSource the underlying input source for the controller
  50226. * @param _options options for this controller creation
  50227. */
  50228. constructor(_scene: Scene,
  50229. /** The underlying input source for the controller */
  50230. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50231. /**
  50232. * Get this controllers unique id
  50233. */
  50234. get uniqueId(): string;
  50235. /**
  50236. * Disposes of the object
  50237. */
  50238. dispose(): void;
  50239. /**
  50240. * Gets a world space ray coming from the pointer or grip
  50241. * @param result the resulting ray
  50242. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50243. */
  50244. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50245. /**
  50246. * Updates the controller pose based on the given XRFrame
  50247. * @param xrFrame xr frame to update the pose with
  50248. * @param referenceSpace reference space to use
  50249. */
  50250. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50251. }
  50252. }
  50253. declare module "babylonjs/XR/webXRInput" {
  50254. import { Observable } from "babylonjs/Misc/observable";
  50255. import { IDisposable } from "babylonjs/scene";
  50256. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50257. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50258. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50259. /**
  50260. * The schema for initialization options of the XR Input class
  50261. */
  50262. export interface IWebXRInputOptions {
  50263. /**
  50264. * If set to true no model will be automatically loaded
  50265. */
  50266. doNotLoadControllerMeshes?: boolean;
  50267. /**
  50268. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50269. * If not found, the xr input profile data will be used.
  50270. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50271. */
  50272. forceInputProfile?: string;
  50273. /**
  50274. * Do not send a request to the controller repository to load the profile.
  50275. *
  50276. * Instead, use the controllers available in babylon itself.
  50277. */
  50278. disableOnlineControllerRepository?: boolean;
  50279. /**
  50280. * A custom URL for the controllers repository
  50281. */
  50282. customControllersRepositoryURL?: string;
  50283. /**
  50284. * Should the controller model's components not move according to the user input
  50285. */
  50286. disableControllerAnimation?: boolean;
  50287. /**
  50288. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50289. */
  50290. controllerOptions?: IWebXRControllerOptions;
  50291. }
  50292. /**
  50293. * XR input used to track XR inputs such as controllers/rays
  50294. */
  50295. export class WebXRInput implements IDisposable {
  50296. /**
  50297. * the xr session manager for this session
  50298. */
  50299. xrSessionManager: WebXRSessionManager;
  50300. /**
  50301. * the WebXR camera for this session. Mainly used for teleportation
  50302. */
  50303. xrCamera: WebXRCamera;
  50304. private readonly options;
  50305. /**
  50306. * XR controllers being tracked
  50307. */
  50308. controllers: Array<WebXRInputSource>;
  50309. private _frameObserver;
  50310. private _sessionEndedObserver;
  50311. private _sessionInitObserver;
  50312. /**
  50313. * Event when a controller has been connected/added
  50314. */
  50315. onControllerAddedObservable: Observable<WebXRInputSource>;
  50316. /**
  50317. * Event when a controller has been removed/disconnected
  50318. */
  50319. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50320. /**
  50321. * Initializes the WebXRInput
  50322. * @param xrSessionManager the xr session manager for this session
  50323. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50324. * @param options = initialization options for this xr input
  50325. */
  50326. constructor(
  50327. /**
  50328. * the xr session manager for this session
  50329. */
  50330. xrSessionManager: WebXRSessionManager,
  50331. /**
  50332. * the WebXR camera for this session. Mainly used for teleportation
  50333. */
  50334. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50335. private _onInputSourcesChange;
  50336. private _addAndRemoveControllers;
  50337. /**
  50338. * Disposes of the object
  50339. */
  50340. dispose(): void;
  50341. }
  50342. }
  50343. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50344. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50345. import { Observable, EventState } from "babylonjs/Misc/observable";
  50346. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50347. /**
  50348. * This is the base class for all WebXR features.
  50349. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50350. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50351. */
  50352. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50353. protected _xrSessionManager: WebXRSessionManager;
  50354. private _attached;
  50355. private _removeOnDetach;
  50356. /**
  50357. * Should auto-attach be disabled?
  50358. */
  50359. disableAutoAttach: boolean;
  50360. /**
  50361. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50362. */
  50363. xrNativeFeatureName: string;
  50364. /**
  50365. * Construct a new (abstract) WebXR feature
  50366. * @param _xrSessionManager the xr session manager for this feature
  50367. */
  50368. constructor(_xrSessionManager: WebXRSessionManager);
  50369. /**
  50370. * Is this feature attached
  50371. */
  50372. get attached(): boolean;
  50373. /**
  50374. * attach this feature
  50375. *
  50376. * @param force should attachment be forced (even when already attached)
  50377. * @returns true if successful, false is failed or already attached
  50378. */
  50379. attach(force?: boolean): boolean;
  50380. /**
  50381. * detach this feature.
  50382. *
  50383. * @returns true if successful, false if failed or already detached
  50384. */
  50385. detach(): boolean;
  50386. /**
  50387. * Dispose this feature and all of the resources attached
  50388. */
  50389. dispose(): void;
  50390. /**
  50391. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50392. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50393. *
  50394. * @returns whether or not the feature is compatible in this environment
  50395. */
  50396. isCompatible(): boolean;
  50397. /**
  50398. * This is used to register callbacks that will automatically be removed when detach is called.
  50399. * @param observable the observable to which the observer will be attached
  50400. * @param callback the callback to register
  50401. */
  50402. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50403. /**
  50404. * Code in this function will be executed on each xrFrame received from the browser.
  50405. * This function will not execute after the feature is detached.
  50406. * @param _xrFrame the current frame
  50407. */
  50408. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50409. }
  50410. }
  50411. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50412. import { IDisposable, Scene } from "babylonjs/scene";
  50413. import { Nullable } from "babylonjs/types";
  50414. import { Observable } from "babylonjs/Misc/observable";
  50415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50416. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50417. import { Camera } from "babylonjs/Cameras/camera";
  50418. /**
  50419. * Renders a layer on top of an existing scene
  50420. */
  50421. export class UtilityLayerRenderer implements IDisposable {
  50422. /** the original scene that will be rendered on top of */
  50423. originalScene: Scene;
  50424. private _pointerCaptures;
  50425. private _lastPointerEvents;
  50426. private static _DefaultUtilityLayer;
  50427. private static _DefaultKeepDepthUtilityLayer;
  50428. private _sharedGizmoLight;
  50429. private _renderCamera;
  50430. /**
  50431. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50432. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50433. * @returns the camera that is used when rendering the utility layer
  50434. */
  50435. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50436. /**
  50437. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50438. * @param cam the camera that should be used when rendering the utility layer
  50439. */
  50440. setRenderCamera(cam: Nullable<Camera>): void;
  50441. /**
  50442. * @hidden
  50443. * Light which used by gizmos to get light shading
  50444. */
  50445. _getSharedGizmoLight(): HemisphericLight;
  50446. /**
  50447. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50448. */
  50449. pickUtilitySceneFirst: boolean;
  50450. /**
  50451. * 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)
  50452. */
  50453. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50454. /**
  50455. * 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)
  50456. */
  50457. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50458. /**
  50459. * The scene that is rendered on top of the original scene
  50460. */
  50461. utilityLayerScene: Scene;
  50462. /**
  50463. * If the utility layer should automatically be rendered on top of existing scene
  50464. */
  50465. shouldRender: boolean;
  50466. /**
  50467. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50468. */
  50469. onlyCheckPointerDownEvents: boolean;
  50470. /**
  50471. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50472. */
  50473. processAllEvents: boolean;
  50474. /**
  50475. * Observable raised when the pointer move from the utility layer scene to the main scene
  50476. */
  50477. onPointerOutObservable: Observable<number>;
  50478. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50479. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50480. private _afterRenderObserver;
  50481. private _sceneDisposeObserver;
  50482. private _originalPointerObserver;
  50483. /**
  50484. * Instantiates a UtilityLayerRenderer
  50485. * @param originalScene the original scene that will be rendered on top of
  50486. * @param handleEvents boolean indicating if the utility layer should handle events
  50487. */
  50488. constructor(
  50489. /** the original scene that will be rendered on top of */
  50490. originalScene: Scene, handleEvents?: boolean);
  50491. private _notifyObservers;
  50492. /**
  50493. * Renders the utility layers scene on top of the original scene
  50494. */
  50495. render(): void;
  50496. /**
  50497. * Disposes of the renderer
  50498. */
  50499. dispose(): void;
  50500. private _updateCamera;
  50501. }
  50502. }
  50503. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50504. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50506. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50507. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50508. import { Scene } from "babylonjs/scene";
  50509. import { Nullable } from "babylonjs/types";
  50510. import { Color3 } from "babylonjs/Maths/math.color";
  50511. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50512. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50513. /**
  50514. * Options interface for the pointer selection module
  50515. */
  50516. export interface IWebXRControllerPointerSelectionOptions {
  50517. /**
  50518. * if provided, this scene will be used to render meshes.
  50519. */
  50520. customUtilityLayerScene?: Scene;
  50521. /**
  50522. * 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)
  50523. * If not disabled, the last picked point will be used to execute a pointer up event
  50524. * If disabled, pointer up event will be triggered right after the pointer down event.
  50525. * Used in screen and gaze target ray mode only
  50526. */
  50527. disablePointerUpOnTouchOut: boolean;
  50528. /**
  50529. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50530. */
  50531. forceGazeMode: boolean;
  50532. /**
  50533. * 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
  50534. * to start a new countdown to the pointer down event.
  50535. * Defaults to 1.
  50536. */
  50537. gazeModePointerMovedFactor?: number;
  50538. /**
  50539. * Different button type to use instead of the main component
  50540. */
  50541. overrideButtonId?: string;
  50542. /**
  50543. * use this rendering group id for the meshes (optional)
  50544. */
  50545. renderingGroupId?: number;
  50546. /**
  50547. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50548. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50549. * 3000 means 3 seconds between pointing at something and selecting it
  50550. */
  50551. timeToSelect?: number;
  50552. /**
  50553. * Should meshes created here be added to a utility layer or the main scene
  50554. */
  50555. useUtilityLayer?: boolean;
  50556. /**
  50557. * Optional WebXR camera to be used for gaze selection
  50558. */
  50559. gazeCamera?: WebXRCamera;
  50560. /**
  50561. * the xr input to use with this pointer selection
  50562. */
  50563. xrInput: WebXRInput;
  50564. }
  50565. /**
  50566. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50567. */
  50568. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50569. private readonly _options;
  50570. private static _idCounter;
  50571. private _attachController;
  50572. private _controllers;
  50573. private _scene;
  50574. private _tmpVectorForPickCompare;
  50575. /**
  50576. * The module's name
  50577. */
  50578. static readonly Name: string;
  50579. /**
  50580. * The (Babylon) version of this module.
  50581. * This is an integer representing the implementation version.
  50582. * This number does not correspond to the WebXR specs version
  50583. */
  50584. static readonly Version: number;
  50585. /**
  50586. * Disable lighting on the laser pointer (so it will always be visible)
  50587. */
  50588. disablePointerLighting: boolean;
  50589. /**
  50590. * Disable lighting on the selection mesh (so it will always be visible)
  50591. */
  50592. disableSelectionMeshLighting: boolean;
  50593. /**
  50594. * Should the laser pointer be displayed
  50595. */
  50596. displayLaserPointer: boolean;
  50597. /**
  50598. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50599. */
  50600. displaySelectionMesh: boolean;
  50601. /**
  50602. * This color will be set to the laser pointer when selection is triggered
  50603. */
  50604. laserPointerPickedColor: Color3;
  50605. /**
  50606. * Default color of the laser pointer
  50607. */
  50608. laserPointerDefaultColor: Color3;
  50609. /**
  50610. * default color of the selection ring
  50611. */
  50612. selectionMeshDefaultColor: Color3;
  50613. /**
  50614. * This color will be applied to the selection ring when selection is triggered
  50615. */
  50616. selectionMeshPickedColor: Color3;
  50617. /**
  50618. * Optional filter to be used for ray selection. This predicate shares behavior with
  50619. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50620. */
  50621. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50622. /**
  50623. * constructs a new background remover module
  50624. * @param _xrSessionManager the session manager for this module
  50625. * @param _options read-only options to be used in this module
  50626. */
  50627. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50628. /**
  50629. * attach this feature
  50630. * Will usually be called by the features manager
  50631. *
  50632. * @returns true if successful.
  50633. */
  50634. attach(): boolean;
  50635. /**
  50636. * detach this feature.
  50637. * Will usually be called by the features manager
  50638. *
  50639. * @returns true if successful.
  50640. */
  50641. detach(): boolean;
  50642. /**
  50643. * Will get the mesh under a specific pointer.
  50644. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50645. * @param controllerId the controllerId to check
  50646. * @returns The mesh under pointer or null if no mesh is under the pointer
  50647. */
  50648. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50649. /**
  50650. * Get the xr controller that correlates to the pointer id in the pointer event
  50651. *
  50652. * @param id the pointer id to search for
  50653. * @returns the controller that correlates to this id or null if not found
  50654. */
  50655. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50656. protected _onXRFrame(_xrFrame: XRFrame): void;
  50657. private _attachGazeMode;
  50658. private _attachScreenRayMode;
  50659. private _attachTrackedPointerRayMode;
  50660. private _convertNormalToDirectionOfRay;
  50661. private _detachController;
  50662. private _generateNewMeshPair;
  50663. private _pickingMoved;
  50664. private _updatePointerDistance;
  50665. /** @hidden */
  50666. get lasterPointerDefaultColor(): Color3;
  50667. }
  50668. }
  50669. declare module "babylonjs/XR/webXREnterExitUI" {
  50670. import { Nullable } from "babylonjs/types";
  50671. import { Observable } from "babylonjs/Misc/observable";
  50672. import { IDisposable, Scene } from "babylonjs/scene";
  50673. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50674. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50675. /**
  50676. * Button which can be used to enter a different mode of XR
  50677. */
  50678. export class WebXREnterExitUIButton {
  50679. /** button element */
  50680. element: HTMLElement;
  50681. /** XR initialization options for the button */
  50682. sessionMode: XRSessionMode;
  50683. /** Reference space type */
  50684. referenceSpaceType: XRReferenceSpaceType;
  50685. /**
  50686. * Creates a WebXREnterExitUIButton
  50687. * @param element button element
  50688. * @param sessionMode XR initialization session mode
  50689. * @param referenceSpaceType the type of reference space to be used
  50690. */
  50691. constructor(
  50692. /** button element */
  50693. element: HTMLElement,
  50694. /** XR initialization options for the button */
  50695. sessionMode: XRSessionMode,
  50696. /** Reference space type */
  50697. referenceSpaceType: XRReferenceSpaceType);
  50698. /**
  50699. * Extendable function which can be used to update the button's visuals when the state changes
  50700. * @param activeButton the current active button in the UI
  50701. */
  50702. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50703. }
  50704. /**
  50705. * Options to create the webXR UI
  50706. */
  50707. export class WebXREnterExitUIOptions {
  50708. /**
  50709. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50710. */
  50711. customButtons?: Array<WebXREnterExitUIButton>;
  50712. /**
  50713. * A reference space type to use when creating the default button.
  50714. * Default is local-floor
  50715. */
  50716. referenceSpaceType?: XRReferenceSpaceType;
  50717. /**
  50718. * Context to enter xr with
  50719. */
  50720. renderTarget?: Nullable<WebXRRenderTarget>;
  50721. /**
  50722. * A session mode to use when creating the default button.
  50723. * Default is immersive-vr
  50724. */
  50725. sessionMode?: XRSessionMode;
  50726. /**
  50727. * A list of optional features to init the session with
  50728. */
  50729. optionalFeatures?: string[];
  50730. /**
  50731. * A list of optional features to init the session with
  50732. */
  50733. requiredFeatures?: string[];
  50734. }
  50735. /**
  50736. * UI to allow the user to enter/exit XR mode
  50737. */
  50738. export class WebXREnterExitUI implements IDisposable {
  50739. private scene;
  50740. /** version of the options passed to this UI */
  50741. options: WebXREnterExitUIOptions;
  50742. private _activeButton;
  50743. private _buttons;
  50744. private _overlay;
  50745. /**
  50746. * Fired every time the active button is changed.
  50747. *
  50748. * When xr is entered via a button that launches xr that button will be the callback parameter
  50749. *
  50750. * When exiting xr the callback parameter will be null)
  50751. */
  50752. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50753. /**
  50754. *
  50755. * @param scene babylon scene object to use
  50756. * @param options (read-only) version of the options passed to this UI
  50757. */
  50758. private constructor();
  50759. /**
  50760. * Creates UI to allow the user to enter/exit XR mode
  50761. * @param scene the scene to add the ui to
  50762. * @param helper the xr experience helper to enter/exit xr with
  50763. * @param options options to configure the UI
  50764. * @returns the created ui
  50765. */
  50766. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50767. /**
  50768. * Disposes of the XR UI component
  50769. */
  50770. dispose(): void;
  50771. private _updateButtons;
  50772. }
  50773. }
  50774. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50775. import { Vector3 } from "babylonjs/Maths/math.vector";
  50776. import { Color4 } from "babylonjs/Maths/math.color";
  50777. import { Nullable } from "babylonjs/types";
  50778. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50779. import { Scene } from "babylonjs/scene";
  50780. /**
  50781. * Class containing static functions to help procedurally build meshes
  50782. */
  50783. export class LinesBuilder {
  50784. /**
  50785. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50786. * * 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
  50787. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50788. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50789. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50790. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50791. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50792. * * 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
  50793. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50796. * @param name defines the name of the new line system
  50797. * @param options defines the options used to create the line system
  50798. * @param scene defines the hosting scene
  50799. * @returns a new line system mesh
  50800. */
  50801. static CreateLineSystem(name: string, options: {
  50802. lines: Vector3[][];
  50803. updatable?: boolean;
  50804. instance?: Nullable<LinesMesh>;
  50805. colors?: Nullable<Color4[][]>;
  50806. useVertexAlpha?: boolean;
  50807. }, scene: Nullable<Scene>): LinesMesh;
  50808. /**
  50809. * Creates a line mesh
  50810. * 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
  50811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50812. * * The parameter `points` is an array successive Vector3
  50813. * * 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
  50814. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50815. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50816. * * When updating an instance, remember that only point positions can change, not the number of points
  50817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50819. * @param name defines the name of the new line system
  50820. * @param options defines the options used to create the line system
  50821. * @param scene defines the hosting scene
  50822. * @returns a new line mesh
  50823. */
  50824. static CreateLines(name: string, options: {
  50825. points: Vector3[];
  50826. updatable?: boolean;
  50827. instance?: Nullable<LinesMesh>;
  50828. colors?: Color4[];
  50829. useVertexAlpha?: boolean;
  50830. }, scene?: Nullable<Scene>): LinesMesh;
  50831. /**
  50832. * Creates a dashed line mesh
  50833. * * 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
  50834. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50835. * * The parameter `points` is an array successive Vector3
  50836. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50837. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50838. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50839. * * 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
  50840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50841. * * When updating an instance, remember that only point positions can change, not the number of points
  50842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50843. * @param name defines the name of the mesh
  50844. * @param options defines the options used to create the mesh
  50845. * @param scene defines the hosting scene
  50846. * @returns the dashed line mesh
  50847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50848. */
  50849. static CreateDashedLines(name: string, options: {
  50850. points: Vector3[];
  50851. dashSize?: number;
  50852. gapSize?: number;
  50853. dashNb?: number;
  50854. updatable?: boolean;
  50855. instance?: LinesMesh;
  50856. useVertexAlpha?: boolean;
  50857. }, scene?: Nullable<Scene>): LinesMesh;
  50858. }
  50859. }
  50860. declare module "babylonjs/Misc/timer" {
  50861. import { Observable, Observer } from "babylonjs/Misc/observable";
  50862. import { Nullable } from "babylonjs/types";
  50863. import { IDisposable } from "babylonjs/scene";
  50864. /**
  50865. * Construction options for a timer
  50866. */
  50867. export interface ITimerOptions<T> {
  50868. /**
  50869. * Time-to-end
  50870. */
  50871. timeout: number;
  50872. /**
  50873. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50874. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50875. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50876. */
  50877. contextObservable: Observable<T>;
  50878. /**
  50879. * Optional parameters when adding an observer to the observable
  50880. */
  50881. observableParameters?: {
  50882. mask?: number;
  50883. insertFirst?: boolean;
  50884. scope?: any;
  50885. };
  50886. /**
  50887. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50888. */
  50889. breakCondition?: (data?: ITimerData<T>) => boolean;
  50890. /**
  50891. * Will be triggered when the time condition has met
  50892. */
  50893. onEnded?: (data: ITimerData<any>) => void;
  50894. /**
  50895. * Will be triggered when the break condition has met (prematurely ended)
  50896. */
  50897. onAborted?: (data: ITimerData<any>) => void;
  50898. /**
  50899. * Optional function to execute on each tick (or count)
  50900. */
  50901. onTick?: (data: ITimerData<any>) => void;
  50902. }
  50903. /**
  50904. * An interface defining the data sent by the timer
  50905. */
  50906. export interface ITimerData<T> {
  50907. /**
  50908. * When did it start
  50909. */
  50910. startTime: number;
  50911. /**
  50912. * Time now
  50913. */
  50914. currentTime: number;
  50915. /**
  50916. * Time passed since started
  50917. */
  50918. deltaTime: number;
  50919. /**
  50920. * How much is completed, in [0.0...1.0].
  50921. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50922. */
  50923. completeRate: number;
  50924. /**
  50925. * What the registered observable sent in the last count
  50926. */
  50927. payload: T;
  50928. }
  50929. /**
  50930. * The current state of the timer
  50931. */
  50932. export enum TimerState {
  50933. /**
  50934. * Timer initialized, not yet started
  50935. */
  50936. INIT = 0,
  50937. /**
  50938. * Timer started and counting
  50939. */
  50940. STARTED = 1,
  50941. /**
  50942. * Timer ended (whether aborted or time reached)
  50943. */
  50944. ENDED = 2
  50945. }
  50946. /**
  50947. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50948. *
  50949. * @param options options with which to initialize this timer
  50950. */
  50951. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50952. /**
  50953. * An advanced implementation of a timer class
  50954. */
  50955. export class AdvancedTimer<T = any> implements IDisposable {
  50956. /**
  50957. * Will notify each time the timer calculates the remaining time
  50958. */
  50959. onEachCountObservable: Observable<ITimerData<T>>;
  50960. /**
  50961. * Will trigger when the timer was aborted due to the break condition
  50962. */
  50963. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50964. /**
  50965. * Will trigger when the timer ended successfully
  50966. */
  50967. onTimerEndedObservable: Observable<ITimerData<T>>;
  50968. /**
  50969. * Will trigger when the timer state has changed
  50970. */
  50971. onStateChangedObservable: Observable<TimerState>;
  50972. private _observer;
  50973. private _contextObservable;
  50974. private _observableParameters;
  50975. private _startTime;
  50976. private _timer;
  50977. private _state;
  50978. private _breakCondition;
  50979. private _timeToEnd;
  50980. private _breakOnNextTick;
  50981. /**
  50982. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50983. * @param options construction options for this advanced timer
  50984. */
  50985. constructor(options: ITimerOptions<T>);
  50986. /**
  50987. * set a breaking condition for this timer. Default is to never break during count
  50988. * @param predicate the new break condition. Returns true to break, false otherwise
  50989. */
  50990. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50991. /**
  50992. * Reset ALL associated observables in this advanced timer
  50993. */
  50994. clearObservables(): void;
  50995. /**
  50996. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50997. *
  50998. * @param timeToEnd how much time to measure until timer ended
  50999. */
  51000. start(timeToEnd?: number): void;
  51001. /**
  51002. * Will force a stop on the next tick.
  51003. */
  51004. stop(): void;
  51005. /**
  51006. * Dispose this timer, clearing all resources
  51007. */
  51008. dispose(): void;
  51009. private _setState;
  51010. private _tick;
  51011. private _stop;
  51012. }
  51013. }
  51014. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51015. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51016. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51017. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51019. import { Vector3 } from "babylonjs/Maths/math.vector";
  51020. import { Material } from "babylonjs/Materials/material";
  51021. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51022. import { Scene } from "babylonjs/scene";
  51023. /**
  51024. * The options container for the teleportation module
  51025. */
  51026. export interface IWebXRTeleportationOptions {
  51027. /**
  51028. * if provided, this scene will be used to render meshes.
  51029. */
  51030. customUtilityLayerScene?: Scene;
  51031. /**
  51032. * Values to configure the default target mesh
  51033. */
  51034. defaultTargetMeshOptions?: {
  51035. /**
  51036. * Fill color of the teleportation area
  51037. */
  51038. teleportationFillColor?: string;
  51039. /**
  51040. * Border color for the teleportation area
  51041. */
  51042. teleportationBorderColor?: string;
  51043. /**
  51044. * Disable the mesh's animation sequence
  51045. */
  51046. disableAnimation?: boolean;
  51047. /**
  51048. * Disable lighting on the material or the ring and arrow
  51049. */
  51050. disableLighting?: boolean;
  51051. /**
  51052. * Override the default material of the torus and arrow
  51053. */
  51054. torusArrowMaterial?: Material;
  51055. };
  51056. /**
  51057. * A list of meshes to use as floor meshes.
  51058. * Meshes can be added and removed after initializing the feature using the
  51059. * addFloorMesh and removeFloorMesh functions
  51060. * If empty, rotation will still work
  51061. */
  51062. floorMeshes?: AbstractMesh[];
  51063. /**
  51064. * use this rendering group id for the meshes (optional)
  51065. */
  51066. renderingGroupId?: number;
  51067. /**
  51068. * Should teleportation move only to snap points
  51069. */
  51070. snapPointsOnly?: boolean;
  51071. /**
  51072. * An array of points to which the teleportation will snap to.
  51073. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51074. */
  51075. snapPositions?: Vector3[];
  51076. /**
  51077. * How close should the teleportation ray be in order to snap to position.
  51078. * Default to 0.8 units (meters)
  51079. */
  51080. snapToPositionRadius?: number;
  51081. /**
  51082. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51083. * If you want to support rotation, make sure your mesh has a direction indicator.
  51084. *
  51085. * When left untouched, the default mesh will be initialized.
  51086. */
  51087. teleportationTargetMesh?: AbstractMesh;
  51088. /**
  51089. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51090. */
  51091. timeToTeleport?: number;
  51092. /**
  51093. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51094. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51095. */
  51096. useMainComponentOnly?: boolean;
  51097. /**
  51098. * Should meshes created here be added to a utility layer or the main scene
  51099. */
  51100. useUtilityLayer?: boolean;
  51101. /**
  51102. * Babylon XR Input class for controller
  51103. */
  51104. xrInput: WebXRInput;
  51105. }
  51106. /**
  51107. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51108. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51109. * the input of the attached controllers.
  51110. */
  51111. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51112. private _options;
  51113. private _controllers;
  51114. private _currentTeleportationControllerId;
  51115. private _floorMeshes;
  51116. private _quadraticBezierCurve;
  51117. private _selectionFeature;
  51118. private _snapToPositions;
  51119. private _snappedToPoint;
  51120. private _teleportationRingMaterial?;
  51121. private _tmpRay;
  51122. private _tmpVector;
  51123. /**
  51124. * The module's name
  51125. */
  51126. static readonly Name: string;
  51127. /**
  51128. * The (Babylon) version of this module.
  51129. * This is an integer representing the implementation version.
  51130. * This number does not correspond to the webxr specs version
  51131. */
  51132. static readonly Version: number;
  51133. /**
  51134. * Is movement backwards enabled
  51135. */
  51136. backwardsMovementEnabled: boolean;
  51137. /**
  51138. * Distance to travel when moving backwards
  51139. */
  51140. backwardsTeleportationDistance: number;
  51141. /**
  51142. * The distance from the user to the inspection point in the direction of the controller
  51143. * A higher number will allow the user to move further
  51144. * defaults to 5 (meters, in xr units)
  51145. */
  51146. parabolicCheckRadius: number;
  51147. /**
  51148. * Should the module support parabolic ray on top of direct ray
  51149. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51150. * Very helpful when moving between floors / different heights
  51151. */
  51152. parabolicRayEnabled: boolean;
  51153. /**
  51154. * How much rotation should be applied when rotating right and left
  51155. */
  51156. rotationAngle: number;
  51157. /**
  51158. * Is rotation enabled when moving forward?
  51159. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51160. */
  51161. rotationEnabled: boolean;
  51162. /**
  51163. * constructs a new anchor system
  51164. * @param _xrSessionManager an instance of WebXRSessionManager
  51165. * @param _options configuration object for this feature
  51166. */
  51167. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51168. /**
  51169. * Get the snapPointsOnly flag
  51170. */
  51171. get snapPointsOnly(): boolean;
  51172. /**
  51173. * Sets the snapPointsOnly flag
  51174. * @param snapToPoints should teleportation be exclusively to snap points
  51175. */
  51176. set snapPointsOnly(snapToPoints: boolean);
  51177. /**
  51178. * Add a new mesh to the floor meshes array
  51179. * @param mesh the mesh to use as floor mesh
  51180. */
  51181. addFloorMesh(mesh: AbstractMesh): void;
  51182. /**
  51183. * Add a new snap-to point to fix teleportation to this position
  51184. * @param newSnapPoint The new Snap-To point
  51185. */
  51186. addSnapPoint(newSnapPoint: Vector3): void;
  51187. attach(): boolean;
  51188. detach(): boolean;
  51189. dispose(): void;
  51190. /**
  51191. * Remove a mesh from the floor meshes array
  51192. * @param mesh the mesh to remove
  51193. */
  51194. removeFloorMesh(mesh: AbstractMesh): void;
  51195. /**
  51196. * Remove a mesh from the floor meshes array using its name
  51197. * @param name the mesh name to remove
  51198. */
  51199. removeFloorMeshByName(name: string): void;
  51200. /**
  51201. * 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
  51202. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51203. * @returns was the point found and removed or not
  51204. */
  51205. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51206. /**
  51207. * This function sets a selection feature that will be disabled when
  51208. * the forward ray is shown and will be reattached when hidden.
  51209. * This is used to remove the selection rays when moving.
  51210. * @param selectionFeature the feature to disable when forward movement is enabled
  51211. */
  51212. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51213. protected _onXRFrame(_xrFrame: XRFrame): void;
  51214. private _attachController;
  51215. private _createDefaultTargetMesh;
  51216. private _detachController;
  51217. private _findClosestSnapPointWithRadius;
  51218. private _setTargetMeshPosition;
  51219. private _setTargetMeshVisibility;
  51220. private _showParabolicPath;
  51221. private _teleportForward;
  51222. }
  51223. }
  51224. declare module "babylonjs/XR/webXRDefaultExperience" {
  51225. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51226. import { Scene } from "babylonjs/scene";
  51227. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51228. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51229. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51230. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51232. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51233. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51234. /**
  51235. * Options for the default xr helper
  51236. */
  51237. export class WebXRDefaultExperienceOptions {
  51238. /**
  51239. * Enable or disable default UI to enter XR
  51240. */
  51241. disableDefaultUI?: boolean;
  51242. /**
  51243. * Should teleportation not initialize. defaults to false.
  51244. */
  51245. disableTeleportation?: boolean;
  51246. /**
  51247. * Floor meshes that will be used for teleport
  51248. */
  51249. floorMeshes?: Array<AbstractMesh>;
  51250. /**
  51251. * If set to true, the first frame will not be used to reset position
  51252. * The first frame is mainly used when copying transformation from the old camera
  51253. * Mainly used in AR
  51254. */
  51255. ignoreNativeCameraTransformation?: boolean;
  51256. /**
  51257. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51258. */
  51259. inputOptions?: IWebXRInputOptions;
  51260. /**
  51261. * optional configuration for the output canvas
  51262. */
  51263. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51264. /**
  51265. * optional UI options. This can be used among other to change session mode and reference space type
  51266. */
  51267. uiOptions?: WebXREnterExitUIOptions;
  51268. /**
  51269. * When loading teleportation and pointer select, use stable versions instead of latest.
  51270. */
  51271. useStablePlugins?: boolean;
  51272. /**
  51273. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51274. */
  51275. renderingGroupId?: number;
  51276. /**
  51277. * A list of optional features to init the session with
  51278. * If set to true, all features we support will be added
  51279. */
  51280. optionalFeatures?: boolean | string[];
  51281. }
  51282. /**
  51283. * Default experience which provides a similar setup to the previous webVRExperience
  51284. */
  51285. export class WebXRDefaultExperience {
  51286. /**
  51287. * Base experience
  51288. */
  51289. baseExperience: WebXRExperienceHelper;
  51290. /**
  51291. * Enables ui for entering/exiting xr
  51292. */
  51293. enterExitUI: WebXREnterExitUI;
  51294. /**
  51295. * Input experience extension
  51296. */
  51297. input: WebXRInput;
  51298. /**
  51299. * Enables laser pointer and selection
  51300. */
  51301. pointerSelection: WebXRControllerPointerSelection;
  51302. /**
  51303. * Default target xr should render to
  51304. */
  51305. renderTarget: WebXRRenderTarget;
  51306. /**
  51307. * Enables teleportation
  51308. */
  51309. teleportation: WebXRMotionControllerTeleportation;
  51310. private constructor();
  51311. /**
  51312. * Creates the default xr experience
  51313. * @param scene scene
  51314. * @param options options for basic configuration
  51315. * @returns resulting WebXRDefaultExperience
  51316. */
  51317. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51318. /**
  51319. * DIsposes of the experience helper
  51320. */
  51321. dispose(): void;
  51322. }
  51323. }
  51324. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51325. import { Observable } from "babylonjs/Misc/observable";
  51326. import { Nullable } from "babylonjs/types";
  51327. import { Camera } from "babylonjs/Cameras/camera";
  51328. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51329. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51330. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51331. import { Scene } from "babylonjs/scene";
  51332. import { Vector3 } from "babylonjs/Maths/math.vector";
  51333. import { Color3 } from "babylonjs/Maths/math.color";
  51334. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51336. import { Mesh } from "babylonjs/Meshes/mesh";
  51337. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51338. import { EasingFunction } from "babylonjs/Animations/easing";
  51339. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51340. import "babylonjs/Meshes/Builders/groundBuilder";
  51341. import "babylonjs/Meshes/Builders/torusBuilder";
  51342. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51343. import "babylonjs/Gamepads/gamepadSceneComponent";
  51344. import "babylonjs/Animations/animatable";
  51345. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51346. /**
  51347. * Options to modify the vr teleportation behavior.
  51348. */
  51349. export interface VRTeleportationOptions {
  51350. /**
  51351. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51352. */
  51353. floorMeshName?: string;
  51354. /**
  51355. * A list of meshes to be used as the teleportation floor. (default: empty)
  51356. */
  51357. floorMeshes?: Mesh[];
  51358. /**
  51359. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51360. */
  51361. teleportationMode?: number;
  51362. /**
  51363. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51364. */
  51365. teleportationTime?: number;
  51366. /**
  51367. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51368. */
  51369. teleportationSpeed?: number;
  51370. /**
  51371. * The easing function used in the animation or null for Linear. (default CircleEase)
  51372. */
  51373. easingFunction?: EasingFunction;
  51374. }
  51375. /**
  51376. * Options to modify the vr experience helper's behavior.
  51377. */
  51378. export interface VRExperienceHelperOptions extends WebVROptions {
  51379. /**
  51380. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51381. */
  51382. createDeviceOrientationCamera?: boolean;
  51383. /**
  51384. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51385. */
  51386. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51387. /**
  51388. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51389. */
  51390. laserToggle?: boolean;
  51391. /**
  51392. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51393. */
  51394. floorMeshes?: Mesh[];
  51395. /**
  51396. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51397. */
  51398. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51399. /**
  51400. * Defines if WebXR should be used instead of WebVR (if available)
  51401. */
  51402. useXR?: boolean;
  51403. }
  51404. /**
  51405. * Event containing information after VR has been entered
  51406. */
  51407. export class OnAfterEnteringVRObservableEvent {
  51408. /**
  51409. * If entering vr was successful
  51410. */
  51411. success: boolean;
  51412. }
  51413. /**
  51414. * Helps to quickly add VR support to an existing scene.
  51415. * See https://doc.babylonjs.com/how_to/webvr_helper
  51416. */
  51417. export class VRExperienceHelper {
  51418. /** Options to modify the vr experience helper's behavior. */
  51419. webVROptions: VRExperienceHelperOptions;
  51420. private _scene;
  51421. private _position;
  51422. private _btnVR;
  51423. private _btnVRDisplayed;
  51424. private _webVRsupported;
  51425. private _webVRready;
  51426. private _webVRrequesting;
  51427. private _webVRpresenting;
  51428. private _hasEnteredVR;
  51429. private _fullscreenVRpresenting;
  51430. private _inputElement;
  51431. private _webVRCamera;
  51432. private _vrDeviceOrientationCamera;
  51433. private _deviceOrientationCamera;
  51434. private _existingCamera;
  51435. private _onKeyDown;
  51436. private _onVrDisplayPresentChange;
  51437. private _onVRDisplayChanged;
  51438. private _onVRRequestPresentStart;
  51439. private _onVRRequestPresentComplete;
  51440. /**
  51441. * 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)
  51442. */
  51443. enableGazeEvenWhenNoPointerLock: boolean;
  51444. /**
  51445. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51446. */
  51447. exitVROnDoubleTap: boolean;
  51448. /**
  51449. * Observable raised right before entering VR.
  51450. */
  51451. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51452. /**
  51453. * Observable raised when entering VR has completed.
  51454. */
  51455. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51456. /**
  51457. * Observable raised when exiting VR.
  51458. */
  51459. onExitingVRObservable: Observable<VRExperienceHelper>;
  51460. /**
  51461. * Observable raised when controller mesh is loaded.
  51462. */
  51463. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51464. /** Return this.onEnteringVRObservable
  51465. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51466. */
  51467. get onEnteringVR(): Observable<VRExperienceHelper>;
  51468. /** Return this.onExitingVRObservable
  51469. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51470. */
  51471. get onExitingVR(): Observable<VRExperienceHelper>;
  51472. /** Return this.onControllerMeshLoadedObservable
  51473. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51474. */
  51475. get onControllerMeshLoaded(): Observable<WebVRController>;
  51476. private _rayLength;
  51477. private _useCustomVRButton;
  51478. private _teleportationRequested;
  51479. private _teleportActive;
  51480. private _floorMeshName;
  51481. private _floorMeshesCollection;
  51482. private _teleportationMode;
  51483. private _teleportationTime;
  51484. private _teleportationSpeed;
  51485. private _teleportationEasing;
  51486. private _rotationAllowed;
  51487. private _teleportBackwardsVector;
  51488. private _teleportationTarget;
  51489. private _isDefaultTeleportationTarget;
  51490. private _postProcessMove;
  51491. private _teleportationFillColor;
  51492. private _teleportationBorderColor;
  51493. private _rotationAngle;
  51494. private _haloCenter;
  51495. private _cameraGazer;
  51496. private _padSensibilityUp;
  51497. private _padSensibilityDown;
  51498. private _leftController;
  51499. private _rightController;
  51500. private _gazeColor;
  51501. private _laserColor;
  51502. private _pickedLaserColor;
  51503. private _pickedGazeColor;
  51504. /**
  51505. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51506. */
  51507. onNewMeshSelected: Observable<AbstractMesh>;
  51508. /**
  51509. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51510. * This observable will provide the mesh and the controller used to select the mesh
  51511. */
  51512. onMeshSelectedWithController: Observable<{
  51513. mesh: AbstractMesh;
  51514. controller: WebVRController;
  51515. }>;
  51516. /**
  51517. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51518. */
  51519. onNewMeshPicked: Observable<PickingInfo>;
  51520. private _circleEase;
  51521. /**
  51522. * Observable raised before camera teleportation
  51523. */
  51524. onBeforeCameraTeleport: Observable<Vector3>;
  51525. /**
  51526. * Observable raised after camera teleportation
  51527. */
  51528. onAfterCameraTeleport: Observable<Vector3>;
  51529. /**
  51530. * Observable raised when current selected mesh gets unselected
  51531. */
  51532. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51533. private _raySelectionPredicate;
  51534. /**
  51535. * To be optionaly changed by user to define custom ray selection
  51536. */
  51537. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51538. /**
  51539. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51540. */
  51541. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51542. /**
  51543. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51544. */
  51545. teleportationEnabled: boolean;
  51546. private _defaultHeight;
  51547. private _teleportationInitialized;
  51548. private _interactionsEnabled;
  51549. private _interactionsRequested;
  51550. private _displayGaze;
  51551. private _displayLaserPointer;
  51552. /**
  51553. * The mesh used to display where the user is going to teleport.
  51554. */
  51555. get teleportationTarget(): Mesh;
  51556. /**
  51557. * Sets the mesh to be used to display where the user is going to teleport.
  51558. */
  51559. set teleportationTarget(value: Mesh);
  51560. /**
  51561. * 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
  51562. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51563. * See https://doc.babylonjs.com/resources/baking_transformations
  51564. */
  51565. get gazeTrackerMesh(): Mesh;
  51566. set gazeTrackerMesh(value: Mesh);
  51567. /**
  51568. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51569. */
  51570. updateGazeTrackerScale: boolean;
  51571. /**
  51572. * If the gaze trackers color should be updated when selecting meshes
  51573. */
  51574. updateGazeTrackerColor: boolean;
  51575. /**
  51576. * If the controller laser color should be updated when selecting meshes
  51577. */
  51578. updateControllerLaserColor: boolean;
  51579. /**
  51580. * The gaze tracking mesh corresponding to the left controller
  51581. */
  51582. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51583. /**
  51584. * The gaze tracking mesh corresponding to the right controller
  51585. */
  51586. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51587. /**
  51588. * If the ray of the gaze should be displayed.
  51589. */
  51590. get displayGaze(): boolean;
  51591. /**
  51592. * Sets if the ray of the gaze should be displayed.
  51593. */
  51594. set displayGaze(value: boolean);
  51595. /**
  51596. * If the ray of the LaserPointer should be displayed.
  51597. */
  51598. get displayLaserPointer(): boolean;
  51599. /**
  51600. * Sets if the ray of the LaserPointer should be displayed.
  51601. */
  51602. set displayLaserPointer(value: boolean);
  51603. /**
  51604. * The deviceOrientationCamera used as the camera when not in VR.
  51605. */
  51606. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51607. /**
  51608. * Based on the current WebVR support, returns the current VR camera used.
  51609. */
  51610. get currentVRCamera(): Nullable<Camera>;
  51611. /**
  51612. * The webVRCamera which is used when in VR.
  51613. */
  51614. get webVRCamera(): WebVRFreeCamera;
  51615. /**
  51616. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51617. */
  51618. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51619. /**
  51620. * The html button that is used to trigger entering into VR.
  51621. */
  51622. get vrButton(): Nullable<HTMLButtonElement>;
  51623. private get _teleportationRequestInitiated();
  51624. /**
  51625. * Defines whether or not Pointer lock should be requested when switching to
  51626. * full screen.
  51627. */
  51628. requestPointerLockOnFullScreen: boolean;
  51629. /**
  51630. * If asking to force XR, this will be populated with the default xr experience
  51631. */
  51632. xr: WebXRDefaultExperience;
  51633. /**
  51634. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51635. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51636. */
  51637. xrTestDone: boolean;
  51638. /**
  51639. * Instantiates a VRExperienceHelper.
  51640. * Helps to quickly add VR support to an existing scene.
  51641. * @param scene The scene the VRExperienceHelper belongs to.
  51642. * @param webVROptions Options to modify the vr experience helper's behavior.
  51643. */
  51644. constructor(scene: Scene,
  51645. /** Options to modify the vr experience helper's behavior. */
  51646. webVROptions?: VRExperienceHelperOptions);
  51647. private completeVRInit;
  51648. private _onDefaultMeshLoaded;
  51649. private _onResize;
  51650. private _onFullscreenChange;
  51651. /**
  51652. * Gets a value indicating if we are currently in VR mode.
  51653. */
  51654. get isInVRMode(): boolean;
  51655. private onVrDisplayPresentChange;
  51656. private onVRDisplayChanged;
  51657. private moveButtonToBottomRight;
  51658. private displayVRButton;
  51659. private updateButtonVisibility;
  51660. private _cachedAngularSensibility;
  51661. /**
  51662. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51663. * Otherwise, will use the fullscreen API.
  51664. */
  51665. enterVR(): void;
  51666. /**
  51667. * Attempt to exit VR, or fullscreen.
  51668. */
  51669. exitVR(): void;
  51670. /**
  51671. * The position of the vr experience helper.
  51672. */
  51673. get position(): Vector3;
  51674. /**
  51675. * Sets the position of the vr experience helper.
  51676. */
  51677. set position(value: Vector3);
  51678. /**
  51679. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51680. */
  51681. enableInteractions(): void;
  51682. private get _noControllerIsActive();
  51683. private beforeRender;
  51684. private _isTeleportationFloor;
  51685. /**
  51686. * Adds a floor mesh to be used for teleportation.
  51687. * @param floorMesh the mesh to be used for teleportation.
  51688. */
  51689. addFloorMesh(floorMesh: Mesh): void;
  51690. /**
  51691. * Removes a floor mesh from being used for teleportation.
  51692. * @param floorMesh the mesh to be removed.
  51693. */
  51694. removeFloorMesh(floorMesh: Mesh): void;
  51695. /**
  51696. * Enables interactions and teleportation using the VR controllers and gaze.
  51697. * @param vrTeleportationOptions options to modify teleportation behavior.
  51698. */
  51699. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51700. private _onNewGamepadConnected;
  51701. private _tryEnableInteractionOnController;
  51702. private _onNewGamepadDisconnected;
  51703. private _enableInteractionOnController;
  51704. private _checkTeleportWithRay;
  51705. private _checkRotate;
  51706. private _checkTeleportBackwards;
  51707. private _enableTeleportationOnController;
  51708. private _createTeleportationCircles;
  51709. private _displayTeleportationTarget;
  51710. private _hideTeleportationTarget;
  51711. private _rotateCamera;
  51712. private _moveTeleportationSelectorTo;
  51713. private _workingVector;
  51714. private _workingQuaternion;
  51715. private _workingMatrix;
  51716. /**
  51717. * Time Constant Teleportation Mode
  51718. */
  51719. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51720. /**
  51721. * Speed Constant Teleportation Mode
  51722. */
  51723. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51724. /**
  51725. * Teleports the users feet to the desired location
  51726. * @param location The location where the user's feet should be placed
  51727. */
  51728. teleportCamera(location: Vector3): void;
  51729. private _convertNormalToDirectionOfRay;
  51730. private _castRayAndSelectObject;
  51731. private _notifySelectedMeshUnselected;
  51732. /**
  51733. * Permanently set new colors for the laser pointer
  51734. * @param color the new laser color
  51735. * @param pickedColor the new laser color when picked mesh detected
  51736. */
  51737. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51738. /**
  51739. * Set lighting enabled / disabled on the laser pointer of both controllers
  51740. * @param enabled should the lighting be enabled on the laser pointer
  51741. */
  51742. setLaserLightingState(enabled?: boolean): void;
  51743. /**
  51744. * Permanently set new colors for the gaze pointer
  51745. * @param color the new gaze color
  51746. * @param pickedColor the new gaze color when picked mesh detected
  51747. */
  51748. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51749. /**
  51750. * Sets the color of the laser ray from the vr controllers.
  51751. * @param color new color for the ray.
  51752. */
  51753. changeLaserColor(color: Color3): void;
  51754. /**
  51755. * Sets the color of the ray from the vr headsets gaze.
  51756. * @param color new color for the ray.
  51757. */
  51758. changeGazeColor(color: Color3): void;
  51759. /**
  51760. * Exits VR and disposes of the vr experience helper
  51761. */
  51762. dispose(): void;
  51763. /**
  51764. * Gets the name of the VRExperienceHelper class
  51765. * @returns "VRExperienceHelper"
  51766. */
  51767. getClassName(): string;
  51768. }
  51769. }
  51770. declare module "babylonjs/Cameras/VR/index" {
  51771. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51772. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51773. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51774. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51775. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51776. export * from "babylonjs/Cameras/VR/webVRCamera";
  51777. }
  51778. declare module "babylonjs/Cameras/RigModes/index" {
  51779. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51780. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51781. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51782. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51783. }
  51784. declare module "babylonjs/Cameras/index" {
  51785. export * from "babylonjs/Cameras/Inputs/index";
  51786. export * from "babylonjs/Cameras/cameraInputsManager";
  51787. export * from "babylonjs/Cameras/camera";
  51788. export * from "babylonjs/Cameras/targetCamera";
  51789. export * from "babylonjs/Cameras/freeCamera";
  51790. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51791. export * from "babylonjs/Cameras/touchCamera";
  51792. export * from "babylonjs/Cameras/arcRotateCamera";
  51793. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51794. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51795. export * from "babylonjs/Cameras/flyCamera";
  51796. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51797. export * from "babylonjs/Cameras/followCamera";
  51798. export * from "babylonjs/Cameras/followCameraInputsManager";
  51799. export * from "babylonjs/Cameras/gamepadCamera";
  51800. export * from "babylonjs/Cameras/Stereoscopic/index";
  51801. export * from "babylonjs/Cameras/universalCamera";
  51802. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51803. export * from "babylonjs/Cameras/VR/index";
  51804. export * from "babylonjs/Cameras/RigModes/index";
  51805. }
  51806. declare module "babylonjs/Collisions/index" {
  51807. export * from "babylonjs/Collisions/collider";
  51808. export * from "babylonjs/Collisions/collisionCoordinator";
  51809. export * from "babylonjs/Collisions/pickingInfo";
  51810. export * from "babylonjs/Collisions/intersectionInfo";
  51811. export * from "babylonjs/Collisions/meshCollisionData";
  51812. }
  51813. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51814. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51815. import { Vector3 } from "babylonjs/Maths/math.vector";
  51816. import { Ray } from "babylonjs/Culling/ray";
  51817. import { Plane } from "babylonjs/Maths/math.plane";
  51818. /**
  51819. * Contains an array of blocks representing the octree
  51820. */
  51821. export interface IOctreeContainer<T> {
  51822. /**
  51823. * Blocks within the octree
  51824. */
  51825. blocks: Array<OctreeBlock<T>>;
  51826. }
  51827. /**
  51828. * Class used to store a cell in an octree
  51829. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51830. */
  51831. export class OctreeBlock<T> {
  51832. /**
  51833. * Gets the content of the current block
  51834. */
  51835. entries: T[];
  51836. /**
  51837. * Gets the list of block children
  51838. */
  51839. blocks: Array<OctreeBlock<T>>;
  51840. private _depth;
  51841. private _maxDepth;
  51842. private _capacity;
  51843. private _minPoint;
  51844. private _maxPoint;
  51845. private _boundingVectors;
  51846. private _creationFunc;
  51847. /**
  51848. * Creates a new block
  51849. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51850. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51851. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51852. * @param depth defines the current depth of this block in the octree
  51853. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51854. * @param creationFunc defines a callback to call when an element is added to the block
  51855. */
  51856. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51857. /**
  51858. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51859. */
  51860. get capacity(): number;
  51861. /**
  51862. * Gets the minimum vector (in world space) of the block's bounding box
  51863. */
  51864. get minPoint(): Vector3;
  51865. /**
  51866. * Gets the maximum vector (in world space) of the block's bounding box
  51867. */
  51868. get maxPoint(): Vector3;
  51869. /**
  51870. * Add a new element to this block
  51871. * @param entry defines the element to add
  51872. */
  51873. addEntry(entry: T): void;
  51874. /**
  51875. * Remove an element from this block
  51876. * @param entry defines the element to remove
  51877. */
  51878. removeEntry(entry: T): void;
  51879. /**
  51880. * Add an array of elements to this block
  51881. * @param entries defines the array of elements to add
  51882. */
  51883. addEntries(entries: T[]): void;
  51884. /**
  51885. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51886. * @param frustumPlanes defines the frustum planes to test
  51887. * @param selection defines the array to store current content if selection is positive
  51888. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51889. */
  51890. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51891. /**
  51892. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51893. * @param sphereCenter defines the bounding sphere center
  51894. * @param sphereRadius defines the bounding sphere radius
  51895. * @param selection defines the array to store current content if selection is positive
  51896. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51897. */
  51898. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51899. /**
  51900. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51901. * @param ray defines the ray to test with
  51902. * @param selection defines the array to store current content if selection is positive
  51903. */
  51904. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51905. /**
  51906. * Subdivide the content into child blocks (this block will then be empty)
  51907. */
  51908. createInnerBlocks(): void;
  51909. /**
  51910. * @hidden
  51911. */
  51912. 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;
  51913. }
  51914. }
  51915. declare module "babylonjs/Culling/Octrees/octree" {
  51916. import { SmartArray } from "babylonjs/Misc/smartArray";
  51917. import { Vector3 } from "babylonjs/Maths/math.vector";
  51918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51920. import { Ray } from "babylonjs/Culling/ray";
  51921. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51922. import { Plane } from "babylonjs/Maths/math.plane";
  51923. /**
  51924. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51925. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51926. */
  51927. export class Octree<T> {
  51928. /** 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.) */
  51929. maxDepth: number;
  51930. /**
  51931. * Blocks within the octree containing objects
  51932. */
  51933. blocks: Array<OctreeBlock<T>>;
  51934. /**
  51935. * Content stored in the octree
  51936. */
  51937. dynamicContent: T[];
  51938. private _maxBlockCapacity;
  51939. private _selectionContent;
  51940. private _creationFunc;
  51941. /**
  51942. * Creates a octree
  51943. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51944. * @param creationFunc function to be used to instatiate the octree
  51945. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51946. * @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.)
  51947. */
  51948. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51949. /** 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.) */
  51950. maxDepth?: number);
  51951. /**
  51952. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51953. * @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);
  51954. * @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);
  51955. * @param entries meshes to be added to the octree blocks
  51956. */
  51957. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51958. /**
  51959. * Adds a mesh to the octree
  51960. * @param entry Mesh to add to the octree
  51961. */
  51962. addMesh(entry: T): void;
  51963. /**
  51964. * Remove an element from the octree
  51965. * @param entry defines the element to remove
  51966. */
  51967. removeMesh(entry: T): void;
  51968. /**
  51969. * Selects an array of meshes within the frustum
  51970. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51971. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51972. * @returns array of meshes within the frustum
  51973. */
  51974. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51975. /**
  51976. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51977. * @param sphereCenter defines the bounding sphere center
  51978. * @param sphereRadius defines the bounding sphere radius
  51979. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51980. * @returns an array of objects that intersect the sphere
  51981. */
  51982. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51983. /**
  51984. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51985. * @param ray defines the ray to test with
  51986. * @returns array of intersected objects
  51987. */
  51988. intersectsRay(ray: Ray): SmartArray<T>;
  51989. /**
  51990. * Adds a mesh into the octree block if it intersects the block
  51991. */
  51992. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51993. /**
  51994. * Adds a submesh into the octree block if it intersects the block
  51995. */
  51996. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51997. }
  51998. }
  51999. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52000. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52001. import { Scene } from "babylonjs/scene";
  52002. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52004. import { Ray } from "babylonjs/Culling/ray";
  52005. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52006. import { Collider } from "babylonjs/Collisions/collider";
  52007. module "babylonjs/scene" {
  52008. interface Scene {
  52009. /**
  52010. * @hidden
  52011. * Backing Filed
  52012. */
  52013. _selectionOctree: Octree<AbstractMesh>;
  52014. /**
  52015. * Gets the octree used to boost mesh selection (picking)
  52016. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52017. */
  52018. selectionOctree: Octree<AbstractMesh>;
  52019. /**
  52020. * Creates or updates the octree used to boost selection (picking)
  52021. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52022. * @param maxCapacity defines the maximum capacity per leaf
  52023. * @param maxDepth defines the maximum depth of the octree
  52024. * @returns an octree of AbstractMesh
  52025. */
  52026. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52027. }
  52028. }
  52029. module "babylonjs/Meshes/abstractMesh" {
  52030. interface AbstractMesh {
  52031. /**
  52032. * @hidden
  52033. * Backing Field
  52034. */
  52035. _submeshesOctree: Octree<SubMesh>;
  52036. /**
  52037. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52038. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52039. * @param maxCapacity defines the maximum size of each block (64 by default)
  52040. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52041. * @returns the new octree
  52042. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52044. */
  52045. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52046. }
  52047. }
  52048. /**
  52049. * Defines the octree scene component responsible to manage any octrees
  52050. * in a given scene.
  52051. */
  52052. export class OctreeSceneComponent {
  52053. /**
  52054. * The component name help to identify the component in the list of scene components.
  52055. */
  52056. readonly name: string;
  52057. /**
  52058. * The scene the component belongs to.
  52059. */
  52060. scene: Scene;
  52061. /**
  52062. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52063. */
  52064. readonly checksIsEnabled: boolean;
  52065. /**
  52066. * Creates a new instance of the component for the given scene
  52067. * @param scene Defines the scene to register the component in
  52068. */
  52069. constructor(scene: Scene);
  52070. /**
  52071. * Registers the component in a given scene
  52072. */
  52073. register(): void;
  52074. /**
  52075. * Return the list of active meshes
  52076. * @returns the list of active meshes
  52077. */
  52078. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52079. /**
  52080. * Return the list of active sub meshes
  52081. * @param mesh The mesh to get the candidates sub meshes from
  52082. * @returns the list of active sub meshes
  52083. */
  52084. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52085. private _tempRay;
  52086. /**
  52087. * Return the list of sub meshes intersecting with a given local ray
  52088. * @param mesh defines the mesh to find the submesh for
  52089. * @param localRay defines the ray in local space
  52090. * @returns the list of intersecting sub meshes
  52091. */
  52092. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52093. /**
  52094. * Return the list of sub meshes colliding with a collider
  52095. * @param mesh defines the mesh to find the submesh for
  52096. * @param collider defines the collider to evaluate the collision against
  52097. * @returns the list of colliding sub meshes
  52098. */
  52099. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52100. /**
  52101. * Rebuilds the elements related to this component in case of
  52102. * context lost for instance.
  52103. */
  52104. rebuild(): void;
  52105. /**
  52106. * Disposes the component and the associated ressources.
  52107. */
  52108. dispose(): void;
  52109. }
  52110. }
  52111. declare module "babylonjs/Culling/Octrees/index" {
  52112. export * from "babylonjs/Culling/Octrees/octree";
  52113. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52114. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52115. }
  52116. declare module "babylonjs/Culling/index" {
  52117. export * from "babylonjs/Culling/boundingBox";
  52118. export * from "babylonjs/Culling/boundingInfo";
  52119. export * from "babylonjs/Culling/boundingSphere";
  52120. export * from "babylonjs/Culling/Octrees/index";
  52121. export * from "babylonjs/Culling/ray";
  52122. }
  52123. declare module "babylonjs/Gizmos/gizmo" {
  52124. import { Nullable } from "babylonjs/types";
  52125. import { IDisposable } from "babylonjs/scene";
  52126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52127. import { Mesh } from "babylonjs/Meshes/mesh";
  52128. import { Node } from "babylonjs/node";
  52129. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52130. /**
  52131. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52132. */
  52133. export class Gizmo implements IDisposable {
  52134. /** The utility layer the gizmo will be added to */
  52135. gizmoLayer: UtilityLayerRenderer;
  52136. /**
  52137. * The root mesh of the gizmo
  52138. */
  52139. _rootMesh: Mesh;
  52140. private _attachedMesh;
  52141. private _attachedNode;
  52142. /**
  52143. * Ratio for the scale of the gizmo (Default: 1)
  52144. */
  52145. scaleRatio: number;
  52146. /**
  52147. * If a custom mesh has been set (Default: false)
  52148. */
  52149. protected _customMeshSet: boolean;
  52150. /**
  52151. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52152. * * When set, interactions will be enabled
  52153. */
  52154. get attachedMesh(): Nullable<AbstractMesh>;
  52155. set attachedMesh(value: Nullable<AbstractMesh>);
  52156. /**
  52157. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52158. * * When set, interactions will be enabled
  52159. */
  52160. get attachedNode(): Nullable<Node>;
  52161. set attachedNode(value: Nullable<Node>);
  52162. /**
  52163. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52164. * @param mesh The mesh to replace the default mesh of the gizmo
  52165. */
  52166. setCustomMesh(mesh: Mesh): void;
  52167. /**
  52168. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52169. */
  52170. updateGizmoRotationToMatchAttachedMesh: boolean;
  52171. /**
  52172. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52173. */
  52174. updateGizmoPositionToMatchAttachedMesh: boolean;
  52175. /**
  52176. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52177. */
  52178. updateScale: boolean;
  52179. protected _interactionsEnabled: boolean;
  52180. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52181. private _beforeRenderObserver;
  52182. private _tempQuaternion;
  52183. private _tempVector;
  52184. private _tempVector2;
  52185. /**
  52186. * Creates a gizmo
  52187. * @param gizmoLayer The utility layer the gizmo will be added to
  52188. */
  52189. constructor(
  52190. /** The utility layer the gizmo will be added to */
  52191. gizmoLayer?: UtilityLayerRenderer);
  52192. /**
  52193. * Updates the gizmo to match the attached mesh's position/rotation
  52194. */
  52195. protected _update(): void;
  52196. /**
  52197. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52198. * @param value Node, TransformNode or mesh
  52199. */
  52200. protected _matrixChanged(): void;
  52201. /**
  52202. * Disposes of the gizmo
  52203. */
  52204. dispose(): void;
  52205. }
  52206. }
  52207. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52208. import { Observable } from "babylonjs/Misc/observable";
  52209. import { Nullable } from "babylonjs/types";
  52210. import { Vector3 } from "babylonjs/Maths/math.vector";
  52211. import { Color3 } from "babylonjs/Maths/math.color";
  52212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52213. import { Node } from "babylonjs/node";
  52214. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52215. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52217. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52218. import { Scene } from "babylonjs/scene";
  52219. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52220. /**
  52221. * Single plane drag gizmo
  52222. */
  52223. export class PlaneDragGizmo extends Gizmo {
  52224. /**
  52225. * Drag behavior responsible for the gizmos dragging interactions
  52226. */
  52227. dragBehavior: PointerDragBehavior;
  52228. private _pointerObserver;
  52229. /**
  52230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52231. */
  52232. snapDistance: number;
  52233. /**
  52234. * Event that fires each time the gizmo snaps to a new location.
  52235. * * snapDistance is the the change in distance
  52236. */
  52237. onSnapObservable: Observable<{
  52238. snapDistance: number;
  52239. }>;
  52240. private _plane;
  52241. private _coloredMaterial;
  52242. private _hoverMaterial;
  52243. private _isEnabled;
  52244. private _parent;
  52245. /** @hidden */
  52246. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52247. /** @hidden */
  52248. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52249. /**
  52250. * Creates a PlaneDragGizmo
  52251. * @param gizmoLayer The utility layer the gizmo will be added to
  52252. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52253. * @param color The color of the gizmo
  52254. */
  52255. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52256. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52257. /**
  52258. * If the gizmo is enabled
  52259. */
  52260. set isEnabled(value: boolean);
  52261. get isEnabled(): boolean;
  52262. /**
  52263. * Disposes of the gizmo
  52264. */
  52265. dispose(): void;
  52266. }
  52267. }
  52268. declare module "babylonjs/Gizmos/positionGizmo" {
  52269. import { Observable } from "babylonjs/Misc/observable";
  52270. import { Nullable } from "babylonjs/types";
  52271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52272. import { Node } from "babylonjs/node";
  52273. import { Mesh } from "babylonjs/Meshes/mesh";
  52274. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52275. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52276. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52277. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52278. /**
  52279. * Gizmo that enables dragging a mesh along 3 axis
  52280. */
  52281. export class PositionGizmo extends Gizmo {
  52282. /**
  52283. * Internal gizmo used for interactions on the x axis
  52284. */
  52285. xGizmo: AxisDragGizmo;
  52286. /**
  52287. * Internal gizmo used for interactions on the y axis
  52288. */
  52289. yGizmo: AxisDragGizmo;
  52290. /**
  52291. * Internal gizmo used for interactions on the z axis
  52292. */
  52293. zGizmo: AxisDragGizmo;
  52294. /**
  52295. * Internal gizmo used for interactions on the yz plane
  52296. */
  52297. xPlaneGizmo: PlaneDragGizmo;
  52298. /**
  52299. * Internal gizmo used for interactions on the xz plane
  52300. */
  52301. yPlaneGizmo: PlaneDragGizmo;
  52302. /**
  52303. * Internal gizmo used for interactions on the xy plane
  52304. */
  52305. zPlaneGizmo: PlaneDragGizmo;
  52306. /**
  52307. * private variables
  52308. */
  52309. private _meshAttached;
  52310. private _nodeAttached;
  52311. private _updateGizmoRotationToMatchAttachedMesh;
  52312. private _snapDistance;
  52313. private _scaleRatio;
  52314. /** Fires an event when any of it's sub gizmos are dragged */
  52315. onDragStartObservable: Observable<unknown>;
  52316. /** Fires an event when any of it's sub gizmos are released from dragging */
  52317. onDragEndObservable: Observable<unknown>;
  52318. /**
  52319. * If set to true, planar drag is enabled
  52320. */
  52321. private _planarGizmoEnabled;
  52322. get attachedMesh(): Nullable<AbstractMesh>;
  52323. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52324. get attachedNode(): Nullable<Node>;
  52325. set attachedNode(node: Nullable<Node>);
  52326. /**
  52327. * Creates a PositionGizmo
  52328. * @param gizmoLayer The utility layer the gizmo will be added to
  52329. @param thickness display gizmo axis thickness
  52330. */
  52331. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52332. /**
  52333. * If the planar drag gizmo is enabled
  52334. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52335. */
  52336. set planarGizmoEnabled(value: boolean);
  52337. get planarGizmoEnabled(): boolean;
  52338. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52339. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52340. /**
  52341. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52342. */
  52343. set snapDistance(value: number);
  52344. get snapDistance(): number;
  52345. /**
  52346. * Ratio for the scale of the gizmo (Default: 1)
  52347. */
  52348. set scaleRatio(value: number);
  52349. get scaleRatio(): number;
  52350. /**
  52351. * Disposes of the gizmo
  52352. */
  52353. dispose(): void;
  52354. /**
  52355. * CustomMeshes are not supported by this gizmo
  52356. * @param mesh The mesh to replace the default mesh of the gizmo
  52357. */
  52358. setCustomMesh(mesh: Mesh): void;
  52359. }
  52360. }
  52361. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52362. import { Observable } from "babylonjs/Misc/observable";
  52363. import { Nullable } from "babylonjs/types";
  52364. import { Vector3 } from "babylonjs/Maths/math.vector";
  52365. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52366. import { Node } from "babylonjs/node";
  52367. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52368. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52369. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52370. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52371. import { Scene } from "babylonjs/scene";
  52372. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52373. import { Color3 } from "babylonjs/Maths/math.color";
  52374. /**
  52375. * Single axis drag gizmo
  52376. */
  52377. export class AxisDragGizmo extends Gizmo {
  52378. /**
  52379. * Drag behavior responsible for the gizmos dragging interactions
  52380. */
  52381. dragBehavior: PointerDragBehavior;
  52382. private _pointerObserver;
  52383. /**
  52384. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52385. */
  52386. snapDistance: number;
  52387. /**
  52388. * Event that fires each time the gizmo snaps to a new location.
  52389. * * snapDistance is the the change in distance
  52390. */
  52391. onSnapObservable: Observable<{
  52392. snapDistance: number;
  52393. }>;
  52394. private _isEnabled;
  52395. private _parent;
  52396. private _arrow;
  52397. private _coloredMaterial;
  52398. private _hoverMaterial;
  52399. /** @hidden */
  52400. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52401. /** @hidden */
  52402. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52403. /**
  52404. * Creates an AxisDragGizmo
  52405. * @param gizmoLayer The utility layer the gizmo will be added to
  52406. * @param dragAxis The axis which the gizmo will be able to drag on
  52407. * @param color The color of the gizmo
  52408. * @param thickness display gizmo axis thickness
  52409. */
  52410. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52411. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52412. /**
  52413. * If the gizmo is enabled
  52414. */
  52415. set isEnabled(value: boolean);
  52416. get isEnabled(): boolean;
  52417. /**
  52418. * Disposes of the gizmo
  52419. */
  52420. dispose(): void;
  52421. }
  52422. }
  52423. declare module "babylonjs/Debug/axesViewer" {
  52424. import { Vector3 } from "babylonjs/Maths/math.vector";
  52425. import { Nullable } from "babylonjs/types";
  52426. import { Scene } from "babylonjs/scene";
  52427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52428. /**
  52429. * The Axes viewer will show 3 axes in a specific point in space
  52430. */
  52431. export class AxesViewer {
  52432. private _xAxis;
  52433. private _yAxis;
  52434. private _zAxis;
  52435. private _scaleLinesFactor;
  52436. private _instanced;
  52437. /**
  52438. * Gets the hosting scene
  52439. */
  52440. scene: Scene;
  52441. /**
  52442. * Gets or sets a number used to scale line length
  52443. */
  52444. scaleLines: number;
  52445. /** Gets the node hierarchy used to render x-axis */
  52446. get xAxis(): TransformNode;
  52447. /** Gets the node hierarchy used to render y-axis */
  52448. get yAxis(): TransformNode;
  52449. /** Gets the node hierarchy used to render z-axis */
  52450. get zAxis(): TransformNode;
  52451. /**
  52452. * Creates a new AxesViewer
  52453. * @param scene defines the hosting scene
  52454. * @param scaleLines defines a number used to scale line length (1 by default)
  52455. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52456. * @param xAxis defines the node hierarchy used to render the x-axis
  52457. * @param yAxis defines the node hierarchy used to render the y-axis
  52458. * @param zAxis defines the node hierarchy used to render the z-axis
  52459. */
  52460. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52461. /**
  52462. * Force the viewer to update
  52463. * @param position defines the position of the viewer
  52464. * @param xaxis defines the x axis of the viewer
  52465. * @param yaxis defines the y axis of the viewer
  52466. * @param zaxis defines the z axis of the viewer
  52467. */
  52468. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52469. /**
  52470. * Creates an instance of this axes viewer.
  52471. * @returns a new axes viewer with instanced meshes
  52472. */
  52473. createInstance(): AxesViewer;
  52474. /** Releases resources */
  52475. dispose(): void;
  52476. private static _SetRenderingGroupId;
  52477. }
  52478. }
  52479. declare module "babylonjs/Debug/boneAxesViewer" {
  52480. import { Nullable } from "babylonjs/types";
  52481. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52482. import { Vector3 } from "babylonjs/Maths/math.vector";
  52483. import { Mesh } from "babylonjs/Meshes/mesh";
  52484. import { Bone } from "babylonjs/Bones/bone";
  52485. import { Scene } from "babylonjs/scene";
  52486. /**
  52487. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52488. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52489. */
  52490. export class BoneAxesViewer extends AxesViewer {
  52491. /**
  52492. * Gets or sets the target mesh where to display the axes viewer
  52493. */
  52494. mesh: Nullable<Mesh>;
  52495. /**
  52496. * Gets or sets the target bone where to display the axes viewer
  52497. */
  52498. bone: Nullable<Bone>;
  52499. /** Gets current position */
  52500. pos: Vector3;
  52501. /** Gets direction of X axis */
  52502. xaxis: Vector3;
  52503. /** Gets direction of Y axis */
  52504. yaxis: Vector3;
  52505. /** Gets direction of Z axis */
  52506. zaxis: Vector3;
  52507. /**
  52508. * Creates a new BoneAxesViewer
  52509. * @param scene defines the hosting scene
  52510. * @param bone defines the target bone
  52511. * @param mesh defines the target mesh
  52512. * @param scaleLines defines a scaling factor for line length (1 by default)
  52513. */
  52514. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52515. /**
  52516. * Force the viewer to update
  52517. */
  52518. update(): void;
  52519. /** Releases resources */
  52520. dispose(): void;
  52521. }
  52522. }
  52523. declare module "babylonjs/Debug/debugLayer" {
  52524. import { Scene } from "babylonjs/scene";
  52525. /**
  52526. * Interface used to define scene explorer extensibility option
  52527. */
  52528. export interface IExplorerExtensibilityOption {
  52529. /**
  52530. * Define the option label
  52531. */
  52532. label: string;
  52533. /**
  52534. * Defines the action to execute on click
  52535. */
  52536. action: (entity: any) => void;
  52537. }
  52538. /**
  52539. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52540. */
  52541. export interface IExplorerExtensibilityGroup {
  52542. /**
  52543. * Defines a predicate to test if a given type mut be extended
  52544. */
  52545. predicate: (entity: any) => boolean;
  52546. /**
  52547. * Gets the list of options added to a type
  52548. */
  52549. entries: IExplorerExtensibilityOption[];
  52550. }
  52551. /**
  52552. * Interface used to define the options to use to create the Inspector
  52553. */
  52554. export interface IInspectorOptions {
  52555. /**
  52556. * Display in overlay mode (default: false)
  52557. */
  52558. overlay?: boolean;
  52559. /**
  52560. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52561. */
  52562. globalRoot?: HTMLElement;
  52563. /**
  52564. * Display the Scene explorer
  52565. */
  52566. showExplorer?: boolean;
  52567. /**
  52568. * Display the property inspector
  52569. */
  52570. showInspector?: boolean;
  52571. /**
  52572. * Display in embed mode (both panes on the right)
  52573. */
  52574. embedMode?: boolean;
  52575. /**
  52576. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52577. */
  52578. handleResize?: boolean;
  52579. /**
  52580. * Allow the panes to popup (default: true)
  52581. */
  52582. enablePopup?: boolean;
  52583. /**
  52584. * Allow the panes to be closed by users (default: true)
  52585. */
  52586. enableClose?: boolean;
  52587. /**
  52588. * Optional list of extensibility entries
  52589. */
  52590. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52591. /**
  52592. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52593. */
  52594. inspectorURL?: string;
  52595. /**
  52596. * Optional initial tab (default to DebugLayerTab.Properties)
  52597. */
  52598. initialTab?: DebugLayerTab;
  52599. }
  52600. module "babylonjs/scene" {
  52601. interface Scene {
  52602. /**
  52603. * @hidden
  52604. * Backing field
  52605. */
  52606. _debugLayer: DebugLayer;
  52607. /**
  52608. * Gets the debug layer (aka Inspector) associated with the scene
  52609. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52610. */
  52611. debugLayer: DebugLayer;
  52612. }
  52613. }
  52614. /**
  52615. * Enum of inspector action tab
  52616. */
  52617. export enum DebugLayerTab {
  52618. /**
  52619. * Properties tag (default)
  52620. */
  52621. Properties = 0,
  52622. /**
  52623. * Debug tab
  52624. */
  52625. Debug = 1,
  52626. /**
  52627. * Statistics tab
  52628. */
  52629. Statistics = 2,
  52630. /**
  52631. * Tools tab
  52632. */
  52633. Tools = 3,
  52634. /**
  52635. * Settings tab
  52636. */
  52637. Settings = 4
  52638. }
  52639. /**
  52640. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52641. * what is happening in your scene
  52642. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52643. */
  52644. export class DebugLayer {
  52645. /**
  52646. * Define the url to get the inspector script from.
  52647. * By default it uses the babylonjs CDN.
  52648. * @ignoreNaming
  52649. */
  52650. static InspectorURL: string;
  52651. private _scene;
  52652. private BJSINSPECTOR;
  52653. private _onPropertyChangedObservable?;
  52654. /**
  52655. * Observable triggered when a property is changed through the inspector.
  52656. */
  52657. get onPropertyChangedObservable(): any;
  52658. /**
  52659. * Instantiates a new debug layer.
  52660. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52661. * what is happening in your scene
  52662. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52663. * @param scene Defines the scene to inspect
  52664. */
  52665. constructor(scene: Scene);
  52666. /** Creates the inspector window. */
  52667. private _createInspector;
  52668. /**
  52669. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52670. * @param entity defines the entity to select
  52671. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52672. */
  52673. select(entity: any, lineContainerTitles?: string | string[]): void;
  52674. /** Get the inspector from bundle or global */
  52675. private _getGlobalInspector;
  52676. /**
  52677. * Get if the inspector is visible or not.
  52678. * @returns true if visible otherwise, false
  52679. */
  52680. isVisible(): boolean;
  52681. /**
  52682. * Hide the inspector and close its window.
  52683. */
  52684. hide(): void;
  52685. /**
  52686. * Update the scene in the inspector
  52687. */
  52688. setAsActiveScene(): void;
  52689. /**
  52690. * Launch the debugLayer.
  52691. * @param config Define the configuration of the inspector
  52692. * @return a promise fulfilled when the debug layer is visible
  52693. */
  52694. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52695. }
  52696. }
  52697. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52698. import { Nullable } from "babylonjs/types";
  52699. import { Scene } from "babylonjs/scene";
  52700. import { Vector4 } from "babylonjs/Maths/math.vector";
  52701. import { Color4 } from "babylonjs/Maths/math.color";
  52702. import { Mesh } from "babylonjs/Meshes/mesh";
  52703. /**
  52704. * Class containing static functions to help procedurally build meshes
  52705. */
  52706. export class BoxBuilder {
  52707. /**
  52708. * Creates a box mesh
  52709. * * The parameter `size` sets the size (float) of each box side (default 1)
  52710. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52711. * * 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)
  52712. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52716. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52717. * @param name defines the name of the mesh
  52718. * @param options defines the options used to create the mesh
  52719. * @param scene defines the hosting scene
  52720. * @returns the box mesh
  52721. */
  52722. static CreateBox(name: string, options: {
  52723. size?: number;
  52724. width?: number;
  52725. height?: number;
  52726. depth?: number;
  52727. faceUV?: Vector4[];
  52728. faceColors?: Color4[];
  52729. sideOrientation?: number;
  52730. frontUVs?: Vector4;
  52731. backUVs?: Vector4;
  52732. wrap?: boolean;
  52733. topBaseAt?: number;
  52734. bottomBaseAt?: number;
  52735. updatable?: boolean;
  52736. }, scene?: Nullable<Scene>): Mesh;
  52737. }
  52738. }
  52739. declare module "babylonjs/Debug/physicsViewer" {
  52740. import { Nullable } from "babylonjs/types";
  52741. import { Scene } from "babylonjs/scene";
  52742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52743. import { Mesh } from "babylonjs/Meshes/mesh";
  52744. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52745. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52746. /**
  52747. * Used to show the physics impostor around the specific mesh
  52748. */
  52749. export class PhysicsViewer {
  52750. /** @hidden */
  52751. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52752. /** @hidden */
  52753. protected _meshes: Array<Nullable<AbstractMesh>>;
  52754. /** @hidden */
  52755. protected _scene: Nullable<Scene>;
  52756. /** @hidden */
  52757. protected _numMeshes: number;
  52758. /** @hidden */
  52759. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52760. private _renderFunction;
  52761. private _utilityLayer;
  52762. private _debugBoxMesh;
  52763. private _debugSphereMesh;
  52764. private _debugCylinderMesh;
  52765. private _debugMaterial;
  52766. private _debugMeshMeshes;
  52767. /**
  52768. * Creates a new PhysicsViewer
  52769. * @param scene defines the hosting scene
  52770. */
  52771. constructor(scene: Scene);
  52772. /** @hidden */
  52773. protected _updateDebugMeshes(): void;
  52774. /**
  52775. * Renders a specified physic impostor
  52776. * @param impostor defines the impostor to render
  52777. * @param targetMesh defines the mesh represented by the impostor
  52778. * @returns the new debug mesh used to render the impostor
  52779. */
  52780. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52781. /**
  52782. * Hides a specified physic impostor
  52783. * @param impostor defines the impostor to hide
  52784. */
  52785. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52786. private _getDebugMaterial;
  52787. private _getDebugBoxMesh;
  52788. private _getDebugSphereMesh;
  52789. private _getDebugCylinderMesh;
  52790. private _getDebugMeshMesh;
  52791. private _getDebugMesh;
  52792. /** Releases all resources */
  52793. dispose(): void;
  52794. }
  52795. }
  52796. declare module "babylonjs/Debug/rayHelper" {
  52797. import { Nullable } from "babylonjs/types";
  52798. import { Ray } from "babylonjs/Culling/ray";
  52799. import { Vector3 } from "babylonjs/Maths/math.vector";
  52800. import { Color3 } from "babylonjs/Maths/math.color";
  52801. import { Scene } from "babylonjs/scene";
  52802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52803. import "babylonjs/Meshes/Builders/linesBuilder";
  52804. /**
  52805. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52806. * in order to better appreciate the issue one might have.
  52807. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52808. */
  52809. export class RayHelper {
  52810. /**
  52811. * Defines the ray we are currently tryin to visualize.
  52812. */
  52813. ray: Nullable<Ray>;
  52814. private _renderPoints;
  52815. private _renderLine;
  52816. private _renderFunction;
  52817. private _scene;
  52818. private _onAfterRenderObserver;
  52819. private _onAfterStepObserver;
  52820. private _attachedToMesh;
  52821. private _meshSpaceDirection;
  52822. private _meshSpaceOrigin;
  52823. /**
  52824. * Helper function to create a colored helper in a scene in one line.
  52825. * @param ray Defines the ray we are currently tryin to visualize
  52826. * @param scene Defines the scene the ray is used in
  52827. * @param color Defines the color we want to see the ray in
  52828. * @returns The newly created ray helper.
  52829. */
  52830. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52831. /**
  52832. * Instantiate a new ray helper.
  52833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52834. * in order to better appreciate the issue one might have.
  52835. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52836. * @param ray Defines the ray we are currently tryin to visualize
  52837. */
  52838. constructor(ray: Ray);
  52839. /**
  52840. * Shows the ray we are willing to debug.
  52841. * @param scene Defines the scene the ray needs to be rendered in
  52842. * @param color Defines the color the ray needs to be rendered in
  52843. */
  52844. show(scene: Scene, color?: Color3): void;
  52845. /**
  52846. * Hides the ray we are debugging.
  52847. */
  52848. hide(): void;
  52849. private _render;
  52850. /**
  52851. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52852. * @param mesh Defines the mesh we want the helper attached to
  52853. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52854. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52855. * @param length Defines the length of the ray
  52856. */
  52857. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52858. /**
  52859. * Detach the ray helper from the mesh it has previously been attached to.
  52860. */
  52861. detachFromMesh(): void;
  52862. private _updateToMesh;
  52863. /**
  52864. * Dispose the helper and release its associated resources.
  52865. */
  52866. dispose(): void;
  52867. }
  52868. }
  52869. declare module "babylonjs/Debug/ISkeletonViewer" {
  52870. /**
  52871. * Defines the options associated with the creation of a SkeletonViewer.
  52872. */
  52873. export interface ISkeletonViewerOptions {
  52874. /** Should the system pause animations before building the Viewer? */
  52875. pauseAnimations: boolean;
  52876. /** Should the system return the skeleton to rest before building? */
  52877. returnToRest: boolean;
  52878. /** public Display Mode of the Viewer */
  52879. displayMode: number;
  52880. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52881. displayOptions: ISkeletonViewerDisplayOptions;
  52882. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52883. computeBonesUsingShaders: boolean;
  52884. }
  52885. /**
  52886. * Defines how to display the various bone meshes for the viewer.
  52887. */
  52888. export interface ISkeletonViewerDisplayOptions {
  52889. /** How far down to start tapering the bone spurs */
  52890. midStep?: number;
  52891. /** How big is the midStep? */
  52892. midStepFactor?: number;
  52893. /** Base for the Sphere Size */
  52894. sphereBaseSize?: number;
  52895. /** The ratio of the sphere to the longest bone in units */
  52896. sphereScaleUnit?: number;
  52897. /** Ratio for the Sphere Size */
  52898. sphereFactor?: number;
  52899. }
  52900. }
  52901. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52902. import { Nullable } from "babylonjs/types";
  52903. import { Scene } from "babylonjs/scene";
  52904. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52905. import { Color4 } from "babylonjs/Maths/math.color";
  52906. import { Mesh } from "babylonjs/Meshes/mesh";
  52907. /**
  52908. * Class containing static functions to help procedurally build meshes
  52909. */
  52910. export class RibbonBuilder {
  52911. /**
  52912. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52913. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52914. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52915. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52916. * * 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
  52917. * * 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
  52918. * * 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
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * 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
  52923. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52924. * * 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
  52925. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52927. * @param name defines the name of the mesh
  52928. * @param options defines the options used to create the mesh
  52929. * @param scene defines the hosting scene
  52930. * @returns the ribbon mesh
  52931. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52933. */
  52934. static CreateRibbon(name: string, options: {
  52935. pathArray: Vector3[][];
  52936. closeArray?: boolean;
  52937. closePath?: boolean;
  52938. offset?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. uvs?: Vector2[];
  52946. colors?: Color4[];
  52947. }, scene?: Nullable<Scene>): Mesh;
  52948. }
  52949. }
  52950. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52951. import { Nullable } from "babylonjs/types";
  52952. import { Scene } from "babylonjs/scene";
  52953. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52954. import { Mesh } from "babylonjs/Meshes/mesh";
  52955. /**
  52956. * Class containing static functions to help procedurally build meshes
  52957. */
  52958. export class ShapeBuilder {
  52959. /**
  52960. * 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.
  52961. * * 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.
  52962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52963. * * 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.
  52964. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52965. * * 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
  52966. * * 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
  52967. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52972. * @param name defines the name of the mesh
  52973. * @param options defines the options used to create the mesh
  52974. * @param scene defines the hosting scene
  52975. * @returns the extruded shape mesh
  52976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52978. */
  52979. static ExtrudeShape(name: string, options: {
  52980. shape: Vector3[];
  52981. path: Vector3[];
  52982. scale?: number;
  52983. rotation?: number;
  52984. cap?: number;
  52985. updatable?: boolean;
  52986. sideOrientation?: number;
  52987. frontUVs?: Vector4;
  52988. backUVs?: Vector4;
  52989. instance?: Mesh;
  52990. invertUV?: boolean;
  52991. }, scene?: Nullable<Scene>): Mesh;
  52992. /**
  52993. * Creates an custom extruded shape mesh.
  52994. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52995. * * 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.
  52996. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52997. * * 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
  52998. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52999. * * 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
  53000. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53001. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53002. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53003. * * 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
  53004. * * 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
  53005. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53010. * @param name defines the name of the mesh
  53011. * @param options defines the options used to create the mesh
  53012. * @param scene defines the hosting scene
  53013. * @returns the custom extruded shape mesh
  53014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53015. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53017. */
  53018. static ExtrudeShapeCustom(name: string, options: {
  53019. shape: Vector3[];
  53020. path: Vector3[];
  53021. scaleFunction?: any;
  53022. rotationFunction?: any;
  53023. ribbonCloseArray?: boolean;
  53024. ribbonClosePath?: boolean;
  53025. cap?: number;
  53026. updatable?: boolean;
  53027. sideOrientation?: number;
  53028. frontUVs?: Vector4;
  53029. backUVs?: Vector4;
  53030. instance?: Mesh;
  53031. invertUV?: boolean;
  53032. }, scene?: Nullable<Scene>): Mesh;
  53033. private static _ExtrudeShapeGeneric;
  53034. }
  53035. }
  53036. declare module "babylonjs/Debug/skeletonViewer" {
  53037. import { Color3 } from "babylonjs/Maths/math.color";
  53038. import { Scene } from "babylonjs/scene";
  53039. import { Nullable } from "babylonjs/types";
  53040. import { Skeleton } from "babylonjs/Bones/skeleton";
  53041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53042. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53043. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53044. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  53045. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  53046. /**
  53047. * Class used to render a debug view of a given skeleton
  53048. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53049. */
  53050. export class SkeletonViewer {
  53051. /** defines the skeleton to render */
  53052. skeleton: Skeleton;
  53053. /** defines the mesh attached to the skeleton */
  53054. mesh: AbstractMesh;
  53055. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53056. autoUpdateBonesMatrices: boolean;
  53057. /** defines the rendering group id to use with the viewer */
  53058. renderingGroupId: number;
  53059. /** is the options for the viewer */
  53060. options: Partial<ISkeletonViewerOptions>;
  53061. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53062. static readonly DISPLAY_LINES: number;
  53063. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53064. static readonly DISPLAY_SPHERES: number;
  53065. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53066. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53067. /** If SkeletonViewer scene scope. */
  53068. private _scene;
  53069. /** Gets or sets the color used to render the skeleton */
  53070. color: Color3;
  53071. /** Array of the points of the skeleton fo the line view. */
  53072. private _debugLines;
  53073. /** The SkeletonViewers Mesh. */
  53074. private _debugMesh;
  53075. /** If SkeletonViewer is enabled. */
  53076. private _isEnabled;
  53077. /** If SkeletonViewer is ready. */
  53078. private _ready;
  53079. /** SkeletonViewer render observable. */
  53080. private _obs;
  53081. /** The Utility Layer to render the gizmos in. */
  53082. private _utilityLayer;
  53083. private _boneIndices;
  53084. /** Gets the Scene. */
  53085. get scene(): Scene;
  53086. /** Gets the utilityLayer. */
  53087. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53088. /** Checks Ready Status. */
  53089. get isReady(): Boolean;
  53090. /** Sets Ready Status. */
  53091. set ready(value: boolean);
  53092. /** Gets the debugMesh */
  53093. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53094. /** Sets the debugMesh */
  53095. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53096. /** Gets the material */
  53097. get material(): StandardMaterial;
  53098. /** Sets the material */
  53099. set material(value: StandardMaterial);
  53100. /** Gets the material */
  53101. get displayMode(): number;
  53102. /** Sets the material */
  53103. set displayMode(value: number);
  53104. /**
  53105. * Creates a new SkeletonViewer
  53106. * @param skeleton defines the skeleton to render
  53107. * @param mesh defines the mesh attached to the skeleton
  53108. * @param scene defines the hosting scene
  53109. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53110. * @param renderingGroupId defines the rendering group id to use with the viewer
  53111. * @param options All of the extra constructor options for the SkeletonViewer
  53112. */
  53113. constructor(
  53114. /** defines the skeleton to render */
  53115. skeleton: Skeleton,
  53116. /** defines the mesh attached to the skeleton */
  53117. mesh: AbstractMesh,
  53118. /** The Scene scope*/
  53119. scene: Scene,
  53120. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53121. autoUpdateBonesMatrices?: boolean,
  53122. /** defines the rendering group id to use with the viewer */
  53123. renderingGroupId?: number,
  53124. /** is the options for the viewer */
  53125. options?: Partial<ISkeletonViewerOptions>);
  53126. /** The Dynamic bindings for the update functions */
  53127. private _bindObs;
  53128. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53129. update(): void;
  53130. /** Gets or sets a boolean indicating if the viewer is enabled */
  53131. set isEnabled(value: boolean);
  53132. get isEnabled(): boolean;
  53133. private _getBonePosition;
  53134. private _getLinesForBonesWithLength;
  53135. private _getLinesForBonesNoLength;
  53136. /** function to revert the mesh and scene back to the initial state. */
  53137. private _revert;
  53138. /** function to build and bind sphere joint points and spur bone representations. */
  53139. private _buildSpheresAndSpurs;
  53140. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53141. private _displayLinesUpdate;
  53142. /** Changes the displayMode of the skeleton viewer
  53143. * @param mode The displayMode numerical value
  53144. */
  53145. changeDisplayMode(mode: number): void;
  53146. /** Changes the displayMode of the skeleton viewer
  53147. * @param option String of the option name
  53148. * @param value The numerical option value
  53149. */
  53150. changeDisplayOptions(option: string, value: number): void;
  53151. /** Release associated resources */
  53152. dispose(): void;
  53153. }
  53154. }
  53155. declare module "babylonjs/Debug/index" {
  53156. export * from "babylonjs/Debug/axesViewer";
  53157. export * from "babylonjs/Debug/boneAxesViewer";
  53158. export * from "babylonjs/Debug/debugLayer";
  53159. export * from "babylonjs/Debug/physicsViewer";
  53160. export * from "babylonjs/Debug/rayHelper";
  53161. export * from "babylonjs/Debug/skeletonViewer";
  53162. export * from "babylonjs/Debug/ISkeletonViewer";
  53163. }
  53164. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53165. /**
  53166. * Enum for Device Types
  53167. */
  53168. export enum DeviceType {
  53169. /** Generic */
  53170. Generic = 0,
  53171. /** Keyboard */
  53172. Keyboard = 1,
  53173. /** Mouse */
  53174. Mouse = 2,
  53175. /** Touch Pointers */
  53176. Touch = 3,
  53177. /** PS4 Dual Shock */
  53178. DualShock = 4,
  53179. /** Xbox */
  53180. Xbox = 5,
  53181. /** Switch Controller */
  53182. Switch = 6
  53183. }
  53184. /**
  53185. * Enum for All Pointers (Touch/Mouse)
  53186. */
  53187. export enum PointerInput {
  53188. /** Horizontal Axis */
  53189. Horizontal = 0,
  53190. /** Vertical Axis */
  53191. Vertical = 1,
  53192. /** Left Click or Touch */
  53193. LeftClick = 2,
  53194. /** Middle Click */
  53195. MiddleClick = 3,
  53196. /** Right Click */
  53197. RightClick = 4,
  53198. /** Browser Back */
  53199. BrowserBack = 5,
  53200. /** Browser Forward */
  53201. BrowserForward = 6
  53202. }
  53203. /**
  53204. * Enum for Dual Shock Gamepad
  53205. */
  53206. export enum DualShockInput {
  53207. /** Cross */
  53208. Cross = 0,
  53209. /** Circle */
  53210. Circle = 1,
  53211. /** Square */
  53212. Square = 2,
  53213. /** Triangle */
  53214. Triangle = 3,
  53215. /** L1 */
  53216. L1 = 4,
  53217. /** R1 */
  53218. R1 = 5,
  53219. /** L2 */
  53220. L2 = 6,
  53221. /** R2 */
  53222. R2 = 7,
  53223. /** Share */
  53224. Share = 8,
  53225. /** Options */
  53226. Options = 9,
  53227. /** L3 */
  53228. L3 = 10,
  53229. /** R3 */
  53230. R3 = 11,
  53231. /** DPadUp */
  53232. DPadUp = 12,
  53233. /** DPadDown */
  53234. DPadDown = 13,
  53235. /** DPadLeft */
  53236. DPadLeft = 14,
  53237. /** DRight */
  53238. DPadRight = 15,
  53239. /** Home */
  53240. Home = 16,
  53241. /** TouchPad */
  53242. TouchPad = 17,
  53243. /** LStickXAxis */
  53244. LStickXAxis = 18,
  53245. /** LStickYAxis */
  53246. LStickYAxis = 19,
  53247. /** RStickXAxis */
  53248. RStickXAxis = 20,
  53249. /** RStickYAxis */
  53250. RStickYAxis = 21
  53251. }
  53252. /**
  53253. * Enum for Xbox Gamepad
  53254. */
  53255. export enum XboxInput {
  53256. /** A */
  53257. A = 0,
  53258. /** B */
  53259. B = 1,
  53260. /** X */
  53261. X = 2,
  53262. /** Y */
  53263. Y = 3,
  53264. /** LB */
  53265. LB = 4,
  53266. /** RB */
  53267. RB = 5,
  53268. /** LT */
  53269. LT = 6,
  53270. /** RT */
  53271. RT = 7,
  53272. /** Back */
  53273. Back = 8,
  53274. /** Start */
  53275. Start = 9,
  53276. /** LS */
  53277. LS = 10,
  53278. /** RS */
  53279. RS = 11,
  53280. /** DPadUp */
  53281. DPadUp = 12,
  53282. /** DPadDown */
  53283. DPadDown = 13,
  53284. /** DPadLeft */
  53285. DPadLeft = 14,
  53286. /** DRight */
  53287. DPadRight = 15,
  53288. /** Home */
  53289. Home = 16,
  53290. /** LStickXAxis */
  53291. LStickXAxis = 17,
  53292. /** LStickYAxis */
  53293. LStickYAxis = 18,
  53294. /** RStickXAxis */
  53295. RStickXAxis = 19,
  53296. /** RStickYAxis */
  53297. RStickYAxis = 20
  53298. }
  53299. /**
  53300. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53301. */
  53302. export enum SwitchInput {
  53303. /** B */
  53304. B = 0,
  53305. /** A */
  53306. A = 1,
  53307. /** Y */
  53308. Y = 2,
  53309. /** X */
  53310. X = 3,
  53311. /** L */
  53312. L = 4,
  53313. /** R */
  53314. R = 5,
  53315. /** ZL */
  53316. ZL = 6,
  53317. /** ZR */
  53318. ZR = 7,
  53319. /** Minus */
  53320. Minus = 8,
  53321. /** Plus */
  53322. Plus = 9,
  53323. /** LS */
  53324. LS = 10,
  53325. /** RS */
  53326. RS = 11,
  53327. /** DPadUp */
  53328. DPadUp = 12,
  53329. /** DPadDown */
  53330. DPadDown = 13,
  53331. /** DPadLeft */
  53332. DPadLeft = 14,
  53333. /** DRight */
  53334. DPadRight = 15,
  53335. /** Home */
  53336. Home = 16,
  53337. /** Capture */
  53338. Capture = 17,
  53339. /** LStickXAxis */
  53340. LStickXAxis = 18,
  53341. /** LStickYAxis */
  53342. LStickYAxis = 19,
  53343. /** RStickXAxis */
  53344. RStickXAxis = 20,
  53345. /** RStickYAxis */
  53346. RStickYAxis = 21
  53347. }
  53348. }
  53349. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53350. import { Engine } from "babylonjs/Engines/engine";
  53351. import { IDisposable } from "babylonjs/scene";
  53352. import { Nullable } from "babylonjs/types";
  53353. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53354. /**
  53355. * This class will take all inputs from Keyboard, Pointer, and
  53356. * any Gamepads and provide a polling system that all devices
  53357. * will use. This class assumes that there will only be one
  53358. * pointer device and one keyboard.
  53359. */
  53360. export class DeviceInputSystem implements IDisposable {
  53361. /**
  53362. * Callback to be triggered when a device is connected
  53363. */
  53364. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53365. /**
  53366. * Callback to be triggered when a device is disconnected
  53367. */
  53368. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53369. /**
  53370. * Callback to be triggered when event driven input is updated
  53371. */
  53372. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53373. private _inputs;
  53374. private _gamepads;
  53375. private _keyboardActive;
  53376. private _pointerActive;
  53377. private _elementToAttachTo;
  53378. private _keyboardDownEvent;
  53379. private _keyboardUpEvent;
  53380. private _pointerMoveEvent;
  53381. private _pointerDownEvent;
  53382. private _pointerUpEvent;
  53383. private _gamepadConnectedEvent;
  53384. private _gamepadDisconnectedEvent;
  53385. private static _MAX_KEYCODES;
  53386. private static _MAX_POINTER_INPUTS;
  53387. private constructor();
  53388. /**
  53389. * Creates a new DeviceInputSystem instance
  53390. * @param engine Engine to pull input element from
  53391. * @returns The new instance
  53392. */
  53393. static Create(engine: Engine): DeviceInputSystem;
  53394. /**
  53395. * Checks for current device input value, given an id and input index
  53396. * @param deviceName Id of connected device
  53397. * @param inputIndex Index of device input
  53398. * @returns Current value of input
  53399. */
  53400. /**
  53401. * Checks for current device input value, given an id and input index
  53402. * @param deviceType Enum specifiying device type
  53403. * @param deviceSlot "Slot" or index that device is referenced in
  53404. * @param inputIndex Id of input to be checked
  53405. * @returns Current value of input
  53406. */
  53407. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53408. /**
  53409. * Dispose of all the eventlisteners
  53410. */
  53411. dispose(): void;
  53412. /**
  53413. * Add device and inputs to device array
  53414. * @param deviceType Enum specifiying device type
  53415. * @param deviceSlot "Slot" or index that device is referenced in
  53416. * @param numberOfInputs Number of input entries to create for given device
  53417. */
  53418. private _registerDevice;
  53419. /**
  53420. * Given a specific device name, remove that device from the device map
  53421. * @param deviceType Enum specifiying device type
  53422. * @param deviceSlot "Slot" or index that device is referenced in
  53423. */
  53424. private _unregisterDevice;
  53425. /**
  53426. * Handle all actions that come from keyboard interaction
  53427. */
  53428. private _handleKeyActions;
  53429. /**
  53430. * Handle all actions that come from pointer interaction
  53431. */
  53432. private _handlePointerActions;
  53433. /**
  53434. * Handle all actions that come from gamepad interaction
  53435. */
  53436. private _handleGamepadActions;
  53437. /**
  53438. * Update all non-event based devices with each frame
  53439. * @param deviceType Enum specifiying device type
  53440. * @param deviceSlot "Slot" or index that device is referenced in
  53441. * @param inputIndex Id of input to be checked
  53442. */
  53443. private _updateDevice;
  53444. /**
  53445. * Gets DeviceType from the device name
  53446. * @param deviceName Name of Device from DeviceInputSystem
  53447. * @returns DeviceType enum value
  53448. */
  53449. private _getGamepadDeviceType;
  53450. }
  53451. }
  53452. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53453. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53454. /**
  53455. * Type to handle enforcement of inputs
  53456. */
  53457. 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;
  53458. }
  53459. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53460. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53461. import { Engine } from "babylonjs/Engines/engine";
  53462. import { IDisposable } from "babylonjs/scene";
  53463. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53464. import { Nullable } from "babylonjs/types";
  53465. import { Observable } from "babylonjs/Misc/observable";
  53466. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53467. /**
  53468. * Class that handles all input for a specific device
  53469. */
  53470. export class DeviceSource<T extends DeviceType> {
  53471. /** Type of device */
  53472. readonly deviceType: DeviceType;
  53473. /** "Slot" or index that device is referenced in */
  53474. readonly deviceSlot: number;
  53475. /**
  53476. * Observable to handle device input changes per device
  53477. */
  53478. readonly onInputChangedObservable: Observable<{
  53479. inputIndex: DeviceInput<T>;
  53480. previousState: Nullable<number>;
  53481. currentState: Nullable<number>;
  53482. }>;
  53483. private readonly _deviceInputSystem;
  53484. /**
  53485. * Default Constructor
  53486. * @param deviceInputSystem Reference to DeviceInputSystem
  53487. * @param deviceType Type of device
  53488. * @param deviceSlot "Slot" or index that device is referenced in
  53489. */
  53490. constructor(deviceInputSystem: DeviceInputSystem,
  53491. /** Type of device */
  53492. deviceType: DeviceType,
  53493. /** "Slot" or index that device is referenced in */
  53494. deviceSlot?: number);
  53495. /**
  53496. * Get input for specific input
  53497. * @param inputIndex index of specific input on device
  53498. * @returns Input value from DeviceInputSystem
  53499. */
  53500. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53501. }
  53502. /**
  53503. * Class to keep track of devices
  53504. */
  53505. export class DeviceSourceManager implements IDisposable {
  53506. /**
  53507. * Observable to be triggered when before a device is connected
  53508. */
  53509. readonly onBeforeDeviceConnectedObservable: Observable<{
  53510. deviceType: DeviceType;
  53511. deviceSlot: number;
  53512. }>;
  53513. /**
  53514. * Observable to be triggered when before a device is disconnected
  53515. */
  53516. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53517. deviceType: DeviceType;
  53518. deviceSlot: number;
  53519. }>;
  53520. /**
  53521. * Observable to be triggered when after a device is connected
  53522. */
  53523. readonly onAfterDeviceConnectedObservable: Observable<{
  53524. deviceType: DeviceType;
  53525. deviceSlot: number;
  53526. }>;
  53527. /**
  53528. * Observable to be triggered when after a device is disconnected
  53529. */
  53530. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53531. deviceType: DeviceType;
  53532. deviceSlot: number;
  53533. }>;
  53534. private readonly _devices;
  53535. private readonly _firstDevice;
  53536. private readonly _deviceInputSystem;
  53537. /**
  53538. * Default Constructor
  53539. * @param engine engine to pull input element from
  53540. */
  53541. constructor(engine: Engine);
  53542. /**
  53543. * Gets a DeviceSource, given a type and slot
  53544. * @param deviceType Enum specifying device type
  53545. * @param deviceSlot "Slot" or index that device is referenced in
  53546. * @returns DeviceSource object
  53547. */
  53548. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53549. /**
  53550. * Gets an array of DeviceSource objects for a given device type
  53551. * @param deviceType Enum specifying device type
  53552. * @returns Array of DeviceSource objects
  53553. */
  53554. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53555. /**
  53556. * Dispose of DeviceInputSystem and other parts
  53557. */
  53558. dispose(): void;
  53559. /**
  53560. * Function to add device name to device list
  53561. * @param deviceType Enum specifying device type
  53562. * @param deviceSlot "Slot" or index that device is referenced in
  53563. */
  53564. private _addDevice;
  53565. /**
  53566. * Function to remove device name to device list
  53567. * @param deviceType Enum specifying device type
  53568. * @param deviceSlot "Slot" or index that device is referenced in
  53569. */
  53570. private _removeDevice;
  53571. /**
  53572. * Updates array storing first connected device of each type
  53573. * @param type Type of Device
  53574. */
  53575. private _updateFirstDevices;
  53576. }
  53577. }
  53578. declare module "babylonjs/DeviceInput/index" {
  53579. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53580. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53581. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53582. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53583. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53584. }
  53585. declare module "babylonjs/Engines/nullEngine" {
  53586. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53587. import { Engine } from "babylonjs/Engines/engine";
  53588. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53589. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53591. import { Effect } from "babylonjs/Materials/effect";
  53592. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53593. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53594. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53595. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53596. /**
  53597. * Options to create the null engine
  53598. */
  53599. export class NullEngineOptions {
  53600. /**
  53601. * Render width (Default: 512)
  53602. */
  53603. renderWidth: number;
  53604. /**
  53605. * Render height (Default: 256)
  53606. */
  53607. renderHeight: number;
  53608. /**
  53609. * Texture size (Default: 512)
  53610. */
  53611. textureSize: number;
  53612. /**
  53613. * If delta time between frames should be constant
  53614. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53615. */
  53616. deterministicLockstep: boolean;
  53617. /**
  53618. * Maximum about of steps between frames (Default: 4)
  53619. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53620. */
  53621. lockstepMaxSteps: number;
  53622. /**
  53623. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53624. */
  53625. useHighPrecisionMatrix?: boolean;
  53626. }
  53627. /**
  53628. * The null engine class provides support for headless version of babylon.js.
  53629. * This can be used in server side scenario or for testing purposes
  53630. */
  53631. export class NullEngine extends Engine {
  53632. private _options;
  53633. /**
  53634. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53635. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53636. * @returns true if engine is in deterministic lock step mode
  53637. */
  53638. isDeterministicLockStep(): boolean;
  53639. /**
  53640. * Gets the max steps when engine is running in deterministic lock step
  53641. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53642. * @returns the max steps
  53643. */
  53644. getLockstepMaxSteps(): number;
  53645. /**
  53646. * Gets the current hardware scaling level.
  53647. * By default the hardware scaling level is computed from the window device ratio.
  53648. * 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.
  53649. * @returns a number indicating the current hardware scaling level
  53650. */
  53651. getHardwareScalingLevel(): number;
  53652. constructor(options?: NullEngineOptions);
  53653. /**
  53654. * Creates a vertex buffer
  53655. * @param vertices the data for the vertex buffer
  53656. * @returns the new WebGL static buffer
  53657. */
  53658. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53659. /**
  53660. * Creates a new index buffer
  53661. * @param indices defines the content of the index buffer
  53662. * @param updatable defines if the index buffer must be updatable
  53663. * @returns a new webGL buffer
  53664. */
  53665. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53666. /**
  53667. * Clear the current render buffer or the current render target (if any is set up)
  53668. * @param color defines the color to use
  53669. * @param backBuffer defines if the back buffer must be cleared
  53670. * @param depth defines if the depth buffer must be cleared
  53671. * @param stencil defines if the stencil buffer must be cleared
  53672. */
  53673. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53674. /**
  53675. * Gets the current render width
  53676. * @param useScreen defines if screen size must be used (or the current render target if any)
  53677. * @returns a number defining the current render width
  53678. */
  53679. getRenderWidth(useScreen?: boolean): number;
  53680. /**
  53681. * Gets the current render height
  53682. * @param useScreen defines if screen size must be used (or the current render target if any)
  53683. * @returns a number defining the current render height
  53684. */
  53685. getRenderHeight(useScreen?: boolean): number;
  53686. /**
  53687. * Set the WebGL's viewport
  53688. * @param viewport defines the viewport element to be used
  53689. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53690. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53691. */
  53692. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53693. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53694. /**
  53695. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53696. * @param pipelineContext defines the pipeline context to use
  53697. * @param uniformsNames defines the list of uniform names
  53698. * @returns an array of webGL uniform locations
  53699. */
  53700. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53701. /**
  53702. * Gets the lsit of active attributes for a given webGL program
  53703. * @param pipelineContext defines the pipeline context to use
  53704. * @param attributesNames defines the list of attribute names to get
  53705. * @returns an array of indices indicating the offset of each attribute
  53706. */
  53707. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53708. /**
  53709. * Binds an effect to the webGL context
  53710. * @param effect defines the effect to bind
  53711. */
  53712. bindSamplers(effect: Effect): void;
  53713. /**
  53714. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53715. * @param effect defines the effect to activate
  53716. */
  53717. enableEffect(effect: Effect): void;
  53718. /**
  53719. * Set various states to the webGL context
  53720. * @param culling defines backface culling state
  53721. * @param zOffset defines the value to apply to zOffset (0 by default)
  53722. * @param force defines if states must be applied even if cache is up to date
  53723. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53724. */
  53725. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53726. /**
  53727. * Set the value of an uniform to an array of int32
  53728. * @param uniform defines the webGL uniform location where to store the value
  53729. * @param array defines the array of int32 to store
  53730. */
  53731. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53732. /**
  53733. * Set the value of an uniform to an array of int32 (stored as vec2)
  53734. * @param uniform defines the webGL uniform location where to store the value
  53735. * @param array defines the array of int32 to store
  53736. */
  53737. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53738. /**
  53739. * Set the value of an uniform to an array of int32 (stored as vec3)
  53740. * @param uniform defines the webGL uniform location where to store the value
  53741. * @param array defines the array of int32 to store
  53742. */
  53743. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53744. /**
  53745. * Set the value of an uniform to an array of int32 (stored as vec4)
  53746. * @param uniform defines the webGL uniform location where to store the value
  53747. * @param array defines the array of int32 to store
  53748. */
  53749. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53750. /**
  53751. * Set the value of an uniform to an array of float32
  53752. * @param uniform defines the webGL uniform location where to store the value
  53753. * @param array defines the array of float32 to store
  53754. */
  53755. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53756. /**
  53757. * Set the value of an uniform to an array of float32 (stored as vec2)
  53758. * @param uniform defines the webGL uniform location where to store the value
  53759. * @param array defines the array of float32 to store
  53760. */
  53761. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53762. /**
  53763. * Set the value of an uniform to an array of float32 (stored as vec3)
  53764. * @param uniform defines the webGL uniform location where to store the value
  53765. * @param array defines the array of float32 to store
  53766. */
  53767. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53768. /**
  53769. * Set the value of an uniform to an array of float32 (stored as vec4)
  53770. * @param uniform defines the webGL uniform location where to store the value
  53771. * @param array defines the array of float32 to store
  53772. */
  53773. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53774. /**
  53775. * Set the value of an uniform to an array of number
  53776. * @param uniform defines the webGL uniform location where to store the value
  53777. * @param array defines the array of number to store
  53778. */
  53779. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53780. /**
  53781. * Set the value of an uniform to an array of number (stored as vec2)
  53782. * @param uniform defines the webGL uniform location where to store the value
  53783. * @param array defines the array of number to store
  53784. */
  53785. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53786. /**
  53787. * Set the value of an uniform to an array of number (stored as vec3)
  53788. * @param uniform defines the webGL uniform location where to store the value
  53789. * @param array defines the array of number to store
  53790. */
  53791. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53792. /**
  53793. * Set the value of an uniform to an array of number (stored as vec4)
  53794. * @param uniform defines the webGL uniform location where to store the value
  53795. * @param array defines the array of number to store
  53796. */
  53797. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53798. /**
  53799. * Set the value of an uniform to an array of float32 (stored as matrices)
  53800. * @param uniform defines the webGL uniform location where to store the value
  53801. * @param matrices defines the array of float32 to store
  53802. */
  53803. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53804. /**
  53805. * Set the value of an uniform to a matrix (3x3)
  53806. * @param uniform defines the webGL uniform location where to store the value
  53807. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53808. */
  53809. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53810. /**
  53811. * Set the value of an uniform to a matrix (2x2)
  53812. * @param uniform defines the webGL uniform location where to store the value
  53813. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53814. */
  53815. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53816. /**
  53817. * Set the value of an uniform to a number (float)
  53818. * @param uniform defines the webGL uniform location where to store the value
  53819. * @param value defines the float number to store
  53820. */
  53821. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53822. /**
  53823. * Set the value of an uniform to a vec2
  53824. * @param uniform defines the webGL uniform location where to store the value
  53825. * @param x defines the 1st component of the value
  53826. * @param y defines the 2nd component of the value
  53827. */
  53828. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53829. /**
  53830. * Set the value of an uniform to a vec3
  53831. * @param uniform defines the webGL uniform location where to store the value
  53832. * @param x defines the 1st component of the value
  53833. * @param y defines the 2nd component of the value
  53834. * @param z defines the 3rd component of the value
  53835. */
  53836. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53837. /**
  53838. * Set the value of an uniform to a boolean
  53839. * @param uniform defines the webGL uniform location where to store the value
  53840. * @param bool defines the boolean to store
  53841. */
  53842. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53843. /**
  53844. * Set the value of an uniform to a vec4
  53845. * @param uniform defines the webGL uniform location where to store the value
  53846. * @param x defines the 1st component of the value
  53847. * @param y defines the 2nd component of the value
  53848. * @param z defines the 3rd component of the value
  53849. * @param w defines the 4th component of the value
  53850. */
  53851. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53852. /**
  53853. * Sets the current alpha mode
  53854. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53855. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53856. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53857. */
  53858. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53859. /**
  53860. * Bind webGl buffers directly to the webGL context
  53861. * @param vertexBuffers defines the vertex buffer to bind
  53862. * @param indexBuffer defines the index buffer to bind
  53863. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53864. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53865. * @param effect defines the effect associated with the vertex buffer
  53866. */
  53867. bindBuffers(vertexBuffers: {
  53868. [key: string]: VertexBuffer;
  53869. }, indexBuffer: DataBuffer, effect: Effect): void;
  53870. /**
  53871. * Force the entire cache to be cleared
  53872. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53873. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53874. */
  53875. wipeCaches(bruteForce?: boolean): void;
  53876. /**
  53877. * Send a draw order
  53878. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53879. * @param indexStart defines the starting index
  53880. * @param indexCount defines the number of index to draw
  53881. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53882. */
  53883. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53884. /**
  53885. * Draw a list of indexed primitives
  53886. * @param fillMode defines the primitive to use
  53887. * @param indexStart defines the starting index
  53888. * @param indexCount defines the number of index to draw
  53889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53890. */
  53891. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53892. /**
  53893. * Draw a list of unindexed primitives
  53894. * @param fillMode defines the primitive to use
  53895. * @param verticesStart defines the index of first vertex to draw
  53896. * @param verticesCount defines the count of vertices to draw
  53897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53898. */
  53899. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53900. /** @hidden */
  53901. _createTexture(): WebGLTexture;
  53902. /** @hidden */
  53903. _releaseTexture(texture: InternalTexture): void;
  53904. /**
  53905. * Usually called from Texture.ts.
  53906. * Passed information to create a WebGLTexture
  53907. * @param urlArg defines a value which contains one of the following:
  53908. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53909. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53910. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53911. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53912. * @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)
  53913. * @param scene needed for loading to the correct scene
  53914. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53915. * @param onLoad optional callback to be called upon successful completion
  53916. * @param onError optional callback to be called upon failure
  53917. * @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
  53918. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53919. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53920. * @param forcedExtension defines the extension to use to pick the right loader
  53921. * @param mimeType defines an optional mime type
  53922. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53923. */
  53924. 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;
  53925. /**
  53926. * Creates a new render target texture
  53927. * @param size defines the size of the texture
  53928. * @param options defines the options used to create the texture
  53929. * @returns a new render target texture stored in an InternalTexture
  53930. */
  53931. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53932. /**
  53933. * Update the sampling mode of a given texture
  53934. * @param samplingMode defines the required sampling mode
  53935. * @param texture defines the texture to update
  53936. */
  53937. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53938. /**
  53939. * Binds the frame buffer to the specified texture.
  53940. * @param texture The texture to render to or null for the default canvas
  53941. * @param faceIndex The face of the texture to render to in case of cube texture
  53942. * @param requiredWidth The width of the target to render to
  53943. * @param requiredHeight The height of the target to render to
  53944. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53945. * @param lodLevel defines le lod level to bind to the frame buffer
  53946. */
  53947. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53948. /**
  53949. * Unbind the current render target texture from the webGL context
  53950. * @param texture defines the render target texture to unbind
  53951. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53952. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53953. */
  53954. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53955. /**
  53956. * Creates a dynamic vertex buffer
  53957. * @param vertices the data for the dynamic vertex buffer
  53958. * @returns the new WebGL dynamic buffer
  53959. */
  53960. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53961. /**
  53962. * Update the content of a dynamic texture
  53963. * @param texture defines the texture to update
  53964. * @param canvas defines the canvas containing the source
  53965. * @param invertY defines if data must be stored with Y axis inverted
  53966. * @param premulAlpha defines if alpha is stored as premultiplied
  53967. * @param format defines the format of the data
  53968. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53969. */
  53970. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53971. /**
  53972. * Gets a boolean indicating if all created effects are ready
  53973. * @returns true if all effects are ready
  53974. */
  53975. areAllEffectsReady(): boolean;
  53976. /**
  53977. * @hidden
  53978. * Get the current error code of the webGL context
  53979. * @returns the error code
  53980. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53981. */
  53982. getError(): number;
  53983. /** @hidden */
  53984. _getUnpackAlignement(): number;
  53985. /** @hidden */
  53986. _unpackFlipY(value: boolean): void;
  53987. /**
  53988. * Update a dynamic index buffer
  53989. * @param indexBuffer defines the target index buffer
  53990. * @param indices defines the data to update
  53991. * @param offset defines the offset in the target index buffer where update should start
  53992. */
  53993. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53994. /**
  53995. * Updates a dynamic vertex buffer.
  53996. * @param vertexBuffer the vertex buffer to update
  53997. * @param vertices the data used to update the vertex buffer
  53998. * @param byteOffset the byte offset of the data (optional)
  53999. * @param byteLength the byte length of the data (optional)
  54000. */
  54001. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54002. /** @hidden */
  54003. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54004. /** @hidden */
  54005. _bindTexture(channel: number, texture: InternalTexture): void;
  54006. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54007. /**
  54008. * 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
  54009. */
  54010. releaseEffects(): void;
  54011. displayLoadingUI(): void;
  54012. hideLoadingUI(): void;
  54013. /** @hidden */
  54014. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54015. /** @hidden */
  54016. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54017. /** @hidden */
  54018. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54019. /** @hidden */
  54020. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54021. }
  54022. }
  54023. declare module "babylonjs/Instrumentation/timeToken" {
  54024. import { Nullable } from "babylonjs/types";
  54025. /**
  54026. * @hidden
  54027. **/
  54028. export class _TimeToken {
  54029. _startTimeQuery: Nullable<WebGLQuery>;
  54030. _endTimeQuery: Nullable<WebGLQuery>;
  54031. _timeElapsedQuery: Nullable<WebGLQuery>;
  54032. _timeElapsedQueryEnded: boolean;
  54033. }
  54034. }
  54035. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54036. import { Nullable, int } from "babylonjs/types";
  54037. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54038. /** @hidden */
  54039. export class _OcclusionDataStorage {
  54040. /** @hidden */
  54041. occlusionInternalRetryCounter: number;
  54042. /** @hidden */
  54043. isOcclusionQueryInProgress: boolean;
  54044. /** @hidden */
  54045. isOccluded: boolean;
  54046. /** @hidden */
  54047. occlusionRetryCount: number;
  54048. /** @hidden */
  54049. occlusionType: number;
  54050. /** @hidden */
  54051. occlusionQueryAlgorithmType: number;
  54052. }
  54053. module "babylonjs/Engines/engine" {
  54054. interface Engine {
  54055. /**
  54056. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54057. * @return the new query
  54058. */
  54059. createQuery(): WebGLQuery;
  54060. /**
  54061. * Delete and release a webGL query
  54062. * @param query defines the query to delete
  54063. * @return the current engine
  54064. */
  54065. deleteQuery(query: WebGLQuery): Engine;
  54066. /**
  54067. * Check if a given query has resolved and got its value
  54068. * @param query defines the query to check
  54069. * @returns true if the query got its value
  54070. */
  54071. isQueryResultAvailable(query: WebGLQuery): boolean;
  54072. /**
  54073. * Gets the value of a given query
  54074. * @param query defines the query to check
  54075. * @returns the value of the query
  54076. */
  54077. getQueryResult(query: WebGLQuery): number;
  54078. /**
  54079. * Initiates an occlusion query
  54080. * @param algorithmType defines the algorithm to use
  54081. * @param query defines the query to use
  54082. * @returns the current engine
  54083. * @see https://doc.babylonjs.com/features/occlusionquery
  54084. */
  54085. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54086. /**
  54087. * Ends an occlusion query
  54088. * @see https://doc.babylonjs.com/features/occlusionquery
  54089. * @param algorithmType defines the algorithm to use
  54090. * @returns the current engine
  54091. */
  54092. endOcclusionQuery(algorithmType: number): Engine;
  54093. /**
  54094. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54095. * Please note that only one query can be issued at a time
  54096. * @returns a time token used to track the time span
  54097. */
  54098. startTimeQuery(): Nullable<_TimeToken>;
  54099. /**
  54100. * Ends a time query
  54101. * @param token defines the token used to measure the time span
  54102. * @returns the time spent (in ns)
  54103. */
  54104. endTimeQuery(token: _TimeToken): int;
  54105. /** @hidden */
  54106. _currentNonTimestampToken: Nullable<_TimeToken>;
  54107. /** @hidden */
  54108. _createTimeQuery(): WebGLQuery;
  54109. /** @hidden */
  54110. _deleteTimeQuery(query: WebGLQuery): void;
  54111. /** @hidden */
  54112. _getGlAlgorithmType(algorithmType: number): number;
  54113. /** @hidden */
  54114. _getTimeQueryResult(query: WebGLQuery): any;
  54115. /** @hidden */
  54116. _getTimeQueryAvailability(query: WebGLQuery): any;
  54117. }
  54118. }
  54119. module "babylonjs/Meshes/abstractMesh" {
  54120. interface AbstractMesh {
  54121. /**
  54122. * Backing filed
  54123. * @hidden
  54124. */
  54125. __occlusionDataStorage: _OcclusionDataStorage;
  54126. /**
  54127. * Access property
  54128. * @hidden
  54129. */
  54130. _occlusionDataStorage: _OcclusionDataStorage;
  54131. /**
  54132. * 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.
  54133. * The default value is -1 which means don't break the query and wait till the result
  54134. * @see https://doc.babylonjs.com/features/occlusionquery
  54135. */
  54136. occlusionRetryCount: number;
  54137. /**
  54138. * 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:
  54139. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54140. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54141. * * 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.
  54142. * @see https://doc.babylonjs.com/features/occlusionquery
  54143. */
  54144. occlusionType: number;
  54145. /**
  54146. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54147. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54148. * * 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.
  54149. * @see https://doc.babylonjs.com/features/occlusionquery
  54150. */
  54151. occlusionQueryAlgorithmType: number;
  54152. /**
  54153. * 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
  54154. * @see https://doc.babylonjs.com/features/occlusionquery
  54155. */
  54156. isOccluded: boolean;
  54157. /**
  54158. * Flag to check the progress status of the query
  54159. * @see https://doc.babylonjs.com/features/occlusionquery
  54160. */
  54161. isOcclusionQueryInProgress: boolean;
  54162. }
  54163. }
  54164. }
  54165. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54166. import { Nullable } from "babylonjs/types";
  54167. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54168. /** @hidden */
  54169. export var _forceTransformFeedbackToBundle: boolean;
  54170. module "babylonjs/Engines/engine" {
  54171. interface Engine {
  54172. /**
  54173. * Creates a webGL transform feedback object
  54174. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54175. * @returns the webGL transform feedback object
  54176. */
  54177. createTransformFeedback(): WebGLTransformFeedback;
  54178. /**
  54179. * Delete a webGL transform feedback object
  54180. * @param value defines the webGL transform feedback object to delete
  54181. */
  54182. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54183. /**
  54184. * Bind a webGL transform feedback object to the webgl context
  54185. * @param value defines the webGL transform feedback object to bind
  54186. */
  54187. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54188. /**
  54189. * Begins a transform feedback operation
  54190. * @param usePoints defines if points or triangles must be used
  54191. */
  54192. beginTransformFeedback(usePoints: boolean): void;
  54193. /**
  54194. * Ends a transform feedback operation
  54195. */
  54196. endTransformFeedback(): void;
  54197. /**
  54198. * Specify the varyings to use with transform feedback
  54199. * @param program defines the associated webGL program
  54200. * @param value defines the list of strings representing the varying names
  54201. */
  54202. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54203. /**
  54204. * Bind a webGL buffer for a transform feedback operation
  54205. * @param value defines the webGL buffer to bind
  54206. */
  54207. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54208. }
  54209. }
  54210. }
  54211. declare module "babylonjs/Engines/Extensions/engine.views" {
  54212. import { Camera } from "babylonjs/Cameras/camera";
  54213. import { Nullable } from "babylonjs/types";
  54214. /**
  54215. * Class used to define an additional view for the engine
  54216. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54217. */
  54218. export class EngineView {
  54219. /** Defines the canvas where to render the view */
  54220. target: HTMLCanvasElement;
  54221. /** Defines an optional camera used to render the view (will use active camera else) */
  54222. camera?: Camera;
  54223. }
  54224. module "babylonjs/Engines/engine" {
  54225. interface Engine {
  54226. /**
  54227. * Gets or sets the HTML element to use for attaching events
  54228. */
  54229. inputElement: Nullable<HTMLElement>;
  54230. /**
  54231. * Gets the current engine view
  54232. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54233. */
  54234. activeView: Nullable<EngineView>;
  54235. /** Gets or sets the list of views */
  54236. views: EngineView[];
  54237. /**
  54238. * Register a new child canvas
  54239. * @param canvas defines the canvas to register
  54240. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54241. * @returns the associated view
  54242. */
  54243. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54244. /**
  54245. * Remove a registered child canvas
  54246. * @param canvas defines the canvas to remove
  54247. * @returns the current engine
  54248. */
  54249. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54250. }
  54251. }
  54252. }
  54253. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54254. import { Nullable } from "babylonjs/types";
  54255. module "babylonjs/Engines/engine" {
  54256. interface Engine {
  54257. /** @hidden */
  54258. _excludedCompressedTextures: string[];
  54259. /** @hidden */
  54260. _textureFormatInUse: string;
  54261. /**
  54262. * Gets the list of texture formats supported
  54263. */
  54264. readonly texturesSupported: Array<string>;
  54265. /**
  54266. * Gets the texture format in use
  54267. */
  54268. readonly textureFormatInUse: Nullable<string>;
  54269. /**
  54270. * Set the compressed texture extensions or file names to skip.
  54271. *
  54272. * @param skippedFiles defines the list of those texture files you want to skip
  54273. * Example: [".dds", ".env", "myfile.png"]
  54274. */
  54275. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54276. /**
  54277. * Set the compressed texture format to use, based on the formats you have, and the formats
  54278. * supported by the hardware / browser.
  54279. *
  54280. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54281. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54282. * to API arguments needed to compressed textures. This puts the burden on the container
  54283. * generator to house the arcane code for determining these for current & future formats.
  54284. *
  54285. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54286. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54287. *
  54288. * Note: The result of this call is not taken into account when a texture is base64.
  54289. *
  54290. * @param formatsAvailable defines the list of those format families you have created
  54291. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54292. *
  54293. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54294. * @returns The extension selected.
  54295. */
  54296. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54297. }
  54298. }
  54299. }
  54300. declare module "babylonjs/Engines/Extensions/index" {
  54301. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54302. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54303. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54304. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54305. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54306. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54307. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54308. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54309. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54310. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54311. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54312. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54313. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54314. export * from "babylonjs/Engines/Extensions/engine.views";
  54315. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54316. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54317. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54318. }
  54319. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54320. import { Nullable } from "babylonjs/types";
  54321. /**
  54322. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54323. */
  54324. export interface CubeMapInfo {
  54325. /**
  54326. * The pixel array for the front face.
  54327. * This is stored in format, left to right, up to down format.
  54328. */
  54329. front: Nullable<ArrayBufferView>;
  54330. /**
  54331. * The pixel array for the back face.
  54332. * This is stored in format, left to right, up to down format.
  54333. */
  54334. back: Nullable<ArrayBufferView>;
  54335. /**
  54336. * The pixel array for the left face.
  54337. * This is stored in format, left to right, up to down format.
  54338. */
  54339. left: Nullable<ArrayBufferView>;
  54340. /**
  54341. * The pixel array for the right face.
  54342. * This is stored in format, left to right, up to down format.
  54343. */
  54344. right: Nullable<ArrayBufferView>;
  54345. /**
  54346. * The pixel array for the up face.
  54347. * This is stored in format, left to right, up to down format.
  54348. */
  54349. up: Nullable<ArrayBufferView>;
  54350. /**
  54351. * The pixel array for the down face.
  54352. * This is stored in format, left to right, up to down format.
  54353. */
  54354. down: Nullable<ArrayBufferView>;
  54355. /**
  54356. * The size of the cubemap stored.
  54357. *
  54358. * Each faces will be size * size pixels.
  54359. */
  54360. size: number;
  54361. /**
  54362. * The format of the texture.
  54363. *
  54364. * RGBA, RGB.
  54365. */
  54366. format: number;
  54367. /**
  54368. * The type of the texture data.
  54369. *
  54370. * UNSIGNED_INT, FLOAT.
  54371. */
  54372. type: number;
  54373. /**
  54374. * Specifies whether the texture is in gamma space.
  54375. */
  54376. gammaSpace: boolean;
  54377. }
  54378. /**
  54379. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54380. */
  54381. export class PanoramaToCubeMapTools {
  54382. private static FACE_LEFT;
  54383. private static FACE_RIGHT;
  54384. private static FACE_FRONT;
  54385. private static FACE_BACK;
  54386. private static FACE_DOWN;
  54387. private static FACE_UP;
  54388. /**
  54389. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54390. *
  54391. * @param float32Array The source data.
  54392. * @param inputWidth The width of the input panorama.
  54393. * @param inputHeight The height of the input panorama.
  54394. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54395. * @return The cubemap data
  54396. */
  54397. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54398. private static CreateCubemapTexture;
  54399. private static CalcProjectionSpherical;
  54400. }
  54401. }
  54402. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54403. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54405. import { Nullable } from "babylonjs/types";
  54406. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54407. /**
  54408. * Helper class dealing with the extraction of spherical polynomial dataArray
  54409. * from a cube map.
  54410. */
  54411. export class CubeMapToSphericalPolynomialTools {
  54412. private static FileFaces;
  54413. /**
  54414. * Converts a texture to the according Spherical Polynomial data.
  54415. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54416. *
  54417. * @param texture The texture to extract the information from.
  54418. * @return The Spherical Polynomial data.
  54419. */
  54420. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54421. /**
  54422. * Converts a cubemap to the according Spherical Polynomial data.
  54423. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54424. *
  54425. * @param cubeInfo The Cube map to extract the information from.
  54426. * @return The Spherical Polynomial data.
  54427. */
  54428. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54429. }
  54430. }
  54431. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54432. import { Nullable } from "babylonjs/types";
  54433. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54434. module "babylonjs/Materials/Textures/baseTexture" {
  54435. interface BaseTexture {
  54436. /**
  54437. * Get the polynomial representation of the texture data.
  54438. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54439. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54440. */
  54441. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54442. }
  54443. }
  54444. }
  54445. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54446. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54447. /** @hidden */
  54448. export var rgbdEncodePixelShader: {
  54449. name: string;
  54450. shader: string;
  54451. };
  54452. }
  54453. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54455. /** @hidden */
  54456. export var rgbdDecodePixelShader: {
  54457. name: string;
  54458. shader: string;
  54459. };
  54460. }
  54461. declare module "babylonjs/Misc/environmentTextureTools" {
  54462. import { Nullable } from "babylonjs/types";
  54463. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54466. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54467. import "babylonjs/Engines/Extensions/engine.readTexture";
  54468. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54469. import "babylonjs/Shaders/rgbdEncode.fragment";
  54470. import "babylonjs/Shaders/rgbdDecode.fragment";
  54471. /**
  54472. * Raw texture data and descriptor sufficient for WebGL texture upload
  54473. */
  54474. export interface EnvironmentTextureInfo {
  54475. /**
  54476. * Version of the environment map
  54477. */
  54478. version: number;
  54479. /**
  54480. * Width of image
  54481. */
  54482. width: number;
  54483. /**
  54484. * Irradiance information stored in the file.
  54485. */
  54486. irradiance: any;
  54487. /**
  54488. * Specular information stored in the file.
  54489. */
  54490. specular: any;
  54491. }
  54492. /**
  54493. * Defines One Image in the file. It requires only the position in the file
  54494. * as well as the length.
  54495. */
  54496. interface BufferImageData {
  54497. /**
  54498. * Length of the image data.
  54499. */
  54500. length: number;
  54501. /**
  54502. * Position of the data from the null terminator delimiting the end of the JSON.
  54503. */
  54504. position: number;
  54505. }
  54506. /**
  54507. * Defines the specular data enclosed in the file.
  54508. * This corresponds to the version 1 of the data.
  54509. */
  54510. export interface EnvironmentTextureSpecularInfoV1 {
  54511. /**
  54512. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54513. */
  54514. specularDataPosition?: number;
  54515. /**
  54516. * This contains all the images data needed to reconstruct the cubemap.
  54517. */
  54518. mipmaps: Array<BufferImageData>;
  54519. /**
  54520. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54521. */
  54522. lodGenerationScale: number;
  54523. }
  54524. /**
  54525. * Sets of helpers addressing the serialization and deserialization of environment texture
  54526. * stored in a BabylonJS env file.
  54527. * Those files are usually stored as .env files.
  54528. */
  54529. export class EnvironmentTextureTools {
  54530. /**
  54531. * Magic number identifying the env file.
  54532. */
  54533. private static _MagicBytes;
  54534. /**
  54535. * Gets the environment info from an env file.
  54536. * @param data The array buffer containing the .env bytes.
  54537. * @returns the environment file info (the json header) if successfully parsed.
  54538. */
  54539. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54540. /**
  54541. * Creates an environment texture from a loaded cube texture.
  54542. * @param texture defines the cube texture to convert in env file
  54543. * @return a promise containing the environment data if succesfull.
  54544. */
  54545. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54546. /**
  54547. * Creates a JSON representation of the spherical data.
  54548. * @param texture defines the texture containing the polynomials
  54549. * @return the JSON representation of the spherical info
  54550. */
  54551. private static _CreateEnvTextureIrradiance;
  54552. /**
  54553. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54554. * @param data the image data
  54555. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54556. * @return the views described by info providing access to the underlying buffer
  54557. */
  54558. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54559. /**
  54560. * Uploads the texture info contained in the env file to the GPU.
  54561. * @param texture defines the internal texture to upload to
  54562. * @param data defines the data to load
  54563. * @param info defines the texture info retrieved through the GetEnvInfo method
  54564. * @returns a promise
  54565. */
  54566. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54567. private static _OnImageReadyAsync;
  54568. /**
  54569. * Uploads the levels of image data to the GPU.
  54570. * @param texture defines the internal texture to upload to
  54571. * @param imageData defines the array buffer views of image data [mipmap][face]
  54572. * @returns a promise
  54573. */
  54574. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54575. /**
  54576. * Uploads spherical polynomials information to the texture.
  54577. * @param texture defines the texture we are trying to upload the information to
  54578. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54579. */
  54580. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54581. /** @hidden */
  54582. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54583. }
  54584. }
  54585. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54586. /**
  54587. * Class used to inline functions in shader code
  54588. */
  54589. export class ShaderCodeInliner {
  54590. private static readonly _RegexpFindFunctionNameAndType;
  54591. private _sourceCode;
  54592. private _functionDescr;
  54593. private _numMaxIterations;
  54594. /** Gets or sets the token used to mark the functions to inline */
  54595. inlineToken: string;
  54596. /** Gets or sets the debug mode */
  54597. debug: boolean;
  54598. /** Gets the code after the inlining process */
  54599. get code(): string;
  54600. /**
  54601. * Initializes the inliner
  54602. * @param sourceCode shader code source to inline
  54603. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54604. */
  54605. constructor(sourceCode: string, numMaxIterations?: number);
  54606. /**
  54607. * Start the processing of the shader code
  54608. */
  54609. processCode(): void;
  54610. private _collectFunctions;
  54611. private _processInlining;
  54612. private _extractBetweenMarkers;
  54613. private _skipWhitespaces;
  54614. private _removeComments;
  54615. private _replaceFunctionCallsByCode;
  54616. private _findBackward;
  54617. private _escapeRegExp;
  54618. private _replaceNames;
  54619. }
  54620. }
  54621. declare module "babylonjs/Engines/nativeEngine" {
  54622. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54623. import { Engine } from "babylonjs/Engines/engine";
  54624. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54625. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54627. import { Effect } from "babylonjs/Materials/effect";
  54628. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54629. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54630. import { IColor4Like } from "babylonjs/Maths/math.like";
  54631. import { Scene } from "babylonjs/scene";
  54632. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54633. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54634. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54635. /**
  54636. * Container for accessors for natively-stored mesh data buffers.
  54637. */
  54638. class NativeDataBuffer extends DataBuffer {
  54639. /**
  54640. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54641. */
  54642. nativeIndexBuffer?: any;
  54643. /**
  54644. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54645. */
  54646. nativeVertexBuffer?: any;
  54647. }
  54648. /** @hidden */
  54649. class NativeTexture extends InternalTexture {
  54650. getInternalTexture(): InternalTexture;
  54651. getViewCount(): number;
  54652. }
  54653. /** @hidden */
  54654. export class NativeEngine extends Engine {
  54655. private readonly _native;
  54656. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54657. private readonly INVALID_HANDLE;
  54658. private _boundBuffersVertexArray;
  54659. getHardwareScalingLevel(): number;
  54660. constructor();
  54661. dispose(): void;
  54662. /**
  54663. * Can be used to override the current requestAnimationFrame requester.
  54664. * @hidden
  54665. */
  54666. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54667. /**
  54668. * Override default engine behavior.
  54669. * @param color
  54670. * @param backBuffer
  54671. * @param depth
  54672. * @param stencil
  54673. */
  54674. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54675. /**
  54676. * Gets host document
  54677. * @returns the host document object
  54678. */
  54679. getHostDocument(): Nullable<Document>;
  54680. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54681. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54682. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54683. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54684. [key: string]: VertexBuffer;
  54685. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54686. bindBuffers(vertexBuffers: {
  54687. [key: string]: VertexBuffer;
  54688. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54689. recordVertexArrayObject(vertexBuffers: {
  54690. [key: string]: VertexBuffer;
  54691. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54692. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54693. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54694. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54695. /**
  54696. * Draw a list of indexed primitives
  54697. * @param fillMode defines the primitive to use
  54698. * @param indexStart defines the starting index
  54699. * @param indexCount defines the number of index to draw
  54700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54701. */
  54702. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54703. /**
  54704. * Draw a list of unindexed primitives
  54705. * @param fillMode defines the primitive to use
  54706. * @param verticesStart defines the index of first vertex to draw
  54707. * @param verticesCount defines the count of vertices to draw
  54708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54709. */
  54710. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54711. createPipelineContext(): IPipelineContext;
  54712. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54713. /** @hidden */
  54714. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54715. /** @hidden */
  54716. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54717. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54718. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54719. protected _setProgram(program: WebGLProgram): void;
  54720. _releaseEffect(effect: Effect): void;
  54721. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54722. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54723. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54724. bindSamplers(effect: Effect): void;
  54725. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54726. getRenderWidth(useScreen?: boolean): number;
  54727. getRenderHeight(useScreen?: boolean): number;
  54728. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54730. /**
  54731. * Set the z offset to apply to current rendering
  54732. * @param value defines the offset to apply
  54733. */
  54734. setZOffset(value: number): void;
  54735. /**
  54736. * Gets the current value of the zOffset
  54737. * @returns the current zOffset state
  54738. */
  54739. getZOffset(): number;
  54740. /**
  54741. * Enable or disable depth buffering
  54742. * @param enable defines the state to set
  54743. */
  54744. setDepthBuffer(enable: boolean): void;
  54745. /**
  54746. * Gets a boolean indicating if depth writing is enabled
  54747. * @returns the current depth writing state
  54748. */
  54749. getDepthWrite(): boolean;
  54750. /**
  54751. * Enable or disable depth writing
  54752. * @param enable defines the state to set
  54753. */
  54754. setDepthWrite(enable: boolean): void;
  54755. /**
  54756. * Enable or disable color writing
  54757. * @param enable defines the state to set
  54758. */
  54759. setColorWrite(enable: boolean): void;
  54760. /**
  54761. * Gets a boolean indicating if color writing is enabled
  54762. * @returns the current color writing state
  54763. */
  54764. getColorWrite(): boolean;
  54765. /**
  54766. * Sets alpha constants used by some alpha blending modes
  54767. * @param r defines the red component
  54768. * @param g defines the green component
  54769. * @param b defines the blue component
  54770. * @param a defines the alpha component
  54771. */
  54772. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54773. /**
  54774. * Sets the current alpha mode
  54775. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54776. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54777. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54778. */
  54779. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54780. /**
  54781. * Gets the current alpha mode
  54782. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54783. * @returns the current alpha mode
  54784. */
  54785. getAlphaMode(): number;
  54786. setInt(uniform: WebGLUniformLocation, int: number): void;
  54787. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54788. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54789. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54790. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54791. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54792. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54793. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54794. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54795. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54796. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54797. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54798. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54799. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54800. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54801. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54802. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54803. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54804. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54805. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54806. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54807. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54808. wipeCaches(bruteForce?: boolean): void;
  54809. _createTexture(): WebGLTexture;
  54810. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54811. /**
  54812. * Usually called from Texture.ts.
  54813. * Passed information to create a WebGLTexture
  54814. * @param url defines a value which contains one of the following:
  54815. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54816. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54817. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54818. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54819. * @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)
  54820. * @param scene needed for loading to the correct scene
  54821. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54822. * @param onLoad optional callback to be called upon successful completion
  54823. * @param onError optional callback to be called upon failure
  54824. * @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
  54825. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54826. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54827. * @param forcedExtension defines the extension to use to pick the right loader
  54828. * @param mimeType defines an optional mime type
  54829. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54830. */
  54831. 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;
  54832. /**
  54833. * Creates a cube texture
  54834. * @param rootUrl defines the url where the files to load is located
  54835. * @param scene defines the current scene
  54836. * @param files defines the list of files to load (1 per face)
  54837. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54838. * @param onLoad defines an optional callback raised when the texture is loaded
  54839. * @param onError defines an optional callback raised if there is an issue to load the texture
  54840. * @param format defines the format of the data
  54841. * @param forcedExtension defines the extension to use to pick the right loader
  54842. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54843. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54844. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54845. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54846. * @returns the cube texture as an InternalTexture
  54847. */
  54848. 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;
  54849. private _getSamplingFilter;
  54850. private static _GetNativeTextureFormat;
  54851. createRenderTargetTexture(size: number | {
  54852. width: number;
  54853. height: number;
  54854. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54855. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54856. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54857. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54858. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54859. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54860. /**
  54861. * Updates a dynamic vertex buffer.
  54862. * @param vertexBuffer the vertex buffer to update
  54863. * @param data the data used to update the vertex buffer
  54864. * @param byteOffset the byte offset of the data (optional)
  54865. * @param byteLength the byte length of the data (optional)
  54866. */
  54867. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54868. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54869. private _updateAnisotropicLevel;
  54870. private _getAddressMode;
  54871. /** @hidden */
  54872. _bindTexture(channel: number, texture: InternalTexture): void;
  54873. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54874. releaseEffects(): void;
  54875. /** @hidden */
  54876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54877. /** @hidden */
  54878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54879. /** @hidden */
  54880. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54881. /** @hidden */
  54882. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54883. }
  54884. }
  54885. declare module "babylonjs/Engines/index" {
  54886. export * from "babylonjs/Engines/constants";
  54887. export * from "babylonjs/Engines/engineCapabilities";
  54888. export * from "babylonjs/Engines/instancingAttributeInfo";
  54889. export * from "babylonjs/Engines/thinEngine";
  54890. export * from "babylonjs/Engines/engine";
  54891. export * from "babylonjs/Engines/engineStore";
  54892. export * from "babylonjs/Engines/nullEngine";
  54893. export * from "babylonjs/Engines/Extensions/index";
  54894. export * from "babylonjs/Engines/IPipelineContext";
  54895. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54896. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54897. export * from "babylonjs/Engines/nativeEngine";
  54898. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54899. export * from "babylonjs/Engines/performanceConfigurator";
  54900. }
  54901. declare module "babylonjs/Events/clipboardEvents" {
  54902. /**
  54903. * Gather the list of clipboard event types as constants.
  54904. */
  54905. export class ClipboardEventTypes {
  54906. /**
  54907. * The clipboard event is fired when a copy command is active (pressed).
  54908. */
  54909. static readonly COPY: number;
  54910. /**
  54911. * The clipboard event is fired when a cut command is active (pressed).
  54912. */
  54913. static readonly CUT: number;
  54914. /**
  54915. * The clipboard event is fired when a paste command is active (pressed).
  54916. */
  54917. static readonly PASTE: number;
  54918. }
  54919. /**
  54920. * This class is used to store clipboard related info for the onClipboardObservable event.
  54921. */
  54922. export class ClipboardInfo {
  54923. /**
  54924. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54925. */
  54926. type: number;
  54927. /**
  54928. * Defines the related dom event
  54929. */
  54930. event: ClipboardEvent;
  54931. /**
  54932. *Creates an instance of ClipboardInfo.
  54933. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54934. * @param event Defines the related dom event
  54935. */
  54936. constructor(
  54937. /**
  54938. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54939. */
  54940. type: number,
  54941. /**
  54942. * Defines the related dom event
  54943. */
  54944. event: ClipboardEvent);
  54945. /**
  54946. * Get the clipboard event's type from the keycode.
  54947. * @param keyCode Defines the keyCode for the current keyboard event.
  54948. * @return {number}
  54949. */
  54950. static GetTypeFromCharacter(keyCode: number): number;
  54951. }
  54952. }
  54953. declare module "babylonjs/Events/index" {
  54954. export * from "babylonjs/Events/keyboardEvents";
  54955. export * from "babylonjs/Events/pointerEvents";
  54956. export * from "babylonjs/Events/clipboardEvents";
  54957. }
  54958. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54959. import { Scene } from "babylonjs/scene";
  54960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54961. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54962. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54963. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54964. /**
  54965. * Google Daydream controller
  54966. */
  54967. export class DaydreamController extends WebVRController {
  54968. /**
  54969. * Base Url for the controller model.
  54970. */
  54971. static MODEL_BASE_URL: string;
  54972. /**
  54973. * File name for the controller model.
  54974. */
  54975. static MODEL_FILENAME: string;
  54976. /**
  54977. * Gamepad Id prefix used to identify Daydream Controller.
  54978. */
  54979. static readonly GAMEPAD_ID_PREFIX: string;
  54980. /**
  54981. * Creates a new DaydreamController from a gamepad
  54982. * @param vrGamepad the gamepad that the controller should be created from
  54983. */
  54984. constructor(vrGamepad: any);
  54985. /**
  54986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54987. * @param scene scene in which to add meshes
  54988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54989. */
  54990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54991. /**
  54992. * Called once for each button that changed state since the last frame
  54993. * @param buttonIdx Which button index changed
  54994. * @param state New state of the button
  54995. * @param changes Which properties on the state changed since last frame
  54996. */
  54997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54998. }
  54999. }
  55000. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55001. import { Scene } from "babylonjs/scene";
  55002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55003. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55004. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55005. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55006. /**
  55007. * Gear VR Controller
  55008. */
  55009. export class GearVRController extends WebVRController {
  55010. /**
  55011. * Base Url for the controller model.
  55012. */
  55013. static MODEL_BASE_URL: string;
  55014. /**
  55015. * File name for the controller model.
  55016. */
  55017. static MODEL_FILENAME: string;
  55018. /**
  55019. * Gamepad Id prefix used to identify this controller.
  55020. */
  55021. static readonly GAMEPAD_ID_PREFIX: string;
  55022. private readonly _buttonIndexToObservableNameMap;
  55023. /**
  55024. * Creates a new GearVRController from a gamepad
  55025. * @param vrGamepad the gamepad that the controller should be created from
  55026. */
  55027. constructor(vrGamepad: any);
  55028. /**
  55029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55030. * @param scene scene in which to add meshes
  55031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55032. */
  55033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55034. /**
  55035. * Called once for each button that changed state since the last frame
  55036. * @param buttonIdx Which button index changed
  55037. * @param state New state of the button
  55038. * @param changes Which properties on the state changed since last frame
  55039. */
  55040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55041. }
  55042. }
  55043. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55044. import { Scene } from "babylonjs/scene";
  55045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55046. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55047. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55048. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55049. /**
  55050. * Generic Controller
  55051. */
  55052. export class GenericController extends WebVRController {
  55053. /**
  55054. * Base Url for the controller model.
  55055. */
  55056. static readonly MODEL_BASE_URL: string;
  55057. /**
  55058. * File name for the controller model.
  55059. */
  55060. static readonly MODEL_FILENAME: string;
  55061. /**
  55062. * Creates a new GenericController from a gamepad
  55063. * @param vrGamepad the gamepad that the controller should be created from
  55064. */
  55065. constructor(vrGamepad: any);
  55066. /**
  55067. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55068. * @param scene scene in which to add meshes
  55069. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55070. */
  55071. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55072. /**
  55073. * Called once for each button that changed state since the last frame
  55074. * @param buttonIdx Which button index changed
  55075. * @param state New state of the button
  55076. * @param changes Which properties on the state changed since last frame
  55077. */
  55078. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55079. }
  55080. }
  55081. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55082. import { Observable } from "babylonjs/Misc/observable";
  55083. import { Scene } from "babylonjs/scene";
  55084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55085. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55086. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55087. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55088. /**
  55089. * Oculus Touch Controller
  55090. */
  55091. export class OculusTouchController extends WebVRController {
  55092. /**
  55093. * Base Url for the controller model.
  55094. */
  55095. static MODEL_BASE_URL: string;
  55096. /**
  55097. * File name for the left controller model.
  55098. */
  55099. static MODEL_LEFT_FILENAME: string;
  55100. /**
  55101. * File name for the right controller model.
  55102. */
  55103. static MODEL_RIGHT_FILENAME: string;
  55104. /**
  55105. * Base Url for the Quest controller model.
  55106. */
  55107. static QUEST_MODEL_BASE_URL: string;
  55108. /**
  55109. * @hidden
  55110. * If the controllers are running on a device that needs the updated Quest controller models
  55111. */
  55112. static _IsQuest: boolean;
  55113. /**
  55114. * Fired when the secondary trigger on this controller is modified
  55115. */
  55116. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55117. /**
  55118. * Fired when the thumb rest on this controller is modified
  55119. */
  55120. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55121. /**
  55122. * Creates a new OculusTouchController from a gamepad
  55123. * @param vrGamepad the gamepad that the controller should be created from
  55124. */
  55125. constructor(vrGamepad: any);
  55126. /**
  55127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55128. * @param scene scene in which to add meshes
  55129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55130. */
  55131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55132. /**
  55133. * Fired when the A button on this controller is modified
  55134. */
  55135. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55136. /**
  55137. * Fired when the B button on this controller is modified
  55138. */
  55139. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55140. /**
  55141. * Fired when the X button on this controller is modified
  55142. */
  55143. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55144. /**
  55145. * Fired when the Y button on this controller is modified
  55146. */
  55147. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55148. /**
  55149. * Called once for each button that changed state since the last frame
  55150. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55151. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55152. * 2) secondary trigger (same)
  55153. * 3) A (right) X (left), touch, pressed = value
  55154. * 4) B / Y
  55155. * 5) thumb rest
  55156. * @param buttonIdx Which button index changed
  55157. * @param state New state of the button
  55158. * @param changes Which properties on the state changed since last frame
  55159. */
  55160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55161. }
  55162. }
  55163. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55164. import { Scene } from "babylonjs/scene";
  55165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55166. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55167. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55168. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55169. import { Observable } from "babylonjs/Misc/observable";
  55170. /**
  55171. * Vive Controller
  55172. */
  55173. export class ViveController extends WebVRController {
  55174. /**
  55175. * Base Url for the controller model.
  55176. */
  55177. static MODEL_BASE_URL: string;
  55178. /**
  55179. * File name for the controller model.
  55180. */
  55181. static MODEL_FILENAME: string;
  55182. /**
  55183. * Creates a new ViveController from a gamepad
  55184. * @param vrGamepad the gamepad that the controller should be created from
  55185. */
  55186. constructor(vrGamepad: any);
  55187. /**
  55188. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55189. * @param scene scene in which to add meshes
  55190. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55191. */
  55192. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55193. /**
  55194. * Fired when the left button on this controller is modified
  55195. */
  55196. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55197. /**
  55198. * Fired when the right button on this controller is modified
  55199. */
  55200. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55201. /**
  55202. * Fired when the menu button on this controller is modified
  55203. */
  55204. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55205. /**
  55206. * Called once for each button that changed state since the last frame
  55207. * Vive mapping:
  55208. * 0: touchpad
  55209. * 1: trigger
  55210. * 2: left AND right buttons
  55211. * 3: menu button
  55212. * @param buttonIdx Which button index changed
  55213. * @param state New state of the button
  55214. * @param changes Which properties on the state changed since last frame
  55215. */
  55216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55217. }
  55218. }
  55219. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55220. import { Observable } from "babylonjs/Misc/observable";
  55221. import { Scene } from "babylonjs/scene";
  55222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55223. import { Ray } from "babylonjs/Culling/ray";
  55224. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55225. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55226. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55227. /**
  55228. * Defines the WindowsMotionController object that the state of the windows motion controller
  55229. */
  55230. export class WindowsMotionController extends WebVRController {
  55231. /**
  55232. * The base url used to load the left and right controller models
  55233. */
  55234. static MODEL_BASE_URL: string;
  55235. /**
  55236. * The name of the left controller model file
  55237. */
  55238. static MODEL_LEFT_FILENAME: string;
  55239. /**
  55240. * The name of the right controller model file
  55241. */
  55242. static MODEL_RIGHT_FILENAME: string;
  55243. /**
  55244. * The controller name prefix for this controller type
  55245. */
  55246. static readonly GAMEPAD_ID_PREFIX: string;
  55247. /**
  55248. * The controller id pattern for this controller type
  55249. */
  55250. private static readonly GAMEPAD_ID_PATTERN;
  55251. private _loadedMeshInfo;
  55252. protected readonly _mapping: {
  55253. buttons: string[];
  55254. buttonMeshNames: {
  55255. trigger: string;
  55256. menu: string;
  55257. grip: string;
  55258. thumbstick: string;
  55259. trackpad: string;
  55260. };
  55261. buttonObservableNames: {
  55262. trigger: string;
  55263. menu: string;
  55264. grip: string;
  55265. thumbstick: string;
  55266. trackpad: string;
  55267. };
  55268. axisMeshNames: string[];
  55269. pointingPoseMeshName: string;
  55270. };
  55271. /**
  55272. * Fired when the trackpad on this controller is clicked
  55273. */
  55274. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55275. /**
  55276. * Fired when the trackpad on this controller is modified
  55277. */
  55278. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55279. /**
  55280. * The current x and y values of this controller's trackpad
  55281. */
  55282. trackpad: StickValues;
  55283. /**
  55284. * Creates a new WindowsMotionController from a gamepad
  55285. * @param vrGamepad the gamepad that the controller should be created from
  55286. */
  55287. constructor(vrGamepad: any);
  55288. /**
  55289. * Fired when the trigger on this controller is modified
  55290. */
  55291. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55292. /**
  55293. * Fired when the menu button on this controller is modified
  55294. */
  55295. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55296. /**
  55297. * Fired when the grip button on this controller is modified
  55298. */
  55299. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55300. /**
  55301. * Fired when the thumbstick button on this controller is modified
  55302. */
  55303. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55304. /**
  55305. * Fired when the touchpad button on this controller is modified
  55306. */
  55307. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55308. /**
  55309. * Fired when the touchpad values on this controller are modified
  55310. */
  55311. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55312. protected _updateTrackpad(): void;
  55313. /**
  55314. * Called once per frame by the engine.
  55315. */
  55316. update(): void;
  55317. /**
  55318. * Called once for each button that changed state since the last frame
  55319. * @param buttonIdx Which button index changed
  55320. * @param state New state of the button
  55321. * @param changes Which properties on the state changed since last frame
  55322. */
  55323. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55324. /**
  55325. * Moves the buttons on the controller mesh based on their current state
  55326. * @param buttonName the name of the button to move
  55327. * @param buttonValue the value of the button which determines the buttons new position
  55328. */
  55329. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55330. /**
  55331. * Moves the axis on the controller mesh based on its current state
  55332. * @param axis the index of the axis
  55333. * @param axisValue the value of the axis which determines the meshes new position
  55334. * @hidden
  55335. */
  55336. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55337. /**
  55338. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55339. * @param scene scene in which to add meshes
  55340. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55341. */
  55342. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55343. /**
  55344. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55345. * can be transformed by button presses and axes values, based on this._mapping.
  55346. *
  55347. * @param scene scene in which the meshes exist
  55348. * @param meshes list of meshes that make up the controller model to process
  55349. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55350. */
  55351. private processModel;
  55352. private createMeshInfo;
  55353. /**
  55354. * Gets the ray of the controller in the direction the controller is pointing
  55355. * @param length the length the resulting ray should be
  55356. * @returns a ray in the direction the controller is pointing
  55357. */
  55358. getForwardRay(length?: number): Ray;
  55359. /**
  55360. * Disposes of the controller
  55361. */
  55362. dispose(): void;
  55363. }
  55364. /**
  55365. * This class represents a new windows motion controller in XR.
  55366. */
  55367. export class XRWindowsMotionController extends WindowsMotionController {
  55368. /**
  55369. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55370. */
  55371. protected readonly _mapping: {
  55372. buttons: string[];
  55373. buttonMeshNames: {
  55374. trigger: string;
  55375. menu: string;
  55376. grip: string;
  55377. thumbstick: string;
  55378. trackpad: string;
  55379. };
  55380. buttonObservableNames: {
  55381. trigger: string;
  55382. menu: string;
  55383. grip: string;
  55384. thumbstick: string;
  55385. trackpad: string;
  55386. };
  55387. axisMeshNames: string[];
  55388. pointingPoseMeshName: string;
  55389. };
  55390. /**
  55391. * Construct a new XR-Based windows motion controller
  55392. *
  55393. * @param gamepadInfo the gamepad object from the browser
  55394. */
  55395. constructor(gamepadInfo: any);
  55396. /**
  55397. * holds the thumbstick values (X,Y)
  55398. */
  55399. thumbstickValues: StickValues;
  55400. /**
  55401. * Fired when the thumbstick on this controller is clicked
  55402. */
  55403. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55404. /**
  55405. * Fired when the thumbstick on this controller is modified
  55406. */
  55407. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55408. /**
  55409. * Fired when the touchpad button on this controller is modified
  55410. */
  55411. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55412. /**
  55413. * Fired when the touchpad values on this controller are modified
  55414. */
  55415. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55416. /**
  55417. * Fired when the thumbstick button on this controller is modified
  55418. * here to prevent breaking changes
  55419. */
  55420. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55421. /**
  55422. * updating the thumbstick(!) and not the trackpad.
  55423. * This is named this way due to the difference between WebVR and XR and to avoid
  55424. * changing the parent class.
  55425. */
  55426. protected _updateTrackpad(): void;
  55427. /**
  55428. * Disposes the class with joy
  55429. */
  55430. dispose(): void;
  55431. }
  55432. }
  55433. declare module "babylonjs/Gamepads/Controllers/index" {
  55434. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55435. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55436. export * from "babylonjs/Gamepads/Controllers/genericController";
  55437. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55438. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55439. export * from "babylonjs/Gamepads/Controllers/viveController";
  55440. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55441. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55442. }
  55443. declare module "babylonjs/Gamepads/index" {
  55444. export * from "babylonjs/Gamepads/Controllers/index";
  55445. export * from "babylonjs/Gamepads/gamepad";
  55446. export * from "babylonjs/Gamepads/gamepadManager";
  55447. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55448. export * from "babylonjs/Gamepads/xboxGamepad";
  55449. export * from "babylonjs/Gamepads/dualShockGamepad";
  55450. }
  55451. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Vector4 } from "babylonjs/Maths/math.vector";
  55454. import { Color4 } from "babylonjs/Maths/math.color";
  55455. import { Mesh } from "babylonjs/Meshes/mesh";
  55456. import { Nullable } from "babylonjs/types";
  55457. /**
  55458. * Class containing static functions to help procedurally build meshes
  55459. */
  55460. export class PolyhedronBuilder {
  55461. /**
  55462. * Creates a polyhedron mesh
  55463. * * 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
  55464. * * The parameter `size` (positive float, default 1) sets the polygon size
  55465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55466. * * 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`
  55467. * * 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
  55468. * * 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)`)
  55469. * * 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
  55470. * * 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
  55471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55474. * @param name defines the name of the mesh
  55475. * @param options defines the options used to create the mesh
  55476. * @param scene defines the hosting scene
  55477. * @returns the polyhedron mesh
  55478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55479. */
  55480. static CreatePolyhedron(name: string, options: {
  55481. type?: number;
  55482. size?: number;
  55483. sizeX?: number;
  55484. sizeY?: number;
  55485. sizeZ?: number;
  55486. custom?: any;
  55487. faceUV?: Vector4[];
  55488. faceColors?: Color4[];
  55489. flat?: boolean;
  55490. updatable?: boolean;
  55491. sideOrientation?: number;
  55492. frontUVs?: Vector4;
  55493. backUVs?: Vector4;
  55494. }, scene?: Nullable<Scene>): Mesh;
  55495. }
  55496. }
  55497. declare module "babylonjs/Gizmos/scaleGizmo" {
  55498. import { Observable } from "babylonjs/Misc/observable";
  55499. import { Nullable } from "babylonjs/types";
  55500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55501. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55502. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55503. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55504. import { Node } from "babylonjs/node";
  55505. /**
  55506. * Gizmo that enables scaling a mesh along 3 axis
  55507. */
  55508. export class ScaleGizmo extends Gizmo {
  55509. /**
  55510. * Internal gizmo used for interactions on the x axis
  55511. */
  55512. xGizmo: AxisScaleGizmo;
  55513. /**
  55514. * Internal gizmo used for interactions on the y axis
  55515. */
  55516. yGizmo: AxisScaleGizmo;
  55517. /**
  55518. * Internal gizmo used for interactions on the z axis
  55519. */
  55520. zGizmo: AxisScaleGizmo;
  55521. /**
  55522. * Internal gizmo used to scale all axis equally
  55523. */
  55524. uniformScaleGizmo: AxisScaleGizmo;
  55525. private _meshAttached;
  55526. private _nodeAttached;
  55527. private _updateGizmoRotationToMatchAttachedMesh;
  55528. private _snapDistance;
  55529. private _scaleRatio;
  55530. private _uniformScalingMesh;
  55531. private _octahedron;
  55532. private _sensitivity;
  55533. /** Fires an event when any of it's sub gizmos are dragged */
  55534. onDragStartObservable: Observable<unknown>;
  55535. /** Fires an event when any of it's sub gizmos are released from dragging */
  55536. onDragEndObservable: Observable<unknown>;
  55537. get attachedMesh(): Nullable<AbstractMesh>;
  55538. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55539. get attachedNode(): Nullable<Node>;
  55540. set attachedNode(node: Nullable<Node>);
  55541. /**
  55542. * Creates a ScaleGizmo
  55543. * @param gizmoLayer The utility layer the gizmo will be added to
  55544. * @param thickness display gizmo axis thickness
  55545. */
  55546. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55547. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55548. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55549. /**
  55550. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55551. */
  55552. set snapDistance(value: number);
  55553. get snapDistance(): number;
  55554. /**
  55555. * Ratio for the scale of the gizmo (Default: 1)
  55556. */
  55557. set scaleRatio(value: number);
  55558. get scaleRatio(): number;
  55559. /**
  55560. * Sensitivity factor for dragging (Default: 1)
  55561. */
  55562. set sensitivity(value: number);
  55563. get sensitivity(): number;
  55564. /**
  55565. * Disposes of the gizmo
  55566. */
  55567. dispose(): void;
  55568. }
  55569. }
  55570. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55571. import { Observable } from "babylonjs/Misc/observable";
  55572. import { Nullable } from "babylonjs/types";
  55573. import { Vector3 } from "babylonjs/Maths/math.vector";
  55574. import { Node } from "babylonjs/node";
  55575. import { Mesh } from "babylonjs/Meshes/mesh";
  55576. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55577. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55579. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55580. import { Color3 } from "babylonjs/Maths/math.color";
  55581. /**
  55582. * Single axis scale gizmo
  55583. */
  55584. export class AxisScaleGizmo extends Gizmo {
  55585. /**
  55586. * Drag behavior responsible for the gizmos dragging interactions
  55587. */
  55588. dragBehavior: PointerDragBehavior;
  55589. private _pointerObserver;
  55590. /**
  55591. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55592. */
  55593. snapDistance: number;
  55594. /**
  55595. * Event that fires each time the gizmo snaps to a new location.
  55596. * * snapDistance is the the change in distance
  55597. */
  55598. onSnapObservable: Observable<{
  55599. snapDistance: number;
  55600. }>;
  55601. /**
  55602. * If the scaling operation should be done on all axis (default: false)
  55603. */
  55604. uniformScaling: boolean;
  55605. /**
  55606. * Custom sensitivity value for the drag strength
  55607. */
  55608. sensitivity: number;
  55609. private _isEnabled;
  55610. private _parent;
  55611. private _arrow;
  55612. private _coloredMaterial;
  55613. private _hoverMaterial;
  55614. /**
  55615. * Creates an AxisScaleGizmo
  55616. * @param gizmoLayer The utility layer the gizmo will be added to
  55617. * @param dragAxis The axis which the gizmo will be able to scale on
  55618. * @param color The color of the gizmo
  55619. * @param thickness display gizmo axis thickness
  55620. */
  55621. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55622. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55623. /**
  55624. * If the gizmo is enabled
  55625. */
  55626. set isEnabled(value: boolean);
  55627. get isEnabled(): boolean;
  55628. /**
  55629. * Disposes of the gizmo
  55630. */
  55631. dispose(): void;
  55632. /**
  55633. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55634. * @param mesh The mesh to replace the default mesh of the gizmo
  55635. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55636. */
  55637. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55638. }
  55639. }
  55640. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55641. import { Observable } from "babylonjs/Misc/observable";
  55642. import { Nullable } from "babylonjs/types";
  55643. import { Vector3 } from "babylonjs/Maths/math.vector";
  55644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55645. import { Mesh } from "babylonjs/Meshes/mesh";
  55646. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55647. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55648. import { Color3 } from "babylonjs/Maths/math.color";
  55649. import "babylonjs/Meshes/Builders/boxBuilder";
  55650. /**
  55651. * Bounding box gizmo
  55652. */
  55653. export class BoundingBoxGizmo extends Gizmo {
  55654. private _lineBoundingBox;
  55655. private _rotateSpheresParent;
  55656. private _scaleBoxesParent;
  55657. private _boundingDimensions;
  55658. private _renderObserver;
  55659. private _pointerObserver;
  55660. private _scaleDragSpeed;
  55661. private _tmpQuaternion;
  55662. private _tmpVector;
  55663. private _tmpRotationMatrix;
  55664. /**
  55665. * 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)
  55666. */
  55667. ignoreChildren: boolean;
  55668. /**
  55669. * 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)
  55670. */
  55671. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55672. /**
  55673. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55674. */
  55675. rotationSphereSize: number;
  55676. /**
  55677. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55678. */
  55679. scaleBoxSize: number;
  55680. /**
  55681. * 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)
  55682. */
  55683. fixedDragMeshScreenSize: boolean;
  55684. /**
  55685. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55686. */
  55687. fixedDragMeshScreenSizeDistanceFactor: number;
  55688. /**
  55689. * Fired when a rotation sphere or scale box is dragged
  55690. */
  55691. onDragStartObservable: Observable<{}>;
  55692. /**
  55693. * Fired when a scale box is dragged
  55694. */
  55695. onScaleBoxDragObservable: Observable<{}>;
  55696. /**
  55697. * Fired when a scale box drag is ended
  55698. */
  55699. onScaleBoxDragEndObservable: Observable<{}>;
  55700. /**
  55701. * Fired when a rotation sphere is dragged
  55702. */
  55703. onRotationSphereDragObservable: Observable<{}>;
  55704. /**
  55705. * Fired when a rotation sphere drag is ended
  55706. */
  55707. onRotationSphereDragEndObservable: Observable<{}>;
  55708. /**
  55709. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  55710. */
  55711. scalePivot: Nullable<Vector3>;
  55712. /**
  55713. * Mesh used as a pivot to rotate the attached node
  55714. */
  55715. private _anchorMesh;
  55716. private _existingMeshScale;
  55717. private _dragMesh;
  55718. private pointerDragBehavior;
  55719. private coloredMaterial;
  55720. private hoverColoredMaterial;
  55721. /**
  55722. * Sets the color of the bounding box gizmo
  55723. * @param color the color to set
  55724. */
  55725. setColor(color: Color3): void;
  55726. /**
  55727. * Creates an BoundingBoxGizmo
  55728. * @param gizmoLayer The utility layer the gizmo will be added to
  55729. * @param color The color of the gizmo
  55730. */
  55731. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55732. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55733. private _selectNode;
  55734. /**
  55735. * Updates the bounding box information for the Gizmo
  55736. */
  55737. updateBoundingBox(): void;
  55738. private _updateRotationSpheres;
  55739. private _updateScaleBoxes;
  55740. /**
  55741. * Enables rotation on the specified axis and disables rotation on the others
  55742. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55743. */
  55744. setEnabledRotationAxis(axis: string): void;
  55745. /**
  55746. * Enables/disables scaling
  55747. * @param enable if scaling should be enabled
  55748. * @param homogeneousScaling defines if scaling should only be homogeneous
  55749. */
  55750. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55751. private _updateDummy;
  55752. /**
  55753. * Enables a pointer drag behavior on the bounding box of the gizmo
  55754. */
  55755. enableDragBehavior(): void;
  55756. /**
  55757. * Disposes of the gizmo
  55758. */
  55759. dispose(): void;
  55760. /**
  55761. * 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)
  55762. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55763. * @returns the bounding box mesh with the passed in mesh as a child
  55764. */
  55765. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55766. /**
  55767. * CustomMeshes are not supported by this gizmo
  55768. * @param mesh The mesh to replace the default mesh of the gizmo
  55769. */
  55770. setCustomMesh(mesh: Mesh): void;
  55771. }
  55772. }
  55773. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55774. import { Observable } from "babylonjs/Misc/observable";
  55775. import { Nullable } from "babylonjs/types";
  55776. import { Vector3 } from "babylonjs/Maths/math.vector";
  55777. import { Color3 } from "babylonjs/Maths/math.color";
  55778. import { Node } from "babylonjs/node";
  55779. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55780. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55781. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55782. import "babylonjs/Meshes/Builders/linesBuilder";
  55783. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55784. /**
  55785. * Single plane rotation gizmo
  55786. */
  55787. export class PlaneRotationGizmo extends Gizmo {
  55788. /**
  55789. * Drag behavior responsible for the gizmos dragging interactions
  55790. */
  55791. dragBehavior: PointerDragBehavior;
  55792. private _pointerObserver;
  55793. /**
  55794. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55795. */
  55796. snapDistance: number;
  55797. /**
  55798. * Event that fires each time the gizmo snaps to a new location.
  55799. * * snapDistance is the the change in distance
  55800. */
  55801. onSnapObservable: Observable<{
  55802. snapDistance: number;
  55803. }>;
  55804. private _isEnabled;
  55805. private _parent;
  55806. /**
  55807. * Creates a PlaneRotationGizmo
  55808. * @param gizmoLayer The utility layer the gizmo will be added to
  55809. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55810. * @param color The color of the gizmo
  55811. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55812. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55813. * @param thickness display gizmo axis thickness
  55814. */
  55815. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55816. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55817. /**
  55818. * If the gizmo is enabled
  55819. */
  55820. set isEnabled(value: boolean);
  55821. get isEnabled(): boolean;
  55822. /**
  55823. * Disposes of the gizmo
  55824. */
  55825. dispose(): void;
  55826. }
  55827. }
  55828. declare module "babylonjs/Gizmos/rotationGizmo" {
  55829. import { Observable } from "babylonjs/Misc/observable";
  55830. import { Nullable } from "babylonjs/types";
  55831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55832. import { Mesh } from "babylonjs/Meshes/mesh";
  55833. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55834. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55835. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55836. import { Node } from "babylonjs/node";
  55837. /**
  55838. * Gizmo that enables rotating a mesh along 3 axis
  55839. */
  55840. export class RotationGizmo extends Gizmo {
  55841. /**
  55842. * Internal gizmo used for interactions on the x axis
  55843. */
  55844. xGizmo: PlaneRotationGizmo;
  55845. /**
  55846. * Internal gizmo used for interactions on the y axis
  55847. */
  55848. yGizmo: PlaneRotationGizmo;
  55849. /**
  55850. * Internal gizmo used for interactions on the z axis
  55851. */
  55852. zGizmo: PlaneRotationGizmo;
  55853. /** Fires an event when any of it's sub gizmos are dragged */
  55854. onDragStartObservable: Observable<unknown>;
  55855. /** Fires an event when any of it's sub gizmos are released from dragging */
  55856. onDragEndObservable: Observable<unknown>;
  55857. private _meshAttached;
  55858. private _nodeAttached;
  55859. get attachedMesh(): Nullable<AbstractMesh>;
  55860. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55861. get attachedNode(): Nullable<Node>;
  55862. set attachedNode(node: Nullable<Node>);
  55863. /**
  55864. * Creates a RotationGizmo
  55865. * @param gizmoLayer The utility layer the gizmo will be added to
  55866. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55867. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55868. * @param thickness display gizmo axis thickness
  55869. */
  55870. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55871. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55872. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55873. /**
  55874. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55875. */
  55876. set snapDistance(value: number);
  55877. get snapDistance(): number;
  55878. /**
  55879. * Ratio for the scale of the gizmo (Default: 1)
  55880. */
  55881. set scaleRatio(value: number);
  55882. get scaleRatio(): number;
  55883. /**
  55884. * Disposes of the gizmo
  55885. */
  55886. dispose(): void;
  55887. /**
  55888. * CustomMeshes are not supported by this gizmo
  55889. * @param mesh The mesh to replace the default mesh of the gizmo
  55890. */
  55891. setCustomMesh(mesh: Mesh): void;
  55892. }
  55893. }
  55894. declare module "babylonjs/Gizmos/gizmoManager" {
  55895. import { Observable } from "babylonjs/Misc/observable";
  55896. import { Nullable } from "babylonjs/types";
  55897. import { Scene, IDisposable } from "babylonjs/scene";
  55898. import { Node } from "babylonjs/node";
  55899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55901. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55902. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55903. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55904. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55905. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55906. /**
  55907. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  55908. */
  55909. export class GizmoManager implements IDisposable {
  55910. private scene;
  55911. /**
  55912. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55913. */
  55914. gizmos: {
  55915. positionGizmo: Nullable<PositionGizmo>;
  55916. rotationGizmo: Nullable<RotationGizmo>;
  55917. scaleGizmo: Nullable<ScaleGizmo>;
  55918. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55919. };
  55920. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55921. clearGizmoOnEmptyPointerEvent: boolean;
  55922. /** Fires an event when the manager is attached to a mesh */
  55923. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55924. /** Fires an event when the manager is attached to a node */
  55925. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  55926. private _gizmosEnabled;
  55927. private _pointerObserver;
  55928. private _attachedMesh;
  55929. private _attachedNode;
  55930. private _boundingBoxColor;
  55931. private _defaultUtilityLayer;
  55932. private _defaultKeepDepthUtilityLayer;
  55933. private _thickness;
  55934. /**
  55935. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55936. */
  55937. boundingBoxDragBehavior: SixDofDragBehavior;
  55938. /**
  55939. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55940. */
  55941. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55942. /**
  55943. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  55944. */
  55945. attachableNodes: Nullable<Array<Node>>;
  55946. /**
  55947. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  55948. */
  55949. usePointerToAttachGizmos: boolean;
  55950. /**
  55951. * Utility layer that the bounding box gizmo belongs to
  55952. */
  55953. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55954. /**
  55955. * Utility layer that all gizmos besides bounding box belong to
  55956. */
  55957. get utilityLayer(): UtilityLayerRenderer;
  55958. /**
  55959. * Instatiates a gizmo manager
  55960. * @param scene the scene to overlay the gizmos on top of
  55961. * @param thickness display gizmo axis thickness
  55962. */
  55963. constructor(scene: Scene, thickness?: number);
  55964. /**
  55965. * Attaches a set of gizmos to the specified mesh
  55966. * @param mesh The mesh the gizmo's should be attached to
  55967. */
  55968. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55969. /**
  55970. * Attaches a set of gizmos to the specified node
  55971. * @param node The node the gizmo's should be attached to
  55972. */
  55973. attachToNode(node: Nullable<Node>): void;
  55974. /**
  55975. * If the position gizmo is enabled
  55976. */
  55977. set positionGizmoEnabled(value: boolean);
  55978. get positionGizmoEnabled(): boolean;
  55979. /**
  55980. * If the rotation gizmo is enabled
  55981. */
  55982. set rotationGizmoEnabled(value: boolean);
  55983. get rotationGizmoEnabled(): boolean;
  55984. /**
  55985. * If the scale gizmo is enabled
  55986. */
  55987. set scaleGizmoEnabled(value: boolean);
  55988. get scaleGizmoEnabled(): boolean;
  55989. /**
  55990. * If the boundingBox gizmo is enabled
  55991. */
  55992. set boundingBoxGizmoEnabled(value: boolean);
  55993. get boundingBoxGizmoEnabled(): boolean;
  55994. /**
  55995. * Disposes of the gizmo manager
  55996. */
  55997. dispose(): void;
  55998. }
  55999. }
  56000. declare module "babylonjs/Lights/directionalLight" {
  56001. import { Camera } from "babylonjs/Cameras/camera";
  56002. import { Scene } from "babylonjs/scene";
  56003. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56005. import { Light } from "babylonjs/Lights/light";
  56006. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56007. import { Effect } from "babylonjs/Materials/effect";
  56008. /**
  56009. * A directional light is defined by a direction (what a surprise!).
  56010. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56011. * 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.
  56012. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56013. */
  56014. export class DirectionalLight extends ShadowLight {
  56015. private _shadowFrustumSize;
  56016. /**
  56017. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56018. */
  56019. get shadowFrustumSize(): number;
  56020. /**
  56021. * Specifies a fix frustum size for the shadow generation.
  56022. */
  56023. set shadowFrustumSize(value: number);
  56024. private _shadowOrthoScale;
  56025. /**
  56026. * Gets the shadow projection scale against the optimal computed one.
  56027. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56028. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56029. */
  56030. get shadowOrthoScale(): number;
  56031. /**
  56032. * Sets the shadow projection scale against the optimal computed one.
  56033. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56034. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56035. */
  56036. set shadowOrthoScale(value: number);
  56037. /**
  56038. * Automatically compute the projection matrix to best fit (including all the casters)
  56039. * on each frame.
  56040. */
  56041. autoUpdateExtends: boolean;
  56042. /**
  56043. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56044. * on each frame. autoUpdateExtends must be set to true for this to work
  56045. */
  56046. autoCalcShadowZBounds: boolean;
  56047. private _orthoLeft;
  56048. private _orthoRight;
  56049. private _orthoTop;
  56050. private _orthoBottom;
  56051. /**
  56052. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56053. * The directional light is emitted from everywhere in the given direction.
  56054. * It can cast shadows.
  56055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56056. * @param name The friendly name of the light
  56057. * @param direction The direction of the light
  56058. * @param scene The scene the light belongs to
  56059. */
  56060. constructor(name: string, direction: Vector3, scene: Scene);
  56061. /**
  56062. * Returns the string "DirectionalLight".
  56063. * @return The class name
  56064. */
  56065. getClassName(): string;
  56066. /**
  56067. * Returns the integer 1.
  56068. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56069. */
  56070. getTypeID(): number;
  56071. /**
  56072. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56073. * Returns the DirectionalLight Shadow projection matrix.
  56074. */
  56075. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56076. /**
  56077. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56078. * Returns the DirectionalLight Shadow projection matrix.
  56079. */
  56080. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56081. /**
  56082. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56083. * Returns the DirectionalLight Shadow projection matrix.
  56084. */
  56085. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56086. protected _buildUniformLayout(): void;
  56087. /**
  56088. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56089. * @param effect The effect to update
  56090. * @param lightIndex The index of the light in the effect to update
  56091. * @returns The directional light
  56092. */
  56093. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56094. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56095. /**
  56096. * Gets the minZ used for shadow according to both the scene and the light.
  56097. *
  56098. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56099. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56100. * @param activeCamera The camera we are returning the min for
  56101. * @returns the depth min z
  56102. */
  56103. getDepthMinZ(activeCamera: Camera): number;
  56104. /**
  56105. * Gets the maxZ used for shadow according to both the scene and the light.
  56106. *
  56107. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56108. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56109. * @param activeCamera The camera we are returning the max for
  56110. * @returns the depth max z
  56111. */
  56112. getDepthMaxZ(activeCamera: Camera): number;
  56113. /**
  56114. * Prepares the list of defines specific to the light type.
  56115. * @param defines the list of defines
  56116. * @param lightIndex defines the index of the light for the effect
  56117. */
  56118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56119. }
  56120. }
  56121. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56122. import { Mesh } from "babylonjs/Meshes/mesh";
  56123. /**
  56124. * Class containing static functions to help procedurally build meshes
  56125. */
  56126. export class HemisphereBuilder {
  56127. /**
  56128. * Creates a hemisphere mesh
  56129. * @param name defines the name of the mesh
  56130. * @param options defines the options used to create the mesh
  56131. * @param scene defines the hosting scene
  56132. * @returns the hemisphere mesh
  56133. */
  56134. static CreateHemisphere(name: string, options: {
  56135. segments?: number;
  56136. diameter?: number;
  56137. sideOrientation?: number;
  56138. }, scene: any): Mesh;
  56139. }
  56140. }
  56141. declare module "babylonjs/Lights/spotLight" {
  56142. import { Nullable } from "babylonjs/types";
  56143. import { Scene } from "babylonjs/scene";
  56144. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56146. import { Effect } from "babylonjs/Materials/effect";
  56147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56148. import { Light } from "babylonjs/Lights/light";
  56149. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56150. /**
  56151. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56152. * These values define a cone of light starting from the position, emitting toward the direction.
  56153. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56154. * and the exponent defines the speed of the decay of the light with distance (reach).
  56155. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56156. */
  56157. export class SpotLight extends ShadowLight {
  56158. private _angle;
  56159. private _innerAngle;
  56160. private _cosHalfAngle;
  56161. private _lightAngleScale;
  56162. private _lightAngleOffset;
  56163. /**
  56164. * Gets the cone angle of the spot light in Radians.
  56165. */
  56166. get angle(): number;
  56167. /**
  56168. * Sets the cone angle of the spot light in Radians.
  56169. */
  56170. set angle(value: number);
  56171. /**
  56172. * Only used in gltf falloff mode, this defines the angle where
  56173. * the directional falloff will start before cutting at angle which could be seen
  56174. * as outer angle.
  56175. */
  56176. get innerAngle(): number;
  56177. /**
  56178. * Only used in gltf falloff mode, this defines the angle where
  56179. * the directional falloff will start before cutting at angle which could be seen
  56180. * as outer angle.
  56181. */
  56182. set innerAngle(value: number);
  56183. private _shadowAngleScale;
  56184. /**
  56185. * Allows scaling the angle of the light for shadow generation only.
  56186. */
  56187. get shadowAngleScale(): number;
  56188. /**
  56189. * Allows scaling the angle of the light for shadow generation only.
  56190. */
  56191. set shadowAngleScale(value: number);
  56192. /**
  56193. * The light decay speed with the distance from the emission spot.
  56194. */
  56195. exponent: number;
  56196. private _projectionTextureMatrix;
  56197. /**
  56198. * Allows reading the projecton texture
  56199. */
  56200. get projectionTextureMatrix(): Matrix;
  56201. protected _projectionTextureLightNear: number;
  56202. /**
  56203. * Gets the near clip of the Spotlight for texture projection.
  56204. */
  56205. get projectionTextureLightNear(): number;
  56206. /**
  56207. * Sets the near clip of the Spotlight for texture projection.
  56208. */
  56209. set projectionTextureLightNear(value: number);
  56210. protected _projectionTextureLightFar: number;
  56211. /**
  56212. * Gets the far clip of the Spotlight for texture projection.
  56213. */
  56214. get projectionTextureLightFar(): number;
  56215. /**
  56216. * Sets the far clip of the Spotlight for texture projection.
  56217. */
  56218. set projectionTextureLightFar(value: number);
  56219. protected _projectionTextureUpDirection: Vector3;
  56220. /**
  56221. * Gets the Up vector of the Spotlight for texture projection.
  56222. */
  56223. get projectionTextureUpDirection(): Vector3;
  56224. /**
  56225. * Sets the Up vector of the Spotlight for texture projection.
  56226. */
  56227. set projectionTextureUpDirection(value: Vector3);
  56228. private _projectionTexture;
  56229. /**
  56230. * Gets the projection texture of the light.
  56231. */
  56232. get projectionTexture(): Nullable<BaseTexture>;
  56233. /**
  56234. * Sets the projection texture of the light.
  56235. */
  56236. set projectionTexture(value: Nullable<BaseTexture>);
  56237. private _projectionTextureViewLightDirty;
  56238. private _projectionTextureProjectionLightDirty;
  56239. private _projectionTextureDirty;
  56240. private _projectionTextureViewTargetVector;
  56241. private _projectionTextureViewLightMatrix;
  56242. private _projectionTextureProjectionLightMatrix;
  56243. private _projectionTextureScalingMatrix;
  56244. /**
  56245. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56246. * It can cast shadows.
  56247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56248. * @param name The light friendly name
  56249. * @param position The position of the spot light in the scene
  56250. * @param direction The direction of the light in the scene
  56251. * @param angle The cone angle of the light in Radians
  56252. * @param exponent The light decay speed with the distance from the emission spot
  56253. * @param scene The scene the lights belongs to
  56254. */
  56255. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56256. /**
  56257. * Returns the string "SpotLight".
  56258. * @returns the class name
  56259. */
  56260. getClassName(): string;
  56261. /**
  56262. * Returns the integer 2.
  56263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56264. */
  56265. getTypeID(): number;
  56266. /**
  56267. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56268. */
  56269. protected _setDirection(value: Vector3): void;
  56270. /**
  56271. * Overrides the position setter to recompute the projection texture view light Matrix.
  56272. */
  56273. protected _setPosition(value: Vector3): void;
  56274. /**
  56275. * 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.
  56276. * Returns the SpotLight.
  56277. */
  56278. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56279. protected _computeProjectionTextureViewLightMatrix(): void;
  56280. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56281. /**
  56282. * Main function for light texture projection matrix computing.
  56283. */
  56284. protected _computeProjectionTextureMatrix(): void;
  56285. protected _buildUniformLayout(): void;
  56286. private _computeAngleValues;
  56287. /**
  56288. * Sets the passed Effect "effect" with the Light textures.
  56289. * @param effect The effect to update
  56290. * @param lightIndex The index of the light in the effect to update
  56291. * @returns The light
  56292. */
  56293. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56294. /**
  56295. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56296. * @param effect The effect to update
  56297. * @param lightIndex The index of the light in the effect to update
  56298. * @returns The spot light
  56299. */
  56300. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56301. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56302. /**
  56303. * Disposes the light and the associated resources.
  56304. */
  56305. dispose(): void;
  56306. /**
  56307. * Prepares the list of defines specific to the light type.
  56308. * @param defines the list of defines
  56309. * @param lightIndex defines the index of the light for the effect
  56310. */
  56311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56312. }
  56313. }
  56314. declare module "babylonjs/Gizmos/lightGizmo" {
  56315. import { Nullable } from "babylonjs/types";
  56316. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56317. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56318. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56319. import { Light } from "babylonjs/Lights/light";
  56320. /**
  56321. * Gizmo that enables viewing a light
  56322. */
  56323. export class LightGizmo extends Gizmo {
  56324. private _lightMesh;
  56325. private _material;
  56326. private _cachedPosition;
  56327. private _cachedForward;
  56328. private _attachedMeshParent;
  56329. /**
  56330. * Creates a LightGizmo
  56331. * @param gizmoLayer The utility layer the gizmo will be added to
  56332. */
  56333. constructor(gizmoLayer?: UtilityLayerRenderer);
  56334. private _light;
  56335. /**
  56336. * The light that the gizmo is attached to
  56337. */
  56338. set light(light: Nullable<Light>);
  56339. get light(): Nullable<Light>;
  56340. /**
  56341. * Gets the material used to render the light gizmo
  56342. */
  56343. get material(): StandardMaterial;
  56344. /**
  56345. * @hidden
  56346. * Updates the gizmo to match the attached mesh's position/rotation
  56347. */
  56348. protected _update(): void;
  56349. private static _Scale;
  56350. /**
  56351. * Creates the lines for a light mesh
  56352. */
  56353. private static _CreateLightLines;
  56354. /**
  56355. * Disposes of the light gizmo
  56356. */
  56357. dispose(): void;
  56358. private static _CreateHemisphericLightMesh;
  56359. private static _CreatePointLightMesh;
  56360. private static _CreateSpotLightMesh;
  56361. private static _CreateDirectionalLightMesh;
  56362. }
  56363. }
  56364. declare module "babylonjs/Gizmos/cameraGizmo" {
  56365. import { Nullable } from "babylonjs/types";
  56366. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56367. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56368. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56369. import { Camera } from "babylonjs/Cameras/camera";
  56370. /**
  56371. * Gizmo that enables viewing a camera
  56372. */
  56373. export class CameraGizmo extends Gizmo {
  56374. private _cameraMesh;
  56375. private _cameraLinesMesh;
  56376. private _material;
  56377. /**
  56378. * Creates a CameraGizmo
  56379. * @param gizmoLayer The utility layer the gizmo will be added to
  56380. */
  56381. constructor(gizmoLayer?: UtilityLayerRenderer);
  56382. private _camera;
  56383. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56384. get displayFrustum(): boolean;
  56385. set displayFrustum(value: boolean);
  56386. /**
  56387. * The camera that the gizmo is attached to
  56388. */
  56389. set camera(camera: Nullable<Camera>);
  56390. get camera(): Nullable<Camera>;
  56391. /**
  56392. * Gets the material used to render the camera gizmo
  56393. */
  56394. get material(): StandardMaterial;
  56395. /**
  56396. * @hidden
  56397. * Updates the gizmo to match the attached mesh's position/rotation
  56398. */
  56399. protected _update(): void;
  56400. private static _Scale;
  56401. private _invProjection;
  56402. /**
  56403. * Disposes of the camera gizmo
  56404. */
  56405. dispose(): void;
  56406. private static _CreateCameraMesh;
  56407. private static _CreateCameraFrustum;
  56408. }
  56409. }
  56410. declare module "babylonjs/Gizmos/index" {
  56411. export * from "babylonjs/Gizmos/axisDragGizmo";
  56412. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56413. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56414. export * from "babylonjs/Gizmos/gizmo";
  56415. export * from "babylonjs/Gizmos/gizmoManager";
  56416. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56417. export * from "babylonjs/Gizmos/positionGizmo";
  56418. export * from "babylonjs/Gizmos/rotationGizmo";
  56419. export * from "babylonjs/Gizmos/scaleGizmo";
  56420. export * from "babylonjs/Gizmos/lightGizmo";
  56421. export * from "babylonjs/Gizmos/cameraGizmo";
  56422. export * from "babylonjs/Gizmos/planeDragGizmo";
  56423. }
  56424. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56425. /** @hidden */
  56426. export var backgroundFragmentDeclaration: {
  56427. name: string;
  56428. shader: string;
  56429. };
  56430. }
  56431. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56432. /** @hidden */
  56433. export var backgroundUboDeclaration: {
  56434. name: string;
  56435. shader: string;
  56436. };
  56437. }
  56438. declare module "babylonjs/Shaders/background.fragment" {
  56439. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56440. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56441. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56442. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56443. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56444. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56446. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56447. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56448. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56449. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56450. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56451. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56452. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56453. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56454. /** @hidden */
  56455. export var backgroundPixelShader: {
  56456. name: string;
  56457. shader: string;
  56458. };
  56459. }
  56460. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56461. /** @hidden */
  56462. export var backgroundVertexDeclaration: {
  56463. name: string;
  56464. shader: string;
  56465. };
  56466. }
  56467. declare module "babylonjs/Shaders/background.vertex" {
  56468. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56469. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56470. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56471. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56472. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56473. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56474. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56475. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56476. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56477. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56478. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56479. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56480. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56481. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56482. /** @hidden */
  56483. export var backgroundVertexShader: {
  56484. name: string;
  56485. shader: string;
  56486. };
  56487. }
  56488. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56489. import { Nullable, int, float } from "babylonjs/types";
  56490. import { Scene } from "babylonjs/scene";
  56491. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56494. import { Mesh } from "babylonjs/Meshes/mesh";
  56495. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56496. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56497. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56499. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56500. import { Color3 } from "babylonjs/Maths/math.color";
  56501. import "babylonjs/Shaders/background.fragment";
  56502. import "babylonjs/Shaders/background.vertex";
  56503. /**
  56504. * Background material used to create an efficient environement around your scene.
  56505. */
  56506. export class BackgroundMaterial extends PushMaterial {
  56507. /**
  56508. * Standard reflectance value at parallel view angle.
  56509. */
  56510. static StandardReflectance0: number;
  56511. /**
  56512. * Standard reflectance value at grazing angle.
  56513. */
  56514. static StandardReflectance90: number;
  56515. protected _primaryColor: Color3;
  56516. /**
  56517. * Key light Color (multiply against the environement texture)
  56518. */
  56519. primaryColor: Color3;
  56520. protected __perceptualColor: Nullable<Color3>;
  56521. /**
  56522. * Experimental Internal Use Only.
  56523. *
  56524. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56525. * This acts as a helper to set the primary color to a more "human friendly" value.
  56526. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56527. * output color as close as possible from the chosen value.
  56528. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56529. * part of lighting setup.)
  56530. */
  56531. get _perceptualColor(): Nullable<Color3>;
  56532. set _perceptualColor(value: Nullable<Color3>);
  56533. protected _primaryColorShadowLevel: float;
  56534. /**
  56535. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56536. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56537. */
  56538. get primaryColorShadowLevel(): float;
  56539. set primaryColorShadowLevel(value: float);
  56540. protected _primaryColorHighlightLevel: float;
  56541. /**
  56542. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56543. * The primary color is used at the level chosen to define what the white area would look.
  56544. */
  56545. get primaryColorHighlightLevel(): float;
  56546. set primaryColorHighlightLevel(value: float);
  56547. protected _reflectionTexture: Nullable<BaseTexture>;
  56548. /**
  56549. * Reflection Texture used in the material.
  56550. * Should be author in a specific way for the best result (refer to the documentation).
  56551. */
  56552. reflectionTexture: Nullable<BaseTexture>;
  56553. protected _reflectionBlur: float;
  56554. /**
  56555. * Reflection Texture level of blur.
  56556. *
  56557. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56558. * texture twice.
  56559. */
  56560. reflectionBlur: float;
  56561. protected _diffuseTexture: Nullable<BaseTexture>;
  56562. /**
  56563. * Diffuse Texture used in the material.
  56564. * Should be author in a specific way for the best result (refer to the documentation).
  56565. */
  56566. diffuseTexture: Nullable<BaseTexture>;
  56567. protected _shadowLights: Nullable<IShadowLight[]>;
  56568. /**
  56569. * Specify the list of lights casting shadow on the material.
  56570. * All scene shadow lights will be included if null.
  56571. */
  56572. shadowLights: Nullable<IShadowLight[]>;
  56573. protected _shadowLevel: float;
  56574. /**
  56575. * Helps adjusting the shadow to a softer level if required.
  56576. * 0 means black shadows and 1 means no shadows.
  56577. */
  56578. shadowLevel: float;
  56579. protected _sceneCenter: Vector3;
  56580. /**
  56581. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56582. * It is usually zero but might be interesting to modify according to your setup.
  56583. */
  56584. sceneCenter: Vector3;
  56585. protected _opacityFresnel: boolean;
  56586. /**
  56587. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56588. * This helps ensuring a nice transition when the camera goes under the ground.
  56589. */
  56590. opacityFresnel: boolean;
  56591. protected _reflectionFresnel: boolean;
  56592. /**
  56593. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56594. * This helps adding a mirror texture on the ground.
  56595. */
  56596. reflectionFresnel: boolean;
  56597. protected _reflectionFalloffDistance: number;
  56598. /**
  56599. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56600. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56601. */
  56602. reflectionFalloffDistance: number;
  56603. protected _reflectionAmount: number;
  56604. /**
  56605. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56606. */
  56607. reflectionAmount: number;
  56608. protected _reflectionReflectance0: number;
  56609. /**
  56610. * This specifies the weight of the reflection at grazing angle.
  56611. */
  56612. reflectionReflectance0: number;
  56613. protected _reflectionReflectance90: number;
  56614. /**
  56615. * This specifies the weight of the reflection at a perpendicular point of view.
  56616. */
  56617. reflectionReflectance90: number;
  56618. /**
  56619. * Sets the reflection reflectance fresnel values according to the default standard
  56620. * empirically know to work well :-)
  56621. */
  56622. set reflectionStandardFresnelWeight(value: number);
  56623. protected _useRGBColor: boolean;
  56624. /**
  56625. * Helps to directly use the maps channels instead of their level.
  56626. */
  56627. useRGBColor: boolean;
  56628. protected _enableNoise: boolean;
  56629. /**
  56630. * This helps reducing the banding effect that could occur on the background.
  56631. */
  56632. enableNoise: boolean;
  56633. /**
  56634. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56635. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56636. * Recommended to be keep at 1.0 except for special cases.
  56637. */
  56638. get fovMultiplier(): number;
  56639. set fovMultiplier(value: number);
  56640. private _fovMultiplier;
  56641. /**
  56642. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56643. */
  56644. useEquirectangularFOV: boolean;
  56645. private _maxSimultaneousLights;
  56646. /**
  56647. * Number of Simultaneous lights allowed on the material.
  56648. */
  56649. maxSimultaneousLights: int;
  56650. private _shadowOnly;
  56651. /**
  56652. * Make the material only render shadows
  56653. */
  56654. shadowOnly: boolean;
  56655. /**
  56656. * Default configuration related to image processing available in the Background Material.
  56657. */
  56658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56659. /**
  56660. * Keep track of the image processing observer to allow dispose and replace.
  56661. */
  56662. private _imageProcessingObserver;
  56663. /**
  56664. * Attaches a new image processing configuration to the PBR Material.
  56665. * @param configuration (if null the scene configuration will be use)
  56666. */
  56667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56668. /**
  56669. * Gets the image processing configuration used either in this material.
  56670. */
  56671. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56672. /**
  56673. * Sets the Default image processing configuration used either in the this material.
  56674. *
  56675. * If sets to null, the scene one is in use.
  56676. */
  56677. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56678. /**
  56679. * Gets wether the color curves effect is enabled.
  56680. */
  56681. get cameraColorCurvesEnabled(): boolean;
  56682. /**
  56683. * Sets wether the color curves effect is enabled.
  56684. */
  56685. set cameraColorCurvesEnabled(value: boolean);
  56686. /**
  56687. * Gets wether the color grading effect is enabled.
  56688. */
  56689. get cameraColorGradingEnabled(): boolean;
  56690. /**
  56691. * Gets wether the color grading effect is enabled.
  56692. */
  56693. set cameraColorGradingEnabled(value: boolean);
  56694. /**
  56695. * Gets wether tonemapping is enabled or not.
  56696. */
  56697. get cameraToneMappingEnabled(): boolean;
  56698. /**
  56699. * Sets wether tonemapping is enabled or not
  56700. */
  56701. set cameraToneMappingEnabled(value: boolean);
  56702. /**
  56703. * The camera exposure used on this material.
  56704. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56705. * This corresponds to a photographic exposure.
  56706. */
  56707. get cameraExposure(): float;
  56708. /**
  56709. * The camera exposure used on this material.
  56710. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56711. * This corresponds to a photographic exposure.
  56712. */
  56713. set cameraExposure(value: float);
  56714. /**
  56715. * Gets The camera contrast used on this material.
  56716. */
  56717. get cameraContrast(): float;
  56718. /**
  56719. * Sets The camera contrast used on this material.
  56720. */
  56721. set cameraContrast(value: float);
  56722. /**
  56723. * Gets the Color Grading 2D Lookup Texture.
  56724. */
  56725. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56726. /**
  56727. * Sets the Color Grading 2D Lookup Texture.
  56728. */
  56729. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56730. /**
  56731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56733. * 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;
  56734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56735. */
  56736. get cameraColorCurves(): Nullable<ColorCurves>;
  56737. /**
  56738. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56739. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56740. * 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;
  56741. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56742. */
  56743. set cameraColorCurves(value: Nullable<ColorCurves>);
  56744. /**
  56745. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56746. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56747. */
  56748. switchToBGR: boolean;
  56749. private _renderTargets;
  56750. private _reflectionControls;
  56751. private _white;
  56752. private _primaryShadowColor;
  56753. private _primaryHighlightColor;
  56754. /**
  56755. * Instantiates a Background Material in the given scene
  56756. * @param name The friendly name of the material
  56757. * @param scene The scene to add the material to
  56758. */
  56759. constructor(name: string, scene: Scene);
  56760. /**
  56761. * Gets a boolean indicating that current material needs to register RTT
  56762. */
  56763. get hasRenderTargetTextures(): boolean;
  56764. /**
  56765. * The entire material has been created in order to prevent overdraw.
  56766. * @returns false
  56767. */
  56768. needAlphaTesting(): boolean;
  56769. /**
  56770. * The entire material has been created in order to prevent overdraw.
  56771. * @returns true if blending is enable
  56772. */
  56773. needAlphaBlending(): boolean;
  56774. /**
  56775. * Checks wether the material is ready to be rendered for a given mesh.
  56776. * @param mesh The mesh to render
  56777. * @param subMesh The submesh to check against
  56778. * @param useInstances Specify wether or not the material is used with instances
  56779. * @returns true if all the dependencies are ready (Textures, Effects...)
  56780. */
  56781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56782. /**
  56783. * Compute the primary color according to the chosen perceptual color.
  56784. */
  56785. private _computePrimaryColorFromPerceptualColor;
  56786. /**
  56787. * Compute the highlights and shadow colors according to their chosen levels.
  56788. */
  56789. private _computePrimaryColors;
  56790. /**
  56791. * Build the uniform buffer used in the material.
  56792. */
  56793. buildUniformLayout(): void;
  56794. /**
  56795. * Unbind the material.
  56796. */
  56797. unbind(): void;
  56798. /**
  56799. * Bind only the world matrix to the material.
  56800. * @param world The world matrix to bind.
  56801. */
  56802. bindOnlyWorldMatrix(world: Matrix): void;
  56803. /**
  56804. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56805. * @param world The world matrix to bind.
  56806. * @param subMesh The submesh to bind for.
  56807. */
  56808. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56809. /**
  56810. * Checks to see if a texture is used in the material.
  56811. * @param texture - Base texture to use.
  56812. * @returns - Boolean specifying if a texture is used in the material.
  56813. */
  56814. hasTexture(texture: BaseTexture): boolean;
  56815. /**
  56816. * Dispose the material.
  56817. * @param forceDisposeEffect Force disposal of the associated effect.
  56818. * @param forceDisposeTextures Force disposal of the associated textures.
  56819. */
  56820. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56821. /**
  56822. * Clones the material.
  56823. * @param name The cloned name.
  56824. * @returns The cloned material.
  56825. */
  56826. clone(name: string): BackgroundMaterial;
  56827. /**
  56828. * Serializes the current material to its JSON representation.
  56829. * @returns The JSON representation.
  56830. */
  56831. serialize(): any;
  56832. /**
  56833. * Gets the class name of the material
  56834. * @returns "BackgroundMaterial"
  56835. */
  56836. getClassName(): string;
  56837. /**
  56838. * Parse a JSON input to create back a background material.
  56839. * @param source The JSON data to parse
  56840. * @param scene The scene to create the parsed material in
  56841. * @param rootUrl The root url of the assets the material depends upon
  56842. * @returns the instantiated BackgroundMaterial.
  56843. */
  56844. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56845. }
  56846. }
  56847. declare module "babylonjs/Helpers/environmentHelper" {
  56848. import { Observable } from "babylonjs/Misc/observable";
  56849. import { Nullable } from "babylonjs/types";
  56850. import { Scene } from "babylonjs/scene";
  56851. import { Vector3 } from "babylonjs/Maths/math.vector";
  56852. import { Color3 } from "babylonjs/Maths/math.color";
  56853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56854. import { Mesh } from "babylonjs/Meshes/mesh";
  56855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56856. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56857. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56858. import "babylonjs/Meshes/Builders/planeBuilder";
  56859. import "babylonjs/Meshes/Builders/boxBuilder";
  56860. /**
  56861. * Represents the different options available during the creation of
  56862. * a Environment helper.
  56863. *
  56864. * This can control the default ground, skybox and image processing setup of your scene.
  56865. */
  56866. export interface IEnvironmentHelperOptions {
  56867. /**
  56868. * Specifies whether or not to create a ground.
  56869. * True by default.
  56870. */
  56871. createGround: boolean;
  56872. /**
  56873. * Specifies the ground size.
  56874. * 15 by default.
  56875. */
  56876. groundSize: number;
  56877. /**
  56878. * The texture used on the ground for the main color.
  56879. * Comes from the BabylonJS CDN by default.
  56880. *
  56881. * Remarks: Can be either a texture or a url.
  56882. */
  56883. groundTexture: string | BaseTexture;
  56884. /**
  56885. * The color mixed in the ground texture by default.
  56886. * BabylonJS clearColor by default.
  56887. */
  56888. groundColor: Color3;
  56889. /**
  56890. * Specifies the ground opacity.
  56891. * 1 by default.
  56892. */
  56893. groundOpacity: number;
  56894. /**
  56895. * Enables the ground to receive shadows.
  56896. * True by default.
  56897. */
  56898. enableGroundShadow: boolean;
  56899. /**
  56900. * Helps preventing the shadow to be fully black on the ground.
  56901. * 0.5 by default.
  56902. */
  56903. groundShadowLevel: number;
  56904. /**
  56905. * Creates a mirror texture attach to the ground.
  56906. * false by default.
  56907. */
  56908. enableGroundMirror: boolean;
  56909. /**
  56910. * Specifies the ground mirror size ratio.
  56911. * 0.3 by default as the default kernel is 64.
  56912. */
  56913. groundMirrorSizeRatio: number;
  56914. /**
  56915. * Specifies the ground mirror blur kernel size.
  56916. * 64 by default.
  56917. */
  56918. groundMirrorBlurKernel: number;
  56919. /**
  56920. * Specifies the ground mirror visibility amount.
  56921. * 1 by default
  56922. */
  56923. groundMirrorAmount: number;
  56924. /**
  56925. * Specifies the ground mirror reflectance weight.
  56926. * This uses the standard weight of the background material to setup the fresnel effect
  56927. * of the mirror.
  56928. * 1 by default.
  56929. */
  56930. groundMirrorFresnelWeight: number;
  56931. /**
  56932. * Specifies the ground mirror Falloff distance.
  56933. * This can helps reducing the size of the reflection.
  56934. * 0 by Default.
  56935. */
  56936. groundMirrorFallOffDistance: number;
  56937. /**
  56938. * Specifies the ground mirror texture type.
  56939. * Unsigned Int by Default.
  56940. */
  56941. groundMirrorTextureType: number;
  56942. /**
  56943. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56944. * the shown objects.
  56945. */
  56946. groundYBias: number;
  56947. /**
  56948. * Specifies whether or not to create a skybox.
  56949. * True by default.
  56950. */
  56951. createSkybox: boolean;
  56952. /**
  56953. * Specifies the skybox size.
  56954. * 20 by default.
  56955. */
  56956. skyboxSize: number;
  56957. /**
  56958. * The texture used on the skybox for the main color.
  56959. * Comes from the BabylonJS CDN by default.
  56960. *
  56961. * Remarks: Can be either a texture or a url.
  56962. */
  56963. skyboxTexture: string | BaseTexture;
  56964. /**
  56965. * The color mixed in the skybox texture by default.
  56966. * BabylonJS clearColor by default.
  56967. */
  56968. skyboxColor: Color3;
  56969. /**
  56970. * The background rotation around the Y axis of the scene.
  56971. * This helps aligning the key lights of your scene with the background.
  56972. * 0 by default.
  56973. */
  56974. backgroundYRotation: number;
  56975. /**
  56976. * Compute automatically the size of the elements to best fit with the scene.
  56977. */
  56978. sizeAuto: boolean;
  56979. /**
  56980. * Default position of the rootMesh if autoSize is not true.
  56981. */
  56982. rootPosition: Vector3;
  56983. /**
  56984. * Sets up the image processing in the scene.
  56985. * true by default.
  56986. */
  56987. setupImageProcessing: boolean;
  56988. /**
  56989. * The texture used as your environment texture in the scene.
  56990. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56991. *
  56992. * Remarks: Can be either a texture or a url.
  56993. */
  56994. environmentTexture: string | BaseTexture;
  56995. /**
  56996. * The value of the exposure to apply to the scene.
  56997. * 0.6 by default if setupImageProcessing is true.
  56998. */
  56999. cameraExposure: number;
  57000. /**
  57001. * The value of the contrast to apply to the scene.
  57002. * 1.6 by default if setupImageProcessing is true.
  57003. */
  57004. cameraContrast: number;
  57005. /**
  57006. * Specifies whether or not tonemapping should be enabled in the scene.
  57007. * true by default if setupImageProcessing is true.
  57008. */
  57009. toneMappingEnabled: boolean;
  57010. }
  57011. /**
  57012. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57013. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57014. * It also helps with the default setup of your imageProcessing configuration.
  57015. */
  57016. export class EnvironmentHelper {
  57017. /**
  57018. * Default ground texture URL.
  57019. */
  57020. private static _groundTextureCDNUrl;
  57021. /**
  57022. * Default skybox texture URL.
  57023. */
  57024. private static _skyboxTextureCDNUrl;
  57025. /**
  57026. * Default environment texture URL.
  57027. */
  57028. private static _environmentTextureCDNUrl;
  57029. /**
  57030. * Creates the default options for the helper.
  57031. */
  57032. private static _getDefaultOptions;
  57033. private _rootMesh;
  57034. /**
  57035. * Gets the root mesh created by the helper.
  57036. */
  57037. get rootMesh(): Mesh;
  57038. private _skybox;
  57039. /**
  57040. * Gets the skybox created by the helper.
  57041. */
  57042. get skybox(): Nullable<Mesh>;
  57043. private _skyboxTexture;
  57044. /**
  57045. * Gets the skybox texture created by the helper.
  57046. */
  57047. get skyboxTexture(): Nullable<BaseTexture>;
  57048. private _skyboxMaterial;
  57049. /**
  57050. * Gets the skybox material created by the helper.
  57051. */
  57052. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57053. private _ground;
  57054. /**
  57055. * Gets the ground mesh created by the helper.
  57056. */
  57057. get ground(): Nullable<Mesh>;
  57058. private _groundTexture;
  57059. /**
  57060. * Gets the ground texture created by the helper.
  57061. */
  57062. get groundTexture(): Nullable<BaseTexture>;
  57063. private _groundMirror;
  57064. /**
  57065. * Gets the ground mirror created by the helper.
  57066. */
  57067. get groundMirror(): Nullable<MirrorTexture>;
  57068. /**
  57069. * Gets the ground mirror render list to helps pushing the meshes
  57070. * you wish in the ground reflection.
  57071. */
  57072. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57073. private _groundMaterial;
  57074. /**
  57075. * Gets the ground material created by the helper.
  57076. */
  57077. get groundMaterial(): Nullable<BackgroundMaterial>;
  57078. /**
  57079. * Stores the creation options.
  57080. */
  57081. private readonly _scene;
  57082. private _options;
  57083. /**
  57084. * This observable will be notified with any error during the creation of the environment,
  57085. * mainly texture creation errors.
  57086. */
  57087. onErrorObservable: Observable<{
  57088. message?: string;
  57089. exception?: any;
  57090. }>;
  57091. /**
  57092. * constructor
  57093. * @param options Defines the options we want to customize the helper
  57094. * @param scene The scene to add the material to
  57095. */
  57096. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57097. /**
  57098. * Updates the background according to the new options
  57099. * @param options
  57100. */
  57101. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57102. /**
  57103. * Sets the primary color of all the available elements.
  57104. * @param color the main color to affect to the ground and the background
  57105. */
  57106. setMainColor(color: Color3): void;
  57107. /**
  57108. * Setup the image processing according to the specified options.
  57109. */
  57110. private _setupImageProcessing;
  57111. /**
  57112. * Setup the environment texture according to the specified options.
  57113. */
  57114. private _setupEnvironmentTexture;
  57115. /**
  57116. * Setup the background according to the specified options.
  57117. */
  57118. private _setupBackground;
  57119. /**
  57120. * Get the scene sizes according to the setup.
  57121. */
  57122. private _getSceneSize;
  57123. /**
  57124. * Setup the ground according to the specified options.
  57125. */
  57126. private _setupGround;
  57127. /**
  57128. * Setup the ground material according to the specified options.
  57129. */
  57130. private _setupGroundMaterial;
  57131. /**
  57132. * Setup the ground diffuse texture according to the specified options.
  57133. */
  57134. private _setupGroundDiffuseTexture;
  57135. /**
  57136. * Setup the ground mirror texture according to the specified options.
  57137. */
  57138. private _setupGroundMirrorTexture;
  57139. /**
  57140. * Setup the ground to receive the mirror texture.
  57141. */
  57142. private _setupMirrorInGroundMaterial;
  57143. /**
  57144. * Setup the skybox according to the specified options.
  57145. */
  57146. private _setupSkybox;
  57147. /**
  57148. * Setup the skybox material according to the specified options.
  57149. */
  57150. private _setupSkyboxMaterial;
  57151. /**
  57152. * Setup the skybox reflection texture according to the specified options.
  57153. */
  57154. private _setupSkyboxReflectionTexture;
  57155. private _errorHandler;
  57156. /**
  57157. * Dispose all the elements created by the Helper.
  57158. */
  57159. dispose(): void;
  57160. }
  57161. }
  57162. declare module "babylonjs/Helpers/photoDome" {
  57163. import { Observable } from "babylonjs/Misc/observable";
  57164. import { Nullable } from "babylonjs/types";
  57165. import { Scene } from "babylonjs/scene";
  57166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57167. import { Mesh } from "babylonjs/Meshes/mesh";
  57168. import { Texture } from "babylonjs/Materials/Textures/texture";
  57169. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57170. import "babylonjs/Meshes/Builders/sphereBuilder";
  57171. /**
  57172. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57173. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57174. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57175. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57176. */
  57177. export class PhotoDome extends TransformNode {
  57178. /**
  57179. * Define the image as a Monoscopic panoramic 360 image.
  57180. */
  57181. static readonly MODE_MONOSCOPIC: number;
  57182. /**
  57183. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57184. */
  57185. static readonly MODE_TOPBOTTOM: number;
  57186. /**
  57187. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57188. */
  57189. static readonly MODE_SIDEBYSIDE: number;
  57190. private _useDirectMapping;
  57191. /**
  57192. * The texture being displayed on the sphere
  57193. */
  57194. protected _photoTexture: Texture;
  57195. /**
  57196. * Gets or sets the texture being displayed on the sphere
  57197. */
  57198. get photoTexture(): Texture;
  57199. set photoTexture(value: Texture);
  57200. /**
  57201. * Observable raised when an error occured while loading the 360 image
  57202. */
  57203. onLoadErrorObservable: Observable<string>;
  57204. /**
  57205. * The skybox material
  57206. */
  57207. protected _material: BackgroundMaterial;
  57208. /**
  57209. * The surface used for the skybox
  57210. */
  57211. protected _mesh: Mesh;
  57212. /**
  57213. * Gets the mesh used for the skybox.
  57214. */
  57215. get mesh(): Mesh;
  57216. /**
  57217. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57218. * Also see the options.resolution property.
  57219. */
  57220. get fovMultiplier(): number;
  57221. set fovMultiplier(value: number);
  57222. private _imageMode;
  57223. /**
  57224. * Gets or set the current video mode for the video. It can be:
  57225. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57226. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57227. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57228. */
  57229. get imageMode(): number;
  57230. set imageMode(value: number);
  57231. /**
  57232. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57233. * @param name Element's name, child elements will append suffixes for their own names.
  57234. * @param urlsOfPhoto defines the url of the photo to display
  57235. * @param options defines an object containing optional or exposed sub element properties
  57236. * @param onError defines a callback called when an error occured while loading the texture
  57237. */
  57238. constructor(name: string, urlOfPhoto: string, options: {
  57239. resolution?: number;
  57240. size?: number;
  57241. useDirectMapping?: boolean;
  57242. faceForward?: boolean;
  57243. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57244. private _onBeforeCameraRenderObserver;
  57245. private _changeImageMode;
  57246. /**
  57247. * Releases resources associated with this node.
  57248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57250. */
  57251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57252. }
  57253. }
  57254. declare module "babylonjs/Misc/rgbdTextureTools" {
  57255. import "babylonjs/Shaders/rgbdDecode.fragment";
  57256. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57257. import { Texture } from "babylonjs/Materials/Textures/texture";
  57258. /**
  57259. * Class used to host RGBD texture specific utilities
  57260. */
  57261. export class RGBDTextureTools {
  57262. /**
  57263. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57264. * @param texture the texture to expand.
  57265. */
  57266. static ExpandRGBDTexture(texture: Texture): void;
  57267. }
  57268. }
  57269. declare module "babylonjs/Misc/brdfTextureTools" {
  57270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57271. import { Scene } from "babylonjs/scene";
  57272. /**
  57273. * Class used to host texture specific utilities
  57274. */
  57275. export class BRDFTextureTools {
  57276. /**
  57277. * Prevents texture cache collision
  57278. */
  57279. private static _instanceNumber;
  57280. /**
  57281. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57282. * @param scene defines the hosting scene
  57283. * @returns the environment BRDF texture
  57284. */
  57285. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57286. private static _environmentBRDFBase64Texture;
  57287. }
  57288. }
  57289. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57290. import { Nullable } from "babylonjs/types";
  57291. import { Color3 } from "babylonjs/Maths/math.color";
  57292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57293. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57294. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57295. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57296. import { Engine } from "babylonjs/Engines/engine";
  57297. import { Scene } from "babylonjs/scene";
  57298. /**
  57299. * @hidden
  57300. */
  57301. export interface IMaterialClearCoatDefines {
  57302. CLEARCOAT: boolean;
  57303. CLEARCOAT_DEFAULTIOR: boolean;
  57304. CLEARCOAT_TEXTURE: boolean;
  57305. CLEARCOAT_TEXTUREDIRECTUV: number;
  57306. CLEARCOAT_BUMP: boolean;
  57307. CLEARCOAT_BUMPDIRECTUV: number;
  57308. CLEARCOAT_TINT: boolean;
  57309. CLEARCOAT_TINT_TEXTURE: boolean;
  57310. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57311. /** @hidden */
  57312. _areTexturesDirty: boolean;
  57313. }
  57314. /**
  57315. * Define the code related to the clear coat parameters of the pbr material.
  57316. */
  57317. export class PBRClearCoatConfiguration {
  57318. /**
  57319. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57320. * The default fits with a polyurethane material.
  57321. */
  57322. private static readonly _DefaultIndexOfRefraction;
  57323. private _isEnabled;
  57324. /**
  57325. * Defines if the clear coat is enabled in the material.
  57326. */
  57327. isEnabled: boolean;
  57328. /**
  57329. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57330. */
  57331. intensity: number;
  57332. /**
  57333. * Defines the clear coat layer roughness.
  57334. */
  57335. roughness: number;
  57336. private _indexOfRefraction;
  57337. /**
  57338. * Defines the index of refraction of the clear coat.
  57339. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57340. * The default fits with a polyurethane material.
  57341. * Changing the default value is more performance intensive.
  57342. */
  57343. indexOfRefraction: number;
  57344. private _texture;
  57345. /**
  57346. * Stores the clear coat values in a texture.
  57347. */
  57348. texture: Nullable<BaseTexture>;
  57349. private _bumpTexture;
  57350. /**
  57351. * Define the clear coat specific bump texture.
  57352. */
  57353. bumpTexture: Nullable<BaseTexture>;
  57354. private _isTintEnabled;
  57355. /**
  57356. * Defines if the clear coat tint is enabled in the material.
  57357. */
  57358. isTintEnabled: boolean;
  57359. /**
  57360. * Defines the clear coat tint of the material.
  57361. * This is only use if tint is enabled
  57362. */
  57363. tintColor: Color3;
  57364. /**
  57365. * Defines the distance at which the tint color should be found in the
  57366. * clear coat media.
  57367. * This is only use if tint is enabled
  57368. */
  57369. tintColorAtDistance: number;
  57370. /**
  57371. * Defines the clear coat layer thickness.
  57372. * This is only use if tint is enabled
  57373. */
  57374. tintThickness: number;
  57375. private _tintTexture;
  57376. /**
  57377. * Stores the clear tint values in a texture.
  57378. * rgb is tint
  57379. * a is a thickness factor
  57380. */
  57381. tintTexture: Nullable<BaseTexture>;
  57382. /** @hidden */
  57383. private _internalMarkAllSubMeshesAsTexturesDirty;
  57384. /** @hidden */
  57385. _markAllSubMeshesAsTexturesDirty(): void;
  57386. /**
  57387. * Instantiate a new istance of clear coat configuration.
  57388. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57389. */
  57390. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57391. /**
  57392. * Gets wehter the submesh is ready to be used or not.
  57393. * @param defines the list of "defines" to update.
  57394. * @param scene defines the scene the material belongs to.
  57395. * @param engine defines the engine the material belongs to.
  57396. * @param disableBumpMap defines wether the material disables bump or not.
  57397. * @returns - boolean indicating that the submesh is ready or not.
  57398. */
  57399. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57400. /**
  57401. * Checks to see if a texture is used in the material.
  57402. * @param defines the list of "defines" to update.
  57403. * @param scene defines the scene to the material belongs to.
  57404. */
  57405. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57406. /**
  57407. * Binds the material data.
  57408. * @param uniformBuffer defines the Uniform buffer to fill in.
  57409. * @param scene defines the scene the material belongs to.
  57410. * @param engine defines the engine the material belongs to.
  57411. * @param disableBumpMap defines wether the material disables bump or not.
  57412. * @param isFrozen defines wether the material is frozen or not.
  57413. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57414. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57415. */
  57416. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57417. /**
  57418. * Checks to see if a texture is used in the material.
  57419. * @param texture - Base texture to use.
  57420. * @returns - Boolean specifying if a texture is used in the material.
  57421. */
  57422. hasTexture(texture: BaseTexture): boolean;
  57423. /**
  57424. * Returns an array of the actively used textures.
  57425. * @param activeTextures Array of BaseTextures
  57426. */
  57427. getActiveTextures(activeTextures: BaseTexture[]): void;
  57428. /**
  57429. * Returns the animatable textures.
  57430. * @param animatables Array of animatable textures.
  57431. */
  57432. getAnimatables(animatables: IAnimatable[]): void;
  57433. /**
  57434. * Disposes the resources of the material.
  57435. * @param forceDisposeTextures - Forces the disposal of all textures.
  57436. */
  57437. dispose(forceDisposeTextures?: boolean): void;
  57438. /**
  57439. * Get the current class name of the texture useful for serialization or dynamic coding.
  57440. * @returns "PBRClearCoatConfiguration"
  57441. */
  57442. getClassName(): string;
  57443. /**
  57444. * Add fallbacks to the effect fallbacks list.
  57445. * @param defines defines the Base texture to use.
  57446. * @param fallbacks defines the current fallback list.
  57447. * @param currentRank defines the current fallback rank.
  57448. * @returns the new fallback rank.
  57449. */
  57450. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57451. /**
  57452. * Add the required uniforms to the current list.
  57453. * @param uniforms defines the current uniform list.
  57454. */
  57455. static AddUniforms(uniforms: string[]): void;
  57456. /**
  57457. * Add the required samplers to the current list.
  57458. * @param samplers defines the current sampler list.
  57459. */
  57460. static AddSamplers(samplers: string[]): void;
  57461. /**
  57462. * Add the required uniforms to the current buffer.
  57463. * @param uniformBuffer defines the current uniform buffer.
  57464. */
  57465. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57466. /**
  57467. * Makes a duplicate of the current configuration into another one.
  57468. * @param clearCoatConfiguration define the config where to copy the info
  57469. */
  57470. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57471. /**
  57472. * Serializes this clear coat configuration.
  57473. * @returns - An object with the serialized config.
  57474. */
  57475. serialize(): any;
  57476. /**
  57477. * Parses a anisotropy Configuration from a serialized object.
  57478. * @param source - Serialized object.
  57479. * @param scene Defines the scene we are parsing for
  57480. * @param rootUrl Defines the rootUrl to load from
  57481. */
  57482. parse(source: any, scene: Scene, rootUrl: string): void;
  57483. }
  57484. }
  57485. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57488. import { Vector2 } from "babylonjs/Maths/math.vector";
  57489. import { Scene } from "babylonjs/scene";
  57490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57491. import { Nullable } from "babylonjs/types";
  57492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57493. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57494. /**
  57495. * @hidden
  57496. */
  57497. export interface IMaterialAnisotropicDefines {
  57498. ANISOTROPIC: boolean;
  57499. ANISOTROPIC_TEXTURE: boolean;
  57500. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57501. MAINUV1: boolean;
  57502. _areTexturesDirty: boolean;
  57503. _needUVs: boolean;
  57504. }
  57505. /**
  57506. * Define the code related to the anisotropic parameters of the pbr material.
  57507. */
  57508. export class PBRAnisotropicConfiguration {
  57509. private _isEnabled;
  57510. /**
  57511. * Defines if the anisotropy is enabled in the material.
  57512. */
  57513. isEnabled: boolean;
  57514. /**
  57515. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57516. */
  57517. intensity: number;
  57518. /**
  57519. * Defines if the effect is along the tangents, bitangents or in between.
  57520. * By default, the effect is "strectching" the highlights along the tangents.
  57521. */
  57522. direction: Vector2;
  57523. private _texture;
  57524. /**
  57525. * Stores the anisotropy values in a texture.
  57526. * rg is direction (like normal from -1 to 1)
  57527. * b is a intensity
  57528. */
  57529. texture: Nullable<BaseTexture>;
  57530. /** @hidden */
  57531. private _internalMarkAllSubMeshesAsTexturesDirty;
  57532. /** @hidden */
  57533. _markAllSubMeshesAsTexturesDirty(): void;
  57534. /**
  57535. * Instantiate a new istance of anisotropy configuration.
  57536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57537. */
  57538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57539. /**
  57540. * Specifies that the submesh is ready to be used.
  57541. * @param defines the list of "defines" to update.
  57542. * @param scene defines the scene the material belongs to.
  57543. * @returns - boolean indicating that the submesh is ready or not.
  57544. */
  57545. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57546. /**
  57547. * Checks to see if a texture is used in the material.
  57548. * @param defines the list of "defines" to update.
  57549. * @param mesh the mesh we are preparing the defines for.
  57550. * @param scene defines the scene the material belongs to.
  57551. */
  57552. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57553. /**
  57554. * Binds the material data.
  57555. * @param uniformBuffer defines the Uniform buffer to fill in.
  57556. * @param scene defines the scene the material belongs to.
  57557. * @param isFrozen defines wether the material is frozen or not.
  57558. */
  57559. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57560. /**
  57561. * Checks to see if a texture is used in the material.
  57562. * @param texture - Base texture to use.
  57563. * @returns - Boolean specifying if a texture is used in the material.
  57564. */
  57565. hasTexture(texture: BaseTexture): boolean;
  57566. /**
  57567. * Returns an array of the actively used textures.
  57568. * @param activeTextures Array of BaseTextures
  57569. */
  57570. getActiveTextures(activeTextures: BaseTexture[]): void;
  57571. /**
  57572. * Returns the animatable textures.
  57573. * @param animatables Array of animatable textures.
  57574. */
  57575. getAnimatables(animatables: IAnimatable[]): void;
  57576. /**
  57577. * Disposes the resources of the material.
  57578. * @param forceDisposeTextures - Forces the disposal of all textures.
  57579. */
  57580. dispose(forceDisposeTextures?: boolean): void;
  57581. /**
  57582. * Get the current class name of the texture useful for serialization or dynamic coding.
  57583. * @returns "PBRAnisotropicConfiguration"
  57584. */
  57585. getClassName(): string;
  57586. /**
  57587. * Add fallbacks to the effect fallbacks list.
  57588. * @param defines defines the Base texture to use.
  57589. * @param fallbacks defines the current fallback list.
  57590. * @param currentRank defines the current fallback rank.
  57591. * @returns the new fallback rank.
  57592. */
  57593. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57594. /**
  57595. * Add the required uniforms to the current list.
  57596. * @param uniforms defines the current uniform list.
  57597. */
  57598. static AddUniforms(uniforms: string[]): void;
  57599. /**
  57600. * Add the required uniforms to the current buffer.
  57601. * @param uniformBuffer defines the current uniform buffer.
  57602. */
  57603. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57604. /**
  57605. * Add the required samplers to the current list.
  57606. * @param samplers defines the current sampler list.
  57607. */
  57608. static AddSamplers(samplers: string[]): void;
  57609. /**
  57610. * Makes a duplicate of the current configuration into another one.
  57611. * @param anisotropicConfiguration define the config where to copy the info
  57612. */
  57613. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57614. /**
  57615. * Serializes this anisotropy configuration.
  57616. * @returns - An object with the serialized config.
  57617. */
  57618. serialize(): any;
  57619. /**
  57620. * Parses a anisotropy Configuration from a serialized object.
  57621. * @param source - Serialized object.
  57622. * @param scene Defines the scene we are parsing for
  57623. * @param rootUrl Defines the rootUrl to load from
  57624. */
  57625. parse(source: any, scene: Scene, rootUrl: string): void;
  57626. }
  57627. }
  57628. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57629. import { Scene } from "babylonjs/scene";
  57630. /**
  57631. * @hidden
  57632. */
  57633. export interface IMaterialBRDFDefines {
  57634. BRDF_V_HEIGHT_CORRELATED: boolean;
  57635. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57636. SPHERICAL_HARMONICS: boolean;
  57637. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57638. /** @hidden */
  57639. _areMiscDirty: boolean;
  57640. }
  57641. /**
  57642. * Define the code related to the BRDF parameters of the pbr material.
  57643. */
  57644. export class PBRBRDFConfiguration {
  57645. /**
  57646. * Default value used for the energy conservation.
  57647. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57648. */
  57649. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57650. /**
  57651. * Default value used for the Smith Visibility Height Correlated mode.
  57652. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57653. */
  57654. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57655. /**
  57656. * Default value used for the IBL diffuse part.
  57657. * This can help switching back to the polynomials mode globally which is a tiny bit
  57658. * less GPU intensive at the drawback of a lower quality.
  57659. */
  57660. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57661. /**
  57662. * Default value used for activating energy conservation for the specular workflow.
  57663. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57664. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57665. */
  57666. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57667. private _useEnergyConservation;
  57668. /**
  57669. * Defines if the material uses energy conservation.
  57670. */
  57671. useEnergyConservation: boolean;
  57672. private _useSmithVisibilityHeightCorrelated;
  57673. /**
  57674. * LEGACY Mode set to false
  57675. * Defines if the material uses height smith correlated visibility term.
  57676. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57677. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57678. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57679. * Not relying on height correlated will also disable energy conservation.
  57680. */
  57681. useSmithVisibilityHeightCorrelated: boolean;
  57682. private _useSphericalHarmonics;
  57683. /**
  57684. * LEGACY Mode set to false
  57685. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57686. * diffuse part of the IBL.
  57687. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57688. * to the ground truth.
  57689. */
  57690. useSphericalHarmonics: boolean;
  57691. private _useSpecularGlossinessInputEnergyConservation;
  57692. /**
  57693. * Defines if the material uses energy conservation, when the specular workflow is active.
  57694. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57695. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57696. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57697. */
  57698. useSpecularGlossinessInputEnergyConservation: boolean;
  57699. /** @hidden */
  57700. private _internalMarkAllSubMeshesAsMiscDirty;
  57701. /** @hidden */
  57702. _markAllSubMeshesAsMiscDirty(): void;
  57703. /**
  57704. * Instantiate a new istance of clear coat configuration.
  57705. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57706. */
  57707. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57708. /**
  57709. * Checks to see if a texture is used in the material.
  57710. * @param defines the list of "defines" to update.
  57711. */
  57712. prepareDefines(defines: IMaterialBRDFDefines): void;
  57713. /**
  57714. * Get the current class name of the texture useful for serialization or dynamic coding.
  57715. * @returns "PBRClearCoatConfiguration"
  57716. */
  57717. getClassName(): string;
  57718. /**
  57719. * Makes a duplicate of the current configuration into another one.
  57720. * @param brdfConfiguration define the config where to copy the info
  57721. */
  57722. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57723. /**
  57724. * Serializes this BRDF configuration.
  57725. * @returns - An object with the serialized config.
  57726. */
  57727. serialize(): any;
  57728. /**
  57729. * Parses a anisotropy Configuration from a serialized object.
  57730. * @param source - Serialized object.
  57731. * @param scene Defines the scene we are parsing for
  57732. * @param rootUrl Defines the rootUrl to load from
  57733. */
  57734. parse(source: any, scene: Scene, rootUrl: string): void;
  57735. }
  57736. }
  57737. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57738. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57739. import { Color3 } from "babylonjs/Maths/math.color";
  57740. import { Scene } from "babylonjs/scene";
  57741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57742. import { Nullable } from "babylonjs/types";
  57743. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57744. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57745. /**
  57746. * @hidden
  57747. */
  57748. export interface IMaterialSheenDefines {
  57749. SHEEN: boolean;
  57750. SHEEN_TEXTURE: boolean;
  57751. SHEEN_TEXTUREDIRECTUV: number;
  57752. SHEEN_LINKWITHALBEDO: boolean;
  57753. SHEEN_ROUGHNESS: boolean;
  57754. SHEEN_ALBEDOSCALING: boolean;
  57755. /** @hidden */
  57756. _areTexturesDirty: boolean;
  57757. }
  57758. /**
  57759. * Define the code related to the Sheen parameters of the pbr material.
  57760. */
  57761. export class PBRSheenConfiguration {
  57762. private _isEnabled;
  57763. /**
  57764. * Defines if the material uses sheen.
  57765. */
  57766. isEnabled: boolean;
  57767. private _linkSheenWithAlbedo;
  57768. /**
  57769. * Defines if the sheen is linked to the sheen color.
  57770. */
  57771. linkSheenWithAlbedo: boolean;
  57772. /**
  57773. * Defines the sheen intensity.
  57774. */
  57775. intensity: number;
  57776. /**
  57777. * Defines the sheen color.
  57778. */
  57779. color: Color3;
  57780. private _texture;
  57781. /**
  57782. * Stores the sheen tint values in a texture.
  57783. * rgb is tint
  57784. * a is a intensity or roughness if roughness has been defined
  57785. */
  57786. texture: Nullable<BaseTexture>;
  57787. private _roughness;
  57788. /**
  57789. * Defines the sheen roughness.
  57790. * It is not taken into account if linkSheenWithAlbedo is true.
  57791. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57792. */
  57793. roughness: Nullable<number>;
  57794. private _albedoScaling;
  57795. /**
  57796. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57797. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57798. * making it easier to setup and tweak the effect
  57799. */
  57800. albedoScaling: boolean;
  57801. /** @hidden */
  57802. private _internalMarkAllSubMeshesAsTexturesDirty;
  57803. /** @hidden */
  57804. _markAllSubMeshesAsTexturesDirty(): void;
  57805. /**
  57806. * Instantiate a new istance of clear coat configuration.
  57807. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57808. */
  57809. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57810. /**
  57811. * Specifies that the submesh is ready to be used.
  57812. * @param defines the list of "defines" to update.
  57813. * @param scene defines the scene the material belongs to.
  57814. * @returns - boolean indicating that the submesh is ready or not.
  57815. */
  57816. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57817. /**
  57818. * Checks to see if a texture is used in the material.
  57819. * @param defines the list of "defines" to update.
  57820. * @param scene defines the scene the material belongs to.
  57821. */
  57822. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57823. /**
  57824. * Binds the material data.
  57825. * @param uniformBuffer defines the Uniform buffer to fill in.
  57826. * @param scene defines the scene the material belongs to.
  57827. * @param isFrozen defines wether the material is frozen or not.
  57828. */
  57829. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57830. /**
  57831. * Checks to see if a texture is used in the material.
  57832. * @param texture - Base texture to use.
  57833. * @returns - Boolean specifying if a texture is used in the material.
  57834. */
  57835. hasTexture(texture: BaseTexture): boolean;
  57836. /**
  57837. * Returns an array of the actively used textures.
  57838. * @param activeTextures Array of BaseTextures
  57839. */
  57840. getActiveTextures(activeTextures: BaseTexture[]): void;
  57841. /**
  57842. * Returns the animatable textures.
  57843. * @param animatables Array of animatable textures.
  57844. */
  57845. getAnimatables(animatables: IAnimatable[]): void;
  57846. /**
  57847. * Disposes the resources of the material.
  57848. * @param forceDisposeTextures - Forces the disposal of all textures.
  57849. */
  57850. dispose(forceDisposeTextures?: boolean): void;
  57851. /**
  57852. * Get the current class name of the texture useful for serialization or dynamic coding.
  57853. * @returns "PBRSheenConfiguration"
  57854. */
  57855. getClassName(): string;
  57856. /**
  57857. * Add fallbacks to the effect fallbacks list.
  57858. * @param defines defines the Base texture to use.
  57859. * @param fallbacks defines the current fallback list.
  57860. * @param currentRank defines the current fallback rank.
  57861. * @returns the new fallback rank.
  57862. */
  57863. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57864. /**
  57865. * Add the required uniforms to the current list.
  57866. * @param uniforms defines the current uniform list.
  57867. */
  57868. static AddUniforms(uniforms: string[]): void;
  57869. /**
  57870. * Add the required uniforms to the current buffer.
  57871. * @param uniformBuffer defines the current uniform buffer.
  57872. */
  57873. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57874. /**
  57875. * Add the required samplers to the current list.
  57876. * @param samplers defines the current sampler list.
  57877. */
  57878. static AddSamplers(samplers: string[]): void;
  57879. /**
  57880. * Makes a duplicate of the current configuration into another one.
  57881. * @param sheenConfiguration define the config where to copy the info
  57882. */
  57883. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57884. /**
  57885. * Serializes this BRDF configuration.
  57886. * @returns - An object with the serialized config.
  57887. */
  57888. serialize(): any;
  57889. /**
  57890. * Parses a anisotropy Configuration from a serialized object.
  57891. * @param source - Serialized object.
  57892. * @param scene Defines the scene we are parsing for
  57893. * @param rootUrl Defines the rootUrl to load from
  57894. */
  57895. parse(source: any, scene: Scene, rootUrl: string): void;
  57896. }
  57897. }
  57898. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57899. import { Nullable } from "babylonjs/types";
  57900. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57901. import { Color3 } from "babylonjs/Maths/math.color";
  57902. import { SmartArray } from "babylonjs/Misc/smartArray";
  57903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57904. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57905. import { Effect } from "babylonjs/Materials/effect";
  57906. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57907. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57908. import { Engine } from "babylonjs/Engines/engine";
  57909. import { Scene } from "babylonjs/scene";
  57910. /**
  57911. * @hidden
  57912. */
  57913. export interface IMaterialSubSurfaceDefines {
  57914. SUBSURFACE: boolean;
  57915. SS_REFRACTION: boolean;
  57916. SS_TRANSLUCENCY: boolean;
  57917. SS_SCATTERING: boolean;
  57918. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57919. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57920. SS_REFRACTIONMAP_3D: boolean;
  57921. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57922. SS_LODINREFRACTIONALPHA: boolean;
  57923. SS_GAMMAREFRACTION: boolean;
  57924. SS_RGBDREFRACTION: boolean;
  57925. SS_LINEARSPECULARREFRACTION: boolean;
  57926. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57927. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57928. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57929. /** @hidden */
  57930. _areTexturesDirty: boolean;
  57931. }
  57932. /**
  57933. * Define the code related to the sub surface parameters of the pbr material.
  57934. */
  57935. export class PBRSubSurfaceConfiguration {
  57936. private _isRefractionEnabled;
  57937. /**
  57938. * Defines if the refraction is enabled in the material.
  57939. */
  57940. isRefractionEnabled: boolean;
  57941. private _isTranslucencyEnabled;
  57942. /**
  57943. * Defines if the translucency is enabled in the material.
  57944. */
  57945. isTranslucencyEnabled: boolean;
  57946. private _isScatteringEnabled;
  57947. /**
  57948. * Defines if the sub surface scattering is enabled in the material.
  57949. */
  57950. isScatteringEnabled: boolean;
  57951. private _scatteringDiffusionProfileIndex;
  57952. /**
  57953. * Diffusion profile for subsurface scattering.
  57954. * Useful for better scattering in the skins or foliages.
  57955. */
  57956. get scatteringDiffusionProfile(): Nullable<Color3>;
  57957. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57958. /**
  57959. * Defines the refraction intensity of the material.
  57960. * The refraction when enabled replaces the Diffuse part of the material.
  57961. * The intensity helps transitionning between diffuse and refraction.
  57962. */
  57963. refractionIntensity: number;
  57964. /**
  57965. * Defines the translucency intensity of the material.
  57966. * When translucency has been enabled, this defines how much of the "translucency"
  57967. * is addded to the diffuse part of the material.
  57968. */
  57969. translucencyIntensity: number;
  57970. /**
  57971. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57972. */
  57973. useAlbedoToTintRefraction: boolean;
  57974. private _thicknessTexture;
  57975. /**
  57976. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57977. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57978. * 0 would mean minimumThickness
  57979. * 1 would mean maximumThickness
  57980. * The other channels might be use as a mask to vary the different effects intensity.
  57981. */
  57982. thicknessTexture: Nullable<BaseTexture>;
  57983. private _refractionTexture;
  57984. /**
  57985. * Defines the texture to use for refraction.
  57986. */
  57987. refractionTexture: Nullable<BaseTexture>;
  57988. private _indexOfRefraction;
  57989. /**
  57990. * Index of refraction of the material base layer.
  57991. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57992. *
  57993. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57994. *
  57995. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57996. */
  57997. indexOfRefraction: number;
  57998. private _volumeIndexOfRefraction;
  57999. /**
  58000. * Index of refraction of the material's volume.
  58001. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58002. *
  58003. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58004. * the volume will use the same IOR as the surface.
  58005. */
  58006. get volumeIndexOfRefraction(): number;
  58007. set volumeIndexOfRefraction(value: number);
  58008. private _invertRefractionY;
  58009. /**
  58010. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58011. */
  58012. invertRefractionY: boolean;
  58013. private _linkRefractionWithTransparency;
  58014. /**
  58015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58016. * Materials half opaque for instance using refraction could benefit from this control.
  58017. */
  58018. linkRefractionWithTransparency: boolean;
  58019. /**
  58020. * Defines the minimum thickness stored in the thickness map.
  58021. * If no thickness map is defined, this value will be used to simulate thickness.
  58022. */
  58023. minimumThickness: number;
  58024. /**
  58025. * Defines the maximum thickness stored in the thickness map.
  58026. */
  58027. maximumThickness: number;
  58028. /**
  58029. * Defines the volume tint of the material.
  58030. * This is used for both translucency and scattering.
  58031. */
  58032. tintColor: Color3;
  58033. /**
  58034. * Defines the distance at which the tint color should be found in the media.
  58035. * This is used for refraction only.
  58036. */
  58037. tintColorAtDistance: number;
  58038. /**
  58039. * Defines how far each channel transmit through the media.
  58040. * It is defined as a color to simplify it selection.
  58041. */
  58042. diffusionDistance: Color3;
  58043. private _useMaskFromThicknessTexture;
  58044. /**
  58045. * Stores the intensity of the different subsurface effects in the thickness texture.
  58046. * * the green channel is the translucency intensity.
  58047. * * the blue channel is the scattering intensity.
  58048. * * the alpha channel is the refraction intensity.
  58049. */
  58050. useMaskFromThicknessTexture: boolean;
  58051. private _scene;
  58052. /** @hidden */
  58053. private _internalMarkAllSubMeshesAsTexturesDirty;
  58054. private _internalMarkScenePrePassDirty;
  58055. /** @hidden */
  58056. _markAllSubMeshesAsTexturesDirty(): void;
  58057. /** @hidden */
  58058. _markScenePrePassDirty(): void;
  58059. /**
  58060. * Instantiate a new istance of sub surface configuration.
  58061. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58062. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58063. * @param scene The scene
  58064. */
  58065. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58066. /**
  58067. * Gets wehter the submesh is ready to be used or not.
  58068. * @param defines the list of "defines" to update.
  58069. * @param scene defines the scene the material belongs to.
  58070. * @returns - boolean indicating that the submesh is ready or not.
  58071. */
  58072. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58073. /**
  58074. * Checks to see if a texture is used in the material.
  58075. * @param defines the list of "defines" to update.
  58076. * @param scene defines the scene to the material belongs to.
  58077. */
  58078. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58079. /**
  58080. * Binds the material data.
  58081. * @param uniformBuffer defines the Uniform buffer to fill in.
  58082. * @param scene defines the scene the material belongs to.
  58083. * @param engine defines the engine the material belongs to.
  58084. * @param isFrozen defines whether the material is frozen or not.
  58085. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58086. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58087. */
  58088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58089. /**
  58090. * Unbinds the material from the mesh.
  58091. * @param activeEffect defines the effect that should be unbound from.
  58092. * @returns true if unbound, otherwise false
  58093. */
  58094. unbind(activeEffect: Effect): boolean;
  58095. /**
  58096. * Returns the texture used for refraction or null if none is used.
  58097. * @param scene defines the scene the material belongs to.
  58098. * @returns - Refraction texture if present. If no refraction texture and refraction
  58099. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58100. */
  58101. private _getRefractionTexture;
  58102. /**
  58103. * Returns true if alpha blending should be disabled.
  58104. */
  58105. get disableAlphaBlending(): boolean;
  58106. /**
  58107. * Fills the list of render target textures.
  58108. * @param renderTargets the list of render targets to update
  58109. */
  58110. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58111. /**
  58112. * Checks to see if a texture is used in the material.
  58113. * @param texture - Base texture to use.
  58114. * @returns - Boolean specifying if a texture is used in the material.
  58115. */
  58116. hasTexture(texture: BaseTexture): boolean;
  58117. /**
  58118. * Gets a boolean indicating that current material needs to register RTT
  58119. * @returns true if this uses a render target otherwise false.
  58120. */
  58121. hasRenderTargetTextures(): boolean;
  58122. /**
  58123. * Returns an array of the actively used textures.
  58124. * @param activeTextures Array of BaseTextures
  58125. */
  58126. getActiveTextures(activeTextures: BaseTexture[]): void;
  58127. /**
  58128. * Returns the animatable textures.
  58129. * @param animatables Array of animatable textures.
  58130. */
  58131. getAnimatables(animatables: IAnimatable[]): void;
  58132. /**
  58133. * Disposes the resources of the material.
  58134. * @param forceDisposeTextures - Forces the disposal of all textures.
  58135. */
  58136. dispose(forceDisposeTextures?: boolean): void;
  58137. /**
  58138. * Get the current class name of the texture useful for serialization or dynamic coding.
  58139. * @returns "PBRSubSurfaceConfiguration"
  58140. */
  58141. getClassName(): string;
  58142. /**
  58143. * Add fallbacks to the effect fallbacks list.
  58144. * @param defines defines the Base texture to use.
  58145. * @param fallbacks defines the current fallback list.
  58146. * @param currentRank defines the current fallback rank.
  58147. * @returns the new fallback rank.
  58148. */
  58149. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58150. /**
  58151. * Add the required uniforms to the current list.
  58152. * @param uniforms defines the current uniform list.
  58153. */
  58154. static AddUniforms(uniforms: string[]): void;
  58155. /**
  58156. * Add the required samplers to the current list.
  58157. * @param samplers defines the current sampler list.
  58158. */
  58159. static AddSamplers(samplers: string[]): void;
  58160. /**
  58161. * Add the required uniforms to the current buffer.
  58162. * @param uniformBuffer defines the current uniform buffer.
  58163. */
  58164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58165. /**
  58166. * Makes a duplicate of the current configuration into another one.
  58167. * @param configuration define the config where to copy the info
  58168. */
  58169. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58170. /**
  58171. * Serializes this Sub Surface configuration.
  58172. * @returns - An object with the serialized config.
  58173. */
  58174. serialize(): any;
  58175. /**
  58176. * Parses a anisotropy Configuration from a serialized object.
  58177. * @param source - Serialized object.
  58178. * @param scene Defines the scene we are parsing for
  58179. * @param rootUrl Defines the rootUrl to load from
  58180. */
  58181. parse(source: any, scene: Scene, rootUrl: string): void;
  58182. }
  58183. }
  58184. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58185. /** @hidden */
  58186. export var pbrFragmentDeclaration: {
  58187. name: string;
  58188. shader: string;
  58189. };
  58190. }
  58191. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58192. /** @hidden */
  58193. export var pbrUboDeclaration: {
  58194. name: string;
  58195. shader: string;
  58196. };
  58197. }
  58198. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58199. /** @hidden */
  58200. export var pbrFragmentExtraDeclaration: {
  58201. name: string;
  58202. shader: string;
  58203. };
  58204. }
  58205. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58206. /** @hidden */
  58207. export var pbrFragmentSamplersDeclaration: {
  58208. name: string;
  58209. shader: string;
  58210. };
  58211. }
  58212. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58213. /** @hidden */
  58214. export var importanceSampling: {
  58215. name: string;
  58216. shader: string;
  58217. };
  58218. }
  58219. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58220. /** @hidden */
  58221. export var pbrHelperFunctions: {
  58222. name: string;
  58223. shader: string;
  58224. };
  58225. }
  58226. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58227. /** @hidden */
  58228. export var harmonicsFunctions: {
  58229. name: string;
  58230. shader: string;
  58231. };
  58232. }
  58233. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58234. /** @hidden */
  58235. export var pbrDirectLightingSetupFunctions: {
  58236. name: string;
  58237. shader: string;
  58238. };
  58239. }
  58240. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58241. /** @hidden */
  58242. export var pbrDirectLightingFalloffFunctions: {
  58243. name: string;
  58244. shader: string;
  58245. };
  58246. }
  58247. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58248. /** @hidden */
  58249. export var pbrBRDFFunctions: {
  58250. name: string;
  58251. shader: string;
  58252. };
  58253. }
  58254. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58255. /** @hidden */
  58256. export var hdrFilteringFunctions: {
  58257. name: string;
  58258. shader: string;
  58259. };
  58260. }
  58261. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58262. /** @hidden */
  58263. export var pbrDirectLightingFunctions: {
  58264. name: string;
  58265. shader: string;
  58266. };
  58267. }
  58268. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58269. /** @hidden */
  58270. export var pbrIBLFunctions: {
  58271. name: string;
  58272. shader: string;
  58273. };
  58274. }
  58275. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58276. /** @hidden */
  58277. export var pbrBlockAlbedoOpacity: {
  58278. name: string;
  58279. shader: string;
  58280. };
  58281. }
  58282. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58283. /** @hidden */
  58284. export var pbrBlockReflectivity: {
  58285. name: string;
  58286. shader: string;
  58287. };
  58288. }
  58289. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58290. /** @hidden */
  58291. export var pbrBlockAmbientOcclusion: {
  58292. name: string;
  58293. shader: string;
  58294. };
  58295. }
  58296. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58297. /** @hidden */
  58298. export var pbrBlockAlphaFresnel: {
  58299. name: string;
  58300. shader: string;
  58301. };
  58302. }
  58303. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58304. /** @hidden */
  58305. export var pbrBlockAnisotropic: {
  58306. name: string;
  58307. shader: string;
  58308. };
  58309. }
  58310. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58311. /** @hidden */
  58312. export var pbrBlockReflection: {
  58313. name: string;
  58314. shader: string;
  58315. };
  58316. }
  58317. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58318. /** @hidden */
  58319. export var pbrBlockSheen: {
  58320. name: string;
  58321. shader: string;
  58322. };
  58323. }
  58324. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58325. /** @hidden */
  58326. export var pbrBlockClearcoat: {
  58327. name: string;
  58328. shader: string;
  58329. };
  58330. }
  58331. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58332. /** @hidden */
  58333. export var pbrBlockSubSurface: {
  58334. name: string;
  58335. shader: string;
  58336. };
  58337. }
  58338. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58339. /** @hidden */
  58340. export var pbrBlockNormalGeometric: {
  58341. name: string;
  58342. shader: string;
  58343. };
  58344. }
  58345. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58346. /** @hidden */
  58347. export var pbrBlockNormalFinal: {
  58348. name: string;
  58349. shader: string;
  58350. };
  58351. }
  58352. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58353. /** @hidden */
  58354. export var pbrBlockLightmapInit: {
  58355. name: string;
  58356. shader: string;
  58357. };
  58358. }
  58359. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58360. /** @hidden */
  58361. export var pbrBlockGeometryInfo: {
  58362. name: string;
  58363. shader: string;
  58364. };
  58365. }
  58366. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58367. /** @hidden */
  58368. export var pbrBlockReflectance0: {
  58369. name: string;
  58370. shader: string;
  58371. };
  58372. }
  58373. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58374. /** @hidden */
  58375. export var pbrBlockReflectance: {
  58376. name: string;
  58377. shader: string;
  58378. };
  58379. }
  58380. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58381. /** @hidden */
  58382. export var pbrBlockDirectLighting: {
  58383. name: string;
  58384. shader: string;
  58385. };
  58386. }
  58387. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58388. /** @hidden */
  58389. export var pbrBlockFinalLitComponents: {
  58390. name: string;
  58391. shader: string;
  58392. };
  58393. }
  58394. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58395. /** @hidden */
  58396. export var pbrBlockFinalUnlitComponents: {
  58397. name: string;
  58398. shader: string;
  58399. };
  58400. }
  58401. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58402. /** @hidden */
  58403. export var pbrBlockFinalColorComposition: {
  58404. name: string;
  58405. shader: string;
  58406. };
  58407. }
  58408. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58409. /** @hidden */
  58410. export var pbrBlockImageProcessing: {
  58411. name: string;
  58412. shader: string;
  58413. };
  58414. }
  58415. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58416. /** @hidden */
  58417. export var pbrDebug: {
  58418. name: string;
  58419. shader: string;
  58420. };
  58421. }
  58422. declare module "babylonjs/Shaders/pbr.fragment" {
  58423. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58424. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58425. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58426. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58427. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58428. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58429. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58430. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58432. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58433. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58434. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58435. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58436. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58437. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58438. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58439. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58440. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58441. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58442. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58443. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58444. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58445. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58446. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58447. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58448. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58449. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58450. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58451. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58452. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58453. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58454. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58455. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58456. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58457. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58458. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58459. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58460. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58461. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58462. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58463. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58464. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58465. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58466. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58467. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58468. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58469. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58470. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58471. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58472. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58473. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58474. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58475. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58476. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58477. /** @hidden */
  58478. export var pbrPixelShader: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58484. /** @hidden */
  58485. export var pbrVertexDeclaration: {
  58486. name: string;
  58487. shader: string;
  58488. };
  58489. }
  58490. declare module "babylonjs/Shaders/pbr.vertex" {
  58491. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58492. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58494. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58495. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58496. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58497. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58499. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58500. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58501. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58504. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58506. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58507. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58508. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58510. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58511. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58512. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58513. /** @hidden */
  58514. export var pbrVertexShader: {
  58515. name: string;
  58516. shader: string;
  58517. };
  58518. }
  58519. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58520. import { Nullable } from "babylonjs/types";
  58521. import { Scene } from "babylonjs/scene";
  58522. import { Matrix } from "babylonjs/Maths/math.vector";
  58523. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58525. import { Mesh } from "babylonjs/Meshes/mesh";
  58526. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58527. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58528. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58529. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58530. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58531. import { Color3 } from "babylonjs/Maths/math.color";
  58532. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58533. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58534. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58535. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58536. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58537. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58538. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58539. import "babylonjs/Shaders/pbr.fragment";
  58540. import "babylonjs/Shaders/pbr.vertex";
  58541. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58542. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58543. /**
  58544. * Manages the defines for the PBR Material.
  58545. * @hidden
  58546. */
  58547. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58548. PBR: boolean;
  58549. NUM_SAMPLES: string;
  58550. REALTIME_FILTERING: boolean;
  58551. MAINUV1: boolean;
  58552. MAINUV2: boolean;
  58553. UV1: boolean;
  58554. UV2: boolean;
  58555. ALBEDO: boolean;
  58556. GAMMAALBEDO: boolean;
  58557. ALBEDODIRECTUV: number;
  58558. VERTEXCOLOR: boolean;
  58559. DETAIL: boolean;
  58560. DETAILDIRECTUV: number;
  58561. DETAIL_NORMALBLENDMETHOD: number;
  58562. AMBIENT: boolean;
  58563. AMBIENTDIRECTUV: number;
  58564. AMBIENTINGRAYSCALE: boolean;
  58565. OPACITY: boolean;
  58566. VERTEXALPHA: boolean;
  58567. OPACITYDIRECTUV: number;
  58568. OPACITYRGB: boolean;
  58569. ALPHATEST: boolean;
  58570. DEPTHPREPASS: boolean;
  58571. ALPHABLEND: boolean;
  58572. ALPHAFROMALBEDO: boolean;
  58573. ALPHATESTVALUE: string;
  58574. SPECULAROVERALPHA: boolean;
  58575. RADIANCEOVERALPHA: boolean;
  58576. ALPHAFRESNEL: boolean;
  58577. LINEARALPHAFRESNEL: boolean;
  58578. PREMULTIPLYALPHA: boolean;
  58579. EMISSIVE: boolean;
  58580. EMISSIVEDIRECTUV: number;
  58581. REFLECTIVITY: boolean;
  58582. REFLECTIVITYDIRECTUV: number;
  58583. SPECULARTERM: boolean;
  58584. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58585. MICROSURFACEAUTOMATIC: boolean;
  58586. LODBASEDMICROSFURACE: boolean;
  58587. MICROSURFACEMAP: boolean;
  58588. MICROSURFACEMAPDIRECTUV: number;
  58589. METALLICWORKFLOW: boolean;
  58590. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58591. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58592. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58593. AOSTOREINMETALMAPRED: boolean;
  58594. METALLIC_REFLECTANCE: boolean;
  58595. METALLIC_REFLECTANCEDIRECTUV: number;
  58596. ENVIRONMENTBRDF: boolean;
  58597. ENVIRONMENTBRDF_RGBD: boolean;
  58598. NORMAL: boolean;
  58599. TANGENT: boolean;
  58600. BUMP: boolean;
  58601. BUMPDIRECTUV: number;
  58602. OBJECTSPACE_NORMALMAP: boolean;
  58603. PARALLAX: boolean;
  58604. PARALLAXOCCLUSION: boolean;
  58605. NORMALXYSCALE: boolean;
  58606. LIGHTMAP: boolean;
  58607. LIGHTMAPDIRECTUV: number;
  58608. USELIGHTMAPASSHADOWMAP: boolean;
  58609. GAMMALIGHTMAP: boolean;
  58610. RGBDLIGHTMAP: boolean;
  58611. REFLECTION: boolean;
  58612. REFLECTIONMAP_3D: boolean;
  58613. REFLECTIONMAP_SPHERICAL: boolean;
  58614. REFLECTIONMAP_PLANAR: boolean;
  58615. REFLECTIONMAP_CUBIC: boolean;
  58616. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58617. REFLECTIONMAP_PROJECTION: boolean;
  58618. REFLECTIONMAP_SKYBOX: boolean;
  58619. REFLECTIONMAP_EXPLICIT: boolean;
  58620. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58621. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58622. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58623. INVERTCUBICMAP: boolean;
  58624. USESPHERICALFROMREFLECTIONMAP: boolean;
  58625. USEIRRADIANCEMAP: boolean;
  58626. SPHERICAL_HARMONICS: boolean;
  58627. USESPHERICALINVERTEX: boolean;
  58628. REFLECTIONMAP_OPPOSITEZ: boolean;
  58629. LODINREFLECTIONALPHA: boolean;
  58630. GAMMAREFLECTION: boolean;
  58631. RGBDREFLECTION: boolean;
  58632. LINEARSPECULARREFLECTION: boolean;
  58633. RADIANCEOCCLUSION: boolean;
  58634. HORIZONOCCLUSION: boolean;
  58635. INSTANCES: boolean;
  58636. THIN_INSTANCES: boolean;
  58637. PREPASS: boolean;
  58638. SCENE_MRT_COUNT: number;
  58639. NUM_BONE_INFLUENCERS: number;
  58640. BonesPerMesh: number;
  58641. BONETEXTURE: boolean;
  58642. NONUNIFORMSCALING: boolean;
  58643. MORPHTARGETS: boolean;
  58644. MORPHTARGETS_NORMAL: boolean;
  58645. MORPHTARGETS_TANGENT: boolean;
  58646. MORPHTARGETS_UV: boolean;
  58647. NUM_MORPH_INFLUENCERS: number;
  58648. IMAGEPROCESSING: boolean;
  58649. VIGNETTE: boolean;
  58650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58651. VIGNETTEBLENDMODEOPAQUE: boolean;
  58652. TONEMAPPING: boolean;
  58653. TONEMAPPING_ACES: boolean;
  58654. CONTRAST: boolean;
  58655. COLORCURVES: boolean;
  58656. COLORGRADING: boolean;
  58657. COLORGRADING3D: boolean;
  58658. SAMPLER3DGREENDEPTH: boolean;
  58659. SAMPLER3DBGRMAP: boolean;
  58660. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58661. EXPOSURE: boolean;
  58662. MULTIVIEW: boolean;
  58663. USEPHYSICALLIGHTFALLOFF: boolean;
  58664. USEGLTFLIGHTFALLOFF: boolean;
  58665. TWOSIDEDLIGHTING: boolean;
  58666. SHADOWFLOAT: boolean;
  58667. CLIPPLANE: boolean;
  58668. CLIPPLANE2: boolean;
  58669. CLIPPLANE3: boolean;
  58670. CLIPPLANE4: boolean;
  58671. CLIPPLANE5: boolean;
  58672. CLIPPLANE6: boolean;
  58673. POINTSIZE: boolean;
  58674. FOG: boolean;
  58675. LOGARITHMICDEPTH: boolean;
  58676. FORCENORMALFORWARD: boolean;
  58677. SPECULARAA: boolean;
  58678. CLEARCOAT: boolean;
  58679. CLEARCOAT_DEFAULTIOR: boolean;
  58680. CLEARCOAT_TEXTURE: boolean;
  58681. CLEARCOAT_TEXTUREDIRECTUV: number;
  58682. CLEARCOAT_BUMP: boolean;
  58683. CLEARCOAT_BUMPDIRECTUV: number;
  58684. CLEARCOAT_TINT: boolean;
  58685. CLEARCOAT_TINT_TEXTURE: boolean;
  58686. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58687. ANISOTROPIC: boolean;
  58688. ANISOTROPIC_TEXTURE: boolean;
  58689. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58690. BRDF_V_HEIGHT_CORRELATED: boolean;
  58691. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58692. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58693. SHEEN: boolean;
  58694. SHEEN_TEXTURE: boolean;
  58695. SHEEN_TEXTUREDIRECTUV: number;
  58696. SHEEN_LINKWITHALBEDO: boolean;
  58697. SHEEN_ROUGHNESS: boolean;
  58698. SHEEN_ALBEDOSCALING: boolean;
  58699. SUBSURFACE: boolean;
  58700. SS_REFRACTION: boolean;
  58701. SS_TRANSLUCENCY: boolean;
  58702. SS_SCATTERING: boolean;
  58703. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58704. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58705. SS_REFRACTIONMAP_3D: boolean;
  58706. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58707. SS_LODINREFRACTIONALPHA: boolean;
  58708. SS_GAMMAREFRACTION: boolean;
  58709. SS_RGBDREFRACTION: boolean;
  58710. SS_LINEARSPECULARREFRACTION: boolean;
  58711. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58712. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58713. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58714. UNLIT: boolean;
  58715. DEBUGMODE: number;
  58716. /**
  58717. * Initializes the PBR Material defines.
  58718. */
  58719. constructor();
  58720. /**
  58721. * Resets the PBR Material defines.
  58722. */
  58723. reset(): void;
  58724. }
  58725. /**
  58726. * The Physically based material base class of BJS.
  58727. *
  58728. * This offers the main features of a standard PBR material.
  58729. * For more information, please refer to the documentation :
  58730. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58731. */
  58732. export abstract class PBRBaseMaterial extends PushMaterial {
  58733. /**
  58734. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58735. */
  58736. static readonly PBRMATERIAL_OPAQUE: number;
  58737. /**
  58738. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58739. */
  58740. static readonly PBRMATERIAL_ALPHATEST: number;
  58741. /**
  58742. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58743. */
  58744. static readonly PBRMATERIAL_ALPHABLEND: number;
  58745. /**
  58746. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58747. * They are also discarded below the alpha cutoff threshold to improve performances.
  58748. */
  58749. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58750. /**
  58751. * Defines the default value of how much AO map is occluding the analytical lights
  58752. * (point spot...).
  58753. */
  58754. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58755. /**
  58756. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58757. */
  58758. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58759. /**
  58760. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58761. * to enhance interoperability with other engines.
  58762. */
  58763. static readonly LIGHTFALLOFF_GLTF: number;
  58764. /**
  58765. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58766. * to enhance interoperability with other materials.
  58767. */
  58768. static readonly LIGHTFALLOFF_STANDARD: number;
  58769. /**
  58770. * Intensity of the direct lights e.g. the four lights available in your scene.
  58771. * This impacts both the direct diffuse and specular highlights.
  58772. */
  58773. protected _directIntensity: number;
  58774. /**
  58775. * Intensity of the emissive part of the material.
  58776. * This helps controlling the emissive effect without modifying the emissive color.
  58777. */
  58778. protected _emissiveIntensity: number;
  58779. /**
  58780. * Intensity of the environment e.g. how much the environment will light the object
  58781. * either through harmonics for rough material or through the refelction for shiny ones.
  58782. */
  58783. protected _environmentIntensity: number;
  58784. /**
  58785. * This is a special control allowing the reduction of the specular highlights coming from the
  58786. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58787. */
  58788. protected _specularIntensity: number;
  58789. /**
  58790. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58791. */
  58792. private _lightingInfos;
  58793. /**
  58794. * Debug Control allowing disabling the bump map on this material.
  58795. */
  58796. protected _disableBumpMap: boolean;
  58797. /**
  58798. * AKA Diffuse Texture in standard nomenclature.
  58799. */
  58800. protected _albedoTexture: Nullable<BaseTexture>;
  58801. /**
  58802. * AKA Occlusion Texture in other nomenclature.
  58803. */
  58804. protected _ambientTexture: Nullable<BaseTexture>;
  58805. /**
  58806. * AKA Occlusion Texture Intensity in other nomenclature.
  58807. */
  58808. protected _ambientTextureStrength: number;
  58809. /**
  58810. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58811. * 1 means it completely occludes it
  58812. * 0 mean it has no impact
  58813. */
  58814. protected _ambientTextureImpactOnAnalyticalLights: number;
  58815. /**
  58816. * Stores the alpha values in a texture.
  58817. */
  58818. protected _opacityTexture: Nullable<BaseTexture>;
  58819. /**
  58820. * Stores the reflection values in a texture.
  58821. */
  58822. protected _reflectionTexture: Nullable<BaseTexture>;
  58823. /**
  58824. * Stores the emissive values in a texture.
  58825. */
  58826. protected _emissiveTexture: Nullable<BaseTexture>;
  58827. /**
  58828. * AKA Specular texture in other nomenclature.
  58829. */
  58830. protected _reflectivityTexture: Nullable<BaseTexture>;
  58831. /**
  58832. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58833. */
  58834. protected _metallicTexture: Nullable<BaseTexture>;
  58835. /**
  58836. * Specifies the metallic scalar of the metallic/roughness workflow.
  58837. * Can also be used to scale the metalness values of the metallic texture.
  58838. */
  58839. protected _metallic: Nullable<number>;
  58840. /**
  58841. * Specifies the roughness scalar of the metallic/roughness workflow.
  58842. * Can also be used to scale the roughness values of the metallic texture.
  58843. */
  58844. protected _roughness: Nullable<number>;
  58845. /**
  58846. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58847. * By default the indexOfrefraction is used to compute F0;
  58848. *
  58849. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58850. *
  58851. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58852. * F90 = metallicReflectanceColor;
  58853. */
  58854. protected _metallicF0Factor: number;
  58855. /**
  58856. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58857. * By default the F90 is always 1;
  58858. *
  58859. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58860. *
  58861. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58862. * F90 = metallicReflectanceColor;
  58863. */
  58864. protected _metallicReflectanceColor: Color3;
  58865. /**
  58866. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58867. * This is multiply against the scalar values defined in the material.
  58868. */
  58869. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58870. /**
  58871. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58872. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58873. */
  58874. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58875. /**
  58876. * Stores surface normal data used to displace a mesh in a texture.
  58877. */
  58878. protected _bumpTexture: Nullable<BaseTexture>;
  58879. /**
  58880. * Stores the pre-calculated light information of a mesh in a texture.
  58881. */
  58882. protected _lightmapTexture: Nullable<BaseTexture>;
  58883. /**
  58884. * The color of a material in ambient lighting.
  58885. */
  58886. protected _ambientColor: Color3;
  58887. /**
  58888. * AKA Diffuse Color in other nomenclature.
  58889. */
  58890. protected _albedoColor: Color3;
  58891. /**
  58892. * AKA Specular Color in other nomenclature.
  58893. */
  58894. protected _reflectivityColor: Color3;
  58895. /**
  58896. * The color applied when light is reflected from a material.
  58897. */
  58898. protected _reflectionColor: Color3;
  58899. /**
  58900. * The color applied when light is emitted from a material.
  58901. */
  58902. protected _emissiveColor: Color3;
  58903. /**
  58904. * AKA Glossiness in other nomenclature.
  58905. */
  58906. protected _microSurface: number;
  58907. /**
  58908. * Specifies that the material will use the light map as a show map.
  58909. */
  58910. protected _useLightmapAsShadowmap: boolean;
  58911. /**
  58912. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58913. * makes the reflect vector face the model (under horizon).
  58914. */
  58915. protected _useHorizonOcclusion: boolean;
  58916. /**
  58917. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58918. * too much the area relying on ambient texture to define their ambient occlusion.
  58919. */
  58920. protected _useRadianceOcclusion: boolean;
  58921. /**
  58922. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58923. */
  58924. protected _useAlphaFromAlbedoTexture: boolean;
  58925. /**
  58926. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58927. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58928. */
  58929. protected _useSpecularOverAlpha: boolean;
  58930. /**
  58931. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58932. */
  58933. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58934. /**
  58935. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58936. */
  58937. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58938. /**
  58939. * Specifies if the metallic texture contains the roughness information in its green channel.
  58940. */
  58941. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58942. /**
  58943. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58944. */
  58945. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58946. /**
  58947. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58948. */
  58949. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58950. /**
  58951. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58952. */
  58953. protected _useAmbientInGrayScale: boolean;
  58954. /**
  58955. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58956. * The material will try to infer what glossiness each pixel should be.
  58957. */
  58958. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58959. /**
  58960. * Defines the falloff type used in this material.
  58961. * It by default is Physical.
  58962. */
  58963. protected _lightFalloff: number;
  58964. /**
  58965. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58966. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58967. */
  58968. protected _useRadianceOverAlpha: boolean;
  58969. /**
  58970. * Allows using an object space normal map (instead of tangent space).
  58971. */
  58972. protected _useObjectSpaceNormalMap: boolean;
  58973. /**
  58974. * Allows using the bump map in parallax mode.
  58975. */
  58976. protected _useParallax: boolean;
  58977. /**
  58978. * Allows using the bump map in parallax occlusion mode.
  58979. */
  58980. protected _useParallaxOcclusion: boolean;
  58981. /**
  58982. * Controls the scale bias of the parallax mode.
  58983. */
  58984. protected _parallaxScaleBias: number;
  58985. /**
  58986. * If sets to true, disables all the lights affecting the material.
  58987. */
  58988. protected _disableLighting: boolean;
  58989. /**
  58990. * Number of Simultaneous lights allowed on the material.
  58991. */
  58992. protected _maxSimultaneousLights: number;
  58993. /**
  58994. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58995. */
  58996. protected _invertNormalMapX: boolean;
  58997. /**
  58998. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58999. */
  59000. protected _invertNormalMapY: boolean;
  59001. /**
  59002. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59003. */
  59004. protected _twoSidedLighting: boolean;
  59005. /**
  59006. * Defines the alpha limits in alpha test mode.
  59007. */
  59008. protected _alphaCutOff: number;
  59009. /**
  59010. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59011. */
  59012. protected _forceAlphaTest: boolean;
  59013. /**
  59014. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59015. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59016. */
  59017. protected _useAlphaFresnel: boolean;
  59018. /**
  59019. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59020. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59021. */
  59022. protected _useLinearAlphaFresnel: boolean;
  59023. /**
  59024. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59025. * from cos thetav and roughness:
  59026. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59027. */
  59028. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59029. /**
  59030. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59031. */
  59032. protected _forceIrradianceInFragment: boolean;
  59033. private _realTimeFiltering;
  59034. /**
  59035. * Enables realtime filtering on the texture.
  59036. */
  59037. get realTimeFiltering(): boolean;
  59038. set realTimeFiltering(b: boolean);
  59039. private _realTimeFilteringQuality;
  59040. /**
  59041. * Quality switch for realtime filtering
  59042. */
  59043. get realTimeFilteringQuality(): number;
  59044. set realTimeFilteringQuality(n: number);
  59045. /**
  59046. * Can this material render to several textures at once
  59047. */
  59048. get canRenderToMRT(): boolean;
  59049. /**
  59050. * Force normal to face away from face.
  59051. */
  59052. protected _forceNormalForward: boolean;
  59053. /**
  59054. * Enables specular anti aliasing in the PBR shader.
  59055. * It will both interacts on the Geometry for analytical and IBL lighting.
  59056. * It also prefilter the roughness map based on the bump values.
  59057. */
  59058. protected _enableSpecularAntiAliasing: boolean;
  59059. /**
  59060. * Default configuration related to image processing available in the PBR Material.
  59061. */
  59062. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59063. /**
  59064. * Keep track of the image processing observer to allow dispose and replace.
  59065. */
  59066. private _imageProcessingObserver;
  59067. /**
  59068. * Attaches a new image processing configuration to the PBR Material.
  59069. * @param configuration
  59070. */
  59071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59072. /**
  59073. * Stores the available render targets.
  59074. */
  59075. private _renderTargets;
  59076. /**
  59077. * Sets the global ambient color for the material used in lighting calculations.
  59078. */
  59079. private _globalAmbientColor;
  59080. /**
  59081. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59082. */
  59083. private _useLogarithmicDepth;
  59084. /**
  59085. * If set to true, no lighting calculations will be applied.
  59086. */
  59087. private _unlit;
  59088. private _debugMode;
  59089. /**
  59090. * @hidden
  59091. * This is reserved for the inspector.
  59092. * Defines the material debug mode.
  59093. * It helps seeing only some components of the material while troubleshooting.
  59094. */
  59095. debugMode: number;
  59096. /**
  59097. * @hidden
  59098. * This is reserved for the inspector.
  59099. * Specify from where on screen the debug mode should start.
  59100. * The value goes from -1 (full screen) to 1 (not visible)
  59101. * It helps with side by side comparison against the final render
  59102. * This defaults to -1
  59103. */
  59104. private debugLimit;
  59105. /**
  59106. * @hidden
  59107. * This is reserved for the inspector.
  59108. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59109. * You can use the factor to better multiply the final value.
  59110. */
  59111. private debugFactor;
  59112. /**
  59113. * Defines the clear coat layer parameters for the material.
  59114. */
  59115. readonly clearCoat: PBRClearCoatConfiguration;
  59116. /**
  59117. * Defines the anisotropic parameters for the material.
  59118. */
  59119. readonly anisotropy: PBRAnisotropicConfiguration;
  59120. /**
  59121. * Defines the BRDF parameters for the material.
  59122. */
  59123. readonly brdf: PBRBRDFConfiguration;
  59124. /**
  59125. * Defines the Sheen parameters for the material.
  59126. */
  59127. readonly sheen: PBRSheenConfiguration;
  59128. /**
  59129. * Defines the SubSurface parameters for the material.
  59130. */
  59131. readonly subSurface: PBRSubSurfaceConfiguration;
  59132. /**
  59133. * Defines the detail map parameters for the material.
  59134. */
  59135. readonly detailMap: DetailMapConfiguration;
  59136. protected _rebuildInParallel: boolean;
  59137. /**
  59138. * Instantiates a new PBRMaterial instance.
  59139. *
  59140. * @param name The material name
  59141. * @param scene The scene the material will be use in.
  59142. */
  59143. constructor(name: string, scene: Scene);
  59144. /**
  59145. * Gets a boolean indicating that current material needs to register RTT
  59146. */
  59147. get hasRenderTargetTextures(): boolean;
  59148. /**
  59149. * Gets the name of the material class.
  59150. */
  59151. getClassName(): string;
  59152. /**
  59153. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59154. */
  59155. get useLogarithmicDepth(): boolean;
  59156. /**
  59157. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59158. */
  59159. set useLogarithmicDepth(value: boolean);
  59160. /**
  59161. * Returns true if alpha blending should be disabled.
  59162. */
  59163. protected get _disableAlphaBlending(): boolean;
  59164. /**
  59165. * Specifies whether or not this material should be rendered in alpha blend mode.
  59166. */
  59167. needAlphaBlending(): boolean;
  59168. /**
  59169. * Specifies whether or not this material should be rendered in alpha test mode.
  59170. */
  59171. needAlphaTesting(): boolean;
  59172. /**
  59173. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59174. */
  59175. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59176. /**
  59177. * Gets the texture used for the alpha test.
  59178. */
  59179. getAlphaTestTexture(): Nullable<BaseTexture>;
  59180. /**
  59181. * Specifies that the submesh is ready to be used.
  59182. * @param mesh - BJS mesh.
  59183. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59184. * @param useInstances - Specifies that instances should be used.
  59185. * @returns - boolean indicating that the submesh is ready or not.
  59186. */
  59187. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59188. /**
  59189. * Specifies if the material uses metallic roughness workflow.
  59190. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59191. */
  59192. isMetallicWorkflow(): boolean;
  59193. private _prepareEffect;
  59194. private _prepareDefines;
  59195. /**
  59196. * Force shader compilation
  59197. */
  59198. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59199. /**
  59200. * Initializes the uniform buffer layout for the shader.
  59201. */
  59202. buildUniformLayout(): void;
  59203. /**
  59204. * Unbinds the material from the mesh
  59205. */
  59206. unbind(): void;
  59207. /**
  59208. * Binds the submesh data.
  59209. * @param world - The world matrix.
  59210. * @param mesh - The BJS mesh.
  59211. * @param subMesh - A submesh of the BJS mesh.
  59212. */
  59213. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59214. /**
  59215. * Returns the animatable textures.
  59216. * @returns - Array of animatable textures.
  59217. */
  59218. getAnimatables(): IAnimatable[];
  59219. /**
  59220. * Returns the texture used for reflections.
  59221. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59222. */
  59223. private _getReflectionTexture;
  59224. /**
  59225. * Returns an array of the actively used textures.
  59226. * @returns - Array of BaseTextures
  59227. */
  59228. getActiveTextures(): BaseTexture[];
  59229. /**
  59230. * Checks to see if a texture is used in the material.
  59231. * @param texture - Base texture to use.
  59232. * @returns - Boolean specifying if a texture is used in the material.
  59233. */
  59234. hasTexture(texture: BaseTexture): boolean;
  59235. /**
  59236. * Sets the required values to the prepass renderer.
  59237. * @param prePassRenderer defines the prepass renderer to setup
  59238. */
  59239. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59240. /**
  59241. * Disposes the resources of the material.
  59242. * @param forceDisposeEffect - Forces the disposal of effects.
  59243. * @param forceDisposeTextures - Forces the disposal of all textures.
  59244. */
  59245. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59246. }
  59247. }
  59248. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59249. import { Nullable } from "babylonjs/types";
  59250. import { Scene } from "babylonjs/scene";
  59251. import { Color3 } from "babylonjs/Maths/math.color";
  59252. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59253. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59255. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59256. /**
  59257. * The Physically based material of BJS.
  59258. *
  59259. * This offers the main features of a standard PBR material.
  59260. * For more information, please refer to the documentation :
  59261. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59262. */
  59263. export class PBRMaterial extends PBRBaseMaterial {
  59264. /**
  59265. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59266. */
  59267. static readonly PBRMATERIAL_OPAQUE: number;
  59268. /**
  59269. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59270. */
  59271. static readonly PBRMATERIAL_ALPHATEST: number;
  59272. /**
  59273. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59274. */
  59275. static readonly PBRMATERIAL_ALPHABLEND: number;
  59276. /**
  59277. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59278. * They are also discarded below the alpha cutoff threshold to improve performances.
  59279. */
  59280. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59281. /**
  59282. * Defines the default value of how much AO map is occluding the analytical lights
  59283. * (point spot...).
  59284. */
  59285. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59286. /**
  59287. * Intensity of the direct lights e.g. the four lights available in your scene.
  59288. * This impacts both the direct diffuse and specular highlights.
  59289. */
  59290. directIntensity: number;
  59291. /**
  59292. * Intensity of the emissive part of the material.
  59293. * This helps controlling the emissive effect without modifying the emissive color.
  59294. */
  59295. emissiveIntensity: number;
  59296. /**
  59297. * Intensity of the environment e.g. how much the environment will light the object
  59298. * either through harmonics for rough material or through the refelction for shiny ones.
  59299. */
  59300. environmentIntensity: number;
  59301. /**
  59302. * This is a special control allowing the reduction of the specular highlights coming from the
  59303. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59304. */
  59305. specularIntensity: number;
  59306. /**
  59307. * Debug Control allowing disabling the bump map on this material.
  59308. */
  59309. disableBumpMap: boolean;
  59310. /**
  59311. * AKA Diffuse Texture in standard nomenclature.
  59312. */
  59313. albedoTexture: BaseTexture;
  59314. /**
  59315. * AKA Occlusion Texture in other nomenclature.
  59316. */
  59317. ambientTexture: BaseTexture;
  59318. /**
  59319. * AKA Occlusion Texture Intensity in other nomenclature.
  59320. */
  59321. ambientTextureStrength: number;
  59322. /**
  59323. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59324. * 1 means it completely occludes it
  59325. * 0 mean it has no impact
  59326. */
  59327. ambientTextureImpactOnAnalyticalLights: number;
  59328. /**
  59329. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59330. */
  59331. opacityTexture: BaseTexture;
  59332. /**
  59333. * Stores the reflection values in a texture.
  59334. */
  59335. reflectionTexture: Nullable<BaseTexture>;
  59336. /**
  59337. * Stores the emissive values in a texture.
  59338. */
  59339. emissiveTexture: BaseTexture;
  59340. /**
  59341. * AKA Specular texture in other nomenclature.
  59342. */
  59343. reflectivityTexture: BaseTexture;
  59344. /**
  59345. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59346. */
  59347. metallicTexture: BaseTexture;
  59348. /**
  59349. * Specifies the metallic scalar of the metallic/roughness workflow.
  59350. * Can also be used to scale the metalness values of the metallic texture.
  59351. */
  59352. metallic: Nullable<number>;
  59353. /**
  59354. * Specifies the roughness scalar of the metallic/roughness workflow.
  59355. * Can also be used to scale the roughness values of the metallic texture.
  59356. */
  59357. roughness: Nullable<number>;
  59358. /**
  59359. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59360. * By default the indexOfrefraction is used to compute F0;
  59361. *
  59362. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59363. *
  59364. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59365. * F90 = metallicReflectanceColor;
  59366. */
  59367. metallicF0Factor: number;
  59368. /**
  59369. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59370. * By default the F90 is always 1;
  59371. *
  59372. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59373. *
  59374. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59375. * F90 = metallicReflectanceColor;
  59376. */
  59377. metallicReflectanceColor: Color3;
  59378. /**
  59379. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59380. * This is multiply against the scalar values defined in the material.
  59381. */
  59382. metallicReflectanceTexture: Nullable<BaseTexture>;
  59383. /**
  59384. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59385. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59386. */
  59387. microSurfaceTexture: BaseTexture;
  59388. /**
  59389. * Stores surface normal data used to displace a mesh in a texture.
  59390. */
  59391. bumpTexture: BaseTexture;
  59392. /**
  59393. * Stores the pre-calculated light information of a mesh in a texture.
  59394. */
  59395. lightmapTexture: BaseTexture;
  59396. /**
  59397. * Stores the refracted light information in a texture.
  59398. */
  59399. get refractionTexture(): Nullable<BaseTexture>;
  59400. set refractionTexture(value: Nullable<BaseTexture>);
  59401. /**
  59402. * The color of a material in ambient lighting.
  59403. */
  59404. ambientColor: Color3;
  59405. /**
  59406. * AKA Diffuse Color in other nomenclature.
  59407. */
  59408. albedoColor: Color3;
  59409. /**
  59410. * AKA Specular Color in other nomenclature.
  59411. */
  59412. reflectivityColor: Color3;
  59413. /**
  59414. * The color reflected from the material.
  59415. */
  59416. reflectionColor: Color3;
  59417. /**
  59418. * The color emitted from the material.
  59419. */
  59420. emissiveColor: Color3;
  59421. /**
  59422. * AKA Glossiness in other nomenclature.
  59423. */
  59424. microSurface: number;
  59425. /**
  59426. * Index of refraction of the material base layer.
  59427. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59428. *
  59429. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59430. *
  59431. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59432. */
  59433. get indexOfRefraction(): number;
  59434. set indexOfRefraction(value: number);
  59435. /**
  59436. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59437. */
  59438. get invertRefractionY(): boolean;
  59439. set invertRefractionY(value: boolean);
  59440. /**
  59441. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59442. * Materials half opaque for instance using refraction could benefit from this control.
  59443. */
  59444. get linkRefractionWithTransparency(): boolean;
  59445. set linkRefractionWithTransparency(value: boolean);
  59446. /**
  59447. * If true, the light map contains occlusion information instead of lighting info.
  59448. */
  59449. useLightmapAsShadowmap: boolean;
  59450. /**
  59451. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59452. */
  59453. useAlphaFromAlbedoTexture: boolean;
  59454. /**
  59455. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59456. */
  59457. forceAlphaTest: boolean;
  59458. /**
  59459. * Defines the alpha limits in alpha test mode.
  59460. */
  59461. alphaCutOff: number;
  59462. /**
  59463. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59464. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59465. */
  59466. useSpecularOverAlpha: boolean;
  59467. /**
  59468. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59469. */
  59470. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59471. /**
  59472. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59473. */
  59474. useRoughnessFromMetallicTextureAlpha: boolean;
  59475. /**
  59476. * Specifies if the metallic texture contains the roughness information in its green channel.
  59477. */
  59478. useRoughnessFromMetallicTextureGreen: boolean;
  59479. /**
  59480. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59481. */
  59482. useMetallnessFromMetallicTextureBlue: boolean;
  59483. /**
  59484. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59485. */
  59486. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59487. /**
  59488. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59489. */
  59490. useAmbientInGrayScale: boolean;
  59491. /**
  59492. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59493. * The material will try to infer what glossiness each pixel should be.
  59494. */
  59495. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59496. /**
  59497. * BJS is using an harcoded light falloff based on a manually sets up range.
  59498. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59499. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59500. */
  59501. get usePhysicalLightFalloff(): boolean;
  59502. /**
  59503. * BJS is using an harcoded light falloff based on a manually sets up range.
  59504. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59505. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59506. */
  59507. set usePhysicalLightFalloff(value: boolean);
  59508. /**
  59509. * In order to support the falloff compatibility with gltf, a special mode has been added
  59510. * to reproduce the gltf light falloff.
  59511. */
  59512. get useGLTFLightFalloff(): boolean;
  59513. /**
  59514. * In order to support the falloff compatibility with gltf, a special mode has been added
  59515. * to reproduce the gltf light falloff.
  59516. */
  59517. set useGLTFLightFalloff(value: boolean);
  59518. /**
  59519. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59520. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59521. */
  59522. useRadianceOverAlpha: boolean;
  59523. /**
  59524. * Allows using an object space normal map (instead of tangent space).
  59525. */
  59526. useObjectSpaceNormalMap: boolean;
  59527. /**
  59528. * Allows using the bump map in parallax mode.
  59529. */
  59530. useParallax: boolean;
  59531. /**
  59532. * Allows using the bump map in parallax occlusion mode.
  59533. */
  59534. useParallaxOcclusion: boolean;
  59535. /**
  59536. * Controls the scale bias of the parallax mode.
  59537. */
  59538. parallaxScaleBias: number;
  59539. /**
  59540. * If sets to true, disables all the lights affecting the material.
  59541. */
  59542. disableLighting: boolean;
  59543. /**
  59544. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59545. */
  59546. forceIrradianceInFragment: boolean;
  59547. /**
  59548. * Number of Simultaneous lights allowed on the material.
  59549. */
  59550. maxSimultaneousLights: number;
  59551. /**
  59552. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59553. */
  59554. invertNormalMapX: boolean;
  59555. /**
  59556. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59557. */
  59558. invertNormalMapY: boolean;
  59559. /**
  59560. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59561. */
  59562. twoSidedLighting: boolean;
  59563. /**
  59564. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59565. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59566. */
  59567. useAlphaFresnel: boolean;
  59568. /**
  59569. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59570. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59571. */
  59572. useLinearAlphaFresnel: boolean;
  59573. /**
  59574. * Let user defines the brdf lookup texture used for IBL.
  59575. * A default 8bit version is embedded but you could point at :
  59576. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59577. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59578. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59579. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59580. */
  59581. environmentBRDFTexture: Nullable<BaseTexture>;
  59582. /**
  59583. * Force normal to face away from face.
  59584. */
  59585. forceNormalForward: boolean;
  59586. /**
  59587. * Enables specular anti aliasing in the PBR shader.
  59588. * It will both interacts on the Geometry for analytical and IBL lighting.
  59589. * It also prefilter the roughness map based on the bump values.
  59590. */
  59591. enableSpecularAntiAliasing: boolean;
  59592. /**
  59593. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59594. * makes the reflect vector face the model (under horizon).
  59595. */
  59596. useHorizonOcclusion: boolean;
  59597. /**
  59598. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59599. * too much the area relying on ambient texture to define their ambient occlusion.
  59600. */
  59601. useRadianceOcclusion: boolean;
  59602. /**
  59603. * If set to true, no lighting calculations will be applied.
  59604. */
  59605. unlit: boolean;
  59606. /**
  59607. * Gets the image processing configuration used either in this material.
  59608. */
  59609. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59610. /**
  59611. * Sets the Default image processing configuration used either in the this material.
  59612. *
  59613. * If sets to null, the scene one is in use.
  59614. */
  59615. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59616. /**
  59617. * Gets wether the color curves effect is enabled.
  59618. */
  59619. get cameraColorCurvesEnabled(): boolean;
  59620. /**
  59621. * Sets wether the color curves effect is enabled.
  59622. */
  59623. set cameraColorCurvesEnabled(value: boolean);
  59624. /**
  59625. * Gets wether the color grading effect is enabled.
  59626. */
  59627. get cameraColorGradingEnabled(): boolean;
  59628. /**
  59629. * Gets wether the color grading effect is enabled.
  59630. */
  59631. set cameraColorGradingEnabled(value: boolean);
  59632. /**
  59633. * Gets wether tonemapping is enabled or not.
  59634. */
  59635. get cameraToneMappingEnabled(): boolean;
  59636. /**
  59637. * Sets wether tonemapping is enabled or not
  59638. */
  59639. set cameraToneMappingEnabled(value: boolean);
  59640. /**
  59641. * The camera exposure used on this material.
  59642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59643. * This corresponds to a photographic exposure.
  59644. */
  59645. get cameraExposure(): number;
  59646. /**
  59647. * The camera exposure used on this material.
  59648. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59649. * This corresponds to a photographic exposure.
  59650. */
  59651. set cameraExposure(value: number);
  59652. /**
  59653. * Gets The camera contrast used on this material.
  59654. */
  59655. get cameraContrast(): number;
  59656. /**
  59657. * Sets The camera contrast used on this material.
  59658. */
  59659. set cameraContrast(value: number);
  59660. /**
  59661. * Gets the Color Grading 2D Lookup Texture.
  59662. */
  59663. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59664. /**
  59665. * Sets the Color Grading 2D Lookup Texture.
  59666. */
  59667. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59668. /**
  59669. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59670. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59671. * 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;
  59672. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59673. */
  59674. get cameraColorCurves(): Nullable<ColorCurves>;
  59675. /**
  59676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59678. * 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;
  59679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59680. */
  59681. set cameraColorCurves(value: Nullable<ColorCurves>);
  59682. /**
  59683. * Instantiates a new PBRMaterial instance.
  59684. *
  59685. * @param name The material name
  59686. * @param scene The scene the material will be use in.
  59687. */
  59688. constructor(name: string, scene: Scene);
  59689. /**
  59690. * Returns the name of this material class.
  59691. */
  59692. getClassName(): string;
  59693. /**
  59694. * Makes a duplicate of the current material.
  59695. * @param name - name to use for the new material.
  59696. */
  59697. clone(name: string): PBRMaterial;
  59698. /**
  59699. * Serializes this PBR Material.
  59700. * @returns - An object with the serialized material.
  59701. */
  59702. serialize(): any;
  59703. /**
  59704. * Parses a PBR Material from a serialized object.
  59705. * @param source - Serialized object.
  59706. * @param scene - BJS scene instance.
  59707. * @param rootUrl - url for the scene object
  59708. * @returns - PBRMaterial
  59709. */
  59710. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59711. }
  59712. }
  59713. declare module "babylonjs/Misc/dds" {
  59714. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59716. import { Nullable } from "babylonjs/types";
  59717. import { Scene } from "babylonjs/scene";
  59718. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59719. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59720. /**
  59721. * Direct draw surface info
  59722. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59723. */
  59724. export interface DDSInfo {
  59725. /**
  59726. * Width of the texture
  59727. */
  59728. width: number;
  59729. /**
  59730. * Width of the texture
  59731. */
  59732. height: number;
  59733. /**
  59734. * Number of Mipmaps for the texture
  59735. * @see https://en.wikipedia.org/wiki/Mipmap
  59736. */
  59737. mipmapCount: number;
  59738. /**
  59739. * If the textures format is a known fourCC format
  59740. * @see https://www.fourcc.org/
  59741. */
  59742. isFourCC: boolean;
  59743. /**
  59744. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59745. */
  59746. isRGB: boolean;
  59747. /**
  59748. * If the texture is a lumincance format
  59749. */
  59750. isLuminance: boolean;
  59751. /**
  59752. * If this is a cube texture
  59753. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59754. */
  59755. isCube: boolean;
  59756. /**
  59757. * If the texture is a compressed format eg. FOURCC_DXT1
  59758. */
  59759. isCompressed: boolean;
  59760. /**
  59761. * The dxgiFormat of the texture
  59762. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59763. */
  59764. dxgiFormat: number;
  59765. /**
  59766. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59767. */
  59768. textureType: number;
  59769. /**
  59770. * Sphericle polynomial created for the dds texture
  59771. */
  59772. sphericalPolynomial?: SphericalPolynomial;
  59773. }
  59774. /**
  59775. * Class used to provide DDS decompression tools
  59776. */
  59777. export class DDSTools {
  59778. /**
  59779. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59780. */
  59781. static StoreLODInAlphaChannel: boolean;
  59782. /**
  59783. * Gets DDS information from an array buffer
  59784. * @param data defines the array buffer view to read data from
  59785. * @returns the DDS information
  59786. */
  59787. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59788. private static _FloatView;
  59789. private static _Int32View;
  59790. private static _ToHalfFloat;
  59791. private static _FromHalfFloat;
  59792. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59793. private static _GetHalfFloatRGBAArrayBuffer;
  59794. private static _GetFloatRGBAArrayBuffer;
  59795. private static _GetFloatAsUIntRGBAArrayBuffer;
  59796. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59797. private static _GetRGBAArrayBuffer;
  59798. private static _ExtractLongWordOrder;
  59799. private static _GetRGBArrayBuffer;
  59800. private static _GetLuminanceArrayBuffer;
  59801. /**
  59802. * Uploads DDS Levels to a Babylon Texture
  59803. * @hidden
  59804. */
  59805. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59806. }
  59807. module "babylonjs/Engines/thinEngine" {
  59808. interface ThinEngine {
  59809. /**
  59810. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59811. * @param rootUrl defines the url where the file to load is located
  59812. * @param scene defines the current scene
  59813. * @param lodScale defines scale to apply to the mip map selection
  59814. * @param lodOffset defines offset to apply to the mip map selection
  59815. * @param onLoad defines an optional callback raised when the texture is loaded
  59816. * @param onError defines an optional callback raised if there is an issue to load the texture
  59817. * @param format defines the format of the data
  59818. * @param forcedExtension defines the extension to use to pick the right loader
  59819. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59820. * @returns the cube texture as an InternalTexture
  59821. */
  59822. 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;
  59823. }
  59824. }
  59825. }
  59826. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59827. import { Nullable } from "babylonjs/types";
  59828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59830. /**
  59831. * Implementation of the DDS Texture Loader.
  59832. * @hidden
  59833. */
  59834. export class _DDSTextureLoader implements IInternalTextureLoader {
  59835. /**
  59836. * Defines wether the loader supports cascade loading the different faces.
  59837. */
  59838. readonly supportCascades: boolean;
  59839. /**
  59840. * This returns if the loader support the current file information.
  59841. * @param extension defines the file extension of the file being loaded
  59842. * @returns true if the loader can load the specified file
  59843. */
  59844. canLoad(extension: string): boolean;
  59845. /**
  59846. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59847. * @param data contains the texture data
  59848. * @param texture defines the BabylonJS internal texture
  59849. * @param createPolynomials will be true if polynomials have been requested
  59850. * @param onLoad defines the callback to trigger once the texture is ready
  59851. * @param onError defines the callback to trigger in case of error
  59852. */
  59853. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59854. /**
  59855. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59856. * @param data contains the texture data
  59857. * @param texture defines the BabylonJS internal texture
  59858. * @param callback defines the method to call once ready to upload
  59859. */
  59860. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59861. }
  59862. }
  59863. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59864. import { Nullable } from "babylonjs/types";
  59865. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59866. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59867. /**
  59868. * Implementation of the ENV Texture Loader.
  59869. * @hidden
  59870. */
  59871. export class _ENVTextureLoader implements IInternalTextureLoader {
  59872. /**
  59873. * Defines wether the loader supports cascade loading the different faces.
  59874. */
  59875. readonly supportCascades: boolean;
  59876. /**
  59877. * This returns if the loader support the current file information.
  59878. * @param extension defines the file extension of the file being loaded
  59879. * @returns true if the loader can load the specified file
  59880. */
  59881. canLoad(extension: string): boolean;
  59882. /**
  59883. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59884. * @param data contains the texture data
  59885. * @param texture defines the BabylonJS internal texture
  59886. * @param createPolynomials will be true if polynomials have been requested
  59887. * @param onLoad defines the callback to trigger once the texture is ready
  59888. * @param onError defines the callback to trigger in case of error
  59889. */
  59890. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59891. /**
  59892. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59893. * @param data contains the texture data
  59894. * @param texture defines the BabylonJS internal texture
  59895. * @param callback defines the method to call once ready to upload
  59896. */
  59897. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59898. }
  59899. }
  59900. declare module "babylonjs/Misc/khronosTextureContainer" {
  59901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59902. /**
  59903. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59904. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59905. */
  59906. export class KhronosTextureContainer {
  59907. /** contents of the KTX container file */
  59908. data: ArrayBufferView;
  59909. private static HEADER_LEN;
  59910. private static COMPRESSED_2D;
  59911. private static COMPRESSED_3D;
  59912. private static TEX_2D;
  59913. private static TEX_3D;
  59914. /**
  59915. * Gets the openGL type
  59916. */
  59917. glType: number;
  59918. /**
  59919. * Gets the openGL type size
  59920. */
  59921. glTypeSize: number;
  59922. /**
  59923. * Gets the openGL format
  59924. */
  59925. glFormat: number;
  59926. /**
  59927. * Gets the openGL internal format
  59928. */
  59929. glInternalFormat: number;
  59930. /**
  59931. * Gets the base internal format
  59932. */
  59933. glBaseInternalFormat: number;
  59934. /**
  59935. * Gets image width in pixel
  59936. */
  59937. pixelWidth: number;
  59938. /**
  59939. * Gets image height in pixel
  59940. */
  59941. pixelHeight: number;
  59942. /**
  59943. * Gets image depth in pixels
  59944. */
  59945. pixelDepth: number;
  59946. /**
  59947. * Gets the number of array elements
  59948. */
  59949. numberOfArrayElements: number;
  59950. /**
  59951. * Gets the number of faces
  59952. */
  59953. numberOfFaces: number;
  59954. /**
  59955. * Gets the number of mipmap levels
  59956. */
  59957. numberOfMipmapLevels: number;
  59958. /**
  59959. * Gets the bytes of key value data
  59960. */
  59961. bytesOfKeyValueData: number;
  59962. /**
  59963. * Gets the load type
  59964. */
  59965. loadType: number;
  59966. /**
  59967. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59968. */
  59969. isInvalid: boolean;
  59970. /**
  59971. * Creates a new KhronosTextureContainer
  59972. * @param data contents of the KTX container file
  59973. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59974. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59975. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59976. */
  59977. constructor(
  59978. /** contents of the KTX container file */
  59979. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59980. /**
  59981. * Uploads KTX content to a Babylon Texture.
  59982. * It is assumed that the texture has already been created & is currently bound
  59983. * @hidden
  59984. */
  59985. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59986. private _upload2DCompressedLevels;
  59987. /**
  59988. * Checks if the given data starts with a KTX file identifier.
  59989. * @param data the data to check
  59990. * @returns true if the data is a KTX file or false otherwise
  59991. */
  59992. static IsValid(data: ArrayBufferView): boolean;
  59993. }
  59994. }
  59995. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59997. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59998. /**
  59999. * Class for loading KTX2 files
  60000. * !!! Experimental Extension Subject to Changes !!!
  60001. * @hidden
  60002. */
  60003. export class KhronosTextureContainer2 {
  60004. private static _ModulePromise;
  60005. private static _TranscodeFormat;
  60006. constructor(engine: ThinEngine);
  60007. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60008. private _determineTranscodeFormat;
  60009. /**
  60010. * Checks if the given data starts with a KTX2 file identifier.
  60011. * @param data the data to check
  60012. * @returns true if the data is a KTX2 file or false otherwise
  60013. */
  60014. static IsValid(data: ArrayBufferView): boolean;
  60015. }
  60016. }
  60017. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60018. import { Nullable } from "babylonjs/types";
  60019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60020. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60021. /**
  60022. * Implementation of the KTX Texture Loader.
  60023. * @hidden
  60024. */
  60025. export class _KTXTextureLoader implements IInternalTextureLoader {
  60026. /**
  60027. * Defines wether the loader supports cascade loading the different faces.
  60028. */
  60029. readonly supportCascades: boolean;
  60030. /**
  60031. * This returns if the loader support the current file information.
  60032. * @param extension defines the file extension of the file being loaded
  60033. * @param mimeType defines the optional mime type of the file being loaded
  60034. * @returns true if the loader can load the specified file
  60035. */
  60036. canLoad(extension: string, mimeType?: string): boolean;
  60037. /**
  60038. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60039. * @param data contains the texture data
  60040. * @param texture defines the BabylonJS internal texture
  60041. * @param createPolynomials will be true if polynomials have been requested
  60042. * @param onLoad defines the callback to trigger once the texture is ready
  60043. * @param onError defines the callback to trigger in case of error
  60044. */
  60045. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60046. /**
  60047. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60048. * @param data contains the texture data
  60049. * @param texture defines the BabylonJS internal texture
  60050. * @param callback defines the method to call once ready to upload
  60051. */
  60052. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60053. }
  60054. }
  60055. declare module "babylonjs/Helpers/sceneHelpers" {
  60056. import { Nullable } from "babylonjs/types";
  60057. import { Mesh } from "babylonjs/Meshes/mesh";
  60058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60059. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60060. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60061. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60062. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60063. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60064. import "babylonjs/Meshes/Builders/boxBuilder";
  60065. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60066. /** @hidden */
  60067. export var _forceSceneHelpersToBundle: boolean;
  60068. module "babylonjs/scene" {
  60069. interface Scene {
  60070. /**
  60071. * Creates a default light for the scene.
  60072. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60073. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60074. */
  60075. createDefaultLight(replace?: boolean): void;
  60076. /**
  60077. * Creates a default camera for the scene.
  60078. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60079. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60080. * @param replace has default false, when true replaces the active camera in the scene
  60081. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60082. */
  60083. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60084. /**
  60085. * Creates a default camera and a default light.
  60086. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60087. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60088. * @param replace has the default false, when true replaces the active camera/light in the scene
  60089. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60090. */
  60091. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60092. /**
  60093. * Creates a new sky box
  60094. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60095. * @param environmentTexture defines the texture to use as environment texture
  60096. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60097. * @param scale defines the overall scale of the skybox
  60098. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60099. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60100. * @returns a new mesh holding the sky box
  60101. */
  60102. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60103. /**
  60104. * Creates a new environment
  60105. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60106. * @param options defines the options you can use to configure the environment
  60107. * @returns the new EnvironmentHelper
  60108. */
  60109. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60110. /**
  60111. * Creates a new VREXperienceHelper
  60112. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60113. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60114. * @returns a new VREXperienceHelper
  60115. */
  60116. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60117. /**
  60118. * Creates a new WebXRDefaultExperience
  60119. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60120. * @param options experience options
  60121. * @returns a promise for a new WebXRDefaultExperience
  60122. */
  60123. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60124. }
  60125. }
  60126. }
  60127. declare module "babylonjs/Helpers/videoDome" {
  60128. import { Scene } from "babylonjs/scene";
  60129. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60130. import { Mesh } from "babylonjs/Meshes/mesh";
  60131. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60132. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60133. import "babylonjs/Meshes/Builders/sphereBuilder";
  60134. /**
  60135. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60136. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60137. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60138. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60139. */
  60140. export class VideoDome extends TransformNode {
  60141. /**
  60142. * Define the video source as a Monoscopic panoramic 360 video.
  60143. */
  60144. static readonly MODE_MONOSCOPIC: number;
  60145. /**
  60146. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60147. */
  60148. static readonly MODE_TOPBOTTOM: number;
  60149. /**
  60150. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60151. */
  60152. static readonly MODE_SIDEBYSIDE: number;
  60153. private _halfDome;
  60154. private _useDirectMapping;
  60155. /**
  60156. * The video texture being displayed on the sphere
  60157. */
  60158. protected _videoTexture: VideoTexture;
  60159. /**
  60160. * Gets the video texture being displayed on the sphere
  60161. */
  60162. get videoTexture(): VideoTexture;
  60163. /**
  60164. * The skybox material
  60165. */
  60166. protected _material: BackgroundMaterial;
  60167. /**
  60168. * The surface used for the video dome
  60169. */
  60170. protected _mesh: Mesh;
  60171. /**
  60172. * Gets the mesh used for the video dome.
  60173. */
  60174. get mesh(): Mesh;
  60175. /**
  60176. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  60177. */
  60178. private _halfDomeMask;
  60179. /**
  60180. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60181. * Also see the options.resolution property.
  60182. */
  60183. get fovMultiplier(): number;
  60184. set fovMultiplier(value: number);
  60185. private _videoMode;
  60186. /**
  60187. * Gets or set the current video mode for the video. It can be:
  60188. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60189. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60190. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60191. */
  60192. get videoMode(): number;
  60193. set videoMode(value: number);
  60194. /**
  60195. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60196. *
  60197. */
  60198. get halfDome(): boolean;
  60199. /**
  60200. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60201. */
  60202. set halfDome(enabled: boolean);
  60203. /**
  60204. * Oberserver used in Stereoscopic VR Mode.
  60205. */
  60206. private _onBeforeCameraRenderObserver;
  60207. /**
  60208. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60209. * @param name Element's name, child elements will append suffixes for their own names.
  60210. * @param urlsOrVideo defines the url(s) or the video element to use
  60211. * @param options An object containing optional or exposed sub element properties
  60212. */
  60213. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60214. resolution?: number;
  60215. clickToPlay?: boolean;
  60216. autoPlay?: boolean;
  60217. loop?: boolean;
  60218. size?: number;
  60219. poster?: string;
  60220. faceForward?: boolean;
  60221. useDirectMapping?: boolean;
  60222. halfDomeMode?: boolean;
  60223. }, scene: Scene);
  60224. private _changeVideoMode;
  60225. /**
  60226. * Releases resources associated with this node.
  60227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60229. */
  60230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60231. }
  60232. }
  60233. declare module "babylonjs/Helpers/index" {
  60234. export * from "babylonjs/Helpers/environmentHelper";
  60235. export * from "babylonjs/Helpers/photoDome";
  60236. export * from "babylonjs/Helpers/sceneHelpers";
  60237. export * from "babylonjs/Helpers/videoDome";
  60238. }
  60239. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60240. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60241. import { IDisposable } from "babylonjs/scene";
  60242. import { Engine } from "babylonjs/Engines/engine";
  60243. /**
  60244. * This class can be used to get instrumentation data from a Babylon engine
  60245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60246. */
  60247. export class EngineInstrumentation implements IDisposable {
  60248. /**
  60249. * Define the instrumented engine.
  60250. */
  60251. engine: Engine;
  60252. private _captureGPUFrameTime;
  60253. private _gpuFrameTimeToken;
  60254. private _gpuFrameTime;
  60255. private _captureShaderCompilationTime;
  60256. private _shaderCompilationTime;
  60257. private _onBeginFrameObserver;
  60258. private _onEndFrameObserver;
  60259. private _onBeforeShaderCompilationObserver;
  60260. private _onAfterShaderCompilationObserver;
  60261. /**
  60262. * Gets the perf counter used for GPU frame time
  60263. */
  60264. get gpuFrameTimeCounter(): PerfCounter;
  60265. /**
  60266. * Gets the GPU frame time capture status
  60267. */
  60268. get captureGPUFrameTime(): boolean;
  60269. /**
  60270. * Enable or disable the GPU frame time capture
  60271. */
  60272. set captureGPUFrameTime(value: boolean);
  60273. /**
  60274. * Gets the perf counter used for shader compilation time
  60275. */
  60276. get shaderCompilationTimeCounter(): PerfCounter;
  60277. /**
  60278. * Gets the shader compilation time capture status
  60279. */
  60280. get captureShaderCompilationTime(): boolean;
  60281. /**
  60282. * Enable or disable the shader compilation time capture
  60283. */
  60284. set captureShaderCompilationTime(value: boolean);
  60285. /**
  60286. * Instantiates a new engine instrumentation.
  60287. * This class can be used to get instrumentation data from a Babylon engine
  60288. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60289. * @param engine Defines the engine to instrument
  60290. */
  60291. constructor(
  60292. /**
  60293. * Define the instrumented engine.
  60294. */
  60295. engine: Engine);
  60296. /**
  60297. * Dispose and release associated resources.
  60298. */
  60299. dispose(): void;
  60300. }
  60301. }
  60302. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60303. import { Scene, IDisposable } from "babylonjs/scene";
  60304. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60305. /**
  60306. * This class can be used to get instrumentation data from a Babylon engine
  60307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60308. */
  60309. export class SceneInstrumentation implements IDisposable {
  60310. /**
  60311. * Defines the scene to instrument
  60312. */
  60313. scene: Scene;
  60314. private _captureActiveMeshesEvaluationTime;
  60315. private _activeMeshesEvaluationTime;
  60316. private _captureRenderTargetsRenderTime;
  60317. private _renderTargetsRenderTime;
  60318. private _captureFrameTime;
  60319. private _frameTime;
  60320. private _captureRenderTime;
  60321. private _renderTime;
  60322. private _captureInterFrameTime;
  60323. private _interFrameTime;
  60324. private _captureParticlesRenderTime;
  60325. private _particlesRenderTime;
  60326. private _captureSpritesRenderTime;
  60327. private _spritesRenderTime;
  60328. private _capturePhysicsTime;
  60329. private _physicsTime;
  60330. private _captureAnimationsTime;
  60331. private _animationsTime;
  60332. private _captureCameraRenderTime;
  60333. private _cameraRenderTime;
  60334. private _onBeforeActiveMeshesEvaluationObserver;
  60335. private _onAfterActiveMeshesEvaluationObserver;
  60336. private _onBeforeRenderTargetsRenderObserver;
  60337. private _onAfterRenderTargetsRenderObserver;
  60338. private _onAfterRenderObserver;
  60339. private _onBeforeDrawPhaseObserver;
  60340. private _onAfterDrawPhaseObserver;
  60341. private _onBeforeAnimationsObserver;
  60342. private _onBeforeParticlesRenderingObserver;
  60343. private _onAfterParticlesRenderingObserver;
  60344. private _onBeforeSpritesRenderingObserver;
  60345. private _onAfterSpritesRenderingObserver;
  60346. private _onBeforePhysicsObserver;
  60347. private _onAfterPhysicsObserver;
  60348. private _onAfterAnimationsObserver;
  60349. private _onBeforeCameraRenderObserver;
  60350. private _onAfterCameraRenderObserver;
  60351. /**
  60352. * Gets the perf counter used for active meshes evaluation time
  60353. */
  60354. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60355. /**
  60356. * Gets the active meshes evaluation time capture status
  60357. */
  60358. get captureActiveMeshesEvaluationTime(): boolean;
  60359. /**
  60360. * Enable or disable the active meshes evaluation time capture
  60361. */
  60362. set captureActiveMeshesEvaluationTime(value: boolean);
  60363. /**
  60364. * Gets the perf counter used for render targets render time
  60365. */
  60366. get renderTargetsRenderTimeCounter(): PerfCounter;
  60367. /**
  60368. * Gets the render targets render time capture status
  60369. */
  60370. get captureRenderTargetsRenderTime(): boolean;
  60371. /**
  60372. * Enable or disable the render targets render time capture
  60373. */
  60374. set captureRenderTargetsRenderTime(value: boolean);
  60375. /**
  60376. * Gets the perf counter used for particles render time
  60377. */
  60378. get particlesRenderTimeCounter(): PerfCounter;
  60379. /**
  60380. * Gets the particles render time capture status
  60381. */
  60382. get captureParticlesRenderTime(): boolean;
  60383. /**
  60384. * Enable or disable the particles render time capture
  60385. */
  60386. set captureParticlesRenderTime(value: boolean);
  60387. /**
  60388. * Gets the perf counter used for sprites render time
  60389. */
  60390. get spritesRenderTimeCounter(): PerfCounter;
  60391. /**
  60392. * Gets the sprites render time capture status
  60393. */
  60394. get captureSpritesRenderTime(): boolean;
  60395. /**
  60396. * Enable or disable the sprites render time capture
  60397. */
  60398. set captureSpritesRenderTime(value: boolean);
  60399. /**
  60400. * Gets the perf counter used for physics time
  60401. */
  60402. get physicsTimeCounter(): PerfCounter;
  60403. /**
  60404. * Gets the physics time capture status
  60405. */
  60406. get capturePhysicsTime(): boolean;
  60407. /**
  60408. * Enable or disable the physics time capture
  60409. */
  60410. set capturePhysicsTime(value: boolean);
  60411. /**
  60412. * Gets the perf counter used for animations time
  60413. */
  60414. get animationsTimeCounter(): PerfCounter;
  60415. /**
  60416. * Gets the animations time capture status
  60417. */
  60418. get captureAnimationsTime(): boolean;
  60419. /**
  60420. * Enable or disable the animations time capture
  60421. */
  60422. set captureAnimationsTime(value: boolean);
  60423. /**
  60424. * Gets the perf counter used for frame time capture
  60425. */
  60426. get frameTimeCounter(): PerfCounter;
  60427. /**
  60428. * Gets the frame time capture status
  60429. */
  60430. get captureFrameTime(): boolean;
  60431. /**
  60432. * Enable or disable the frame time capture
  60433. */
  60434. set captureFrameTime(value: boolean);
  60435. /**
  60436. * Gets the perf counter used for inter-frames time capture
  60437. */
  60438. get interFrameTimeCounter(): PerfCounter;
  60439. /**
  60440. * Gets the inter-frames time capture status
  60441. */
  60442. get captureInterFrameTime(): boolean;
  60443. /**
  60444. * Enable or disable the inter-frames time capture
  60445. */
  60446. set captureInterFrameTime(value: boolean);
  60447. /**
  60448. * Gets the perf counter used for render time capture
  60449. */
  60450. get renderTimeCounter(): PerfCounter;
  60451. /**
  60452. * Gets the render time capture status
  60453. */
  60454. get captureRenderTime(): boolean;
  60455. /**
  60456. * Enable or disable the render time capture
  60457. */
  60458. set captureRenderTime(value: boolean);
  60459. /**
  60460. * Gets the perf counter used for camera render time capture
  60461. */
  60462. get cameraRenderTimeCounter(): PerfCounter;
  60463. /**
  60464. * Gets the camera render time capture status
  60465. */
  60466. get captureCameraRenderTime(): boolean;
  60467. /**
  60468. * Enable or disable the camera render time capture
  60469. */
  60470. set captureCameraRenderTime(value: boolean);
  60471. /**
  60472. * Gets the perf counter used for draw calls
  60473. */
  60474. get drawCallsCounter(): PerfCounter;
  60475. /**
  60476. * Instantiates a new scene instrumentation.
  60477. * This class can be used to get instrumentation data from a Babylon engine
  60478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60479. * @param scene Defines the scene to instrument
  60480. */
  60481. constructor(
  60482. /**
  60483. * Defines the scene to instrument
  60484. */
  60485. scene: Scene);
  60486. /**
  60487. * Dispose and release associated resources.
  60488. */
  60489. dispose(): void;
  60490. }
  60491. }
  60492. declare module "babylonjs/Instrumentation/index" {
  60493. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60494. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60495. export * from "babylonjs/Instrumentation/timeToken";
  60496. }
  60497. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60498. /** @hidden */
  60499. export var glowMapGenerationPixelShader: {
  60500. name: string;
  60501. shader: string;
  60502. };
  60503. }
  60504. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60508. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60510. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60511. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60512. /** @hidden */
  60513. export var glowMapGenerationVertexShader: {
  60514. name: string;
  60515. shader: string;
  60516. };
  60517. }
  60518. declare module "babylonjs/Layers/effectLayer" {
  60519. import { Observable } from "babylonjs/Misc/observable";
  60520. import { Nullable } from "babylonjs/types";
  60521. import { Camera } from "babylonjs/Cameras/camera";
  60522. import { Scene } from "babylonjs/scene";
  60523. import { ISize } from "babylonjs/Maths/math.size";
  60524. import { Color4 } from "babylonjs/Maths/math.color";
  60525. import { Engine } from "babylonjs/Engines/engine";
  60526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60528. import { Mesh } from "babylonjs/Meshes/mesh";
  60529. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60532. import { Effect } from "babylonjs/Materials/effect";
  60533. import { Material } from "babylonjs/Materials/material";
  60534. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60535. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60536. /**
  60537. * Effect layer options. This helps customizing the behaviour
  60538. * of the effect layer.
  60539. */
  60540. export interface IEffectLayerOptions {
  60541. /**
  60542. * Multiplication factor apply to the canvas size to compute the render target size
  60543. * used to generated the objects (the smaller the faster).
  60544. */
  60545. mainTextureRatio: number;
  60546. /**
  60547. * Enforces a fixed size texture to ensure effect stability across devices.
  60548. */
  60549. mainTextureFixedSize?: number;
  60550. /**
  60551. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60552. */
  60553. alphaBlendingMode: number;
  60554. /**
  60555. * The camera attached to the layer.
  60556. */
  60557. camera: Nullable<Camera>;
  60558. /**
  60559. * The rendering group to draw the layer in.
  60560. */
  60561. renderingGroupId: number;
  60562. }
  60563. /**
  60564. * The effect layer Helps adding post process effect blended with the main pass.
  60565. *
  60566. * This can be for instance use to generate glow or higlight effects on the scene.
  60567. *
  60568. * The effect layer class can not be used directly and is intented to inherited from to be
  60569. * customized per effects.
  60570. */
  60571. export abstract class EffectLayer {
  60572. private _vertexBuffers;
  60573. private _indexBuffer;
  60574. private _cachedDefines;
  60575. private _effectLayerMapGenerationEffect;
  60576. private _effectLayerOptions;
  60577. private _mergeEffect;
  60578. protected _scene: Scene;
  60579. protected _engine: Engine;
  60580. protected _maxSize: number;
  60581. protected _mainTextureDesiredSize: ISize;
  60582. protected _mainTexture: RenderTargetTexture;
  60583. protected _shouldRender: boolean;
  60584. protected _postProcesses: PostProcess[];
  60585. protected _textures: BaseTexture[];
  60586. protected _emissiveTextureAndColor: {
  60587. texture: Nullable<BaseTexture>;
  60588. color: Color4;
  60589. };
  60590. /**
  60591. * The name of the layer
  60592. */
  60593. name: string;
  60594. /**
  60595. * The clear color of the texture used to generate the glow map.
  60596. */
  60597. neutralColor: Color4;
  60598. /**
  60599. * Specifies whether the highlight layer is enabled or not.
  60600. */
  60601. isEnabled: boolean;
  60602. /**
  60603. * Gets the camera attached to the layer.
  60604. */
  60605. get camera(): Nullable<Camera>;
  60606. /**
  60607. * Gets the rendering group id the layer should render in.
  60608. */
  60609. get renderingGroupId(): number;
  60610. set renderingGroupId(renderingGroupId: number);
  60611. /**
  60612. * An event triggered when the effect layer has been disposed.
  60613. */
  60614. onDisposeObservable: Observable<EffectLayer>;
  60615. /**
  60616. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60617. */
  60618. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60619. /**
  60620. * An event triggered when the generated texture is being merged in the scene.
  60621. */
  60622. onBeforeComposeObservable: Observable<EffectLayer>;
  60623. /**
  60624. * An event triggered when the mesh is rendered into the effect render target.
  60625. */
  60626. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60627. /**
  60628. * An event triggered after the mesh has been rendered into the effect render target.
  60629. */
  60630. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60631. /**
  60632. * An event triggered when the generated texture has been merged in the scene.
  60633. */
  60634. onAfterComposeObservable: Observable<EffectLayer>;
  60635. /**
  60636. * An event triggered when the efffect layer changes its size.
  60637. */
  60638. onSizeChangedObservable: Observable<EffectLayer>;
  60639. /** @hidden */
  60640. static _SceneComponentInitialization: (scene: Scene) => void;
  60641. /**
  60642. * Instantiates a new effect Layer and references it in the scene.
  60643. * @param name The name of the layer
  60644. * @param scene The scene to use the layer in
  60645. */
  60646. constructor(
  60647. /** The Friendly of the effect in the scene */
  60648. name: string, scene: Scene);
  60649. /**
  60650. * Get the effect name of the layer.
  60651. * @return The effect name
  60652. */
  60653. abstract getEffectName(): string;
  60654. /**
  60655. * Checks for the readiness of the element composing the layer.
  60656. * @param subMesh the mesh to check for
  60657. * @param useInstances specify whether or not to use instances to render the mesh
  60658. * @return true if ready otherwise, false
  60659. */
  60660. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60661. /**
  60662. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60663. * @returns true if the effect requires stencil during the main canvas render pass.
  60664. */
  60665. abstract needStencil(): boolean;
  60666. /**
  60667. * Create the merge effect. This is the shader use to blit the information back
  60668. * to the main canvas at the end of the scene rendering.
  60669. * @returns The effect containing the shader used to merge the effect on the main canvas
  60670. */
  60671. protected abstract _createMergeEffect(): Effect;
  60672. /**
  60673. * Creates the render target textures and post processes used in the effect layer.
  60674. */
  60675. protected abstract _createTextureAndPostProcesses(): void;
  60676. /**
  60677. * Implementation specific of rendering the generating effect on the main canvas.
  60678. * @param effect The effect used to render through
  60679. */
  60680. protected abstract _internalRender(effect: Effect): void;
  60681. /**
  60682. * Sets the required values for both the emissive texture and and the main color.
  60683. */
  60684. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60685. /**
  60686. * Free any resources and references associated to a mesh.
  60687. * Internal use
  60688. * @param mesh The mesh to free.
  60689. */
  60690. abstract _disposeMesh(mesh: Mesh): void;
  60691. /**
  60692. * Serializes this layer (Glow or Highlight for example)
  60693. * @returns a serialized layer object
  60694. */
  60695. abstract serialize?(): any;
  60696. /**
  60697. * Initializes the effect layer with the required options.
  60698. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60699. */
  60700. protected _init(options: Partial<IEffectLayerOptions>): void;
  60701. /**
  60702. * Generates the index buffer of the full screen quad blending to the main canvas.
  60703. */
  60704. private _generateIndexBuffer;
  60705. /**
  60706. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60707. */
  60708. private _generateVertexBuffer;
  60709. /**
  60710. * Sets the main texture desired size which is the closest power of two
  60711. * of the engine canvas size.
  60712. */
  60713. private _setMainTextureSize;
  60714. /**
  60715. * Creates the main texture for the effect layer.
  60716. */
  60717. protected _createMainTexture(): void;
  60718. /**
  60719. * Adds specific effects defines.
  60720. * @param defines The defines to add specifics to.
  60721. */
  60722. protected _addCustomEffectDefines(defines: string[]): void;
  60723. /**
  60724. * Checks for the readiness of the element composing the layer.
  60725. * @param subMesh the mesh to check for
  60726. * @param useInstances specify whether or not to use instances to render the mesh
  60727. * @param emissiveTexture the associated emissive texture used to generate the glow
  60728. * @return true if ready otherwise, false
  60729. */
  60730. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60731. /**
  60732. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60733. */
  60734. render(): void;
  60735. /**
  60736. * Determine if a given mesh will be used in the current effect.
  60737. * @param mesh mesh to test
  60738. * @returns true if the mesh will be used
  60739. */
  60740. hasMesh(mesh: AbstractMesh): boolean;
  60741. /**
  60742. * Returns true if the layer contains information to display, otherwise false.
  60743. * @returns true if the glow layer should be rendered
  60744. */
  60745. shouldRender(): boolean;
  60746. /**
  60747. * Returns true if the mesh should render, otherwise false.
  60748. * @param mesh The mesh to render
  60749. * @returns true if it should render otherwise false
  60750. */
  60751. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60752. /**
  60753. * Returns true if the mesh can be rendered, otherwise false.
  60754. * @param mesh The mesh to render
  60755. * @param material The material used on the mesh
  60756. * @returns true if it can be rendered otherwise false
  60757. */
  60758. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60759. /**
  60760. * Returns true if the mesh should render, otherwise false.
  60761. * @param mesh The mesh to render
  60762. * @returns true if it should render otherwise false
  60763. */
  60764. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60765. /**
  60766. * Renders the submesh passed in parameter to the generation map.
  60767. */
  60768. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60769. /**
  60770. * Defines whether the current material of the mesh should be use to render the effect.
  60771. * @param mesh defines the current mesh to render
  60772. */
  60773. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60774. /**
  60775. * Rebuild the required buffers.
  60776. * @hidden Internal use only.
  60777. */
  60778. _rebuild(): void;
  60779. /**
  60780. * Dispose only the render target textures and post process.
  60781. */
  60782. private _disposeTextureAndPostProcesses;
  60783. /**
  60784. * Dispose the highlight layer and free resources.
  60785. */
  60786. dispose(): void;
  60787. /**
  60788. * Gets the class name of the effect layer
  60789. * @returns the string with the class name of the effect layer
  60790. */
  60791. getClassName(): string;
  60792. /**
  60793. * Creates an effect layer from parsed effect layer data
  60794. * @param parsedEffectLayer defines effect layer data
  60795. * @param scene defines the current scene
  60796. * @param rootUrl defines the root URL containing the effect layer information
  60797. * @returns a parsed effect Layer
  60798. */
  60799. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60800. }
  60801. }
  60802. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60803. import { Scene } from "babylonjs/scene";
  60804. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60805. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60806. import { AbstractScene } from "babylonjs/abstractScene";
  60807. module "babylonjs/abstractScene" {
  60808. interface AbstractScene {
  60809. /**
  60810. * The list of effect layers (highlights/glow) added to the scene
  60811. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60812. * @see https://doc.babylonjs.com/how_to/glow_layer
  60813. */
  60814. effectLayers: Array<EffectLayer>;
  60815. /**
  60816. * Removes the given effect layer from this scene.
  60817. * @param toRemove defines the effect layer to remove
  60818. * @returns the index of the removed effect layer
  60819. */
  60820. removeEffectLayer(toRemove: EffectLayer): number;
  60821. /**
  60822. * Adds the given effect layer to this scene
  60823. * @param newEffectLayer defines the effect layer to add
  60824. */
  60825. addEffectLayer(newEffectLayer: EffectLayer): void;
  60826. }
  60827. }
  60828. /**
  60829. * Defines the layer scene component responsible to manage any effect layers
  60830. * in a given scene.
  60831. */
  60832. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60833. /**
  60834. * The component name helpfull to identify the component in the list of scene components.
  60835. */
  60836. readonly name: string;
  60837. /**
  60838. * The scene the component belongs to.
  60839. */
  60840. scene: Scene;
  60841. private _engine;
  60842. private _renderEffects;
  60843. private _needStencil;
  60844. private _previousStencilState;
  60845. /**
  60846. * Creates a new instance of the component for the given scene
  60847. * @param scene Defines the scene to register the component in
  60848. */
  60849. constructor(scene: Scene);
  60850. /**
  60851. * Registers the component in a given scene
  60852. */
  60853. register(): void;
  60854. /**
  60855. * Rebuilds the elements related to this component in case of
  60856. * context lost for instance.
  60857. */
  60858. rebuild(): void;
  60859. /**
  60860. * Serializes the component data to the specified json object
  60861. * @param serializationObject The object to serialize to
  60862. */
  60863. serialize(serializationObject: any): void;
  60864. /**
  60865. * Adds all the elements from the container to the scene
  60866. * @param container the container holding the elements
  60867. */
  60868. addFromContainer(container: AbstractScene): void;
  60869. /**
  60870. * Removes all the elements in the container from the scene
  60871. * @param container contains the elements to remove
  60872. * @param dispose if the removed element should be disposed (default: false)
  60873. */
  60874. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60875. /**
  60876. * Disposes the component and the associated ressources.
  60877. */
  60878. dispose(): void;
  60879. private _isReadyForMesh;
  60880. private _renderMainTexture;
  60881. private _setStencil;
  60882. private _setStencilBack;
  60883. private _draw;
  60884. private _drawCamera;
  60885. private _drawRenderingGroup;
  60886. }
  60887. }
  60888. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60889. /** @hidden */
  60890. export var glowMapMergePixelShader: {
  60891. name: string;
  60892. shader: string;
  60893. };
  60894. }
  60895. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60896. /** @hidden */
  60897. export var glowMapMergeVertexShader: {
  60898. name: string;
  60899. shader: string;
  60900. };
  60901. }
  60902. declare module "babylonjs/Layers/glowLayer" {
  60903. import { Nullable } from "babylonjs/types";
  60904. import { Camera } from "babylonjs/Cameras/camera";
  60905. import { Scene } from "babylonjs/scene";
  60906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60908. import { Mesh } from "babylonjs/Meshes/mesh";
  60909. import { Texture } from "babylonjs/Materials/Textures/texture";
  60910. import { Effect } from "babylonjs/Materials/effect";
  60911. import { Material } from "babylonjs/Materials/material";
  60912. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60913. import { Color4 } from "babylonjs/Maths/math.color";
  60914. import "babylonjs/Shaders/glowMapMerge.fragment";
  60915. import "babylonjs/Shaders/glowMapMerge.vertex";
  60916. import "babylonjs/Layers/effectLayerSceneComponent";
  60917. module "babylonjs/abstractScene" {
  60918. interface AbstractScene {
  60919. /**
  60920. * Return a the first highlight layer of the scene with a given name.
  60921. * @param name The name of the highlight layer to look for.
  60922. * @return The highlight layer if found otherwise null.
  60923. */
  60924. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60925. }
  60926. }
  60927. /**
  60928. * Glow layer options. This helps customizing the behaviour
  60929. * of the glow layer.
  60930. */
  60931. export interface IGlowLayerOptions {
  60932. /**
  60933. * Multiplication factor apply to the canvas size to compute the render target size
  60934. * used to generated the glowing objects (the smaller the faster).
  60935. */
  60936. mainTextureRatio: number;
  60937. /**
  60938. * Enforces a fixed size texture to ensure resize independant blur.
  60939. */
  60940. mainTextureFixedSize?: number;
  60941. /**
  60942. * How big is the kernel of the blur texture.
  60943. */
  60944. blurKernelSize: number;
  60945. /**
  60946. * The camera attached to the layer.
  60947. */
  60948. camera: Nullable<Camera>;
  60949. /**
  60950. * Enable MSAA by chosing the number of samples.
  60951. */
  60952. mainTextureSamples?: number;
  60953. /**
  60954. * The rendering group to draw the layer in.
  60955. */
  60956. renderingGroupId: number;
  60957. }
  60958. /**
  60959. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60960. *
  60961. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60962. *
  60963. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60964. */
  60965. export class GlowLayer extends EffectLayer {
  60966. /**
  60967. * Effect Name of the layer.
  60968. */
  60969. static readonly EffectName: string;
  60970. /**
  60971. * The default blur kernel size used for the glow.
  60972. */
  60973. static DefaultBlurKernelSize: number;
  60974. /**
  60975. * The default texture size ratio used for the glow.
  60976. */
  60977. static DefaultTextureRatio: number;
  60978. /**
  60979. * Sets the kernel size of the blur.
  60980. */
  60981. set blurKernelSize(value: number);
  60982. /**
  60983. * Gets the kernel size of the blur.
  60984. */
  60985. get blurKernelSize(): number;
  60986. /**
  60987. * Sets the glow intensity.
  60988. */
  60989. set intensity(value: number);
  60990. /**
  60991. * Gets the glow intensity.
  60992. */
  60993. get intensity(): number;
  60994. private _options;
  60995. private _intensity;
  60996. private _horizontalBlurPostprocess1;
  60997. private _verticalBlurPostprocess1;
  60998. private _horizontalBlurPostprocess2;
  60999. private _verticalBlurPostprocess2;
  61000. private _blurTexture1;
  61001. private _blurTexture2;
  61002. private _postProcesses1;
  61003. private _postProcesses2;
  61004. private _includedOnlyMeshes;
  61005. private _excludedMeshes;
  61006. private _meshesUsingTheirOwnMaterials;
  61007. /**
  61008. * Callback used to let the user override the color selection on a per mesh basis
  61009. */
  61010. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61011. /**
  61012. * Callback used to let the user override the texture selection on a per mesh basis
  61013. */
  61014. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61015. /**
  61016. * Instantiates a new glow Layer and references it to the scene.
  61017. * @param name The name of the layer
  61018. * @param scene The scene to use the layer in
  61019. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61020. */
  61021. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61022. /**
  61023. * Get the effect name of the layer.
  61024. * @return The effect name
  61025. */
  61026. getEffectName(): string;
  61027. /**
  61028. * Create the merge effect. This is the shader use to blit the information back
  61029. * to the main canvas at the end of the scene rendering.
  61030. */
  61031. protected _createMergeEffect(): Effect;
  61032. /**
  61033. * Creates the render target textures and post processes used in the glow layer.
  61034. */
  61035. protected _createTextureAndPostProcesses(): void;
  61036. /**
  61037. * Checks for the readiness of the element composing the layer.
  61038. * @param subMesh the mesh to check for
  61039. * @param useInstances specify wether or not to use instances to render the mesh
  61040. * @param emissiveTexture the associated emissive texture used to generate the glow
  61041. * @return true if ready otherwise, false
  61042. */
  61043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61044. /**
  61045. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61046. */
  61047. needStencil(): boolean;
  61048. /**
  61049. * Returns true if the mesh can be rendered, otherwise false.
  61050. * @param mesh The mesh to render
  61051. * @param material The material used on the mesh
  61052. * @returns true if it can be rendered otherwise false
  61053. */
  61054. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61055. /**
  61056. * Implementation specific of rendering the generating effect on the main canvas.
  61057. * @param effect The effect used to render through
  61058. */
  61059. protected _internalRender(effect: Effect): void;
  61060. /**
  61061. * Sets the required values for both the emissive texture and and the main color.
  61062. */
  61063. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61064. /**
  61065. * Returns true if the mesh should render, otherwise false.
  61066. * @param mesh The mesh to render
  61067. * @returns true if it should render otherwise false
  61068. */
  61069. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61070. /**
  61071. * Adds specific effects defines.
  61072. * @param defines The defines to add specifics to.
  61073. */
  61074. protected _addCustomEffectDefines(defines: string[]): void;
  61075. /**
  61076. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61077. * @param mesh The mesh to exclude from the glow layer
  61078. */
  61079. addExcludedMesh(mesh: Mesh): void;
  61080. /**
  61081. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61082. * @param mesh The mesh to remove
  61083. */
  61084. removeExcludedMesh(mesh: Mesh): void;
  61085. /**
  61086. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61087. * @param mesh The mesh to include in the glow layer
  61088. */
  61089. addIncludedOnlyMesh(mesh: Mesh): void;
  61090. /**
  61091. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61092. * @param mesh The mesh to remove
  61093. */
  61094. removeIncludedOnlyMesh(mesh: Mesh): void;
  61095. /**
  61096. * Determine if a given mesh will be used in the glow layer
  61097. * @param mesh The mesh to test
  61098. * @returns true if the mesh will be highlighted by the current glow layer
  61099. */
  61100. hasMesh(mesh: AbstractMesh): boolean;
  61101. /**
  61102. * Defines whether the current material of the mesh should be use to render the effect.
  61103. * @param mesh defines the current mesh to render
  61104. */
  61105. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61106. /**
  61107. * Add a mesh to be rendered through its own material and not with emissive only.
  61108. * @param mesh The mesh for which we need to use its material
  61109. */
  61110. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61111. /**
  61112. * Remove a mesh from being rendered through its own material and not with emissive only.
  61113. * @param mesh The mesh for which we need to not use its material
  61114. */
  61115. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61116. /**
  61117. * Free any resources and references associated to a mesh.
  61118. * Internal use
  61119. * @param mesh The mesh to free.
  61120. * @hidden
  61121. */
  61122. _disposeMesh(mesh: Mesh): void;
  61123. /**
  61124. * Gets the class name of the effect layer
  61125. * @returns the string with the class name of the effect layer
  61126. */
  61127. getClassName(): string;
  61128. /**
  61129. * Serializes this glow layer
  61130. * @returns a serialized glow layer object
  61131. */
  61132. serialize(): any;
  61133. /**
  61134. * Creates a Glow Layer from parsed glow layer data
  61135. * @param parsedGlowLayer defines glow layer data
  61136. * @param scene defines the current scene
  61137. * @param rootUrl defines the root URL containing the glow layer information
  61138. * @returns a parsed Glow Layer
  61139. */
  61140. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61141. }
  61142. }
  61143. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61144. /** @hidden */
  61145. export var glowBlurPostProcessPixelShader: {
  61146. name: string;
  61147. shader: string;
  61148. };
  61149. }
  61150. declare module "babylonjs/Layers/highlightLayer" {
  61151. import { Observable } from "babylonjs/Misc/observable";
  61152. import { Nullable } from "babylonjs/types";
  61153. import { Camera } from "babylonjs/Cameras/camera";
  61154. import { Scene } from "babylonjs/scene";
  61155. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61157. import { Mesh } from "babylonjs/Meshes/mesh";
  61158. import { Effect } from "babylonjs/Materials/effect";
  61159. import { Material } from "babylonjs/Materials/material";
  61160. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61161. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61162. import "babylonjs/Shaders/glowMapMerge.fragment";
  61163. import "babylonjs/Shaders/glowMapMerge.vertex";
  61164. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61165. module "babylonjs/abstractScene" {
  61166. interface AbstractScene {
  61167. /**
  61168. * Return a the first highlight layer of the scene with a given name.
  61169. * @param name The name of the highlight layer to look for.
  61170. * @return The highlight layer if found otherwise null.
  61171. */
  61172. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61173. }
  61174. }
  61175. /**
  61176. * Highlight layer options. This helps customizing the behaviour
  61177. * of the highlight layer.
  61178. */
  61179. export interface IHighlightLayerOptions {
  61180. /**
  61181. * Multiplication factor apply to the canvas size to compute the render target size
  61182. * used to generated the glowing objects (the smaller the faster).
  61183. */
  61184. mainTextureRatio: number;
  61185. /**
  61186. * Enforces a fixed size texture to ensure resize independant blur.
  61187. */
  61188. mainTextureFixedSize?: number;
  61189. /**
  61190. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61191. * of the picture to blur (the smaller the faster).
  61192. */
  61193. blurTextureSizeRatio: number;
  61194. /**
  61195. * How big in texel of the blur texture is the vertical blur.
  61196. */
  61197. blurVerticalSize: number;
  61198. /**
  61199. * How big in texel of the blur texture is the horizontal blur.
  61200. */
  61201. blurHorizontalSize: number;
  61202. /**
  61203. * Alpha blending mode used to apply the blur. Default is combine.
  61204. */
  61205. alphaBlendingMode: number;
  61206. /**
  61207. * The camera attached to the layer.
  61208. */
  61209. camera: Nullable<Camera>;
  61210. /**
  61211. * Should we display highlight as a solid stroke?
  61212. */
  61213. isStroke?: boolean;
  61214. /**
  61215. * The rendering group to draw the layer in.
  61216. */
  61217. renderingGroupId: number;
  61218. }
  61219. /**
  61220. * The highlight layer Helps adding a glow effect around a mesh.
  61221. *
  61222. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61223. * glowy meshes to your scene.
  61224. *
  61225. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61226. */
  61227. export class HighlightLayer extends EffectLayer {
  61228. name: string;
  61229. /**
  61230. * Effect Name of the highlight layer.
  61231. */
  61232. static readonly EffectName: string;
  61233. /**
  61234. * The neutral color used during the preparation of the glow effect.
  61235. * This is black by default as the blend operation is a blend operation.
  61236. */
  61237. static NeutralColor: Color4;
  61238. /**
  61239. * Stencil value used for glowing meshes.
  61240. */
  61241. static GlowingMeshStencilReference: number;
  61242. /**
  61243. * Stencil value used for the other meshes in the scene.
  61244. */
  61245. static NormalMeshStencilReference: number;
  61246. /**
  61247. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61248. */
  61249. innerGlow: boolean;
  61250. /**
  61251. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61252. */
  61253. outerGlow: boolean;
  61254. /**
  61255. * Specifies the horizontal size of the blur.
  61256. */
  61257. set blurHorizontalSize(value: number);
  61258. /**
  61259. * Specifies the vertical size of the blur.
  61260. */
  61261. set blurVerticalSize(value: number);
  61262. /**
  61263. * Gets the horizontal size of the blur.
  61264. */
  61265. get blurHorizontalSize(): number;
  61266. /**
  61267. * Gets the vertical size of the blur.
  61268. */
  61269. get blurVerticalSize(): number;
  61270. /**
  61271. * An event triggered when the highlight layer is being blurred.
  61272. */
  61273. onBeforeBlurObservable: Observable<HighlightLayer>;
  61274. /**
  61275. * An event triggered when the highlight layer has been blurred.
  61276. */
  61277. onAfterBlurObservable: Observable<HighlightLayer>;
  61278. private _instanceGlowingMeshStencilReference;
  61279. private _options;
  61280. private _downSamplePostprocess;
  61281. private _horizontalBlurPostprocess;
  61282. private _verticalBlurPostprocess;
  61283. private _blurTexture;
  61284. private _meshes;
  61285. private _excludedMeshes;
  61286. /**
  61287. * Instantiates a new highlight Layer and references it to the scene..
  61288. * @param name The name of the layer
  61289. * @param scene The scene to use the layer in
  61290. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61291. */
  61292. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61293. /**
  61294. * Get the effect name of the layer.
  61295. * @return The effect name
  61296. */
  61297. getEffectName(): string;
  61298. /**
  61299. * Create the merge effect. This is the shader use to blit the information back
  61300. * to the main canvas at the end of the scene rendering.
  61301. */
  61302. protected _createMergeEffect(): Effect;
  61303. /**
  61304. * Creates the render target textures and post processes used in the highlight layer.
  61305. */
  61306. protected _createTextureAndPostProcesses(): void;
  61307. /**
  61308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61309. */
  61310. needStencil(): boolean;
  61311. /**
  61312. * Checks for the readiness of the element composing the layer.
  61313. * @param subMesh the mesh to check for
  61314. * @param useInstances specify wether or not to use instances to render the mesh
  61315. * @param emissiveTexture the associated emissive texture used to generate the glow
  61316. * @return true if ready otherwise, false
  61317. */
  61318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61319. /**
  61320. * Implementation specific of rendering the generating effect on the main canvas.
  61321. * @param effect The effect used to render through
  61322. */
  61323. protected _internalRender(effect: Effect): void;
  61324. /**
  61325. * Returns true if the layer contains information to display, otherwise false.
  61326. */
  61327. shouldRender(): boolean;
  61328. /**
  61329. * Returns true if the mesh should render, otherwise false.
  61330. * @param mesh The mesh to render
  61331. * @returns true if it should render otherwise false
  61332. */
  61333. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61334. /**
  61335. * Returns true if the mesh can be rendered, otherwise false.
  61336. * @param mesh The mesh to render
  61337. * @param material The material used on the mesh
  61338. * @returns true if it can be rendered otherwise false
  61339. */
  61340. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61341. /**
  61342. * Adds specific effects defines.
  61343. * @param defines The defines to add specifics to.
  61344. */
  61345. protected _addCustomEffectDefines(defines: string[]): void;
  61346. /**
  61347. * Sets the required values for both the emissive texture and and the main color.
  61348. */
  61349. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61350. /**
  61351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61352. * @param mesh The mesh to exclude from the highlight layer
  61353. */
  61354. addExcludedMesh(mesh: Mesh): void;
  61355. /**
  61356. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61357. * @param mesh The mesh to highlight
  61358. */
  61359. removeExcludedMesh(mesh: Mesh): void;
  61360. /**
  61361. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61362. * @param mesh mesh to test
  61363. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61364. */
  61365. hasMesh(mesh: AbstractMesh): boolean;
  61366. /**
  61367. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61368. * @param mesh The mesh to highlight
  61369. * @param color The color of the highlight
  61370. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61371. */
  61372. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61373. /**
  61374. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61375. * @param mesh The mesh to highlight
  61376. */
  61377. removeMesh(mesh: Mesh): void;
  61378. /**
  61379. * Remove all the meshes currently referenced in the highlight layer
  61380. */
  61381. removeAllMeshes(): void;
  61382. /**
  61383. * Force the stencil to the normal expected value for none glowing parts
  61384. */
  61385. private _defaultStencilReference;
  61386. /**
  61387. * Free any resources and references associated to a mesh.
  61388. * Internal use
  61389. * @param mesh The mesh to free.
  61390. * @hidden
  61391. */
  61392. _disposeMesh(mesh: Mesh): void;
  61393. /**
  61394. * Dispose the highlight layer and free resources.
  61395. */
  61396. dispose(): void;
  61397. /**
  61398. * Gets the class name of the effect layer
  61399. * @returns the string with the class name of the effect layer
  61400. */
  61401. getClassName(): string;
  61402. /**
  61403. * Serializes this Highlight layer
  61404. * @returns a serialized Highlight layer object
  61405. */
  61406. serialize(): any;
  61407. /**
  61408. * Creates a Highlight layer from parsed Highlight layer data
  61409. * @param parsedHightlightLayer defines the Highlight layer data
  61410. * @param scene defines the current scene
  61411. * @param rootUrl defines the root URL containing the Highlight layer information
  61412. * @returns a parsed Highlight layer
  61413. */
  61414. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61415. }
  61416. }
  61417. declare module "babylonjs/Layers/layerSceneComponent" {
  61418. import { Scene } from "babylonjs/scene";
  61419. import { ISceneComponent } from "babylonjs/sceneComponent";
  61420. import { Layer } from "babylonjs/Layers/layer";
  61421. import { AbstractScene } from "babylonjs/abstractScene";
  61422. module "babylonjs/abstractScene" {
  61423. interface AbstractScene {
  61424. /**
  61425. * The list of layers (background and foreground) of the scene
  61426. */
  61427. layers: Array<Layer>;
  61428. }
  61429. }
  61430. /**
  61431. * Defines the layer scene component responsible to manage any layers
  61432. * in a given scene.
  61433. */
  61434. export class LayerSceneComponent implements ISceneComponent {
  61435. /**
  61436. * The component name helpfull to identify the component in the list of scene components.
  61437. */
  61438. readonly name: string;
  61439. /**
  61440. * The scene the component belongs to.
  61441. */
  61442. scene: Scene;
  61443. private _engine;
  61444. /**
  61445. * Creates a new instance of the component for the given scene
  61446. * @param scene Defines the scene to register the component in
  61447. */
  61448. constructor(scene: Scene);
  61449. /**
  61450. * Registers the component in a given scene
  61451. */
  61452. register(): void;
  61453. /**
  61454. * Rebuilds the elements related to this component in case of
  61455. * context lost for instance.
  61456. */
  61457. rebuild(): void;
  61458. /**
  61459. * Disposes the component and the associated ressources.
  61460. */
  61461. dispose(): void;
  61462. private _draw;
  61463. private _drawCameraPredicate;
  61464. private _drawCameraBackground;
  61465. private _drawCameraForeground;
  61466. private _drawRenderTargetPredicate;
  61467. private _drawRenderTargetBackground;
  61468. private _drawRenderTargetForeground;
  61469. /**
  61470. * Adds all the elements from the container to the scene
  61471. * @param container the container holding the elements
  61472. */
  61473. addFromContainer(container: AbstractScene): void;
  61474. /**
  61475. * Removes all the elements in the container from the scene
  61476. * @param container contains the elements to remove
  61477. * @param dispose if the removed element should be disposed (default: false)
  61478. */
  61479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61480. }
  61481. }
  61482. declare module "babylonjs/Shaders/layer.fragment" {
  61483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61484. /** @hidden */
  61485. export var layerPixelShader: {
  61486. name: string;
  61487. shader: string;
  61488. };
  61489. }
  61490. declare module "babylonjs/Shaders/layer.vertex" {
  61491. /** @hidden */
  61492. export var layerVertexShader: {
  61493. name: string;
  61494. shader: string;
  61495. };
  61496. }
  61497. declare module "babylonjs/Layers/layer" {
  61498. import { Observable } from "babylonjs/Misc/observable";
  61499. import { Nullable } from "babylonjs/types";
  61500. import { Scene } from "babylonjs/scene";
  61501. import { Vector2 } from "babylonjs/Maths/math.vector";
  61502. import { Color4 } from "babylonjs/Maths/math.color";
  61503. import { Texture } from "babylonjs/Materials/Textures/texture";
  61504. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61505. import "babylonjs/Shaders/layer.fragment";
  61506. import "babylonjs/Shaders/layer.vertex";
  61507. /**
  61508. * This represents a full screen 2d layer.
  61509. * This can be useful to display a picture in the background of your scene for instance.
  61510. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61511. */
  61512. export class Layer {
  61513. /**
  61514. * Define the name of the layer.
  61515. */
  61516. name: string;
  61517. /**
  61518. * Define the texture the layer should display.
  61519. */
  61520. texture: Nullable<Texture>;
  61521. /**
  61522. * Is the layer in background or foreground.
  61523. */
  61524. isBackground: boolean;
  61525. /**
  61526. * Define the color of the layer (instead of texture).
  61527. */
  61528. color: Color4;
  61529. /**
  61530. * Define the scale of the layer in order to zoom in out of the texture.
  61531. */
  61532. scale: Vector2;
  61533. /**
  61534. * Define an offset for the layer in order to shift the texture.
  61535. */
  61536. offset: Vector2;
  61537. /**
  61538. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61539. */
  61540. alphaBlendingMode: number;
  61541. /**
  61542. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61543. * Alpha test will not mix with the background color in case of transparency.
  61544. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61545. */
  61546. alphaTest: boolean;
  61547. /**
  61548. * Define a mask to restrict the layer to only some of the scene cameras.
  61549. */
  61550. layerMask: number;
  61551. /**
  61552. * Define the list of render target the layer is visible into.
  61553. */
  61554. renderTargetTextures: RenderTargetTexture[];
  61555. /**
  61556. * Define if the layer is only used in renderTarget or if it also
  61557. * renders in the main frame buffer of the canvas.
  61558. */
  61559. renderOnlyInRenderTargetTextures: boolean;
  61560. private _scene;
  61561. private _vertexBuffers;
  61562. private _indexBuffer;
  61563. private _effect;
  61564. private _previousDefines;
  61565. /**
  61566. * An event triggered when the layer is disposed.
  61567. */
  61568. onDisposeObservable: Observable<Layer>;
  61569. private _onDisposeObserver;
  61570. /**
  61571. * Back compatibility with callback before the onDisposeObservable existed.
  61572. * The set callback will be triggered when the layer has been disposed.
  61573. */
  61574. set onDispose(callback: () => void);
  61575. /**
  61576. * An event triggered before rendering the scene
  61577. */
  61578. onBeforeRenderObservable: Observable<Layer>;
  61579. private _onBeforeRenderObserver;
  61580. /**
  61581. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61582. * The set callback will be triggered just before rendering the layer.
  61583. */
  61584. set onBeforeRender(callback: () => void);
  61585. /**
  61586. * An event triggered after rendering the scene
  61587. */
  61588. onAfterRenderObservable: Observable<Layer>;
  61589. private _onAfterRenderObserver;
  61590. /**
  61591. * Back compatibility with callback before the onAfterRenderObservable existed.
  61592. * The set callback will be triggered just after rendering the layer.
  61593. */
  61594. set onAfterRender(callback: () => void);
  61595. /**
  61596. * Instantiates a new layer.
  61597. * This represents a full screen 2d layer.
  61598. * This can be useful to display a picture in the background of your scene for instance.
  61599. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61600. * @param name Define the name of the layer in the scene
  61601. * @param imgUrl Define the url of the texture to display in the layer
  61602. * @param scene Define the scene the layer belongs to
  61603. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61604. * @param color Defines a color for the layer
  61605. */
  61606. constructor(
  61607. /**
  61608. * Define the name of the layer.
  61609. */
  61610. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61611. private _createIndexBuffer;
  61612. /** @hidden */
  61613. _rebuild(): void;
  61614. /**
  61615. * Renders the layer in the scene.
  61616. */
  61617. render(): void;
  61618. /**
  61619. * Disposes and releases the associated ressources.
  61620. */
  61621. dispose(): void;
  61622. }
  61623. }
  61624. declare module "babylonjs/Layers/index" {
  61625. export * from "babylonjs/Layers/effectLayer";
  61626. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61627. export * from "babylonjs/Layers/glowLayer";
  61628. export * from "babylonjs/Layers/highlightLayer";
  61629. export * from "babylonjs/Layers/layer";
  61630. export * from "babylonjs/Layers/layerSceneComponent";
  61631. }
  61632. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61633. /** @hidden */
  61634. export var lensFlarePixelShader: {
  61635. name: string;
  61636. shader: string;
  61637. };
  61638. }
  61639. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61640. /** @hidden */
  61641. export var lensFlareVertexShader: {
  61642. name: string;
  61643. shader: string;
  61644. };
  61645. }
  61646. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61647. import { Scene } from "babylonjs/scene";
  61648. import { Vector3 } from "babylonjs/Maths/math.vector";
  61649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61650. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61651. import "babylonjs/Shaders/lensFlare.fragment";
  61652. import "babylonjs/Shaders/lensFlare.vertex";
  61653. import { Viewport } from "babylonjs/Maths/math.viewport";
  61654. /**
  61655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61656. * It is usually composed of several `lensFlare`.
  61657. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61658. */
  61659. export class LensFlareSystem {
  61660. /**
  61661. * Define the name of the lens flare system
  61662. */
  61663. name: string;
  61664. /**
  61665. * List of lens flares used in this system.
  61666. */
  61667. lensFlares: LensFlare[];
  61668. /**
  61669. * Define a limit from the border the lens flare can be visible.
  61670. */
  61671. borderLimit: number;
  61672. /**
  61673. * Define a viewport border we do not want to see the lens flare in.
  61674. */
  61675. viewportBorder: number;
  61676. /**
  61677. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61678. */
  61679. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61680. /**
  61681. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61682. */
  61683. layerMask: number;
  61684. /**
  61685. * Define the id of the lens flare system in the scene.
  61686. * (equal to name by default)
  61687. */
  61688. id: string;
  61689. private _scene;
  61690. private _emitter;
  61691. private _vertexBuffers;
  61692. private _indexBuffer;
  61693. private _effect;
  61694. private _positionX;
  61695. private _positionY;
  61696. private _isEnabled;
  61697. /** @hidden */
  61698. static _SceneComponentInitialization: (scene: Scene) => void;
  61699. /**
  61700. * Instantiates a lens flare system.
  61701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61702. * It is usually composed of several `lensFlare`.
  61703. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61704. * @param name Define the name of the lens flare system in the scene
  61705. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61706. * @param scene Define the scene the lens flare system belongs to
  61707. */
  61708. constructor(
  61709. /**
  61710. * Define the name of the lens flare system
  61711. */
  61712. name: string, emitter: any, scene: Scene);
  61713. /**
  61714. * Define if the lens flare system is enabled.
  61715. */
  61716. get isEnabled(): boolean;
  61717. set isEnabled(value: boolean);
  61718. /**
  61719. * Get the scene the effects belongs to.
  61720. * @returns the scene holding the lens flare system
  61721. */
  61722. getScene(): Scene;
  61723. /**
  61724. * Get the emitter of the lens flare system.
  61725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61726. * @returns the emitter of the lens flare system
  61727. */
  61728. getEmitter(): any;
  61729. /**
  61730. * Set the emitter of the lens flare system.
  61731. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61732. * @param newEmitter Define the new emitter of the system
  61733. */
  61734. setEmitter(newEmitter: any): void;
  61735. /**
  61736. * Get the lens flare system emitter position.
  61737. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61738. * @returns the position
  61739. */
  61740. getEmitterPosition(): Vector3;
  61741. /**
  61742. * @hidden
  61743. */
  61744. computeEffectivePosition(globalViewport: Viewport): boolean;
  61745. /** @hidden */
  61746. _isVisible(): boolean;
  61747. /**
  61748. * @hidden
  61749. */
  61750. render(): boolean;
  61751. /**
  61752. * Dispose and release the lens flare with its associated resources.
  61753. */
  61754. dispose(): void;
  61755. /**
  61756. * Parse a lens flare system from a JSON repressentation
  61757. * @param parsedLensFlareSystem Define the JSON to parse
  61758. * @param scene Define the scene the parsed system should be instantiated in
  61759. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61760. * @returns the parsed system
  61761. */
  61762. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61763. /**
  61764. * Serialize the current Lens Flare System into a JSON representation.
  61765. * @returns the serialized JSON
  61766. */
  61767. serialize(): any;
  61768. }
  61769. }
  61770. declare module "babylonjs/LensFlares/lensFlare" {
  61771. import { Nullable } from "babylonjs/types";
  61772. import { Color3 } from "babylonjs/Maths/math.color";
  61773. import { Texture } from "babylonjs/Materials/Textures/texture";
  61774. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61775. /**
  61776. * This represents one of the lens effect in a `lensFlareSystem`.
  61777. * It controls one of the indiviual texture used in the effect.
  61778. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61779. */
  61780. export class LensFlare {
  61781. /**
  61782. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61783. */
  61784. size: number;
  61785. /**
  61786. * 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.
  61787. */
  61788. position: number;
  61789. /**
  61790. * Define the lens color.
  61791. */
  61792. color: Color3;
  61793. /**
  61794. * Define the lens texture.
  61795. */
  61796. texture: Nullable<Texture>;
  61797. /**
  61798. * Define the alpha mode to render this particular lens.
  61799. */
  61800. alphaMode: number;
  61801. private _system;
  61802. /**
  61803. * Creates a new Lens Flare.
  61804. * This represents one of the lens effect in a `lensFlareSystem`.
  61805. * It controls one of the indiviual texture used in the effect.
  61806. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61807. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61808. * @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.
  61809. * @param color Define the lens color
  61810. * @param imgUrl Define the lens texture url
  61811. * @param system Define the `lensFlareSystem` this flare is part of
  61812. * @returns The newly created Lens Flare
  61813. */
  61814. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61815. /**
  61816. * Instantiates a new Lens Flare.
  61817. * This represents one of the lens effect in a `lensFlareSystem`.
  61818. * It controls one of the indiviual texture used in the effect.
  61819. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61820. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61821. * @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.
  61822. * @param color Define the lens color
  61823. * @param imgUrl Define the lens texture url
  61824. * @param system Define the `lensFlareSystem` this flare is part of
  61825. */
  61826. constructor(
  61827. /**
  61828. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61829. */
  61830. size: number,
  61831. /**
  61832. * 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.
  61833. */
  61834. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61835. /**
  61836. * Dispose and release the lens flare with its associated resources.
  61837. */
  61838. dispose(): void;
  61839. }
  61840. }
  61841. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61842. import { Nullable } from "babylonjs/types";
  61843. import { Scene } from "babylonjs/scene";
  61844. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61845. import { AbstractScene } from "babylonjs/abstractScene";
  61846. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61847. module "babylonjs/abstractScene" {
  61848. interface AbstractScene {
  61849. /**
  61850. * The list of lens flare system added to the scene
  61851. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61852. */
  61853. lensFlareSystems: Array<LensFlareSystem>;
  61854. /**
  61855. * Removes the given lens flare system from this scene.
  61856. * @param toRemove The lens flare system to remove
  61857. * @returns The index of the removed lens flare system
  61858. */
  61859. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61860. /**
  61861. * Adds the given lens flare system to this scene
  61862. * @param newLensFlareSystem The lens flare system to add
  61863. */
  61864. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61865. /**
  61866. * Gets a lens flare system using its name
  61867. * @param name defines the name to look for
  61868. * @returns the lens flare system or null if not found
  61869. */
  61870. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61871. /**
  61872. * Gets a lens flare system using its id
  61873. * @param id defines the id to look for
  61874. * @returns the lens flare system or null if not found
  61875. */
  61876. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61877. }
  61878. }
  61879. /**
  61880. * Defines the lens flare scene component responsible to manage any lens flares
  61881. * in a given scene.
  61882. */
  61883. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61884. /**
  61885. * The component name helpfull to identify the component in the list of scene components.
  61886. */
  61887. readonly name: string;
  61888. /**
  61889. * The scene the component belongs to.
  61890. */
  61891. scene: Scene;
  61892. /**
  61893. * Creates a new instance of the component for the given scene
  61894. * @param scene Defines the scene to register the component in
  61895. */
  61896. constructor(scene: Scene);
  61897. /**
  61898. * Registers the component in a given scene
  61899. */
  61900. register(): void;
  61901. /**
  61902. * Rebuilds the elements related to this component in case of
  61903. * context lost for instance.
  61904. */
  61905. rebuild(): void;
  61906. /**
  61907. * Adds all the elements from the container to the scene
  61908. * @param container the container holding the elements
  61909. */
  61910. addFromContainer(container: AbstractScene): void;
  61911. /**
  61912. * Removes all the elements in the container from the scene
  61913. * @param container contains the elements to remove
  61914. * @param dispose if the removed element should be disposed (default: false)
  61915. */
  61916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61917. /**
  61918. * Serializes the component data to the specified json object
  61919. * @param serializationObject The object to serialize to
  61920. */
  61921. serialize(serializationObject: any): void;
  61922. /**
  61923. * Disposes the component and the associated ressources.
  61924. */
  61925. dispose(): void;
  61926. private _draw;
  61927. }
  61928. }
  61929. declare module "babylonjs/LensFlares/index" {
  61930. export * from "babylonjs/LensFlares/lensFlare";
  61931. export * from "babylonjs/LensFlares/lensFlareSystem";
  61932. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61933. }
  61934. declare module "babylonjs/Shaders/depth.fragment" {
  61935. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61936. /** @hidden */
  61937. export var depthPixelShader: {
  61938. name: string;
  61939. shader: string;
  61940. };
  61941. }
  61942. declare module "babylonjs/Shaders/depth.vertex" {
  61943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61946. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61950. /** @hidden */
  61951. export var depthVertexShader: {
  61952. name: string;
  61953. shader: string;
  61954. };
  61955. }
  61956. declare module "babylonjs/Rendering/depthRenderer" {
  61957. import { Nullable } from "babylonjs/types";
  61958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61959. import { Scene } from "babylonjs/scene";
  61960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61961. import { Camera } from "babylonjs/Cameras/camera";
  61962. import "babylonjs/Shaders/depth.fragment";
  61963. import "babylonjs/Shaders/depth.vertex";
  61964. /**
  61965. * This represents a depth renderer in Babylon.
  61966. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61967. */
  61968. export class DepthRenderer {
  61969. private _scene;
  61970. private _depthMap;
  61971. private _effect;
  61972. private readonly _storeNonLinearDepth;
  61973. private readonly _clearColor;
  61974. /** Get if the depth renderer is using packed depth or not */
  61975. readonly isPacked: boolean;
  61976. private _cachedDefines;
  61977. private _camera;
  61978. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61979. enabled: boolean;
  61980. /**
  61981. * Specifiess that the depth renderer will only be used within
  61982. * the camera it is created for.
  61983. * This can help forcing its rendering during the camera processing.
  61984. */
  61985. useOnlyInActiveCamera: boolean;
  61986. /** @hidden */
  61987. static _SceneComponentInitialization: (scene: Scene) => void;
  61988. /**
  61989. * Instantiates a depth renderer
  61990. * @param scene The scene the renderer belongs to
  61991. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61992. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61994. */
  61995. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61996. /**
  61997. * Creates the depth rendering effect and checks if the effect is ready.
  61998. * @param subMesh The submesh to be used to render the depth map of
  61999. * @param useInstances If multiple world instances should be used
  62000. * @returns if the depth renderer is ready to render the depth map
  62001. */
  62002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62003. /**
  62004. * Gets the texture which the depth map will be written to.
  62005. * @returns The depth map texture
  62006. */
  62007. getDepthMap(): RenderTargetTexture;
  62008. /**
  62009. * Disposes of the depth renderer.
  62010. */
  62011. dispose(): void;
  62012. }
  62013. }
  62014. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62015. /** @hidden */
  62016. export var minmaxReduxPixelShader: {
  62017. name: string;
  62018. shader: string;
  62019. };
  62020. }
  62021. declare module "babylonjs/Misc/minMaxReducer" {
  62022. import { Nullable } from "babylonjs/types";
  62023. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62024. import { Camera } from "babylonjs/Cameras/camera";
  62025. import { Observer } from "babylonjs/Misc/observable";
  62026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62027. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62028. import { Observable } from "babylonjs/Misc/observable";
  62029. import "babylonjs/Shaders/minmaxRedux.fragment";
  62030. /**
  62031. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62032. * and maximum values from all values of the texture.
  62033. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62034. * The source values are read from the red channel of the texture.
  62035. */
  62036. export class MinMaxReducer {
  62037. /**
  62038. * Observable triggered when the computation has been performed
  62039. */
  62040. onAfterReductionPerformed: Observable<{
  62041. min: number;
  62042. max: number;
  62043. }>;
  62044. protected _camera: Camera;
  62045. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62046. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62047. protected _postProcessManager: PostProcessManager;
  62048. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62049. protected _forceFullscreenViewport: boolean;
  62050. /**
  62051. * Creates a min/max reducer
  62052. * @param camera The camera to use for the post processes
  62053. */
  62054. constructor(camera: Camera);
  62055. /**
  62056. * Gets the texture used to read the values from.
  62057. */
  62058. get sourceTexture(): Nullable<RenderTargetTexture>;
  62059. /**
  62060. * Sets the source texture to read the values from.
  62061. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62062. * because in such textures '1' value must not be taken into account to compute the maximum
  62063. * as this value is used to clear the texture.
  62064. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62065. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62066. * @param depthRedux Indicates if the texture is a depth texture or not
  62067. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62068. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62069. */
  62070. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62071. /**
  62072. * Defines the refresh rate of the computation.
  62073. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62074. */
  62075. get refreshRate(): number;
  62076. set refreshRate(value: number);
  62077. protected _activated: boolean;
  62078. /**
  62079. * Gets the activation status of the reducer
  62080. */
  62081. get activated(): boolean;
  62082. /**
  62083. * Activates the reduction computation.
  62084. * When activated, the observers registered in onAfterReductionPerformed are
  62085. * called after the compuation is performed
  62086. */
  62087. activate(): void;
  62088. /**
  62089. * Deactivates the reduction computation.
  62090. */
  62091. deactivate(): void;
  62092. /**
  62093. * Disposes the min/max reducer
  62094. * @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.
  62095. */
  62096. dispose(disposeAll?: boolean): void;
  62097. }
  62098. }
  62099. declare module "babylonjs/Misc/depthReducer" {
  62100. import { Nullable } from "babylonjs/types";
  62101. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62102. import { Camera } from "babylonjs/Cameras/camera";
  62103. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62104. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62105. /**
  62106. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62107. */
  62108. export class DepthReducer extends MinMaxReducer {
  62109. private _depthRenderer;
  62110. private _depthRendererId;
  62111. /**
  62112. * Gets the depth renderer used for the computation.
  62113. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62114. */
  62115. get depthRenderer(): Nullable<DepthRenderer>;
  62116. /**
  62117. * Creates a depth reducer
  62118. * @param camera The camera used to render the depth texture
  62119. */
  62120. constructor(camera: Camera);
  62121. /**
  62122. * Sets the depth renderer to use to generate the depth map
  62123. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62124. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62125. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62126. */
  62127. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62128. /** @hidden */
  62129. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62130. /**
  62131. * Activates the reduction computation.
  62132. * When activated, the observers registered in onAfterReductionPerformed are
  62133. * called after the compuation is performed
  62134. */
  62135. activate(): void;
  62136. /**
  62137. * Deactivates the reduction computation.
  62138. */
  62139. deactivate(): void;
  62140. /**
  62141. * Disposes the depth reducer
  62142. * @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.
  62143. */
  62144. dispose(disposeAll?: boolean): void;
  62145. }
  62146. }
  62147. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62148. import { Nullable } from "babylonjs/types";
  62149. import { Scene } from "babylonjs/scene";
  62150. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62153. import { Effect } from "babylonjs/Materials/effect";
  62154. import "babylonjs/Shaders/shadowMap.fragment";
  62155. import "babylonjs/Shaders/shadowMap.vertex";
  62156. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62157. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62158. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62159. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62160. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62161. /**
  62162. * A CSM implementation allowing casting shadows on large scenes.
  62163. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62164. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62165. */
  62166. export class CascadedShadowGenerator extends ShadowGenerator {
  62167. private static readonly frustumCornersNDCSpace;
  62168. /**
  62169. * Name of the CSM class
  62170. */
  62171. static CLASSNAME: string;
  62172. /**
  62173. * Defines the default number of cascades used by the CSM.
  62174. */
  62175. static readonly DEFAULT_CASCADES_COUNT: number;
  62176. /**
  62177. * Defines the minimum number of cascades used by the CSM.
  62178. */
  62179. static readonly MIN_CASCADES_COUNT: number;
  62180. /**
  62181. * Defines the maximum number of cascades used by the CSM.
  62182. */
  62183. static readonly MAX_CASCADES_COUNT: number;
  62184. protected _validateFilter(filter: number): number;
  62185. /**
  62186. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62187. */
  62188. penumbraDarkness: number;
  62189. private _numCascades;
  62190. /**
  62191. * Gets or set the number of cascades used by the CSM.
  62192. */
  62193. get numCascades(): number;
  62194. set numCascades(value: number);
  62195. /**
  62196. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62197. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62198. */
  62199. stabilizeCascades: boolean;
  62200. private _freezeShadowCastersBoundingInfo;
  62201. private _freezeShadowCastersBoundingInfoObservable;
  62202. /**
  62203. * Enables or disables the shadow casters bounding info computation.
  62204. * If your shadow casters don't move, you can disable this feature.
  62205. * If it is enabled, the bounding box computation is done every frame.
  62206. */
  62207. get freezeShadowCastersBoundingInfo(): boolean;
  62208. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62209. private _scbiMin;
  62210. private _scbiMax;
  62211. protected _computeShadowCastersBoundingInfo(): void;
  62212. protected _shadowCastersBoundingInfo: BoundingInfo;
  62213. /**
  62214. * Gets or sets the shadow casters bounding info.
  62215. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62216. * so that the system won't overwrite the bounds you provide
  62217. */
  62218. get shadowCastersBoundingInfo(): BoundingInfo;
  62219. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62220. protected _breaksAreDirty: boolean;
  62221. protected _minDistance: number;
  62222. protected _maxDistance: number;
  62223. /**
  62224. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62225. *
  62226. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62227. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62228. * @param min minimal distance for the breaks (default to 0.)
  62229. * @param max maximal distance for the breaks (default to 1.)
  62230. */
  62231. setMinMaxDistance(min: number, max: number): void;
  62232. /** Gets the minimal distance used in the cascade break computation */
  62233. get minDistance(): number;
  62234. /** Gets the maximal distance used in the cascade break computation */
  62235. get maxDistance(): number;
  62236. /**
  62237. * Gets the class name of that object
  62238. * @returns "CascadedShadowGenerator"
  62239. */
  62240. getClassName(): string;
  62241. private _cascadeMinExtents;
  62242. private _cascadeMaxExtents;
  62243. /**
  62244. * Gets a cascade minimum extents
  62245. * @param cascadeIndex index of the cascade
  62246. * @returns the minimum cascade extents
  62247. */
  62248. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62249. /**
  62250. * Gets a cascade maximum extents
  62251. * @param cascadeIndex index of the cascade
  62252. * @returns the maximum cascade extents
  62253. */
  62254. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62255. private _cascades;
  62256. private _currentLayer;
  62257. private _viewSpaceFrustumsZ;
  62258. private _viewMatrices;
  62259. private _projectionMatrices;
  62260. private _transformMatrices;
  62261. private _transformMatricesAsArray;
  62262. private _frustumLengths;
  62263. private _lightSizeUVCorrection;
  62264. private _depthCorrection;
  62265. private _frustumCornersWorldSpace;
  62266. private _frustumCenter;
  62267. private _shadowCameraPos;
  62268. private _shadowMaxZ;
  62269. /**
  62270. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62271. * It defaults to camera.maxZ
  62272. */
  62273. get shadowMaxZ(): number;
  62274. /**
  62275. * Sets the shadow max z distance.
  62276. */
  62277. set shadowMaxZ(value: number);
  62278. protected _debug: boolean;
  62279. /**
  62280. * Gets or sets the debug flag.
  62281. * When enabled, the cascades are materialized by different colors on the screen.
  62282. */
  62283. get debug(): boolean;
  62284. set debug(dbg: boolean);
  62285. private _depthClamp;
  62286. /**
  62287. * Gets or sets the depth clamping value.
  62288. *
  62289. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62290. * to account for the shadow casters far away.
  62291. *
  62292. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62293. */
  62294. get depthClamp(): boolean;
  62295. set depthClamp(value: boolean);
  62296. private _cascadeBlendPercentage;
  62297. /**
  62298. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62299. * It defaults to 0.1 (10% blending).
  62300. */
  62301. get cascadeBlendPercentage(): number;
  62302. set cascadeBlendPercentage(value: number);
  62303. private _lambda;
  62304. /**
  62305. * Gets or set the lambda parameter.
  62306. * This parameter is used to split the camera frustum and create the cascades.
  62307. * 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.
  62308. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62309. */
  62310. get lambda(): number;
  62311. set lambda(value: number);
  62312. /**
  62313. * Gets the view matrix corresponding to a given cascade
  62314. * @param cascadeNum cascade to retrieve the view matrix from
  62315. * @returns the cascade view matrix
  62316. */
  62317. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62318. /**
  62319. * Gets the projection matrix corresponding to a given cascade
  62320. * @param cascadeNum cascade to retrieve the projection matrix from
  62321. * @returns the cascade projection matrix
  62322. */
  62323. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62324. /**
  62325. * Gets the transformation matrix corresponding to a given cascade
  62326. * @param cascadeNum cascade to retrieve the transformation matrix from
  62327. * @returns the cascade transformation matrix
  62328. */
  62329. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62330. private _depthRenderer;
  62331. /**
  62332. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62333. *
  62334. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62335. *
  62336. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62337. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62338. * @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
  62339. */
  62340. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62341. private _depthReducer;
  62342. private _autoCalcDepthBounds;
  62343. /**
  62344. * Gets or sets the autoCalcDepthBounds property.
  62345. *
  62346. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62347. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62348. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62349. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62350. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62351. */
  62352. get autoCalcDepthBounds(): boolean;
  62353. set autoCalcDepthBounds(value: boolean);
  62354. /**
  62355. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62356. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62357. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62358. * for setting the refresh rate on the renderer yourself!
  62359. */
  62360. get autoCalcDepthBoundsRefreshRate(): number;
  62361. set autoCalcDepthBoundsRefreshRate(value: number);
  62362. /**
  62363. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62364. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62365. * you change the camera near/far planes!
  62366. */
  62367. splitFrustum(): void;
  62368. private _splitFrustum;
  62369. private _computeMatrices;
  62370. private _computeFrustumInWorldSpace;
  62371. private _computeCascadeFrustum;
  62372. /**
  62373. * Support test.
  62374. */
  62375. static get IsSupported(): boolean;
  62376. /** @hidden */
  62377. static _SceneComponentInitialization: (scene: Scene) => void;
  62378. /**
  62379. * Creates a Cascaded Shadow Generator object.
  62380. * A ShadowGenerator is the required tool to use the shadows.
  62381. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62382. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62383. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62384. * @param light The directional light object generating the shadows.
  62385. * @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.
  62386. */
  62387. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62388. protected _initializeGenerator(): void;
  62389. protected _createTargetRenderTexture(): void;
  62390. protected _initializeShadowMap(): void;
  62391. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62392. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62393. /**
  62394. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62395. * @param defines Defines of the material we want to update
  62396. * @param lightIndex Index of the light in the enabled light list of the material
  62397. */
  62398. prepareDefines(defines: any, lightIndex: number): void;
  62399. /**
  62400. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62401. * defined in the generator but impacting the effect).
  62402. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62403. * @param effect The effect we are binfing the information for
  62404. */
  62405. bindShadowLight(lightIndex: string, effect: Effect): void;
  62406. /**
  62407. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62408. * (eq to view projection * shadow projection matrices)
  62409. * @returns The transform matrix used to create the shadow map
  62410. */
  62411. getTransformMatrix(): Matrix;
  62412. /**
  62413. * Disposes the ShadowGenerator.
  62414. * Returns nothing.
  62415. */
  62416. dispose(): void;
  62417. /**
  62418. * Serializes the shadow generator setup to a json object.
  62419. * @returns The serialized JSON object
  62420. */
  62421. serialize(): any;
  62422. /**
  62423. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62424. * @param parsedShadowGenerator The JSON object to parse
  62425. * @param scene The scene to create the shadow map for
  62426. * @returns The parsed shadow generator
  62427. */
  62428. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62429. }
  62430. }
  62431. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62432. import { Scene } from "babylonjs/scene";
  62433. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62434. import { AbstractScene } from "babylonjs/abstractScene";
  62435. /**
  62436. * Defines the shadow generator component responsible to manage any shadow generators
  62437. * in a given scene.
  62438. */
  62439. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62440. /**
  62441. * The component name helpfull to identify the component in the list of scene components.
  62442. */
  62443. readonly name: string;
  62444. /**
  62445. * The scene the component belongs to.
  62446. */
  62447. scene: Scene;
  62448. /**
  62449. * Creates a new instance of the component for the given scene
  62450. * @param scene Defines the scene to register the component in
  62451. */
  62452. constructor(scene: Scene);
  62453. /**
  62454. * Registers the component in a given scene
  62455. */
  62456. register(): void;
  62457. /**
  62458. * Rebuilds the elements related to this component in case of
  62459. * context lost for instance.
  62460. */
  62461. rebuild(): void;
  62462. /**
  62463. * Serializes the component data to the specified json object
  62464. * @param serializationObject The object to serialize to
  62465. */
  62466. serialize(serializationObject: any): void;
  62467. /**
  62468. * Adds all the elements from the container to the scene
  62469. * @param container the container holding the elements
  62470. */
  62471. addFromContainer(container: AbstractScene): void;
  62472. /**
  62473. * Removes all the elements in the container from the scene
  62474. * @param container contains the elements to remove
  62475. * @param dispose if the removed element should be disposed (default: false)
  62476. */
  62477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62478. /**
  62479. * Rebuilds the elements related to this component in case of
  62480. * context lost for instance.
  62481. */
  62482. dispose(): void;
  62483. private _gatherRenderTargets;
  62484. }
  62485. }
  62486. declare module "babylonjs/Lights/Shadows/index" {
  62487. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62488. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62489. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62490. }
  62491. declare module "babylonjs/Lights/pointLight" {
  62492. import { Scene } from "babylonjs/scene";
  62493. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62495. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62496. import { Effect } from "babylonjs/Materials/effect";
  62497. /**
  62498. * A point light is a light defined by an unique point in world space.
  62499. * The light is emitted in every direction from this point.
  62500. * A good example of a point light is a standard light bulb.
  62501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62502. */
  62503. export class PointLight extends ShadowLight {
  62504. private _shadowAngle;
  62505. /**
  62506. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62507. * This specifies what angle the shadow will use to be created.
  62508. *
  62509. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62510. */
  62511. get shadowAngle(): number;
  62512. /**
  62513. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62514. * This specifies what angle the shadow will use to be created.
  62515. *
  62516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62517. */
  62518. set shadowAngle(value: number);
  62519. /**
  62520. * Gets the direction if it has been set.
  62521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62522. */
  62523. get direction(): Vector3;
  62524. /**
  62525. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62526. */
  62527. set direction(value: Vector3);
  62528. /**
  62529. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62530. * A PointLight emits the light in every direction.
  62531. * It can cast shadows.
  62532. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62533. * ```javascript
  62534. * var pointLight = new PointLight("pl", camera.position, scene);
  62535. * ```
  62536. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62537. * @param name The light friendly name
  62538. * @param position The position of the point light in the scene
  62539. * @param scene The scene the lights belongs to
  62540. */
  62541. constructor(name: string, position: Vector3, scene: Scene);
  62542. /**
  62543. * Returns the string "PointLight"
  62544. * @returns the class name
  62545. */
  62546. getClassName(): string;
  62547. /**
  62548. * Returns the integer 0.
  62549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62550. */
  62551. getTypeID(): number;
  62552. /**
  62553. * Specifies wether or not the shadowmap should be a cube texture.
  62554. * @returns true if the shadowmap needs to be a cube texture.
  62555. */
  62556. needCube(): boolean;
  62557. /**
  62558. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62559. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62560. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62561. */
  62562. getShadowDirection(faceIndex?: number): Vector3;
  62563. /**
  62564. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62565. * - fov = PI / 2
  62566. * - aspect ratio : 1.0
  62567. * - z-near and far equal to the active camera minZ and maxZ.
  62568. * Returns the PointLight.
  62569. */
  62570. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62571. protected _buildUniformLayout(): void;
  62572. /**
  62573. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62574. * @param effect The effect to update
  62575. * @param lightIndex The index of the light in the effect to update
  62576. * @returns The point light
  62577. */
  62578. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62579. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62580. /**
  62581. * Prepares the list of defines specific to the light type.
  62582. * @param defines the list of defines
  62583. * @param lightIndex defines the index of the light for the effect
  62584. */
  62585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62586. }
  62587. }
  62588. declare module "babylonjs/Lights/index" {
  62589. export * from "babylonjs/Lights/light";
  62590. export * from "babylonjs/Lights/shadowLight";
  62591. export * from "babylonjs/Lights/Shadows/index";
  62592. export * from "babylonjs/Lights/directionalLight";
  62593. export * from "babylonjs/Lights/hemisphericLight";
  62594. export * from "babylonjs/Lights/pointLight";
  62595. export * from "babylonjs/Lights/spotLight";
  62596. }
  62597. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62598. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62599. /**
  62600. * Header information of HDR texture files.
  62601. */
  62602. export interface HDRInfo {
  62603. /**
  62604. * The height of the texture in pixels.
  62605. */
  62606. height: number;
  62607. /**
  62608. * The width of the texture in pixels.
  62609. */
  62610. width: number;
  62611. /**
  62612. * The index of the beginning of the data in the binary file.
  62613. */
  62614. dataPosition: number;
  62615. }
  62616. /**
  62617. * This groups tools to convert HDR texture to native colors array.
  62618. */
  62619. export class HDRTools {
  62620. private static Ldexp;
  62621. private static Rgbe2float;
  62622. private static readStringLine;
  62623. /**
  62624. * Reads header information from an RGBE texture stored in a native array.
  62625. * More information on this format are available here:
  62626. * https://en.wikipedia.org/wiki/RGBE_image_format
  62627. *
  62628. * @param uint8array The binary file stored in native array.
  62629. * @return The header information.
  62630. */
  62631. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62632. /**
  62633. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62634. * This RGBE texture needs to store the information as a panorama.
  62635. *
  62636. * More information on this format are available here:
  62637. * https://en.wikipedia.org/wiki/RGBE_image_format
  62638. *
  62639. * @param buffer The binary file stored in an array buffer.
  62640. * @param size The expected size of the extracted cubemap.
  62641. * @return The Cube Map information.
  62642. */
  62643. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62644. /**
  62645. * Returns the pixels data extracted from an RGBE texture.
  62646. * This pixels will be stored left to right up to down in the R G B order in one array.
  62647. *
  62648. * More information on this format are available here:
  62649. * https://en.wikipedia.org/wiki/RGBE_image_format
  62650. *
  62651. * @param uint8array The binary file stored in an array buffer.
  62652. * @param hdrInfo The header information of the file.
  62653. * @return The pixels data in RGB right to left up to down order.
  62654. */
  62655. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62656. private static RGBE_ReadPixels_RLE;
  62657. private static RGBE_ReadPixels_NOT_RLE;
  62658. }
  62659. }
  62660. declare module "babylonjs/Materials/effectRenderer" {
  62661. import { Nullable } from "babylonjs/types";
  62662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62664. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62665. import { Viewport } from "babylonjs/Maths/math.viewport";
  62666. import { Observable } from "babylonjs/Misc/observable";
  62667. import { Effect } from "babylonjs/Materials/effect";
  62668. import "babylonjs/Shaders/postprocess.vertex";
  62669. /**
  62670. * Effect Render Options
  62671. */
  62672. export interface IEffectRendererOptions {
  62673. /**
  62674. * Defines the vertices positions.
  62675. */
  62676. positions?: number[];
  62677. /**
  62678. * Defines the indices.
  62679. */
  62680. indices?: number[];
  62681. }
  62682. /**
  62683. * Helper class to render one or more effects.
  62684. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62685. */
  62686. export class EffectRenderer {
  62687. private engine;
  62688. private static _DefaultOptions;
  62689. private _vertexBuffers;
  62690. private _indexBuffer;
  62691. private _fullscreenViewport;
  62692. /**
  62693. * Creates an effect renderer
  62694. * @param engine the engine to use for rendering
  62695. * @param options defines the options of the effect renderer
  62696. */
  62697. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62698. /**
  62699. * Sets the current viewport in normalized coordinates 0-1
  62700. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62701. */
  62702. setViewport(viewport?: Viewport): void;
  62703. /**
  62704. * Binds the embedded attributes buffer to the effect.
  62705. * @param effect Defines the effect to bind the attributes for
  62706. */
  62707. bindBuffers(effect: Effect): void;
  62708. /**
  62709. * Sets the current effect wrapper to use during draw.
  62710. * The effect needs to be ready before calling this api.
  62711. * This also sets the default full screen position attribute.
  62712. * @param effectWrapper Defines the effect to draw with
  62713. */
  62714. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62715. /**
  62716. * Restores engine states
  62717. */
  62718. restoreStates(): void;
  62719. /**
  62720. * Draws a full screen quad.
  62721. */
  62722. draw(): void;
  62723. private isRenderTargetTexture;
  62724. /**
  62725. * renders one or more effects to a specified texture
  62726. * @param effectWrapper the effect to renderer
  62727. * @param outputTexture texture to draw to, if null it will render to the screen.
  62728. */
  62729. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62730. /**
  62731. * Disposes of the effect renderer
  62732. */
  62733. dispose(): void;
  62734. }
  62735. /**
  62736. * Options to create an EffectWrapper
  62737. */
  62738. interface EffectWrapperCreationOptions {
  62739. /**
  62740. * Engine to use to create the effect
  62741. */
  62742. engine: ThinEngine;
  62743. /**
  62744. * Fragment shader for the effect
  62745. */
  62746. fragmentShader: string;
  62747. /**
  62748. * Use the shader store instead of direct source code
  62749. */
  62750. useShaderStore?: boolean;
  62751. /**
  62752. * Vertex shader for the effect
  62753. */
  62754. vertexShader?: string;
  62755. /**
  62756. * Attributes to use in the shader
  62757. */
  62758. attributeNames?: Array<string>;
  62759. /**
  62760. * Uniforms to use in the shader
  62761. */
  62762. uniformNames?: Array<string>;
  62763. /**
  62764. * Texture sampler names to use in the shader
  62765. */
  62766. samplerNames?: Array<string>;
  62767. /**
  62768. * Defines to use in the shader
  62769. */
  62770. defines?: Array<string>;
  62771. /**
  62772. * Callback when effect is compiled
  62773. */
  62774. onCompiled?: Nullable<(effect: Effect) => void>;
  62775. /**
  62776. * The friendly name of the effect displayed in Spector.
  62777. */
  62778. name?: string;
  62779. }
  62780. /**
  62781. * Wraps an effect to be used for rendering
  62782. */
  62783. export class EffectWrapper {
  62784. /**
  62785. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62786. */
  62787. onApplyObservable: Observable<{}>;
  62788. /**
  62789. * The underlying effect
  62790. */
  62791. effect: Effect;
  62792. /**
  62793. * Creates an effect to be renderer
  62794. * @param creationOptions options to create the effect
  62795. */
  62796. constructor(creationOptions: EffectWrapperCreationOptions);
  62797. /**
  62798. * Disposes of the effect wrapper
  62799. */
  62800. dispose(): void;
  62801. }
  62802. }
  62803. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62804. /** @hidden */
  62805. export var hdrFilteringVertexShader: {
  62806. name: string;
  62807. shader: string;
  62808. };
  62809. }
  62810. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62811. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62812. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62813. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62814. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62815. /** @hidden */
  62816. export var hdrFilteringPixelShader: {
  62817. name: string;
  62818. shader: string;
  62819. };
  62820. }
  62821. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62823. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62824. import { Nullable } from "babylonjs/types";
  62825. import "babylonjs/Shaders/hdrFiltering.vertex";
  62826. import "babylonjs/Shaders/hdrFiltering.fragment";
  62827. /**
  62828. * Options for texture filtering
  62829. */
  62830. interface IHDRFilteringOptions {
  62831. /**
  62832. * Scales pixel intensity for the input HDR map.
  62833. */
  62834. hdrScale?: number;
  62835. /**
  62836. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62837. */
  62838. quality?: number;
  62839. }
  62840. /**
  62841. * Filters HDR maps to get correct renderings of PBR reflections
  62842. */
  62843. export class HDRFiltering {
  62844. private _engine;
  62845. private _effectRenderer;
  62846. private _effectWrapper;
  62847. private _lodGenerationOffset;
  62848. private _lodGenerationScale;
  62849. /**
  62850. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62851. * you care about baking speed.
  62852. */
  62853. quality: number;
  62854. /**
  62855. * Scales pixel intensity for the input HDR map.
  62856. */
  62857. hdrScale: number;
  62858. /**
  62859. * Instantiates HDR filter for reflection maps
  62860. *
  62861. * @param engine Thin engine
  62862. * @param options Options
  62863. */
  62864. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62865. private _createRenderTarget;
  62866. private _prefilterInternal;
  62867. private _createEffect;
  62868. /**
  62869. * Get a value indicating if the filter is ready to be used
  62870. * @param texture Texture to filter
  62871. * @returns true if the filter is ready
  62872. */
  62873. isReady(texture: BaseTexture): boolean;
  62874. /**
  62875. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62876. * Prefiltering will be invoked at the end of next rendering pass.
  62877. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62878. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62879. * @param texture Texture to filter
  62880. * @param onFinished Callback when filtering is done
  62881. * @return Promise called when prefiltering is done
  62882. */
  62883. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62884. }
  62885. }
  62886. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62887. import { Nullable } from "babylonjs/types";
  62888. import { Scene } from "babylonjs/scene";
  62889. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62892. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62893. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62894. /**
  62895. * This represents a texture coming from an HDR input.
  62896. *
  62897. * The only supported format is currently panorama picture stored in RGBE format.
  62898. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62899. */
  62900. export class HDRCubeTexture extends BaseTexture {
  62901. private static _facesMapping;
  62902. private _generateHarmonics;
  62903. private _noMipmap;
  62904. private _prefilterOnLoad;
  62905. private _textureMatrix;
  62906. private _size;
  62907. private _onLoad;
  62908. private _onError;
  62909. /**
  62910. * The texture URL.
  62911. */
  62912. url: string;
  62913. /**
  62914. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62915. */
  62916. coordinatesMode: number;
  62917. protected _isBlocking: boolean;
  62918. /**
  62919. * Sets wether or not the texture is blocking during loading.
  62920. */
  62921. set isBlocking(value: boolean);
  62922. /**
  62923. * Gets wether or not the texture is blocking during loading.
  62924. */
  62925. get isBlocking(): boolean;
  62926. protected _rotationY: number;
  62927. /**
  62928. * Sets texture matrix rotation angle around Y axis in radians.
  62929. */
  62930. set rotationY(value: number);
  62931. /**
  62932. * Gets texture matrix rotation angle around Y axis radians.
  62933. */
  62934. get rotationY(): number;
  62935. /**
  62936. * Gets or sets the center of the bounding box associated with the cube texture
  62937. * It must define where the camera used to render the texture was set
  62938. */
  62939. boundingBoxPosition: Vector3;
  62940. private _boundingBoxSize;
  62941. /**
  62942. * Gets or sets the size of the bounding box associated with the cube texture
  62943. * When defined, the cubemap will switch to local mode
  62944. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62945. * @example https://www.babylonjs-playground.com/#RNASML
  62946. */
  62947. set boundingBoxSize(value: Vector3);
  62948. get boundingBoxSize(): Vector3;
  62949. /**
  62950. * Instantiates an HDRTexture from the following parameters.
  62951. *
  62952. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62953. * @param sceneOrEngine The scene or engine the texture will be used in
  62954. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62955. * @param noMipmap Forces to not generate the mipmap if true
  62956. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62957. * @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)
  62958. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62959. */
  62960. 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>);
  62961. /**
  62962. * Get the current class name of the texture useful for serialization or dynamic coding.
  62963. * @returns "HDRCubeTexture"
  62964. */
  62965. getClassName(): string;
  62966. /**
  62967. * Occurs when the file is raw .hdr file.
  62968. */
  62969. private loadTexture;
  62970. clone(): HDRCubeTexture;
  62971. delayLoad(): void;
  62972. /**
  62973. * Get the texture reflection matrix used to rotate/transform the reflection.
  62974. * @returns the reflection matrix
  62975. */
  62976. getReflectionTextureMatrix(): Matrix;
  62977. /**
  62978. * Set the texture reflection matrix used to rotate/transform the reflection.
  62979. * @param value Define the reflection matrix to set
  62980. */
  62981. setReflectionTextureMatrix(value: Matrix): void;
  62982. /**
  62983. * Parses a JSON representation of an HDR Texture in order to create the texture
  62984. * @param parsedTexture Define the JSON representation
  62985. * @param scene Define the scene the texture should be created in
  62986. * @param rootUrl Define the root url in case we need to load relative dependencies
  62987. * @returns the newly created texture after parsing
  62988. */
  62989. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62990. serialize(): any;
  62991. }
  62992. }
  62993. declare module "babylonjs/Physics/physicsEngine" {
  62994. import { Nullable } from "babylonjs/types";
  62995. import { Vector3 } from "babylonjs/Maths/math.vector";
  62996. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62997. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62998. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62999. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63000. /**
  63001. * Class used to control physics engine
  63002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63003. */
  63004. export class PhysicsEngine implements IPhysicsEngine {
  63005. private _physicsPlugin;
  63006. /**
  63007. * Global value used to control the smallest number supported by the simulation
  63008. */
  63009. static Epsilon: number;
  63010. private _impostors;
  63011. private _joints;
  63012. private _subTimeStep;
  63013. /**
  63014. * Gets the gravity vector used by the simulation
  63015. */
  63016. gravity: Vector3;
  63017. /**
  63018. * Factory used to create the default physics plugin.
  63019. * @returns The default physics plugin
  63020. */
  63021. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63022. /**
  63023. * Creates a new Physics Engine
  63024. * @param gravity defines the gravity vector used by the simulation
  63025. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63026. */
  63027. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63028. /**
  63029. * Sets the gravity vector used by the simulation
  63030. * @param gravity defines the gravity vector to use
  63031. */
  63032. setGravity(gravity: Vector3): void;
  63033. /**
  63034. * Set the time step of the physics engine.
  63035. * Default is 1/60.
  63036. * To slow it down, enter 1/600 for example.
  63037. * To speed it up, 1/30
  63038. * @param newTimeStep defines the new timestep to apply to this world.
  63039. */
  63040. setTimeStep(newTimeStep?: number): void;
  63041. /**
  63042. * Get the time step of the physics engine.
  63043. * @returns the current time step
  63044. */
  63045. getTimeStep(): number;
  63046. /**
  63047. * Set the sub time step of the physics engine.
  63048. * Default is 0 meaning there is no sub steps
  63049. * To increase physics resolution precision, set a small value (like 1 ms)
  63050. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63051. */
  63052. setSubTimeStep(subTimeStep?: number): void;
  63053. /**
  63054. * Get the sub time step of the physics engine.
  63055. * @returns the current sub time step
  63056. */
  63057. getSubTimeStep(): number;
  63058. /**
  63059. * Release all resources
  63060. */
  63061. dispose(): void;
  63062. /**
  63063. * Gets the name of the current physics plugin
  63064. * @returns the name of the plugin
  63065. */
  63066. getPhysicsPluginName(): string;
  63067. /**
  63068. * Adding a new impostor for the impostor tracking.
  63069. * This will be done by the impostor itself.
  63070. * @param impostor the impostor to add
  63071. */
  63072. addImpostor(impostor: PhysicsImpostor): void;
  63073. /**
  63074. * Remove an impostor from the engine.
  63075. * This impostor and its mesh will not longer be updated by the physics engine.
  63076. * @param impostor the impostor to remove
  63077. */
  63078. removeImpostor(impostor: PhysicsImpostor): void;
  63079. /**
  63080. * Add a joint to the physics engine
  63081. * @param mainImpostor defines the main impostor to which the joint is added.
  63082. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63083. * @param joint defines the joint that will connect both impostors.
  63084. */
  63085. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63086. /**
  63087. * Removes a joint from the simulation
  63088. * @param mainImpostor defines the impostor used with the joint
  63089. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63090. * @param joint defines the joint to remove
  63091. */
  63092. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63093. /**
  63094. * Called by the scene. No need to call it.
  63095. * @param delta defines the timespam between frames
  63096. */
  63097. _step(delta: number): void;
  63098. /**
  63099. * Gets the current plugin used to run the simulation
  63100. * @returns current plugin
  63101. */
  63102. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63103. /**
  63104. * Gets the list of physic impostors
  63105. * @returns an array of PhysicsImpostor
  63106. */
  63107. getImpostors(): Array<PhysicsImpostor>;
  63108. /**
  63109. * Gets the impostor for a physics enabled object
  63110. * @param object defines the object impersonated by the impostor
  63111. * @returns the PhysicsImpostor or null if not found
  63112. */
  63113. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63114. /**
  63115. * Gets the impostor for a physics body object
  63116. * @param body defines physics body used by the impostor
  63117. * @returns the PhysicsImpostor or null if not found
  63118. */
  63119. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63120. /**
  63121. * Does a raycast in the physics world
  63122. * @param from when should the ray start?
  63123. * @param to when should the ray end?
  63124. * @returns PhysicsRaycastResult
  63125. */
  63126. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63127. }
  63128. }
  63129. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63130. import { Nullable } from "babylonjs/types";
  63131. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63133. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63134. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63135. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63136. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63137. /** @hidden */
  63138. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63139. private _useDeltaForWorldStep;
  63140. world: any;
  63141. name: string;
  63142. private _physicsMaterials;
  63143. private _fixedTimeStep;
  63144. private _cannonRaycastResult;
  63145. private _raycastResult;
  63146. private _physicsBodysToRemoveAfterStep;
  63147. private _firstFrame;
  63148. BJSCANNON: any;
  63149. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63150. setGravity(gravity: Vector3): void;
  63151. setTimeStep(timeStep: number): void;
  63152. getTimeStep(): number;
  63153. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63154. private _removeMarkedPhysicsBodiesFromWorld;
  63155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63156. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63158. private _processChildMeshes;
  63159. removePhysicsBody(impostor: PhysicsImpostor): void;
  63160. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63161. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63162. private _addMaterial;
  63163. private _checkWithEpsilon;
  63164. private _createShape;
  63165. private _createHeightmap;
  63166. private _minus90X;
  63167. private _plus90X;
  63168. private _tmpPosition;
  63169. private _tmpDeltaPosition;
  63170. private _tmpUnityRotation;
  63171. private _updatePhysicsBodyTransformation;
  63172. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63173. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63174. isSupported(): boolean;
  63175. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63176. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63177. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63178. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63179. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63180. getBodyMass(impostor: PhysicsImpostor): number;
  63181. getBodyFriction(impostor: PhysicsImpostor): number;
  63182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63183. getBodyRestitution(impostor: PhysicsImpostor): number;
  63184. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63185. sleepBody(impostor: PhysicsImpostor): void;
  63186. wakeUpBody(impostor: PhysicsImpostor): void;
  63187. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63188. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63189. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63190. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63191. getRadius(impostor: PhysicsImpostor): number;
  63192. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63193. dispose(): void;
  63194. private _extendNamespace;
  63195. /**
  63196. * Does a raycast in the physics world
  63197. * @param from when should the ray start?
  63198. * @param to when should the ray end?
  63199. * @returns PhysicsRaycastResult
  63200. */
  63201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63202. }
  63203. }
  63204. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63205. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63206. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63207. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63209. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63210. import { Nullable } from "babylonjs/types";
  63211. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63212. /** @hidden */
  63213. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63214. private _useDeltaForWorldStep;
  63215. world: any;
  63216. name: string;
  63217. BJSOIMO: any;
  63218. private _raycastResult;
  63219. private _fixedTimeStep;
  63220. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63221. setGravity(gravity: Vector3): void;
  63222. setTimeStep(timeStep: number): void;
  63223. getTimeStep(): number;
  63224. private _tmpImpostorsArray;
  63225. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63227. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63228. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63229. private _tmpPositionVector;
  63230. removePhysicsBody(impostor: PhysicsImpostor): void;
  63231. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63232. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63233. isSupported(): boolean;
  63234. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63235. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63236. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63237. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63238. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63239. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63240. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63241. getBodyMass(impostor: PhysicsImpostor): number;
  63242. getBodyFriction(impostor: PhysicsImpostor): number;
  63243. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63244. getBodyRestitution(impostor: PhysicsImpostor): number;
  63245. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63246. sleepBody(impostor: PhysicsImpostor): void;
  63247. wakeUpBody(impostor: PhysicsImpostor): void;
  63248. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63249. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63250. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63251. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63252. getRadius(impostor: PhysicsImpostor): number;
  63253. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63254. dispose(): void;
  63255. /**
  63256. * Does a raycast in the physics world
  63257. * @param from when should the ray start?
  63258. * @param to when should the ray end?
  63259. * @returns PhysicsRaycastResult
  63260. */
  63261. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63262. }
  63263. }
  63264. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63265. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63266. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63267. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63268. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63269. import { Nullable } from "babylonjs/types";
  63270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63271. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63272. /**
  63273. * AmmoJS Physics plugin
  63274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63275. * @see https://github.com/kripken/ammo.js/
  63276. */
  63277. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63278. private _useDeltaForWorldStep;
  63279. /**
  63280. * Reference to the Ammo library
  63281. */
  63282. bjsAMMO: any;
  63283. /**
  63284. * Created ammoJS world which physics bodies are added to
  63285. */
  63286. world: any;
  63287. /**
  63288. * Name of the plugin
  63289. */
  63290. name: string;
  63291. private _timeStep;
  63292. private _fixedTimeStep;
  63293. private _maxSteps;
  63294. private _tmpQuaternion;
  63295. private _tmpAmmoTransform;
  63296. private _tmpAmmoQuaternion;
  63297. private _tmpAmmoConcreteContactResultCallback;
  63298. private _collisionConfiguration;
  63299. private _dispatcher;
  63300. private _overlappingPairCache;
  63301. private _solver;
  63302. private _softBodySolver;
  63303. private _tmpAmmoVectorA;
  63304. private _tmpAmmoVectorB;
  63305. private _tmpAmmoVectorC;
  63306. private _tmpAmmoVectorD;
  63307. private _tmpContactCallbackResult;
  63308. private _tmpAmmoVectorRCA;
  63309. private _tmpAmmoVectorRCB;
  63310. private _raycastResult;
  63311. private static readonly DISABLE_COLLISION_FLAG;
  63312. private static readonly KINEMATIC_FLAG;
  63313. private static readonly DISABLE_DEACTIVATION_FLAG;
  63314. /**
  63315. * Initializes the ammoJS plugin
  63316. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63317. * @param ammoInjection can be used to inject your own ammo reference
  63318. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63319. */
  63320. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63321. /**
  63322. * Sets the gravity of the physics world (m/(s^2))
  63323. * @param gravity Gravity to set
  63324. */
  63325. setGravity(gravity: Vector3): void;
  63326. /**
  63327. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63328. * @param timeStep timestep to use in seconds
  63329. */
  63330. setTimeStep(timeStep: number): void;
  63331. /**
  63332. * 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)
  63333. * @param fixedTimeStep fixedTimeStep to use in seconds
  63334. */
  63335. setFixedTimeStep(fixedTimeStep: number): void;
  63336. /**
  63337. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63338. * @param maxSteps the maximum number of steps by the physics engine per frame
  63339. */
  63340. setMaxSteps(maxSteps: number): void;
  63341. /**
  63342. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63343. * @returns the current timestep in seconds
  63344. */
  63345. getTimeStep(): number;
  63346. /**
  63347. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63348. */
  63349. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63350. private _isImpostorInContact;
  63351. private _isImpostorPairInContact;
  63352. private _stepSimulation;
  63353. /**
  63354. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63355. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63356. * After the step the babylon meshes are set to the position of the physics imposters
  63357. * @param delta amount of time to step forward
  63358. * @param impostors array of imposters to update before/after the step
  63359. */
  63360. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63361. /**
  63362. * Update babylon mesh to match physics world object
  63363. * @param impostor imposter to match
  63364. */
  63365. private _afterSoftStep;
  63366. /**
  63367. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63368. * @param impostor imposter to match
  63369. */
  63370. private _ropeStep;
  63371. /**
  63372. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63373. * @param impostor imposter to match
  63374. */
  63375. private _softbodyOrClothStep;
  63376. private _tmpMatrix;
  63377. /**
  63378. * Applies an impulse on the imposter
  63379. * @param impostor imposter to apply impulse to
  63380. * @param force amount of force to be applied to the imposter
  63381. * @param contactPoint the location to apply the impulse on the imposter
  63382. */
  63383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63384. /**
  63385. * Applies a force on the imposter
  63386. * @param impostor imposter to apply force
  63387. * @param force amount of force to be applied to the imposter
  63388. * @param contactPoint the location to apply the force on the imposter
  63389. */
  63390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63391. /**
  63392. * Creates a physics body using the plugin
  63393. * @param impostor the imposter to create the physics body on
  63394. */
  63395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63396. /**
  63397. * Removes the physics body from the imposter and disposes of the body's memory
  63398. * @param impostor imposter to remove the physics body from
  63399. */
  63400. removePhysicsBody(impostor: PhysicsImpostor): void;
  63401. /**
  63402. * Generates a joint
  63403. * @param impostorJoint the imposter joint to create the joint with
  63404. */
  63405. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63406. /**
  63407. * Removes a joint
  63408. * @param impostorJoint the imposter joint to remove the joint from
  63409. */
  63410. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63411. private _addMeshVerts;
  63412. /**
  63413. * Initialise the soft body vertices to match its object's (mesh) vertices
  63414. * Softbody vertices (nodes) are in world space and to match this
  63415. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63416. * @param impostor to create the softbody for
  63417. */
  63418. private _softVertexData;
  63419. /**
  63420. * Create an impostor's soft body
  63421. * @param impostor to create the softbody for
  63422. */
  63423. private _createSoftbody;
  63424. /**
  63425. * Create cloth for an impostor
  63426. * @param impostor to create the softbody for
  63427. */
  63428. private _createCloth;
  63429. /**
  63430. * Create rope for an impostor
  63431. * @param impostor to create the softbody for
  63432. */
  63433. private _createRope;
  63434. /**
  63435. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63436. * @param impostor to create the custom physics shape for
  63437. */
  63438. private _createCustom;
  63439. private _addHullVerts;
  63440. private _createShape;
  63441. /**
  63442. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63443. * @param impostor imposter containing the physics body and babylon object
  63444. */
  63445. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63446. /**
  63447. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63448. * @param impostor imposter containing the physics body and babylon object
  63449. * @param newPosition new position
  63450. * @param newRotation new rotation
  63451. */
  63452. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63453. /**
  63454. * If this plugin is supported
  63455. * @returns true if its supported
  63456. */
  63457. isSupported(): boolean;
  63458. /**
  63459. * Sets the linear velocity of the physics body
  63460. * @param impostor imposter to set the velocity on
  63461. * @param velocity velocity to set
  63462. */
  63463. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63464. /**
  63465. * Sets the angular velocity of the physics body
  63466. * @param impostor imposter to set the velocity on
  63467. * @param velocity velocity to set
  63468. */
  63469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63470. /**
  63471. * gets the linear velocity
  63472. * @param impostor imposter to get linear velocity from
  63473. * @returns linear velocity
  63474. */
  63475. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63476. /**
  63477. * gets the angular velocity
  63478. * @param impostor imposter to get angular velocity from
  63479. * @returns angular velocity
  63480. */
  63481. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63482. /**
  63483. * Sets the mass of physics body
  63484. * @param impostor imposter to set the mass on
  63485. * @param mass mass to set
  63486. */
  63487. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63488. /**
  63489. * Gets the mass of the physics body
  63490. * @param impostor imposter to get the mass from
  63491. * @returns mass
  63492. */
  63493. getBodyMass(impostor: PhysicsImpostor): number;
  63494. /**
  63495. * Gets friction of the impostor
  63496. * @param impostor impostor to get friction from
  63497. * @returns friction value
  63498. */
  63499. getBodyFriction(impostor: PhysicsImpostor): number;
  63500. /**
  63501. * Sets friction of the impostor
  63502. * @param impostor impostor to set friction on
  63503. * @param friction friction value
  63504. */
  63505. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63506. /**
  63507. * Gets restitution of the impostor
  63508. * @param impostor impostor to get restitution from
  63509. * @returns restitution value
  63510. */
  63511. getBodyRestitution(impostor: PhysicsImpostor): number;
  63512. /**
  63513. * Sets resitution of the impostor
  63514. * @param impostor impostor to set resitution on
  63515. * @param restitution resitution value
  63516. */
  63517. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63518. /**
  63519. * Gets pressure inside the impostor
  63520. * @param impostor impostor to get pressure from
  63521. * @returns pressure value
  63522. */
  63523. getBodyPressure(impostor: PhysicsImpostor): number;
  63524. /**
  63525. * Sets pressure inside a soft body impostor
  63526. * Cloth and rope must remain 0 pressure
  63527. * @param impostor impostor to set pressure on
  63528. * @param pressure pressure value
  63529. */
  63530. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63531. /**
  63532. * Gets stiffness of the impostor
  63533. * @param impostor impostor to get stiffness from
  63534. * @returns pressure value
  63535. */
  63536. getBodyStiffness(impostor: PhysicsImpostor): number;
  63537. /**
  63538. * Sets stiffness of the impostor
  63539. * @param impostor impostor to set stiffness on
  63540. * @param stiffness stiffness value from 0 to 1
  63541. */
  63542. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63543. /**
  63544. * Gets velocityIterations of the impostor
  63545. * @param impostor impostor to get velocity iterations from
  63546. * @returns velocityIterations value
  63547. */
  63548. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63549. /**
  63550. * Sets velocityIterations of the impostor
  63551. * @param impostor impostor to set velocity iterations on
  63552. * @param velocityIterations velocityIterations value
  63553. */
  63554. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63555. /**
  63556. * Gets positionIterations of the impostor
  63557. * @param impostor impostor to get position iterations from
  63558. * @returns positionIterations value
  63559. */
  63560. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63561. /**
  63562. * Sets positionIterations of the impostor
  63563. * @param impostor impostor to set position on
  63564. * @param positionIterations positionIterations value
  63565. */
  63566. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63567. /**
  63568. * Append an anchor to a cloth object
  63569. * @param impostor is the cloth impostor to add anchor to
  63570. * @param otherImpostor is the rigid impostor to anchor to
  63571. * @param width ratio across width from 0 to 1
  63572. * @param height ratio up height from 0 to 1
  63573. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63574. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63575. */
  63576. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63577. /**
  63578. * Append an hook to a rope object
  63579. * @param impostor is the rope impostor to add hook to
  63580. * @param otherImpostor is the rigid impostor to hook to
  63581. * @param length ratio along the rope from 0 to 1
  63582. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63583. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63584. */
  63585. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63586. /**
  63587. * Sleeps the physics body and stops it from being active
  63588. * @param impostor impostor to sleep
  63589. */
  63590. sleepBody(impostor: PhysicsImpostor): void;
  63591. /**
  63592. * Activates the physics body
  63593. * @param impostor impostor to activate
  63594. */
  63595. wakeUpBody(impostor: PhysicsImpostor): void;
  63596. /**
  63597. * Updates the distance parameters of the joint
  63598. * @param joint joint to update
  63599. * @param maxDistance maximum distance of the joint
  63600. * @param minDistance minimum distance of the joint
  63601. */
  63602. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63603. /**
  63604. * Sets a motor on the joint
  63605. * @param joint joint to set motor on
  63606. * @param speed speed of the motor
  63607. * @param maxForce maximum force of the motor
  63608. * @param motorIndex index of the motor
  63609. */
  63610. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63611. /**
  63612. * Sets the motors limit
  63613. * @param joint joint to set limit on
  63614. * @param upperLimit upper limit
  63615. * @param lowerLimit lower limit
  63616. */
  63617. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63618. /**
  63619. * Syncs the position and rotation of a mesh with the impostor
  63620. * @param mesh mesh to sync
  63621. * @param impostor impostor to update the mesh with
  63622. */
  63623. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63624. /**
  63625. * Gets the radius of the impostor
  63626. * @param impostor impostor to get radius from
  63627. * @returns the radius
  63628. */
  63629. getRadius(impostor: PhysicsImpostor): number;
  63630. /**
  63631. * Gets the box size of the impostor
  63632. * @param impostor impostor to get box size from
  63633. * @param result the resulting box size
  63634. */
  63635. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63636. /**
  63637. * Disposes of the impostor
  63638. */
  63639. dispose(): void;
  63640. /**
  63641. * Does a raycast in the physics world
  63642. * @param from when should the ray start?
  63643. * @param to when should the ray end?
  63644. * @returns PhysicsRaycastResult
  63645. */
  63646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63647. }
  63648. }
  63649. declare module "babylonjs/Probes/reflectionProbe" {
  63650. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63651. import { Vector3 } from "babylonjs/Maths/math.vector";
  63652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63653. import { Nullable } from "babylonjs/types";
  63654. import { Scene } from "babylonjs/scene";
  63655. module "babylonjs/abstractScene" {
  63656. interface AbstractScene {
  63657. /**
  63658. * The list of reflection probes added to the scene
  63659. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63660. */
  63661. reflectionProbes: Array<ReflectionProbe>;
  63662. /**
  63663. * Removes the given reflection probe from this scene.
  63664. * @param toRemove The reflection probe to remove
  63665. * @returns The index of the removed reflection probe
  63666. */
  63667. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63668. /**
  63669. * Adds the given reflection probe to this scene.
  63670. * @param newReflectionProbe The reflection probe to add
  63671. */
  63672. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63673. }
  63674. }
  63675. /**
  63676. * Class used to generate realtime reflection / refraction cube textures
  63677. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63678. */
  63679. export class ReflectionProbe {
  63680. /** defines the name of the probe */
  63681. name: string;
  63682. private _scene;
  63683. private _renderTargetTexture;
  63684. private _projectionMatrix;
  63685. private _viewMatrix;
  63686. private _target;
  63687. private _add;
  63688. private _attachedMesh;
  63689. private _invertYAxis;
  63690. /** Gets or sets probe position (center of the cube map) */
  63691. position: Vector3;
  63692. /**
  63693. * Creates a new reflection probe
  63694. * @param name defines the name of the probe
  63695. * @param size defines the texture resolution (for each face)
  63696. * @param scene defines the hosting scene
  63697. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63698. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63699. */
  63700. constructor(
  63701. /** defines the name of the probe */
  63702. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63703. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63704. get samples(): number;
  63705. set samples(value: number);
  63706. /** Gets or sets the refresh rate to use (on every frame by default) */
  63707. get refreshRate(): number;
  63708. set refreshRate(value: number);
  63709. /**
  63710. * Gets the hosting scene
  63711. * @returns a Scene
  63712. */
  63713. getScene(): Scene;
  63714. /** Gets the internal CubeTexture used to render to */
  63715. get cubeTexture(): RenderTargetTexture;
  63716. /** Gets the list of meshes to render */
  63717. get renderList(): Nullable<AbstractMesh[]>;
  63718. /**
  63719. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63720. * @param mesh defines the mesh to attach to
  63721. */
  63722. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63723. /**
  63724. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63725. * @param renderingGroupId The rendering group id corresponding to its index
  63726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63727. */
  63728. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63729. /**
  63730. * Clean all associated resources
  63731. */
  63732. dispose(): void;
  63733. /**
  63734. * Converts the reflection probe information to a readable string for debug purpose.
  63735. * @param fullDetails Supports for multiple levels of logging within scene loading
  63736. * @returns the human readable reflection probe info
  63737. */
  63738. toString(fullDetails?: boolean): string;
  63739. /**
  63740. * Get the class name of the relfection probe.
  63741. * @returns "ReflectionProbe"
  63742. */
  63743. getClassName(): string;
  63744. /**
  63745. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63746. * @returns The JSON representation of the texture
  63747. */
  63748. serialize(): any;
  63749. /**
  63750. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63751. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63752. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63753. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63754. * @returns The parsed reflection probe if successful
  63755. */
  63756. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63757. }
  63758. }
  63759. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63760. /** @hidden */
  63761. export var _BabylonLoaderRegistered: boolean;
  63762. /**
  63763. * Helps setting up some configuration for the babylon file loader.
  63764. */
  63765. export class BabylonFileLoaderConfiguration {
  63766. /**
  63767. * The loader does not allow injecting custom physix engine into the plugins.
  63768. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63769. * So you could set this variable to your engine import to make it work.
  63770. */
  63771. static LoaderInjectedPhysicsEngine: any;
  63772. }
  63773. }
  63774. declare module "babylonjs/Loading/Plugins/index" {
  63775. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63776. }
  63777. declare module "babylonjs/Loading/index" {
  63778. export * from "babylonjs/Loading/loadingScreen";
  63779. export * from "babylonjs/Loading/Plugins/index";
  63780. export * from "babylonjs/Loading/sceneLoader";
  63781. export * from "babylonjs/Loading/sceneLoaderFlags";
  63782. }
  63783. declare module "babylonjs/Materials/Background/index" {
  63784. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63785. }
  63786. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63787. import { Scene } from "babylonjs/scene";
  63788. import { Color3 } from "babylonjs/Maths/math.color";
  63789. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63791. /**
  63792. * The Physically based simple base material of BJS.
  63793. *
  63794. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63795. * It is used as the base class for both the specGloss and metalRough conventions.
  63796. */
  63797. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63798. /**
  63799. * Number of Simultaneous lights allowed on the material.
  63800. */
  63801. maxSimultaneousLights: number;
  63802. /**
  63803. * If sets to true, disables all the lights affecting the material.
  63804. */
  63805. disableLighting: boolean;
  63806. /**
  63807. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63808. */
  63809. environmentTexture: BaseTexture;
  63810. /**
  63811. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63812. */
  63813. invertNormalMapX: boolean;
  63814. /**
  63815. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63816. */
  63817. invertNormalMapY: boolean;
  63818. /**
  63819. * Normal map used in the model.
  63820. */
  63821. normalTexture: BaseTexture;
  63822. /**
  63823. * Emissivie color used to self-illuminate the model.
  63824. */
  63825. emissiveColor: Color3;
  63826. /**
  63827. * Emissivie texture used to self-illuminate the model.
  63828. */
  63829. emissiveTexture: BaseTexture;
  63830. /**
  63831. * Occlusion Channel Strenght.
  63832. */
  63833. occlusionStrength: number;
  63834. /**
  63835. * Occlusion Texture of the material (adding extra occlusion effects).
  63836. */
  63837. occlusionTexture: BaseTexture;
  63838. /**
  63839. * Defines the alpha limits in alpha test mode.
  63840. */
  63841. alphaCutOff: number;
  63842. /**
  63843. * Gets the current double sided mode.
  63844. */
  63845. get doubleSided(): boolean;
  63846. /**
  63847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63848. */
  63849. set doubleSided(value: boolean);
  63850. /**
  63851. * Stores the pre-calculated light information of a mesh in a texture.
  63852. */
  63853. lightmapTexture: BaseTexture;
  63854. /**
  63855. * If true, the light map contains occlusion information instead of lighting info.
  63856. */
  63857. useLightmapAsShadowmap: boolean;
  63858. /**
  63859. * Instantiates a new PBRMaterial instance.
  63860. *
  63861. * @param name The material name
  63862. * @param scene The scene the material will be use in.
  63863. */
  63864. constructor(name: string, scene: Scene);
  63865. getClassName(): string;
  63866. }
  63867. }
  63868. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63869. import { Scene } from "babylonjs/scene";
  63870. import { Color3 } from "babylonjs/Maths/math.color";
  63871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63872. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63873. /**
  63874. * The PBR material of BJS following the metal roughness convention.
  63875. *
  63876. * This fits to the PBR convention in the GLTF definition:
  63877. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63878. */
  63879. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63880. /**
  63881. * The base color has two different interpretations depending on the value of metalness.
  63882. * When the material is a metal, the base color is the specific measured reflectance value
  63883. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63884. * of the material.
  63885. */
  63886. baseColor: Color3;
  63887. /**
  63888. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63889. * well as opacity information in the alpha channel.
  63890. */
  63891. baseTexture: BaseTexture;
  63892. /**
  63893. * Specifies the metallic scalar value of the material.
  63894. * Can also be used to scale the metalness values of the metallic texture.
  63895. */
  63896. metallic: number;
  63897. /**
  63898. * Specifies the roughness scalar value of the material.
  63899. * Can also be used to scale the roughness values of the metallic texture.
  63900. */
  63901. roughness: number;
  63902. /**
  63903. * Texture containing both the metallic value in the B channel and the
  63904. * roughness value in the G channel to keep better precision.
  63905. */
  63906. metallicRoughnessTexture: BaseTexture;
  63907. /**
  63908. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63909. *
  63910. * @param name The material name
  63911. * @param scene The scene the material will be use in.
  63912. */
  63913. constructor(name: string, scene: Scene);
  63914. /**
  63915. * Return the currrent class name of the material.
  63916. */
  63917. getClassName(): string;
  63918. /**
  63919. * Makes a duplicate of the current material.
  63920. * @param name - name to use for the new material.
  63921. */
  63922. clone(name: string): PBRMetallicRoughnessMaterial;
  63923. /**
  63924. * Serialize the material to a parsable JSON object.
  63925. */
  63926. serialize(): any;
  63927. /**
  63928. * Parses a JSON object correponding to the serialize function.
  63929. */
  63930. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63931. }
  63932. }
  63933. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63934. import { Scene } from "babylonjs/scene";
  63935. import { Color3 } from "babylonjs/Maths/math.color";
  63936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63937. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63938. /**
  63939. * The PBR material of BJS following the specular glossiness convention.
  63940. *
  63941. * This fits to the PBR convention in the GLTF definition:
  63942. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63943. */
  63944. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63945. /**
  63946. * Specifies the diffuse color of the material.
  63947. */
  63948. diffuseColor: Color3;
  63949. /**
  63950. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63951. * channel.
  63952. */
  63953. diffuseTexture: BaseTexture;
  63954. /**
  63955. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63956. */
  63957. specularColor: Color3;
  63958. /**
  63959. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63960. */
  63961. glossiness: number;
  63962. /**
  63963. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63964. */
  63965. specularGlossinessTexture: BaseTexture;
  63966. /**
  63967. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63968. *
  63969. * @param name The material name
  63970. * @param scene The scene the material will be use in.
  63971. */
  63972. constructor(name: string, scene: Scene);
  63973. /**
  63974. * Return the currrent class name of the material.
  63975. */
  63976. getClassName(): string;
  63977. /**
  63978. * Makes a duplicate of the current material.
  63979. * @param name - name to use for the new material.
  63980. */
  63981. clone(name: string): PBRSpecularGlossinessMaterial;
  63982. /**
  63983. * Serialize the material to a parsable JSON object.
  63984. */
  63985. serialize(): any;
  63986. /**
  63987. * Parses a JSON object correponding to the serialize function.
  63988. */
  63989. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63990. }
  63991. }
  63992. declare module "babylonjs/Materials/PBR/index" {
  63993. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63994. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63995. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63996. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63997. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63998. }
  63999. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64000. import { Nullable } from "babylonjs/types";
  64001. import { Scene } from "babylonjs/scene";
  64002. import { Matrix } from "babylonjs/Maths/math.vector";
  64003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64004. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64005. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64006. /**
  64007. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64008. * It can help converting any input color in a desired output one. This can then be used to create effects
  64009. * from sepia, black and white to sixties or futuristic rendering...
  64010. *
  64011. * The only supported format is currently 3dl.
  64012. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64013. */
  64014. export class ColorGradingTexture extends BaseTexture {
  64015. /**
  64016. * The texture URL.
  64017. */
  64018. url: string;
  64019. /**
  64020. * Empty line regex stored for GC.
  64021. */
  64022. private static _noneEmptyLineRegex;
  64023. private _textureMatrix;
  64024. private _onLoad;
  64025. /**
  64026. * Instantiates a ColorGradingTexture from the following parameters.
  64027. *
  64028. * @param url The location of the color gradind data (currently only supporting 3dl)
  64029. * @param sceneOrEngine The scene or engine the texture will be used in
  64030. * @param onLoad defines a callback triggered when the texture has been loaded
  64031. */
  64032. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64033. /**
  64034. * Fires the onload event from the constructor if requested.
  64035. */
  64036. private _triggerOnLoad;
  64037. /**
  64038. * Returns the texture matrix used in most of the material.
  64039. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64040. */
  64041. getTextureMatrix(): Matrix;
  64042. /**
  64043. * Occurs when the file being loaded is a .3dl LUT file.
  64044. */
  64045. private load3dlTexture;
  64046. /**
  64047. * Starts the loading process of the texture.
  64048. */
  64049. private loadTexture;
  64050. /**
  64051. * Clones the color gradind texture.
  64052. */
  64053. clone(): ColorGradingTexture;
  64054. /**
  64055. * Called during delayed load for textures.
  64056. */
  64057. delayLoad(): void;
  64058. /**
  64059. * Parses a color grading texture serialized by Babylon.
  64060. * @param parsedTexture The texture information being parsedTexture
  64061. * @param scene The scene to load the texture in
  64062. * @param rootUrl The root url of the data assets to load
  64063. * @return A color gradind texture
  64064. */
  64065. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64066. /**
  64067. * Serializes the LUT texture to json format.
  64068. */
  64069. serialize(): any;
  64070. }
  64071. }
  64072. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64074. import { Scene } from "babylonjs/scene";
  64075. import { Nullable } from "babylonjs/types";
  64076. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64077. /**
  64078. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64079. */
  64080. export class EquiRectangularCubeTexture extends BaseTexture {
  64081. /** The six faces of the cube. */
  64082. private static _FacesMapping;
  64083. private _noMipmap;
  64084. private _onLoad;
  64085. private _onError;
  64086. /** The size of the cubemap. */
  64087. private _size;
  64088. /** The buffer of the image. */
  64089. private _buffer;
  64090. /** The width of the input image. */
  64091. private _width;
  64092. /** The height of the input image. */
  64093. private _height;
  64094. /** The URL to the image. */
  64095. url: string;
  64096. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  64097. coordinatesMode: number;
  64098. /**
  64099. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64100. * @param url The location of the image
  64101. * @param scene The scene the texture will be used in
  64102. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64103. * @param noMipmap Forces to not generate the mipmap if true
  64104. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64105. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64106. * @param onLoad — defines a callback called when texture is loaded
  64107. * @param onError — defines a callback called if there is an error
  64108. */
  64109. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64110. /**
  64111. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64112. */
  64113. private loadImage;
  64114. /**
  64115. * Convert the image buffer into a cubemap and create a CubeTexture.
  64116. */
  64117. private loadTexture;
  64118. /**
  64119. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64120. * @param buffer The ArrayBuffer that should be converted.
  64121. * @returns The buffer as Float32Array.
  64122. */
  64123. private getFloat32ArrayFromArrayBuffer;
  64124. /**
  64125. * Get the current class name of the texture useful for serialization or dynamic coding.
  64126. * @returns "EquiRectangularCubeTexture"
  64127. */
  64128. getClassName(): string;
  64129. /**
  64130. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64131. * @returns A clone of the current EquiRectangularCubeTexture.
  64132. */
  64133. clone(): EquiRectangularCubeTexture;
  64134. }
  64135. }
  64136. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64137. import { Nullable } from "babylonjs/types";
  64138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64139. import { Matrix } from "babylonjs/Maths/math.vector";
  64140. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64141. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64142. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64143. import { Scene } from "babylonjs/scene";
  64144. /**
  64145. * Defines the options related to the creation of an HtmlElementTexture
  64146. */
  64147. export interface IHtmlElementTextureOptions {
  64148. /**
  64149. * Defines wether mip maps should be created or not.
  64150. */
  64151. generateMipMaps?: boolean;
  64152. /**
  64153. * Defines the sampling mode of the texture.
  64154. */
  64155. samplingMode?: number;
  64156. /**
  64157. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64158. */
  64159. engine: Nullable<ThinEngine>;
  64160. /**
  64161. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64162. */
  64163. scene: Nullable<Scene>;
  64164. }
  64165. /**
  64166. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64167. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64168. * is automatically managed.
  64169. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64170. * in your application.
  64171. *
  64172. * As the update is not automatic, you need to call them manually.
  64173. */
  64174. export class HtmlElementTexture extends BaseTexture {
  64175. /**
  64176. * The texture URL.
  64177. */
  64178. element: HTMLVideoElement | HTMLCanvasElement;
  64179. private static readonly DefaultOptions;
  64180. private _textureMatrix;
  64181. private _isVideo;
  64182. private _generateMipMaps;
  64183. private _samplingMode;
  64184. /**
  64185. * Instantiates a HtmlElementTexture from the following parameters.
  64186. *
  64187. * @param name Defines the name of the texture
  64188. * @param element Defines the video or canvas the texture is filled with
  64189. * @param options Defines the other none mandatory texture creation options
  64190. */
  64191. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64192. private _createInternalTexture;
  64193. /**
  64194. * Returns the texture matrix used in most of the material.
  64195. */
  64196. getTextureMatrix(): Matrix;
  64197. /**
  64198. * Updates the content of the texture.
  64199. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64200. */
  64201. update(invertY?: Nullable<boolean>): void;
  64202. }
  64203. }
  64204. declare module "babylonjs/Misc/tga" {
  64205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64206. /**
  64207. * Based on jsTGALoader - Javascript loader for TGA file
  64208. * By Vincent Thibault
  64209. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64210. */
  64211. export class TGATools {
  64212. private static _TYPE_INDEXED;
  64213. private static _TYPE_RGB;
  64214. private static _TYPE_GREY;
  64215. private static _TYPE_RLE_INDEXED;
  64216. private static _TYPE_RLE_RGB;
  64217. private static _TYPE_RLE_GREY;
  64218. private static _ORIGIN_MASK;
  64219. private static _ORIGIN_SHIFT;
  64220. private static _ORIGIN_BL;
  64221. private static _ORIGIN_BR;
  64222. private static _ORIGIN_UL;
  64223. private static _ORIGIN_UR;
  64224. /**
  64225. * Gets the header of a TGA file
  64226. * @param data defines the TGA data
  64227. * @returns the header
  64228. */
  64229. static GetTGAHeader(data: Uint8Array): any;
  64230. /**
  64231. * Uploads TGA content to a Babylon Texture
  64232. * @hidden
  64233. */
  64234. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64235. /** @hidden */
  64236. 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;
  64237. /** @hidden */
  64238. 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;
  64239. /** @hidden */
  64240. 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;
  64241. /** @hidden */
  64242. 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;
  64243. /** @hidden */
  64244. 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;
  64245. /** @hidden */
  64246. 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;
  64247. }
  64248. }
  64249. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64250. import { Nullable } from "babylonjs/types";
  64251. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64252. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64253. /**
  64254. * Implementation of the TGA Texture Loader.
  64255. * @hidden
  64256. */
  64257. export class _TGATextureLoader implements IInternalTextureLoader {
  64258. /**
  64259. * Defines wether the loader supports cascade loading the different faces.
  64260. */
  64261. readonly supportCascades: boolean;
  64262. /**
  64263. * This returns if the loader support the current file information.
  64264. * @param extension defines the file extension of the file being loaded
  64265. * @returns true if the loader can load the specified file
  64266. */
  64267. canLoad(extension: string): boolean;
  64268. /**
  64269. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64270. * @param data contains the texture data
  64271. * @param texture defines the BabylonJS internal texture
  64272. * @param createPolynomials will be true if polynomials have been requested
  64273. * @param onLoad defines the callback to trigger once the texture is ready
  64274. * @param onError defines the callback to trigger in case of error
  64275. */
  64276. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64277. /**
  64278. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64279. * @param data contains the texture data
  64280. * @param texture defines the BabylonJS internal texture
  64281. * @param callback defines the method to call once ready to upload
  64282. */
  64283. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64284. }
  64285. }
  64286. declare module "babylonjs/Misc/basis" {
  64287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64288. /**
  64289. * Info about the .basis files
  64290. */
  64291. class BasisFileInfo {
  64292. /**
  64293. * If the file has alpha
  64294. */
  64295. hasAlpha: boolean;
  64296. /**
  64297. * Info about each image of the basis file
  64298. */
  64299. images: Array<{
  64300. levels: Array<{
  64301. width: number;
  64302. height: number;
  64303. transcodedPixels: ArrayBufferView;
  64304. }>;
  64305. }>;
  64306. }
  64307. /**
  64308. * Result of transcoding a basis file
  64309. */
  64310. class TranscodeResult {
  64311. /**
  64312. * Info about the .basis file
  64313. */
  64314. fileInfo: BasisFileInfo;
  64315. /**
  64316. * Format to use when loading the file
  64317. */
  64318. format: number;
  64319. }
  64320. /**
  64321. * Configuration options for the Basis transcoder
  64322. */
  64323. export class BasisTranscodeConfiguration {
  64324. /**
  64325. * Supported compression formats used to determine the supported output format of the transcoder
  64326. */
  64327. supportedCompressionFormats?: {
  64328. /**
  64329. * etc1 compression format
  64330. */
  64331. etc1?: boolean;
  64332. /**
  64333. * s3tc compression format
  64334. */
  64335. s3tc?: boolean;
  64336. /**
  64337. * pvrtc compression format
  64338. */
  64339. pvrtc?: boolean;
  64340. /**
  64341. * etc2 compression format
  64342. */
  64343. etc2?: boolean;
  64344. };
  64345. /**
  64346. * If mipmap levels should be loaded for transcoded images (Default: true)
  64347. */
  64348. loadMipmapLevels?: boolean;
  64349. /**
  64350. * Index of a single image to load (Default: all images)
  64351. */
  64352. loadSingleImage?: number;
  64353. }
  64354. /**
  64355. * Used to load .Basis files
  64356. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64357. */
  64358. export class BasisTools {
  64359. private static _IgnoreSupportedFormats;
  64360. /**
  64361. * URL to use when loading the basis transcoder
  64362. */
  64363. static JSModuleURL: string;
  64364. /**
  64365. * URL to use when loading the wasm module for the transcoder
  64366. */
  64367. static WasmModuleURL: string;
  64368. /**
  64369. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64370. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64371. * @returns internal format corresponding to the Basis format
  64372. */
  64373. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64374. private static _WorkerPromise;
  64375. private static _Worker;
  64376. private static _actionId;
  64377. private static _CreateWorkerAsync;
  64378. /**
  64379. * Transcodes a loaded image file to compressed pixel data
  64380. * @param data image data to transcode
  64381. * @param config configuration options for the transcoding
  64382. * @returns a promise resulting in the transcoded image
  64383. */
  64384. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64385. /**
  64386. * Loads a texture from the transcode result
  64387. * @param texture texture load to
  64388. * @param transcodeResult the result of transcoding the basis file to load from
  64389. */
  64390. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64391. }
  64392. }
  64393. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64394. import { Nullable } from "babylonjs/types";
  64395. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64396. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64397. /**
  64398. * Loader for .basis file format
  64399. */
  64400. export class _BasisTextureLoader implements IInternalTextureLoader {
  64401. /**
  64402. * Defines whether the loader supports cascade loading the different faces.
  64403. */
  64404. readonly supportCascades: boolean;
  64405. /**
  64406. * This returns if the loader support the current file information.
  64407. * @param extension defines the file extension of the file being loaded
  64408. * @returns true if the loader can load the specified file
  64409. */
  64410. canLoad(extension: string): boolean;
  64411. /**
  64412. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64413. * @param data contains the texture data
  64414. * @param texture defines the BabylonJS internal texture
  64415. * @param createPolynomials will be true if polynomials have been requested
  64416. * @param onLoad defines the callback to trigger once the texture is ready
  64417. * @param onError defines the callback to trigger in case of error
  64418. */
  64419. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64420. /**
  64421. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64422. * @param data contains the texture data
  64423. * @param texture defines the BabylonJS internal texture
  64424. * @param callback defines the method to call once ready to upload
  64425. */
  64426. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64427. }
  64428. }
  64429. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64430. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64431. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64432. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64433. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64434. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64435. }
  64436. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64437. import { Vector2 } from "babylonjs/Maths/math.vector";
  64438. /**
  64439. * Defines the basic options interface of a TexturePacker Frame
  64440. */
  64441. export interface ITexturePackerFrame {
  64442. /**
  64443. * The frame ID
  64444. */
  64445. id: number;
  64446. /**
  64447. * The frames Scale
  64448. */
  64449. scale: Vector2;
  64450. /**
  64451. * The Frames offset
  64452. */
  64453. offset: Vector2;
  64454. }
  64455. /**
  64456. * This is a support class for frame Data on texture packer sets.
  64457. */
  64458. export class TexturePackerFrame implements ITexturePackerFrame {
  64459. /**
  64460. * The frame ID
  64461. */
  64462. id: number;
  64463. /**
  64464. * The frames Scale
  64465. */
  64466. scale: Vector2;
  64467. /**
  64468. * The Frames offset
  64469. */
  64470. offset: Vector2;
  64471. /**
  64472. * Initializes a texture package frame.
  64473. * @param id The numerical frame identifier
  64474. * @param scale Scalar Vector2 for UV frame
  64475. * @param offset Vector2 for the frame position in UV units.
  64476. * @returns TexturePackerFrame
  64477. */
  64478. constructor(id: number, scale: Vector2, offset: Vector2);
  64479. }
  64480. }
  64481. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64483. import { Scene } from "babylonjs/scene";
  64484. import { Nullable } from "babylonjs/types";
  64485. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64486. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64487. /**
  64488. * Defines the basic options interface of a TexturePacker
  64489. */
  64490. export interface ITexturePackerOptions {
  64491. /**
  64492. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64493. */
  64494. map?: string[];
  64495. /**
  64496. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64497. */
  64498. uvsIn?: string;
  64499. /**
  64500. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64501. */
  64502. uvsOut?: string;
  64503. /**
  64504. * number representing the layout style. Defaults to LAYOUT_STRIP
  64505. */
  64506. layout?: number;
  64507. /**
  64508. * number of columns if using custom column count layout(2). This defaults to 4.
  64509. */
  64510. colnum?: number;
  64511. /**
  64512. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64513. */
  64514. updateInputMeshes?: boolean;
  64515. /**
  64516. * boolean flag to dispose all the source textures. Defaults to true.
  64517. */
  64518. disposeSources?: boolean;
  64519. /**
  64520. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64521. */
  64522. fillBlanks?: boolean;
  64523. /**
  64524. * string value representing the context fill style color. Defaults to 'black'.
  64525. */
  64526. customFillColor?: string;
  64527. /**
  64528. * Width and Height Value of each Frame in the TexturePacker Sets
  64529. */
  64530. frameSize?: number;
  64531. /**
  64532. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64533. */
  64534. paddingRatio?: number;
  64535. /**
  64536. * Number that declares the fill method for the padding gutter.
  64537. */
  64538. paddingMode?: number;
  64539. /**
  64540. * If in SUBUV_COLOR padding mode what color to use.
  64541. */
  64542. paddingColor?: Color3 | Color4;
  64543. }
  64544. /**
  64545. * Defines the basic interface of a TexturePacker JSON File
  64546. */
  64547. export interface ITexturePackerJSON {
  64548. /**
  64549. * The frame ID
  64550. */
  64551. name: string;
  64552. /**
  64553. * The base64 channel data
  64554. */
  64555. sets: any;
  64556. /**
  64557. * The options of the Packer
  64558. */
  64559. options: ITexturePackerOptions;
  64560. /**
  64561. * The frame data of the Packer
  64562. */
  64563. frames: Array<number>;
  64564. }
  64565. /**
  64566. * This is a support class that generates a series of packed texture sets.
  64567. * @see https://doc.babylonjs.com/babylon101/materials
  64568. */
  64569. export class TexturePacker {
  64570. /** Packer Layout Constant 0 */
  64571. static readonly LAYOUT_STRIP: number;
  64572. /** Packer Layout Constant 1 */
  64573. static readonly LAYOUT_POWER2: number;
  64574. /** Packer Layout Constant 2 */
  64575. static readonly LAYOUT_COLNUM: number;
  64576. /** Packer Layout Constant 0 */
  64577. static readonly SUBUV_WRAP: number;
  64578. /** Packer Layout Constant 1 */
  64579. static readonly SUBUV_EXTEND: number;
  64580. /** Packer Layout Constant 2 */
  64581. static readonly SUBUV_COLOR: number;
  64582. /** The Name of the Texture Package */
  64583. name: string;
  64584. /** The scene scope of the TexturePacker */
  64585. scene: Scene;
  64586. /** The Meshes to target */
  64587. meshes: AbstractMesh[];
  64588. /** Arguments passed with the Constructor */
  64589. options: ITexturePackerOptions;
  64590. /** The promise that is started upon initialization */
  64591. promise: Nullable<Promise<TexturePacker | string>>;
  64592. /** The Container object for the channel sets that are generated */
  64593. sets: object;
  64594. /** The Container array for the frames that are generated */
  64595. frames: TexturePackerFrame[];
  64596. /** The expected number of textures the system is parsing. */
  64597. private _expecting;
  64598. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64599. private _paddingValue;
  64600. /**
  64601. * Initializes a texture package series from an array of meshes or a single mesh.
  64602. * @param name The name of the package
  64603. * @param meshes The target meshes to compose the package from
  64604. * @param options The arguments that texture packer should follow while building.
  64605. * @param scene The scene which the textures are scoped to.
  64606. * @returns TexturePacker
  64607. */
  64608. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64609. /**
  64610. * Starts the package process
  64611. * @param resolve The promises resolution function
  64612. * @returns TexturePacker
  64613. */
  64614. private _createFrames;
  64615. /**
  64616. * Calculates the Size of the Channel Sets
  64617. * @returns Vector2
  64618. */
  64619. private _calculateSize;
  64620. /**
  64621. * Calculates the UV data for the frames.
  64622. * @param baseSize the base frameSize
  64623. * @param padding the base frame padding
  64624. * @param dtSize size of the Dynamic Texture for that channel
  64625. * @param dtUnits is 1/dtSize
  64626. * @param update flag to update the input meshes
  64627. */
  64628. private _calculateMeshUVFrames;
  64629. /**
  64630. * Calculates the frames Offset.
  64631. * @param index of the frame
  64632. * @returns Vector2
  64633. */
  64634. private _getFrameOffset;
  64635. /**
  64636. * Updates a Mesh to the frame data
  64637. * @param mesh that is the target
  64638. * @param frameID or the frame index
  64639. */
  64640. private _updateMeshUV;
  64641. /**
  64642. * Updates a Meshes materials to use the texture packer channels
  64643. * @param m is the mesh to target
  64644. * @param force all channels on the packer to be set.
  64645. */
  64646. private _updateTextureReferences;
  64647. /**
  64648. * Public method to set a Mesh to a frame
  64649. * @param m that is the target
  64650. * @param frameID or the frame index
  64651. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64652. */
  64653. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64654. /**
  64655. * Starts the async promise to compile the texture packer.
  64656. * @returns Promise<void>
  64657. */
  64658. processAsync(): Promise<void>;
  64659. /**
  64660. * Disposes all textures associated with this packer
  64661. */
  64662. dispose(): void;
  64663. /**
  64664. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64665. * @param imageType is the image type to use.
  64666. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64667. */
  64668. download(imageType?: string, quality?: number): void;
  64669. /**
  64670. * Public method to load a texturePacker JSON file.
  64671. * @param data of the JSON file in string format.
  64672. */
  64673. updateFromJSON(data: string): void;
  64674. }
  64675. }
  64676. declare module "babylonjs/Materials/Textures/Packer/index" {
  64677. export * from "babylonjs/Materials/Textures/Packer/packer";
  64678. export * from "babylonjs/Materials/Textures/Packer/frame";
  64679. }
  64680. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64681. import { Scene } from "babylonjs/scene";
  64682. import { Texture } from "babylonjs/Materials/Textures/texture";
  64683. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64684. /**
  64685. * 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.
  64686. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64687. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64688. */
  64689. export class CustomProceduralTexture extends ProceduralTexture {
  64690. private _animate;
  64691. private _time;
  64692. private _config;
  64693. private _texturePath;
  64694. /**
  64695. * Instantiates a new Custom Procedural Texture.
  64696. * 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.
  64697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64698. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64699. * @param name Define the name of the texture
  64700. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64701. * @param size Define the size of the texture to create
  64702. * @param scene Define the scene the texture belongs to
  64703. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64704. * @param generateMipMaps Define if the texture should creates mip maps or not
  64705. */
  64706. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64707. private _loadJson;
  64708. /**
  64709. * Is the texture ready to be used ? (rendered at least once)
  64710. * @returns true if ready, otherwise, false.
  64711. */
  64712. isReady(): boolean;
  64713. /**
  64714. * Render the texture to its associated render target.
  64715. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64716. */
  64717. render(useCameraPostProcess?: boolean): void;
  64718. /**
  64719. * Update the list of dependant textures samplers in the shader.
  64720. */
  64721. updateTextures(): void;
  64722. /**
  64723. * Update the uniform values of the procedural texture in the shader.
  64724. */
  64725. updateShaderUniforms(): void;
  64726. /**
  64727. * Define if the texture animates or not.
  64728. */
  64729. get animate(): boolean;
  64730. set animate(value: boolean);
  64731. }
  64732. }
  64733. declare module "babylonjs/Shaders/noise.fragment" {
  64734. /** @hidden */
  64735. export var noisePixelShader: {
  64736. name: string;
  64737. shader: string;
  64738. };
  64739. }
  64740. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64741. import { Nullable } from "babylonjs/types";
  64742. import { Scene } from "babylonjs/scene";
  64743. import { Texture } from "babylonjs/Materials/Textures/texture";
  64744. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64745. import "babylonjs/Shaders/noise.fragment";
  64746. /**
  64747. * Class used to generate noise procedural textures
  64748. */
  64749. export class NoiseProceduralTexture extends ProceduralTexture {
  64750. private _time;
  64751. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64752. brightness: number;
  64753. /** Defines the number of octaves to process */
  64754. octaves: number;
  64755. /** Defines the level of persistence (0.8 by default) */
  64756. persistence: number;
  64757. /** Gets or sets animation speed factor (default is 1) */
  64758. animationSpeedFactor: number;
  64759. /**
  64760. * Creates a new NoiseProceduralTexture
  64761. * @param name defines the name fo the texture
  64762. * @param size defines the size of the texture (default is 256)
  64763. * @param scene defines the hosting scene
  64764. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64765. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64766. */
  64767. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64768. private _updateShaderUniforms;
  64769. protected _getDefines(): string;
  64770. /** Generate the current state of the procedural texture */
  64771. render(useCameraPostProcess?: boolean): void;
  64772. /**
  64773. * Serializes this noise procedural texture
  64774. * @returns a serialized noise procedural texture object
  64775. */
  64776. serialize(): any;
  64777. /**
  64778. * Clone the texture.
  64779. * @returns the cloned texture
  64780. */
  64781. clone(): NoiseProceduralTexture;
  64782. /**
  64783. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64784. * @param parsedTexture defines parsed texture data
  64785. * @param scene defines the current scene
  64786. * @param rootUrl defines the root URL containing noise procedural texture information
  64787. * @returns a parsed NoiseProceduralTexture
  64788. */
  64789. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64790. }
  64791. }
  64792. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64793. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64794. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64795. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64796. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64797. }
  64798. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64799. import { Nullable } from "babylonjs/types";
  64800. import { Scene } from "babylonjs/scene";
  64801. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64803. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64804. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64805. /**
  64806. * Raw cube texture where the raw buffers are passed in
  64807. */
  64808. export class RawCubeTexture extends CubeTexture {
  64809. /**
  64810. * Creates a cube texture where the raw buffers are passed in.
  64811. * @param scene defines the scene the texture is attached to
  64812. * @param data defines the array of data to use to create each face
  64813. * @param size defines the size of the textures
  64814. * @param format defines the format of the data
  64815. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64816. * @param generateMipMaps defines if the engine should generate the mip levels
  64817. * @param invertY defines if data must be stored with Y axis inverted
  64818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64819. * @param compression defines the compression used (null by default)
  64820. */
  64821. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64822. /**
  64823. * Updates the raw cube texture.
  64824. * @param data defines the data to store
  64825. * @param format defines the data format
  64826. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64827. * @param invertY defines if data must be stored with Y axis inverted
  64828. * @param compression defines the compression used (null by default)
  64829. * @param level defines which level of the texture to update
  64830. */
  64831. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64832. /**
  64833. * Updates a raw cube texture with RGBD encoded data.
  64834. * @param data defines the array of data [mipmap][face] to use to create each face
  64835. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64838. * @returns a promsie that resolves when the operation is complete
  64839. */
  64840. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64841. /**
  64842. * Clones the raw cube texture.
  64843. * @return a new cube texture
  64844. */
  64845. clone(): CubeTexture;
  64846. /** @hidden */
  64847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64848. }
  64849. }
  64850. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64851. import { Scene } from "babylonjs/scene";
  64852. import { Texture } from "babylonjs/Materials/Textures/texture";
  64853. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64854. /**
  64855. * Class used to store 2D array textures containing user data
  64856. */
  64857. export class RawTexture2DArray extends Texture {
  64858. /** Gets or sets the texture format to use */
  64859. format: number;
  64860. /**
  64861. * Create a new RawTexture2DArray
  64862. * @param data defines the data of the texture
  64863. * @param width defines the width of the texture
  64864. * @param height defines the height of the texture
  64865. * @param depth defines the number of layers of the texture
  64866. * @param format defines the texture format to use
  64867. * @param scene defines the hosting scene
  64868. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64869. * @param invertY defines if texture must be stored with Y axis inverted
  64870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64871. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64872. */
  64873. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64874. /** Gets or sets the texture format to use */
  64875. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64876. /**
  64877. * Update the texture with new data
  64878. * @param data defines the data to store in the texture
  64879. */
  64880. update(data: ArrayBufferView): void;
  64881. }
  64882. }
  64883. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64884. import { Scene } from "babylonjs/scene";
  64885. import { Texture } from "babylonjs/Materials/Textures/texture";
  64886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64887. /**
  64888. * Class used to store 3D textures containing user data
  64889. */
  64890. export class RawTexture3D extends Texture {
  64891. /** Gets or sets the texture format to use */
  64892. format: number;
  64893. /**
  64894. * Create a new RawTexture3D
  64895. * @param data defines the data of the texture
  64896. * @param width defines the width of the texture
  64897. * @param height defines the height of the texture
  64898. * @param depth defines the depth of the texture
  64899. * @param format defines the texture format to use
  64900. * @param scene defines the hosting scene
  64901. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64902. * @param invertY defines if texture must be stored with Y axis inverted
  64903. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64904. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64905. */
  64906. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64907. /** Gets or sets the texture format to use */
  64908. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64909. /**
  64910. * Update the texture with new data
  64911. * @param data defines the data to store in the texture
  64912. */
  64913. update(data: ArrayBufferView): void;
  64914. }
  64915. }
  64916. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64917. import { Scene } from "babylonjs/scene";
  64918. import { Plane } from "babylonjs/Maths/math.plane";
  64919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64920. /**
  64921. * Creates a refraction texture used by refraction channel of the standard material.
  64922. * It is like a mirror but to see through a material.
  64923. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64924. */
  64925. export class RefractionTexture extends RenderTargetTexture {
  64926. /**
  64927. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64928. * 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.
  64929. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64930. */
  64931. refractionPlane: Plane;
  64932. /**
  64933. * Define how deep under the surface we should see.
  64934. */
  64935. depth: number;
  64936. /**
  64937. * Creates a refraction texture used by refraction channel of the standard material.
  64938. * It is like a mirror but to see through a material.
  64939. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64940. * @param name Define the texture name
  64941. * @param size Define the size of the underlying texture
  64942. * @param scene Define the scene the refraction belongs to
  64943. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64944. */
  64945. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64946. /**
  64947. * Clone the refraction texture.
  64948. * @returns the cloned texture
  64949. */
  64950. clone(): RefractionTexture;
  64951. /**
  64952. * Serialize the texture to a JSON representation you could use in Parse later on
  64953. * @returns the serialized JSON representation
  64954. */
  64955. serialize(): any;
  64956. }
  64957. }
  64958. declare module "babylonjs/Materials/Textures/index" {
  64959. export * from "babylonjs/Materials/Textures/baseTexture";
  64960. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64961. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64962. export * from "babylonjs/Materials/Textures/cubeTexture";
  64963. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64964. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64965. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64966. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64967. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64968. export * from "babylonjs/Materials/Textures/internalTexture";
  64969. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64970. export * from "babylonjs/Materials/Textures/Loaders/index";
  64971. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64972. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64973. export * from "babylonjs/Materials/Textures/Packer/index";
  64974. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64975. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64976. export * from "babylonjs/Materials/Textures/rawTexture";
  64977. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64978. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64979. export * from "babylonjs/Materials/Textures/refractionTexture";
  64980. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64981. export * from "babylonjs/Materials/Textures/texture";
  64982. export * from "babylonjs/Materials/Textures/videoTexture";
  64983. }
  64984. declare module "babylonjs/Materials/Node/Enums/index" {
  64985. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64986. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64987. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64988. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64989. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64990. }
  64991. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64995. import { Mesh } from "babylonjs/Meshes/mesh";
  64996. import { Effect } from "babylonjs/Materials/effect";
  64997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64998. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64999. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65000. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65001. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65002. /**
  65003. * Block used to add support for vertex skinning (bones)
  65004. */
  65005. export class BonesBlock extends NodeMaterialBlock {
  65006. /**
  65007. * Creates a new BonesBlock
  65008. * @param name defines the block name
  65009. */
  65010. constructor(name: string);
  65011. /**
  65012. * Initialize the block and prepare the context for build
  65013. * @param state defines the state that will be used for the build
  65014. */
  65015. initialize(state: NodeMaterialBuildState): void;
  65016. /**
  65017. * Gets the current class name
  65018. * @returns the class name
  65019. */
  65020. getClassName(): string;
  65021. /**
  65022. * Gets the matrix indices input component
  65023. */
  65024. get matricesIndices(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the matrix weights input component
  65027. */
  65028. get matricesWeights(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the extra matrix indices input component
  65031. */
  65032. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the extra matrix weights input component
  65035. */
  65036. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the world input component
  65039. */
  65040. get world(): NodeMaterialConnectionPoint;
  65041. /**
  65042. * Gets the output component
  65043. */
  65044. get output(): NodeMaterialConnectionPoint;
  65045. autoConfigure(material: NodeMaterial): void;
  65046. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65049. protected _buildBlock(state: NodeMaterialBuildState): this;
  65050. }
  65051. }
  65052. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65057. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65058. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65059. /**
  65060. * Block used to add support for instances
  65061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65062. */
  65063. export class InstancesBlock extends NodeMaterialBlock {
  65064. /**
  65065. * Creates a new InstancesBlock
  65066. * @param name defines the block name
  65067. */
  65068. constructor(name: string);
  65069. /**
  65070. * Gets the current class name
  65071. * @returns the class name
  65072. */
  65073. getClassName(): string;
  65074. /**
  65075. * Gets the first world row input component
  65076. */
  65077. get world0(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the second world row input component
  65080. */
  65081. get world1(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the third world row input component
  65084. */
  65085. get world2(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the forth world row input component
  65088. */
  65089. get world3(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the world input component
  65092. */
  65093. get world(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the output component
  65096. */
  65097. get output(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the isntanceID component
  65100. */
  65101. get instanceID(): NodeMaterialConnectionPoint;
  65102. autoConfigure(material: NodeMaterial): void;
  65103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65104. protected _buildBlock(state: NodeMaterialBuildState): this;
  65105. }
  65106. }
  65107. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65112. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65113. import { Effect } from "babylonjs/Materials/effect";
  65114. import { Mesh } from "babylonjs/Meshes/mesh";
  65115. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65117. /**
  65118. * Block used to add morph targets support to vertex shader
  65119. */
  65120. export class MorphTargetsBlock extends NodeMaterialBlock {
  65121. private _repeatableContentAnchor;
  65122. /**
  65123. * Create a new MorphTargetsBlock
  65124. * @param name defines the block name
  65125. */
  65126. constructor(name: string);
  65127. /**
  65128. * Gets the current class name
  65129. * @returns the class name
  65130. */
  65131. getClassName(): string;
  65132. /**
  65133. * Gets the position input component
  65134. */
  65135. get position(): NodeMaterialConnectionPoint;
  65136. /**
  65137. * Gets the normal input component
  65138. */
  65139. get normal(): NodeMaterialConnectionPoint;
  65140. /**
  65141. * Gets the tangent input component
  65142. */
  65143. get tangent(): NodeMaterialConnectionPoint;
  65144. /**
  65145. * Gets the tangent input component
  65146. */
  65147. get uv(): NodeMaterialConnectionPoint;
  65148. /**
  65149. * Gets the position output component
  65150. */
  65151. get positionOutput(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the normal output component
  65154. */
  65155. get normalOutput(): NodeMaterialConnectionPoint;
  65156. /**
  65157. * Gets the tangent output component
  65158. */
  65159. get tangentOutput(): NodeMaterialConnectionPoint;
  65160. /**
  65161. * Gets the tangent output component
  65162. */
  65163. get uvOutput(): NodeMaterialConnectionPoint;
  65164. initialize(state: NodeMaterialBuildState): void;
  65165. autoConfigure(material: NodeMaterial): void;
  65166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65168. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65169. protected _buildBlock(state: NodeMaterialBuildState): this;
  65170. }
  65171. }
  65172. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65176. import { Nullable } from "babylonjs/types";
  65177. import { Scene } from "babylonjs/scene";
  65178. import { Effect } from "babylonjs/Materials/effect";
  65179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65180. import { Mesh } from "babylonjs/Meshes/mesh";
  65181. import { Light } from "babylonjs/Lights/light";
  65182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65183. /**
  65184. * Block used to get data information from a light
  65185. */
  65186. export class LightInformationBlock extends NodeMaterialBlock {
  65187. private _lightDataUniformName;
  65188. private _lightColorUniformName;
  65189. private _lightTypeDefineName;
  65190. /**
  65191. * Gets or sets the light associated with this block
  65192. */
  65193. light: Nullable<Light>;
  65194. /**
  65195. * Creates a new LightInformationBlock
  65196. * @param name defines the block name
  65197. */
  65198. constructor(name: string);
  65199. /**
  65200. * Gets the current class name
  65201. * @returns the class name
  65202. */
  65203. getClassName(): string;
  65204. /**
  65205. * Gets the world position input component
  65206. */
  65207. get worldPosition(): NodeMaterialConnectionPoint;
  65208. /**
  65209. * Gets the direction output component
  65210. */
  65211. get direction(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the direction output component
  65214. */
  65215. get color(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the direction output component
  65218. */
  65219. get intensity(): NodeMaterialConnectionPoint;
  65220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65222. protected _buildBlock(state: NodeMaterialBuildState): this;
  65223. serialize(): any;
  65224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65225. }
  65226. }
  65227. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65228. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65229. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65230. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65231. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65232. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65233. }
  65234. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65240. import { Effect } from "babylonjs/Materials/effect";
  65241. import { Mesh } from "babylonjs/Meshes/mesh";
  65242. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65243. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65244. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65245. /**
  65246. * Block used to add image processing support to fragment shader
  65247. */
  65248. export class ImageProcessingBlock extends NodeMaterialBlock {
  65249. /**
  65250. * Create a new ImageProcessingBlock
  65251. * @param name defines the block name
  65252. */
  65253. constructor(name: string);
  65254. /**
  65255. * Gets the current class name
  65256. * @returns the class name
  65257. */
  65258. getClassName(): string;
  65259. /**
  65260. * Gets the color input component
  65261. */
  65262. get color(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the output component
  65265. */
  65266. get output(): NodeMaterialConnectionPoint;
  65267. /**
  65268. * Initialize the block and prepare the context for build
  65269. * @param state defines the state that will be used for the build
  65270. */
  65271. initialize(state: NodeMaterialBuildState): void;
  65272. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65275. protected _buildBlock(state: NodeMaterialBuildState): this;
  65276. }
  65277. }
  65278. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65282. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65284. import { Effect } from "babylonjs/Materials/effect";
  65285. import { Mesh } from "babylonjs/Meshes/mesh";
  65286. import { Scene } from "babylonjs/scene";
  65287. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65288. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65289. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65290. /**
  65291. * Block used to pertub normals based on a normal map
  65292. */
  65293. export class PerturbNormalBlock extends NodeMaterialBlock {
  65294. private _tangentSpaceParameterName;
  65295. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65296. invertX: boolean;
  65297. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65298. invertY: boolean;
  65299. /**
  65300. * Create a new PerturbNormalBlock
  65301. * @param name defines the block name
  65302. */
  65303. constructor(name: string);
  65304. /**
  65305. * Gets the current class name
  65306. * @returns the class name
  65307. */
  65308. getClassName(): string;
  65309. /**
  65310. * Gets the world position input component
  65311. */
  65312. get worldPosition(): NodeMaterialConnectionPoint;
  65313. /**
  65314. * Gets the world normal input component
  65315. */
  65316. get worldNormal(): NodeMaterialConnectionPoint;
  65317. /**
  65318. * Gets the world tangent input component
  65319. */
  65320. get worldTangent(): NodeMaterialConnectionPoint;
  65321. /**
  65322. * Gets the uv input component
  65323. */
  65324. get uv(): NodeMaterialConnectionPoint;
  65325. /**
  65326. * Gets the normal map color input component
  65327. */
  65328. get normalMapColor(): NodeMaterialConnectionPoint;
  65329. /**
  65330. * Gets the strength input component
  65331. */
  65332. get strength(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the output component
  65335. */
  65336. get output(): NodeMaterialConnectionPoint;
  65337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65339. autoConfigure(material: NodeMaterial): void;
  65340. protected _buildBlock(state: NodeMaterialBuildState): this;
  65341. protected _dumpPropertiesCode(): string;
  65342. serialize(): any;
  65343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65344. }
  65345. }
  65346. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65350. /**
  65351. * Block used to discard a pixel if a value is smaller than a cutoff
  65352. */
  65353. export class DiscardBlock extends NodeMaterialBlock {
  65354. /**
  65355. * Create a new DiscardBlock
  65356. * @param name defines the block name
  65357. */
  65358. constructor(name: string);
  65359. /**
  65360. * Gets the current class name
  65361. * @returns the class name
  65362. */
  65363. getClassName(): string;
  65364. /**
  65365. * Gets the color input component
  65366. */
  65367. get value(): NodeMaterialConnectionPoint;
  65368. /**
  65369. * Gets the cutoff input component
  65370. */
  65371. get cutoff(): NodeMaterialConnectionPoint;
  65372. protected _buildBlock(state: NodeMaterialBuildState): this;
  65373. }
  65374. }
  65375. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65379. /**
  65380. * Block used to test if the fragment shader is front facing
  65381. */
  65382. export class FrontFacingBlock extends NodeMaterialBlock {
  65383. /**
  65384. * Creates a new FrontFacingBlock
  65385. * @param name defines the block name
  65386. */
  65387. constructor(name: string);
  65388. /**
  65389. * Gets the current class name
  65390. * @returns the class name
  65391. */
  65392. getClassName(): string;
  65393. /**
  65394. * Gets the output component
  65395. */
  65396. get output(): NodeMaterialConnectionPoint;
  65397. protected _buildBlock(state: NodeMaterialBuildState): this;
  65398. }
  65399. }
  65400. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65404. /**
  65405. * Block used to get the derivative value on x and y of a given input
  65406. */
  65407. export class DerivativeBlock extends NodeMaterialBlock {
  65408. /**
  65409. * Create a new DerivativeBlock
  65410. * @param name defines the block name
  65411. */
  65412. constructor(name: string);
  65413. /**
  65414. * Gets the current class name
  65415. * @returns the class name
  65416. */
  65417. getClassName(): string;
  65418. /**
  65419. * Gets the input component
  65420. */
  65421. get input(): NodeMaterialConnectionPoint;
  65422. /**
  65423. * Gets the derivative output on x
  65424. */
  65425. get dx(): NodeMaterialConnectionPoint;
  65426. /**
  65427. * Gets the derivative output on y
  65428. */
  65429. get dy(): NodeMaterialConnectionPoint;
  65430. protected _buildBlock(state: NodeMaterialBuildState): this;
  65431. }
  65432. }
  65433. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65437. /**
  65438. * Block used to make gl_FragCoord available
  65439. */
  65440. export class FragCoordBlock extends NodeMaterialBlock {
  65441. /**
  65442. * Creates a new FragCoordBlock
  65443. * @param name defines the block name
  65444. */
  65445. constructor(name: string);
  65446. /**
  65447. * Gets the current class name
  65448. * @returns the class name
  65449. */
  65450. getClassName(): string;
  65451. /**
  65452. * Gets the xy component
  65453. */
  65454. get xy(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the xyz component
  65457. */
  65458. get xyz(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the xyzw component
  65461. */
  65462. get xyzw(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the x component
  65465. */
  65466. get x(): NodeMaterialConnectionPoint;
  65467. /**
  65468. * Gets the y component
  65469. */
  65470. get y(): NodeMaterialConnectionPoint;
  65471. /**
  65472. * Gets the z component
  65473. */
  65474. get z(): NodeMaterialConnectionPoint;
  65475. /**
  65476. * Gets the w component
  65477. */
  65478. get output(): NodeMaterialConnectionPoint;
  65479. protected writeOutputs(state: NodeMaterialBuildState): string;
  65480. protected _buildBlock(state: NodeMaterialBuildState): this;
  65481. }
  65482. }
  65483. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65487. import { Effect } from "babylonjs/Materials/effect";
  65488. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65489. import { Mesh } from "babylonjs/Meshes/mesh";
  65490. /**
  65491. * Block used to get the screen sizes
  65492. */
  65493. export class ScreenSizeBlock extends NodeMaterialBlock {
  65494. private _varName;
  65495. private _scene;
  65496. /**
  65497. * Creates a new ScreenSizeBlock
  65498. * @param name defines the block name
  65499. */
  65500. constructor(name: string);
  65501. /**
  65502. * Gets the current class name
  65503. * @returns the class name
  65504. */
  65505. getClassName(): string;
  65506. /**
  65507. * Gets the xy component
  65508. */
  65509. get xy(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the x component
  65512. */
  65513. get x(): NodeMaterialConnectionPoint;
  65514. /**
  65515. * Gets the y component
  65516. */
  65517. get y(): NodeMaterialConnectionPoint;
  65518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65519. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65520. protected _buildBlock(state: NodeMaterialBuildState): this;
  65521. }
  65522. }
  65523. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65524. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65525. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65526. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65527. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65528. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65529. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65530. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65531. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65532. }
  65533. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65536. import { Mesh } from "babylonjs/Meshes/mesh";
  65537. import { Effect } from "babylonjs/Materials/effect";
  65538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65540. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65541. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65542. /**
  65543. * Block used to add support for scene fog
  65544. */
  65545. export class FogBlock extends NodeMaterialBlock {
  65546. private _fogDistanceName;
  65547. private _fogParameters;
  65548. /**
  65549. * Create a new FogBlock
  65550. * @param name defines the block name
  65551. */
  65552. constructor(name: string);
  65553. /**
  65554. * Gets the current class name
  65555. * @returns the class name
  65556. */
  65557. getClassName(): string;
  65558. /**
  65559. * Gets the world position input component
  65560. */
  65561. get worldPosition(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the view input component
  65564. */
  65565. get view(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the color input component
  65568. */
  65569. get input(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the fog color input component
  65572. */
  65573. get fogColor(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the output component
  65576. */
  65577. get output(): NodeMaterialConnectionPoint;
  65578. autoConfigure(material: NodeMaterial): void;
  65579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65581. protected _buildBlock(state: NodeMaterialBuildState): this;
  65582. }
  65583. }
  65584. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  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. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65590. import { Effect } from "babylonjs/Materials/effect";
  65591. import { Mesh } from "babylonjs/Meshes/mesh";
  65592. import { Light } from "babylonjs/Lights/light";
  65593. import { Nullable } from "babylonjs/types";
  65594. import { Scene } from "babylonjs/scene";
  65595. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65596. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65597. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65598. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65599. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65600. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65601. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65602. /**
  65603. * Block used to add light in the fragment shader
  65604. */
  65605. export class LightBlock extends NodeMaterialBlock {
  65606. private _lightId;
  65607. /**
  65608. * Gets or sets the light associated with this block
  65609. */
  65610. light: Nullable<Light>;
  65611. /**
  65612. * Create a new LightBlock
  65613. * @param name defines the block name
  65614. */
  65615. constructor(name: string);
  65616. /**
  65617. * Gets the current class name
  65618. * @returns the class name
  65619. */
  65620. getClassName(): string;
  65621. /**
  65622. * Gets the world position input component
  65623. */
  65624. get worldPosition(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the world normal input component
  65627. */
  65628. get worldNormal(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the camera (or eye) position component
  65631. */
  65632. get cameraPosition(): NodeMaterialConnectionPoint;
  65633. /**
  65634. * Gets the glossiness component
  65635. */
  65636. get glossiness(): NodeMaterialConnectionPoint;
  65637. /**
  65638. * Gets the glossinness power component
  65639. */
  65640. get glossPower(): NodeMaterialConnectionPoint;
  65641. /**
  65642. * Gets the diffuse color component
  65643. */
  65644. get diffuseColor(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the specular color component
  65647. */
  65648. get specularColor(): NodeMaterialConnectionPoint;
  65649. /**
  65650. * Gets the diffuse output component
  65651. */
  65652. get diffuseOutput(): NodeMaterialConnectionPoint;
  65653. /**
  65654. * Gets the specular output component
  65655. */
  65656. get specularOutput(): NodeMaterialConnectionPoint;
  65657. /**
  65658. * Gets the shadow output component
  65659. */
  65660. get shadow(): NodeMaterialConnectionPoint;
  65661. autoConfigure(material: NodeMaterial): void;
  65662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65663. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65665. private _injectVertexCode;
  65666. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65667. serialize(): any;
  65668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65669. }
  65670. }
  65671. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65672. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65673. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65674. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65675. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65676. /**
  65677. * Block used to read a reflection texture from a sampler
  65678. */
  65679. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65680. /**
  65681. * Create a new ReflectionTextureBlock
  65682. * @param name defines the block name
  65683. */
  65684. constructor(name: string);
  65685. /**
  65686. * Gets the current class name
  65687. * @returns the class name
  65688. */
  65689. getClassName(): string;
  65690. /**
  65691. * Gets the world position input component
  65692. */
  65693. get position(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the world position input component
  65696. */
  65697. get worldPosition(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the world normal input component
  65700. */
  65701. get worldNormal(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the world input component
  65704. */
  65705. get world(): NodeMaterialConnectionPoint;
  65706. /**
  65707. * Gets the camera (or eye) position component
  65708. */
  65709. get cameraPosition(): NodeMaterialConnectionPoint;
  65710. /**
  65711. * Gets the view input component
  65712. */
  65713. get view(): NodeMaterialConnectionPoint;
  65714. /**
  65715. * Gets the rgb output component
  65716. */
  65717. get rgb(): NodeMaterialConnectionPoint;
  65718. /**
  65719. * Gets the rgba output component
  65720. */
  65721. get rgba(): NodeMaterialConnectionPoint;
  65722. /**
  65723. * Gets the r output component
  65724. */
  65725. get r(): NodeMaterialConnectionPoint;
  65726. /**
  65727. * Gets the g output component
  65728. */
  65729. get g(): NodeMaterialConnectionPoint;
  65730. /**
  65731. * Gets the b output component
  65732. */
  65733. get b(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the a output component
  65736. */
  65737. get a(): NodeMaterialConnectionPoint;
  65738. autoConfigure(material: NodeMaterial): void;
  65739. protected _buildBlock(state: NodeMaterialBuildState): this;
  65740. }
  65741. }
  65742. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65743. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65744. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65745. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65746. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65747. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65748. }
  65749. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65750. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65751. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65752. }
  65753. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65757. /**
  65758. * Block used to add 2 vectors
  65759. */
  65760. export class AddBlock extends NodeMaterialBlock {
  65761. /**
  65762. * Creates a new AddBlock
  65763. * @param name defines the block name
  65764. */
  65765. constructor(name: string);
  65766. /**
  65767. * Gets the current class name
  65768. * @returns the class name
  65769. */
  65770. getClassName(): string;
  65771. /**
  65772. * Gets the left operand input component
  65773. */
  65774. get left(): NodeMaterialConnectionPoint;
  65775. /**
  65776. * Gets the right operand input component
  65777. */
  65778. get right(): NodeMaterialConnectionPoint;
  65779. /**
  65780. * Gets the output component
  65781. */
  65782. get output(): NodeMaterialConnectionPoint;
  65783. protected _buildBlock(state: NodeMaterialBuildState): this;
  65784. }
  65785. }
  65786. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65790. /**
  65791. * Block used to scale a vector by a float
  65792. */
  65793. export class ScaleBlock extends NodeMaterialBlock {
  65794. /**
  65795. * Creates a new ScaleBlock
  65796. * @param name defines the block name
  65797. */
  65798. constructor(name: string);
  65799. /**
  65800. * Gets the current class name
  65801. * @returns the class name
  65802. */
  65803. getClassName(): string;
  65804. /**
  65805. * Gets the input component
  65806. */
  65807. get input(): NodeMaterialConnectionPoint;
  65808. /**
  65809. * Gets the factor input component
  65810. */
  65811. get factor(): NodeMaterialConnectionPoint;
  65812. /**
  65813. * Gets the output component
  65814. */
  65815. get output(): NodeMaterialConnectionPoint;
  65816. protected _buildBlock(state: NodeMaterialBuildState): this;
  65817. }
  65818. }
  65819. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65823. import { Scene } from "babylonjs/scene";
  65824. /**
  65825. * Block used to clamp a float
  65826. */
  65827. export class ClampBlock extends NodeMaterialBlock {
  65828. /** Gets or sets the minimum range */
  65829. minimum: number;
  65830. /** Gets or sets the maximum range */
  65831. maximum: number;
  65832. /**
  65833. * Creates a new ClampBlock
  65834. * @param name defines the block name
  65835. */
  65836. constructor(name: string);
  65837. /**
  65838. * Gets the current class name
  65839. * @returns the class name
  65840. */
  65841. getClassName(): string;
  65842. /**
  65843. * Gets the value input component
  65844. */
  65845. get value(): NodeMaterialConnectionPoint;
  65846. /**
  65847. * Gets the output component
  65848. */
  65849. get output(): NodeMaterialConnectionPoint;
  65850. protected _buildBlock(state: NodeMaterialBuildState): this;
  65851. protected _dumpPropertiesCode(): string;
  65852. serialize(): any;
  65853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65854. }
  65855. }
  65856. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65860. /**
  65861. * Block used to apply a cross product between 2 vectors
  65862. */
  65863. export class CrossBlock extends NodeMaterialBlock {
  65864. /**
  65865. * Creates a new CrossBlock
  65866. * @param name defines the block name
  65867. */
  65868. constructor(name: string);
  65869. /**
  65870. * Gets the current class name
  65871. * @returns the class name
  65872. */
  65873. getClassName(): string;
  65874. /**
  65875. * Gets the left operand input component
  65876. */
  65877. get left(): NodeMaterialConnectionPoint;
  65878. /**
  65879. * Gets the right operand input component
  65880. */
  65881. get right(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the output component
  65884. */
  65885. get output(): NodeMaterialConnectionPoint;
  65886. protected _buildBlock(state: NodeMaterialBuildState): this;
  65887. }
  65888. }
  65889. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65893. /**
  65894. * Block used to apply a dot product between 2 vectors
  65895. */
  65896. export class DotBlock extends NodeMaterialBlock {
  65897. /**
  65898. * Creates a new DotBlock
  65899. * @param name defines the block name
  65900. */
  65901. constructor(name: string);
  65902. /**
  65903. * Gets the current class name
  65904. * @returns the class name
  65905. */
  65906. getClassName(): string;
  65907. /**
  65908. * Gets the left operand input component
  65909. */
  65910. get left(): NodeMaterialConnectionPoint;
  65911. /**
  65912. * Gets the right operand input component
  65913. */
  65914. get right(): NodeMaterialConnectionPoint;
  65915. /**
  65916. * Gets the output component
  65917. */
  65918. get output(): NodeMaterialConnectionPoint;
  65919. protected _buildBlock(state: NodeMaterialBuildState): this;
  65920. }
  65921. }
  65922. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65926. /**
  65927. * Block used to normalize a vector
  65928. */
  65929. export class NormalizeBlock extends NodeMaterialBlock {
  65930. /**
  65931. * Creates a new NormalizeBlock
  65932. * @param name defines the block name
  65933. */
  65934. constructor(name: string);
  65935. /**
  65936. * Gets the current class name
  65937. * @returns the class name
  65938. */
  65939. getClassName(): string;
  65940. /**
  65941. * Gets the input component
  65942. */
  65943. get input(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the output component
  65946. */
  65947. get output(): NodeMaterialConnectionPoint;
  65948. protected _buildBlock(state: NodeMaterialBuildState): this;
  65949. }
  65950. }
  65951. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65955. import { Scene } from "babylonjs/scene";
  65956. /**
  65957. * Operations supported by the Trigonometry block
  65958. */
  65959. export enum TrigonometryBlockOperations {
  65960. /** Cos */
  65961. Cos = 0,
  65962. /** Sin */
  65963. Sin = 1,
  65964. /** Abs */
  65965. Abs = 2,
  65966. /** Exp */
  65967. Exp = 3,
  65968. /** Exp2 */
  65969. Exp2 = 4,
  65970. /** Round */
  65971. Round = 5,
  65972. /** Floor */
  65973. Floor = 6,
  65974. /** Ceiling */
  65975. Ceiling = 7,
  65976. /** Square root */
  65977. Sqrt = 8,
  65978. /** Log */
  65979. Log = 9,
  65980. /** Tangent */
  65981. Tan = 10,
  65982. /** Arc tangent */
  65983. ArcTan = 11,
  65984. /** Arc cosinus */
  65985. ArcCos = 12,
  65986. /** Arc sinus */
  65987. ArcSin = 13,
  65988. /** Fraction */
  65989. Fract = 14,
  65990. /** Sign */
  65991. Sign = 15,
  65992. /** To radians (from degrees) */
  65993. Radians = 16,
  65994. /** To degrees (from radians) */
  65995. Degrees = 17
  65996. }
  65997. /**
  65998. * Block used to apply trigonometry operation to floats
  65999. */
  66000. export class TrigonometryBlock extends NodeMaterialBlock {
  66001. /**
  66002. * Gets or sets the operation applied by the block
  66003. */
  66004. operation: TrigonometryBlockOperations;
  66005. /**
  66006. * Creates a new TrigonometryBlock
  66007. * @param name defines the block name
  66008. */
  66009. constructor(name: string);
  66010. /**
  66011. * Gets the current class name
  66012. * @returns the class name
  66013. */
  66014. getClassName(): string;
  66015. /**
  66016. * Gets the input component
  66017. */
  66018. get input(): NodeMaterialConnectionPoint;
  66019. /**
  66020. * Gets the output component
  66021. */
  66022. get output(): NodeMaterialConnectionPoint;
  66023. protected _buildBlock(state: NodeMaterialBuildState): this;
  66024. serialize(): any;
  66025. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66026. protected _dumpPropertiesCode(): string;
  66027. }
  66028. }
  66029. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66033. /**
  66034. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66035. */
  66036. export class ColorMergerBlock extends NodeMaterialBlock {
  66037. /**
  66038. * Create a new ColorMergerBlock
  66039. * @param name defines the block name
  66040. */
  66041. constructor(name: string);
  66042. /**
  66043. * Gets the current class name
  66044. * @returns the class name
  66045. */
  66046. getClassName(): string;
  66047. /**
  66048. * Gets the rgb component (input)
  66049. */
  66050. get rgbIn(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the r component (input)
  66053. */
  66054. get r(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the g component (input)
  66057. */
  66058. get g(): NodeMaterialConnectionPoint;
  66059. /**
  66060. * Gets the b component (input)
  66061. */
  66062. get b(): NodeMaterialConnectionPoint;
  66063. /**
  66064. * Gets the a component (input)
  66065. */
  66066. get a(): NodeMaterialConnectionPoint;
  66067. /**
  66068. * Gets the rgba component (output)
  66069. */
  66070. get rgba(): NodeMaterialConnectionPoint;
  66071. /**
  66072. * Gets the rgb component (output)
  66073. */
  66074. get rgbOut(): NodeMaterialConnectionPoint;
  66075. /**
  66076. * Gets the rgb component (output)
  66077. * @deprecated Please use rgbOut instead.
  66078. */
  66079. get rgb(): NodeMaterialConnectionPoint;
  66080. protected _buildBlock(state: NodeMaterialBuildState): this;
  66081. }
  66082. }
  66083. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66087. /**
  66088. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66089. */
  66090. export class VectorSplitterBlock extends NodeMaterialBlock {
  66091. /**
  66092. * Create a new VectorSplitterBlock
  66093. * @param name defines the block name
  66094. */
  66095. constructor(name: string);
  66096. /**
  66097. * Gets the current class name
  66098. * @returns the class name
  66099. */
  66100. getClassName(): string;
  66101. /**
  66102. * Gets the xyzw component (input)
  66103. */
  66104. get xyzw(): NodeMaterialConnectionPoint;
  66105. /**
  66106. * Gets the xyz component (input)
  66107. */
  66108. get xyzIn(): NodeMaterialConnectionPoint;
  66109. /**
  66110. * Gets the xy component (input)
  66111. */
  66112. get xyIn(): NodeMaterialConnectionPoint;
  66113. /**
  66114. * Gets the xyz component (output)
  66115. */
  66116. get xyzOut(): NodeMaterialConnectionPoint;
  66117. /**
  66118. * Gets the xy component (output)
  66119. */
  66120. get xyOut(): NodeMaterialConnectionPoint;
  66121. /**
  66122. * Gets the x component (output)
  66123. */
  66124. get x(): NodeMaterialConnectionPoint;
  66125. /**
  66126. * Gets the y component (output)
  66127. */
  66128. get y(): NodeMaterialConnectionPoint;
  66129. /**
  66130. * Gets the z component (output)
  66131. */
  66132. get z(): NodeMaterialConnectionPoint;
  66133. /**
  66134. * Gets the w component (output)
  66135. */
  66136. get w(): NodeMaterialConnectionPoint;
  66137. protected _inputRename(name: string): string;
  66138. protected _outputRename(name: string): string;
  66139. protected _buildBlock(state: NodeMaterialBuildState): this;
  66140. }
  66141. }
  66142. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66146. /**
  66147. * Block used to lerp between 2 values
  66148. */
  66149. export class LerpBlock extends NodeMaterialBlock {
  66150. /**
  66151. * Creates a new LerpBlock
  66152. * @param name defines the block name
  66153. */
  66154. constructor(name: string);
  66155. /**
  66156. * Gets the current class name
  66157. * @returns the class name
  66158. */
  66159. getClassName(): string;
  66160. /**
  66161. * Gets the left operand input component
  66162. */
  66163. get left(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the right operand input component
  66166. */
  66167. get right(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the gradient operand input component
  66170. */
  66171. get gradient(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the output component
  66174. */
  66175. get output(): NodeMaterialConnectionPoint;
  66176. protected _buildBlock(state: NodeMaterialBuildState): this;
  66177. }
  66178. }
  66179. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66183. /**
  66184. * Block used to divide 2 vectors
  66185. */
  66186. export class DivideBlock extends NodeMaterialBlock {
  66187. /**
  66188. * Creates a new DivideBlock
  66189. * @param name defines the block name
  66190. */
  66191. constructor(name: string);
  66192. /**
  66193. * Gets the current class name
  66194. * @returns the class name
  66195. */
  66196. getClassName(): string;
  66197. /**
  66198. * Gets the left operand input component
  66199. */
  66200. get left(): NodeMaterialConnectionPoint;
  66201. /**
  66202. * Gets the right operand input component
  66203. */
  66204. get right(): NodeMaterialConnectionPoint;
  66205. /**
  66206. * Gets the output component
  66207. */
  66208. get output(): NodeMaterialConnectionPoint;
  66209. protected _buildBlock(state: NodeMaterialBuildState): this;
  66210. }
  66211. }
  66212. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66216. /**
  66217. * Block used to subtract 2 vectors
  66218. */
  66219. export class SubtractBlock extends NodeMaterialBlock {
  66220. /**
  66221. * Creates a new SubtractBlock
  66222. * @param name defines the block name
  66223. */
  66224. constructor(name: string);
  66225. /**
  66226. * Gets the current class name
  66227. * @returns the class name
  66228. */
  66229. getClassName(): string;
  66230. /**
  66231. * Gets the left operand input component
  66232. */
  66233. get left(): NodeMaterialConnectionPoint;
  66234. /**
  66235. * Gets the right operand input component
  66236. */
  66237. get right(): NodeMaterialConnectionPoint;
  66238. /**
  66239. * Gets the output component
  66240. */
  66241. get output(): NodeMaterialConnectionPoint;
  66242. protected _buildBlock(state: NodeMaterialBuildState): this;
  66243. }
  66244. }
  66245. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66249. /**
  66250. * Block used to step a value
  66251. */
  66252. export class StepBlock extends NodeMaterialBlock {
  66253. /**
  66254. * Creates a new StepBlock
  66255. * @param name defines the block name
  66256. */
  66257. constructor(name: string);
  66258. /**
  66259. * Gets the current class name
  66260. * @returns the class name
  66261. */
  66262. getClassName(): string;
  66263. /**
  66264. * Gets the value operand input component
  66265. */
  66266. get value(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the edge operand input component
  66269. */
  66270. get edge(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the output component
  66273. */
  66274. get output(): NodeMaterialConnectionPoint;
  66275. protected _buildBlock(state: NodeMaterialBuildState): this;
  66276. }
  66277. }
  66278. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66282. /**
  66283. * Block used to get the opposite (1 - x) of a value
  66284. */
  66285. export class OneMinusBlock extends NodeMaterialBlock {
  66286. /**
  66287. * Creates a new OneMinusBlock
  66288. * @param name defines the block name
  66289. */
  66290. constructor(name: string);
  66291. /**
  66292. * Gets the current class name
  66293. * @returns the class name
  66294. */
  66295. getClassName(): string;
  66296. /**
  66297. * Gets the input component
  66298. */
  66299. get input(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the output component
  66302. */
  66303. get output(): NodeMaterialConnectionPoint;
  66304. protected _buildBlock(state: NodeMaterialBuildState): this;
  66305. }
  66306. }
  66307. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66311. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66312. /**
  66313. * Block used to get the view direction
  66314. */
  66315. export class ViewDirectionBlock extends NodeMaterialBlock {
  66316. /**
  66317. * Creates a new ViewDirectionBlock
  66318. * @param name defines the block name
  66319. */
  66320. constructor(name: string);
  66321. /**
  66322. * Gets the current class name
  66323. * @returns the class name
  66324. */
  66325. getClassName(): string;
  66326. /**
  66327. * Gets the world position component
  66328. */
  66329. get worldPosition(): NodeMaterialConnectionPoint;
  66330. /**
  66331. * Gets the camera position component
  66332. */
  66333. get cameraPosition(): NodeMaterialConnectionPoint;
  66334. /**
  66335. * Gets the output component
  66336. */
  66337. get output(): NodeMaterialConnectionPoint;
  66338. autoConfigure(material: NodeMaterial): void;
  66339. protected _buildBlock(state: NodeMaterialBuildState): this;
  66340. }
  66341. }
  66342. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66346. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66347. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66348. /**
  66349. * Block used to compute fresnel value
  66350. */
  66351. export class FresnelBlock extends NodeMaterialBlock {
  66352. /**
  66353. * Create a new FresnelBlock
  66354. * @param name defines the block name
  66355. */
  66356. constructor(name: string);
  66357. /**
  66358. * Gets the current class name
  66359. * @returns the class name
  66360. */
  66361. getClassName(): string;
  66362. /**
  66363. * Gets the world normal input component
  66364. */
  66365. get worldNormal(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the view direction input component
  66368. */
  66369. get viewDirection(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the bias input component
  66372. */
  66373. get bias(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the camera (or eye) position component
  66376. */
  66377. get power(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the fresnel output component
  66380. */
  66381. get fresnel(): NodeMaterialConnectionPoint;
  66382. autoConfigure(material: NodeMaterial): void;
  66383. protected _buildBlock(state: NodeMaterialBuildState): this;
  66384. }
  66385. }
  66386. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66390. /**
  66391. * Block used to get the max of 2 values
  66392. */
  66393. export class MaxBlock extends NodeMaterialBlock {
  66394. /**
  66395. * Creates a new MaxBlock
  66396. * @param name defines the block name
  66397. */
  66398. constructor(name: string);
  66399. /**
  66400. * Gets the current class name
  66401. * @returns the class name
  66402. */
  66403. getClassName(): string;
  66404. /**
  66405. * Gets the left operand input component
  66406. */
  66407. get left(): NodeMaterialConnectionPoint;
  66408. /**
  66409. * Gets the right operand input component
  66410. */
  66411. get right(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the output component
  66414. */
  66415. get output(): NodeMaterialConnectionPoint;
  66416. protected _buildBlock(state: NodeMaterialBuildState): this;
  66417. }
  66418. }
  66419. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66420. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66421. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66423. /**
  66424. * Block used to get the min of 2 values
  66425. */
  66426. export class MinBlock extends NodeMaterialBlock {
  66427. /**
  66428. * Creates a new MinBlock
  66429. * @param name defines the block name
  66430. */
  66431. constructor(name: string);
  66432. /**
  66433. * Gets the current class name
  66434. * @returns the class name
  66435. */
  66436. getClassName(): string;
  66437. /**
  66438. * Gets the left operand input component
  66439. */
  66440. get left(): NodeMaterialConnectionPoint;
  66441. /**
  66442. * Gets the right operand input component
  66443. */
  66444. get right(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the output component
  66447. */
  66448. get output(): NodeMaterialConnectionPoint;
  66449. protected _buildBlock(state: NodeMaterialBuildState): this;
  66450. }
  66451. }
  66452. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66456. /**
  66457. * Block used to get the distance between 2 values
  66458. */
  66459. export class DistanceBlock extends NodeMaterialBlock {
  66460. /**
  66461. * Creates a new DistanceBlock
  66462. * @param name defines the block name
  66463. */
  66464. constructor(name: string);
  66465. /**
  66466. * Gets the current class name
  66467. * @returns the class name
  66468. */
  66469. getClassName(): string;
  66470. /**
  66471. * Gets the left operand input component
  66472. */
  66473. get left(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the right operand input component
  66476. */
  66477. get right(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the output component
  66480. */
  66481. get output(): NodeMaterialConnectionPoint;
  66482. protected _buildBlock(state: NodeMaterialBuildState): this;
  66483. }
  66484. }
  66485. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66489. /**
  66490. * Block used to get the length of a vector
  66491. */
  66492. export class LengthBlock extends NodeMaterialBlock {
  66493. /**
  66494. * Creates a new LengthBlock
  66495. * @param name defines the block name
  66496. */
  66497. constructor(name: string);
  66498. /**
  66499. * Gets the current class name
  66500. * @returns the class name
  66501. */
  66502. getClassName(): string;
  66503. /**
  66504. * Gets the value input component
  66505. */
  66506. get value(): NodeMaterialConnectionPoint;
  66507. /**
  66508. * Gets the output component
  66509. */
  66510. get output(): NodeMaterialConnectionPoint;
  66511. protected _buildBlock(state: NodeMaterialBuildState): this;
  66512. }
  66513. }
  66514. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66518. /**
  66519. * Block used to get negative version of a value (i.e. x * -1)
  66520. */
  66521. export class NegateBlock extends NodeMaterialBlock {
  66522. /**
  66523. * Creates a new NegateBlock
  66524. * @param name defines the block name
  66525. */
  66526. constructor(name: string);
  66527. /**
  66528. * Gets the current class name
  66529. * @returns the class name
  66530. */
  66531. getClassName(): string;
  66532. /**
  66533. * Gets the value input component
  66534. */
  66535. get value(): NodeMaterialConnectionPoint;
  66536. /**
  66537. * Gets the output component
  66538. */
  66539. get output(): NodeMaterialConnectionPoint;
  66540. protected _buildBlock(state: NodeMaterialBuildState): this;
  66541. }
  66542. }
  66543. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66544. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66545. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66547. /**
  66548. * Block used to get the value of the first parameter raised to the power of the second
  66549. */
  66550. export class PowBlock extends NodeMaterialBlock {
  66551. /**
  66552. * Creates a new PowBlock
  66553. * @param name defines the block name
  66554. */
  66555. constructor(name: string);
  66556. /**
  66557. * Gets the current class name
  66558. * @returns the class name
  66559. */
  66560. getClassName(): string;
  66561. /**
  66562. * Gets the value operand input component
  66563. */
  66564. get value(): NodeMaterialConnectionPoint;
  66565. /**
  66566. * Gets the power operand input component
  66567. */
  66568. get power(): NodeMaterialConnectionPoint;
  66569. /**
  66570. * Gets the output component
  66571. */
  66572. get output(): NodeMaterialConnectionPoint;
  66573. protected _buildBlock(state: NodeMaterialBuildState): this;
  66574. }
  66575. }
  66576. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66580. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66581. /**
  66582. * Block used to get a random number
  66583. */
  66584. export class RandomNumberBlock extends NodeMaterialBlock {
  66585. /**
  66586. * Creates a new RandomNumberBlock
  66587. * @param name defines the block name
  66588. */
  66589. constructor(name: string);
  66590. /**
  66591. * Gets the current class name
  66592. * @returns the class name
  66593. */
  66594. getClassName(): string;
  66595. /**
  66596. * Gets the seed input component
  66597. */
  66598. get seed(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the output component
  66601. */
  66602. get output(): NodeMaterialConnectionPoint;
  66603. protected _buildBlock(state: NodeMaterialBuildState): this;
  66604. }
  66605. }
  66606. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66610. /**
  66611. * Block used to compute arc tangent of 2 values
  66612. */
  66613. export class ArcTan2Block extends NodeMaterialBlock {
  66614. /**
  66615. * Creates a new ArcTan2Block
  66616. * @param name defines the block name
  66617. */
  66618. constructor(name: string);
  66619. /**
  66620. * Gets the current class name
  66621. * @returns the class name
  66622. */
  66623. getClassName(): string;
  66624. /**
  66625. * Gets the x operand input component
  66626. */
  66627. get x(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the y operand input component
  66630. */
  66631. get y(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the output component
  66634. */
  66635. get output(): NodeMaterialConnectionPoint;
  66636. protected _buildBlock(state: NodeMaterialBuildState): this;
  66637. }
  66638. }
  66639. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66643. /**
  66644. * Block used to smooth step a value
  66645. */
  66646. export class SmoothStepBlock extends NodeMaterialBlock {
  66647. /**
  66648. * Creates a new SmoothStepBlock
  66649. * @param name defines the block name
  66650. */
  66651. constructor(name: string);
  66652. /**
  66653. * Gets the current class name
  66654. * @returns the class name
  66655. */
  66656. getClassName(): string;
  66657. /**
  66658. * Gets the value operand input component
  66659. */
  66660. get value(): NodeMaterialConnectionPoint;
  66661. /**
  66662. * Gets the first edge operand input component
  66663. */
  66664. get edge0(): NodeMaterialConnectionPoint;
  66665. /**
  66666. * Gets the second edge operand input component
  66667. */
  66668. get edge1(): NodeMaterialConnectionPoint;
  66669. /**
  66670. * Gets the output component
  66671. */
  66672. get output(): NodeMaterialConnectionPoint;
  66673. protected _buildBlock(state: NodeMaterialBuildState): this;
  66674. }
  66675. }
  66676. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66680. /**
  66681. * Block used to get the reciprocal (1 / x) of a value
  66682. */
  66683. export class ReciprocalBlock extends NodeMaterialBlock {
  66684. /**
  66685. * Creates a new ReciprocalBlock
  66686. * @param name defines the block name
  66687. */
  66688. constructor(name: string);
  66689. /**
  66690. * Gets the current class name
  66691. * @returns the class name
  66692. */
  66693. getClassName(): string;
  66694. /**
  66695. * Gets the input component
  66696. */
  66697. get input(): NodeMaterialConnectionPoint;
  66698. /**
  66699. * Gets the output component
  66700. */
  66701. get output(): NodeMaterialConnectionPoint;
  66702. protected _buildBlock(state: NodeMaterialBuildState): this;
  66703. }
  66704. }
  66705. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66709. /**
  66710. * Block used to replace a color by another one
  66711. */
  66712. export class ReplaceColorBlock extends NodeMaterialBlock {
  66713. /**
  66714. * Creates a new ReplaceColorBlock
  66715. * @param name defines the block name
  66716. */
  66717. constructor(name: string);
  66718. /**
  66719. * Gets the current class name
  66720. * @returns the class name
  66721. */
  66722. getClassName(): string;
  66723. /**
  66724. * Gets the value input component
  66725. */
  66726. get value(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the reference input component
  66729. */
  66730. get reference(): NodeMaterialConnectionPoint;
  66731. /**
  66732. * Gets the distance input component
  66733. */
  66734. get distance(): NodeMaterialConnectionPoint;
  66735. /**
  66736. * Gets the replacement input component
  66737. */
  66738. get replacement(): NodeMaterialConnectionPoint;
  66739. /**
  66740. * Gets the output component
  66741. */
  66742. get output(): NodeMaterialConnectionPoint;
  66743. protected _buildBlock(state: NodeMaterialBuildState): this;
  66744. }
  66745. }
  66746. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  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. /**
  66751. * Block used to posterize a value
  66752. * @see https://en.wikipedia.org/wiki/Posterization
  66753. */
  66754. export class PosterizeBlock extends NodeMaterialBlock {
  66755. /**
  66756. * Creates a new PosterizeBlock
  66757. * @param name defines the block name
  66758. */
  66759. constructor(name: string);
  66760. /**
  66761. * Gets the current class name
  66762. * @returns the class name
  66763. */
  66764. getClassName(): string;
  66765. /**
  66766. * Gets the value input component
  66767. */
  66768. get value(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the steps input component
  66771. */
  66772. get steps(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the output component
  66775. */
  66776. get output(): NodeMaterialConnectionPoint;
  66777. protected _buildBlock(state: NodeMaterialBuildState): this;
  66778. }
  66779. }
  66780. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66784. import { Scene } from "babylonjs/scene";
  66785. /**
  66786. * Operations supported by the Wave block
  66787. */
  66788. export enum WaveBlockKind {
  66789. /** SawTooth */
  66790. SawTooth = 0,
  66791. /** Square */
  66792. Square = 1,
  66793. /** Triangle */
  66794. Triangle = 2
  66795. }
  66796. /**
  66797. * Block used to apply wave operation to floats
  66798. */
  66799. export class WaveBlock extends NodeMaterialBlock {
  66800. /**
  66801. * Gets or sets the kibnd of wave to be applied by the block
  66802. */
  66803. kind: WaveBlockKind;
  66804. /**
  66805. * Creates a new WaveBlock
  66806. * @param name defines the block name
  66807. */
  66808. constructor(name: string);
  66809. /**
  66810. * Gets the current class name
  66811. * @returns the class name
  66812. */
  66813. getClassName(): string;
  66814. /**
  66815. * Gets the input component
  66816. */
  66817. get input(): NodeMaterialConnectionPoint;
  66818. /**
  66819. * Gets the output component
  66820. */
  66821. get output(): NodeMaterialConnectionPoint;
  66822. protected _buildBlock(state: NodeMaterialBuildState): this;
  66823. serialize(): any;
  66824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66825. }
  66826. }
  66827. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66831. import { Color3 } from "babylonjs/Maths/math.color";
  66832. import { Scene } from "babylonjs/scene";
  66833. /**
  66834. * Class used to store a color step for the GradientBlock
  66835. */
  66836. export class GradientBlockColorStep {
  66837. /**
  66838. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66839. */
  66840. step: number;
  66841. /**
  66842. * Gets or sets the color associated with this step
  66843. */
  66844. color: Color3;
  66845. /**
  66846. * Creates a new GradientBlockColorStep
  66847. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66848. * @param color defines the color associated with this step
  66849. */
  66850. constructor(
  66851. /**
  66852. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66853. */
  66854. step: number,
  66855. /**
  66856. * Gets or sets the color associated with this step
  66857. */
  66858. color: Color3);
  66859. }
  66860. /**
  66861. * Block used to return a color from a gradient based on an input value between 0 and 1
  66862. */
  66863. export class GradientBlock extends NodeMaterialBlock {
  66864. /**
  66865. * Gets or sets the list of color steps
  66866. */
  66867. colorSteps: GradientBlockColorStep[];
  66868. /**
  66869. * Creates a new GradientBlock
  66870. * @param name defines the block name
  66871. */
  66872. constructor(name: string);
  66873. /**
  66874. * Gets the current class name
  66875. * @returns the class name
  66876. */
  66877. getClassName(): string;
  66878. /**
  66879. * Gets the gradient input component
  66880. */
  66881. get gradient(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the output component
  66884. */
  66885. get output(): NodeMaterialConnectionPoint;
  66886. private _writeColorConstant;
  66887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66888. serialize(): any;
  66889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66890. protected _dumpPropertiesCode(): string;
  66891. }
  66892. }
  66893. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66897. /**
  66898. * Block used to normalize lerp between 2 values
  66899. */
  66900. export class NLerpBlock extends NodeMaterialBlock {
  66901. /**
  66902. * Creates a new NLerpBlock
  66903. * @param name defines the block name
  66904. */
  66905. constructor(name: string);
  66906. /**
  66907. * Gets the current class name
  66908. * @returns the class name
  66909. */
  66910. getClassName(): string;
  66911. /**
  66912. * Gets the left operand input component
  66913. */
  66914. get left(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the right operand input component
  66917. */
  66918. get right(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the gradient operand input component
  66921. */
  66922. get gradient(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the output component
  66925. */
  66926. get output(): NodeMaterialConnectionPoint;
  66927. protected _buildBlock(state: NodeMaterialBuildState): this;
  66928. }
  66929. }
  66930. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66934. import { Scene } from "babylonjs/scene";
  66935. /**
  66936. * block used to Generate a Worley Noise 3D Noise Pattern
  66937. */
  66938. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66939. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66940. manhattanDistance: boolean;
  66941. /**
  66942. * Creates a new WorleyNoise3DBlock
  66943. * @param name defines the block name
  66944. */
  66945. constructor(name: string);
  66946. /**
  66947. * Gets the current class name
  66948. * @returns the class name
  66949. */
  66950. getClassName(): string;
  66951. /**
  66952. * Gets the seed input component
  66953. */
  66954. get seed(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the jitter input component
  66957. */
  66958. get jitter(): NodeMaterialConnectionPoint;
  66959. /**
  66960. * Gets the output component
  66961. */
  66962. get output(): NodeMaterialConnectionPoint;
  66963. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66964. /**
  66965. * Exposes the properties to the UI?
  66966. */
  66967. protected _dumpPropertiesCode(): string;
  66968. /**
  66969. * Exposes the properties to the Seralize?
  66970. */
  66971. serialize(): any;
  66972. /**
  66973. * Exposes the properties to the deseralize?
  66974. */
  66975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66976. }
  66977. }
  66978. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66982. /**
  66983. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66984. */
  66985. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66986. /**
  66987. * Creates a new SimplexPerlin3DBlock
  66988. * @param name defines the block name
  66989. */
  66990. constructor(name: string);
  66991. /**
  66992. * Gets the current class name
  66993. * @returns the class name
  66994. */
  66995. getClassName(): string;
  66996. /**
  66997. * Gets the seed operand input component
  66998. */
  66999. get seed(): NodeMaterialConnectionPoint;
  67000. /**
  67001. * Gets the output component
  67002. */
  67003. get output(): NodeMaterialConnectionPoint;
  67004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67005. }
  67006. }
  67007. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67011. /**
  67012. * Block used to blend normals
  67013. */
  67014. export class NormalBlendBlock extends NodeMaterialBlock {
  67015. /**
  67016. * Creates a new NormalBlendBlock
  67017. * @param name defines the block name
  67018. */
  67019. constructor(name: string);
  67020. /**
  67021. * Gets the current class name
  67022. * @returns the class name
  67023. */
  67024. getClassName(): string;
  67025. /**
  67026. * Gets the first input component
  67027. */
  67028. get normalMap0(): NodeMaterialConnectionPoint;
  67029. /**
  67030. * Gets the second input component
  67031. */
  67032. get normalMap1(): NodeMaterialConnectionPoint;
  67033. /**
  67034. * Gets the output component
  67035. */
  67036. get output(): NodeMaterialConnectionPoint;
  67037. protected _buildBlock(state: NodeMaterialBuildState): this;
  67038. }
  67039. }
  67040. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67044. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67045. /**
  67046. * Block used to rotate a 2d vector by a given angle
  67047. */
  67048. export class Rotate2dBlock extends NodeMaterialBlock {
  67049. /**
  67050. * Creates a new Rotate2dBlock
  67051. * @param name defines the block name
  67052. */
  67053. constructor(name: string);
  67054. /**
  67055. * Gets the current class name
  67056. * @returns the class name
  67057. */
  67058. getClassName(): string;
  67059. /**
  67060. * Gets the input vector
  67061. */
  67062. get input(): NodeMaterialConnectionPoint;
  67063. /**
  67064. * Gets the input angle
  67065. */
  67066. get angle(): NodeMaterialConnectionPoint;
  67067. /**
  67068. * Gets the output component
  67069. */
  67070. get output(): NodeMaterialConnectionPoint;
  67071. autoConfigure(material: NodeMaterial): void;
  67072. protected _buildBlock(state: NodeMaterialBuildState): this;
  67073. }
  67074. }
  67075. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67079. /**
  67080. * Block used to get the reflected vector from a direction and a normal
  67081. */
  67082. export class ReflectBlock extends NodeMaterialBlock {
  67083. /**
  67084. * Creates a new ReflectBlock
  67085. * @param name defines the block name
  67086. */
  67087. constructor(name: string);
  67088. /**
  67089. * Gets the current class name
  67090. * @returns the class name
  67091. */
  67092. getClassName(): string;
  67093. /**
  67094. * Gets the incident component
  67095. */
  67096. get incident(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the normal component
  67099. */
  67100. get normal(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the output component
  67103. */
  67104. get output(): NodeMaterialConnectionPoint;
  67105. protected _buildBlock(state: NodeMaterialBuildState): this;
  67106. }
  67107. }
  67108. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67112. /**
  67113. * Block used to get the refracted vector from a direction and a normal
  67114. */
  67115. export class RefractBlock extends NodeMaterialBlock {
  67116. /**
  67117. * Creates a new RefractBlock
  67118. * @param name defines the block name
  67119. */
  67120. constructor(name: string);
  67121. /**
  67122. * Gets the current class name
  67123. * @returns the class name
  67124. */
  67125. getClassName(): string;
  67126. /**
  67127. * Gets the incident component
  67128. */
  67129. get incident(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the normal component
  67132. */
  67133. get normal(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the index of refraction component
  67136. */
  67137. get ior(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the output component
  67140. */
  67141. get output(): NodeMaterialConnectionPoint;
  67142. protected _buildBlock(state: NodeMaterialBuildState): this;
  67143. }
  67144. }
  67145. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67149. /**
  67150. * Block used to desaturate a color
  67151. */
  67152. export class DesaturateBlock extends NodeMaterialBlock {
  67153. /**
  67154. * Creates a new DesaturateBlock
  67155. * @param name defines the block name
  67156. */
  67157. constructor(name: string);
  67158. /**
  67159. * Gets the current class name
  67160. * @returns the class name
  67161. */
  67162. getClassName(): string;
  67163. /**
  67164. * Gets the color operand input component
  67165. */
  67166. get color(): NodeMaterialConnectionPoint;
  67167. /**
  67168. * Gets the level operand input component
  67169. */
  67170. get level(): NodeMaterialConnectionPoint;
  67171. /**
  67172. * Gets the output component
  67173. */
  67174. get output(): NodeMaterialConnectionPoint;
  67175. protected _buildBlock(state: NodeMaterialBuildState): this;
  67176. }
  67177. }
  67178. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67182. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67183. import { Nullable } from "babylonjs/types";
  67184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67185. import { Scene } from "babylonjs/scene";
  67186. /**
  67187. * Block used to implement the ambient occlusion module of the PBR material
  67188. */
  67189. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67190. /**
  67191. * Create a new AmbientOcclusionBlock
  67192. * @param name defines the block name
  67193. */
  67194. constructor(name: string);
  67195. /**
  67196. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67197. */
  67198. useAmbientInGrayScale: boolean;
  67199. /**
  67200. * Initialize the block and prepare the context for build
  67201. * @param state defines the state that will be used for the build
  67202. */
  67203. initialize(state: NodeMaterialBuildState): void;
  67204. /**
  67205. * Gets the current class name
  67206. * @returns the class name
  67207. */
  67208. getClassName(): string;
  67209. /**
  67210. * Gets the texture input component
  67211. */
  67212. get texture(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the texture intensity component
  67215. */
  67216. get intensity(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the direct light intensity input component
  67219. */
  67220. get directLightIntensity(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the ambient occlusion object output component
  67223. */
  67224. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the main code of the block (fragment side)
  67227. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67228. * @returns the shader code
  67229. */
  67230. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67232. protected _buildBlock(state: NodeMaterialBuildState): this;
  67233. protected _dumpPropertiesCode(): string;
  67234. serialize(): any;
  67235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67236. }
  67237. }
  67238. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67239. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67240. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67241. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67242. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67244. import { Nullable } from "babylonjs/types";
  67245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67246. import { Mesh } from "babylonjs/Meshes/mesh";
  67247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67248. import { Effect } from "babylonjs/Materials/effect";
  67249. import { Scene } from "babylonjs/scene";
  67250. /**
  67251. * Block used to implement the reflection module of the PBR material
  67252. */
  67253. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67254. /** @hidden */
  67255. _defineLODReflectionAlpha: string;
  67256. /** @hidden */
  67257. _defineLinearSpecularReflection: string;
  67258. private _vEnvironmentIrradianceName;
  67259. /** @hidden */
  67260. _vReflectionMicrosurfaceInfosName: string;
  67261. /** @hidden */
  67262. _vReflectionInfosName: string;
  67263. /** @hidden */
  67264. _vReflectionFilteringInfoName: string;
  67265. private _scene;
  67266. /**
  67267. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67268. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67269. * It's less burden on the user side in the editor part.
  67270. */
  67271. /** @hidden */
  67272. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67273. /** @hidden */
  67274. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67275. /** @hidden */
  67276. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67277. /**
  67278. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67279. * diffuse part of the IBL.
  67280. */
  67281. useSphericalHarmonics: boolean;
  67282. /**
  67283. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67284. */
  67285. forceIrradianceInFragment: boolean;
  67286. /**
  67287. * Create a new ReflectionBlock
  67288. * @param name defines the block name
  67289. */
  67290. constructor(name: string);
  67291. /**
  67292. * Gets the current class name
  67293. * @returns the class name
  67294. */
  67295. getClassName(): string;
  67296. /**
  67297. * Gets the position input component
  67298. */
  67299. get position(): NodeMaterialConnectionPoint;
  67300. /**
  67301. * Gets the world position input component
  67302. */
  67303. get worldPosition(): NodeMaterialConnectionPoint;
  67304. /**
  67305. * Gets the world normal input component
  67306. */
  67307. get worldNormal(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the world input component
  67310. */
  67311. get world(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the camera (or eye) position component
  67314. */
  67315. get cameraPosition(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the view input component
  67318. */
  67319. get view(): NodeMaterialConnectionPoint;
  67320. /**
  67321. * Gets the color input component
  67322. */
  67323. get color(): NodeMaterialConnectionPoint;
  67324. /**
  67325. * Gets the reflection object output component
  67326. */
  67327. get reflection(): NodeMaterialConnectionPoint;
  67328. /**
  67329. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67330. */
  67331. get hasTexture(): boolean;
  67332. /**
  67333. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67334. */
  67335. get reflectionColor(): string;
  67336. protected _getTexture(): Nullable<BaseTexture>;
  67337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67339. /**
  67340. * Gets the code to inject in the vertex shader
  67341. * @param state current state of the node material building
  67342. * @returns the shader code
  67343. */
  67344. handleVertexSide(state: NodeMaterialBuildState): string;
  67345. /**
  67346. * Gets the main code of the block (fragment side)
  67347. * @param state current state of the node material building
  67348. * @param normalVarName name of the existing variable corresponding to the normal
  67349. * @returns the shader code
  67350. */
  67351. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67352. protected _buildBlock(state: NodeMaterialBuildState): this;
  67353. protected _dumpPropertiesCode(): string;
  67354. serialize(): any;
  67355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67356. }
  67357. }
  67358. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67362. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67364. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67365. import { Scene } from "babylonjs/scene";
  67366. import { Nullable } from "babylonjs/types";
  67367. /**
  67368. * Block used to implement the sheen module of the PBR material
  67369. */
  67370. export class SheenBlock extends NodeMaterialBlock {
  67371. /**
  67372. * Create a new SheenBlock
  67373. * @param name defines the block name
  67374. */
  67375. constructor(name: string);
  67376. /**
  67377. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67378. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67379. * making it easier to setup and tweak the effect
  67380. */
  67381. albedoScaling: boolean;
  67382. /**
  67383. * Defines if the sheen is linked to the sheen color.
  67384. */
  67385. linkSheenWithAlbedo: boolean;
  67386. /**
  67387. * Initialize the block and prepare the context for build
  67388. * @param state defines the state that will be used for the build
  67389. */
  67390. initialize(state: NodeMaterialBuildState): void;
  67391. /**
  67392. * Gets the current class name
  67393. * @returns the class name
  67394. */
  67395. getClassName(): string;
  67396. /**
  67397. * Gets the intensity input component
  67398. */
  67399. get intensity(): NodeMaterialConnectionPoint;
  67400. /**
  67401. * Gets the color input component
  67402. */
  67403. get color(): NodeMaterialConnectionPoint;
  67404. /**
  67405. * Gets the roughness input component
  67406. */
  67407. get roughness(): NodeMaterialConnectionPoint;
  67408. /**
  67409. * Gets the sheen object output component
  67410. */
  67411. get sheen(): NodeMaterialConnectionPoint;
  67412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67413. /**
  67414. * Gets the main code of the block (fragment side)
  67415. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67416. * @returns the shader code
  67417. */
  67418. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67419. protected _buildBlock(state: NodeMaterialBuildState): this;
  67420. protected _dumpPropertiesCode(): string;
  67421. serialize(): any;
  67422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67423. }
  67424. }
  67425. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67431. import { Scene } from "babylonjs/scene";
  67432. import { Nullable } from "babylonjs/types";
  67433. import { Mesh } from "babylonjs/Meshes/mesh";
  67434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67435. import { Effect } from "babylonjs/Materials/effect";
  67436. /**
  67437. * Block used to implement the reflectivity module of the PBR material
  67438. */
  67439. export class ReflectivityBlock extends NodeMaterialBlock {
  67440. private _metallicReflectanceColor;
  67441. private _metallicF0Factor;
  67442. /** @hidden */
  67443. _vMetallicReflectanceFactorsName: string;
  67444. /**
  67445. * The property below is set by the main PBR block prior to calling methods of this class.
  67446. */
  67447. /** @hidden */
  67448. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67449. /**
  67450. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67451. */
  67452. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67453. /**
  67454. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67455. */
  67456. useMetallnessFromMetallicTextureBlue: boolean;
  67457. /**
  67458. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67459. */
  67460. useRoughnessFromMetallicTextureAlpha: boolean;
  67461. /**
  67462. * Specifies if the metallic texture contains the roughness information in its green channel.
  67463. */
  67464. useRoughnessFromMetallicTextureGreen: boolean;
  67465. /**
  67466. * Create a new ReflectivityBlock
  67467. * @param name defines the block name
  67468. */
  67469. constructor(name: string);
  67470. /**
  67471. * Initialize the block and prepare the context for build
  67472. * @param state defines the state that will be used for the build
  67473. */
  67474. initialize(state: NodeMaterialBuildState): void;
  67475. /**
  67476. * Gets the current class name
  67477. * @returns the class name
  67478. */
  67479. getClassName(): string;
  67480. /**
  67481. * Gets the metallic input component
  67482. */
  67483. get metallic(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the roughness input component
  67486. */
  67487. get roughness(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the texture input component
  67490. */
  67491. get texture(): NodeMaterialConnectionPoint;
  67492. /**
  67493. * Gets the reflectivity object output component
  67494. */
  67495. get reflectivity(): NodeMaterialConnectionPoint;
  67496. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67497. /**
  67498. * Gets the main code of the block (fragment side)
  67499. * @param state current state of the node material building
  67500. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67501. * @returns the shader code
  67502. */
  67503. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67505. protected _buildBlock(state: NodeMaterialBuildState): this;
  67506. protected _dumpPropertiesCode(): string;
  67507. serialize(): any;
  67508. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67509. }
  67510. }
  67511. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67512. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67517. /**
  67518. * Block used to implement the anisotropy module of the PBR material
  67519. */
  67520. export class AnisotropyBlock extends NodeMaterialBlock {
  67521. /**
  67522. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67523. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67524. * It's less burden on the user side in the editor part.
  67525. */
  67526. /** @hidden */
  67527. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67528. /** @hidden */
  67529. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67530. /**
  67531. * Create a new AnisotropyBlock
  67532. * @param name defines the block name
  67533. */
  67534. constructor(name: string);
  67535. /**
  67536. * Initialize the block and prepare the context for build
  67537. * @param state defines the state that will be used for the build
  67538. */
  67539. initialize(state: NodeMaterialBuildState): void;
  67540. /**
  67541. * Gets the current class name
  67542. * @returns the class name
  67543. */
  67544. getClassName(): string;
  67545. /**
  67546. * Gets the intensity input component
  67547. */
  67548. get intensity(): NodeMaterialConnectionPoint;
  67549. /**
  67550. * Gets the direction input component
  67551. */
  67552. get direction(): NodeMaterialConnectionPoint;
  67553. /**
  67554. * Gets the texture input component
  67555. */
  67556. get texture(): NodeMaterialConnectionPoint;
  67557. /**
  67558. * Gets the uv input component
  67559. */
  67560. get uv(): NodeMaterialConnectionPoint;
  67561. /**
  67562. * Gets the worldTangent input component
  67563. */
  67564. get worldTangent(): NodeMaterialConnectionPoint;
  67565. /**
  67566. * Gets the anisotropy object output component
  67567. */
  67568. get anisotropy(): NodeMaterialConnectionPoint;
  67569. private _generateTBNSpace;
  67570. /**
  67571. * Gets the main code of the block (fragment side)
  67572. * @param state current state of the node material building
  67573. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67574. * @returns the shader code
  67575. */
  67576. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67578. protected _buildBlock(state: NodeMaterialBuildState): this;
  67579. }
  67580. }
  67581. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67585. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67587. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67588. import { Nullable } from "babylonjs/types";
  67589. import { Mesh } from "babylonjs/Meshes/mesh";
  67590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67591. import { Effect } from "babylonjs/Materials/effect";
  67592. /**
  67593. * Block used to implement the clear coat module of the PBR material
  67594. */
  67595. export class ClearCoatBlock extends NodeMaterialBlock {
  67596. private _scene;
  67597. /**
  67598. * Create a new ClearCoatBlock
  67599. * @param name defines the block name
  67600. */
  67601. constructor(name: string);
  67602. /**
  67603. * Initialize the block and prepare the context for build
  67604. * @param state defines the state that will be used for the build
  67605. */
  67606. initialize(state: NodeMaterialBuildState): void;
  67607. /**
  67608. * Gets the current class name
  67609. * @returns the class name
  67610. */
  67611. getClassName(): string;
  67612. /**
  67613. * Gets the intensity input component
  67614. */
  67615. get intensity(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the roughness input component
  67618. */
  67619. get roughness(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the ior input component
  67622. */
  67623. get ior(): NodeMaterialConnectionPoint;
  67624. /**
  67625. * Gets the texture input component
  67626. */
  67627. get texture(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the bump texture input component
  67630. */
  67631. get bumpTexture(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the uv input component
  67634. */
  67635. get uv(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the tint color input component
  67638. */
  67639. get tintColor(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the tint "at distance" input component
  67642. */
  67643. get tintAtDistance(): NodeMaterialConnectionPoint;
  67644. /**
  67645. * Gets the tint thickness input component
  67646. */
  67647. get tintThickness(): NodeMaterialConnectionPoint;
  67648. /**
  67649. * Gets the world tangent input component
  67650. */
  67651. get worldTangent(): NodeMaterialConnectionPoint;
  67652. /**
  67653. * Gets the clear coat object output component
  67654. */
  67655. get clearcoat(): NodeMaterialConnectionPoint;
  67656. autoConfigure(material: NodeMaterial): void;
  67657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67658. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67659. private _generateTBNSpace;
  67660. /**
  67661. * Gets the main code of the block (fragment side)
  67662. * @param state current state of the node material building
  67663. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67664. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67665. * @param worldPosVarName name of the variable holding the world position
  67666. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67667. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67668. * @param worldNormalVarName name of the variable holding the world normal
  67669. * @returns the shader code
  67670. */
  67671. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67672. protected _buildBlock(state: NodeMaterialBuildState): this;
  67673. }
  67674. }
  67675. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67679. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67681. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67682. import { Nullable } from "babylonjs/types";
  67683. /**
  67684. * Block used to implement the sub surface module of the PBR material
  67685. */
  67686. export class SubSurfaceBlock extends NodeMaterialBlock {
  67687. /**
  67688. * Create a new SubSurfaceBlock
  67689. * @param name defines the block name
  67690. */
  67691. constructor(name: string);
  67692. /**
  67693. * Stores the intensity of the different subsurface effects in the thickness texture.
  67694. * * the green channel is the translucency intensity.
  67695. * * the blue channel is the scattering intensity.
  67696. * * the alpha channel is the refraction intensity.
  67697. */
  67698. useMaskFromThicknessTexture: boolean;
  67699. /**
  67700. * Initialize the block and prepare the context for build
  67701. * @param state defines the state that will be used for the build
  67702. */
  67703. initialize(state: NodeMaterialBuildState): void;
  67704. /**
  67705. * Gets the current class name
  67706. * @returns the class name
  67707. */
  67708. getClassName(): string;
  67709. /**
  67710. * Gets the min thickness input component
  67711. */
  67712. get minThickness(): NodeMaterialConnectionPoint;
  67713. /**
  67714. * Gets the max thickness input component
  67715. */
  67716. get maxThickness(): NodeMaterialConnectionPoint;
  67717. /**
  67718. * Gets the thickness texture component
  67719. */
  67720. get thicknessTexture(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the tint color input component
  67723. */
  67724. get tintColor(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the translucency intensity input component
  67727. */
  67728. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67729. /**
  67730. * Gets the translucency diffusion distance input component
  67731. */
  67732. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the refraction object parameters
  67735. */
  67736. get refraction(): NodeMaterialConnectionPoint;
  67737. /**
  67738. * Gets the sub surface object output component
  67739. */
  67740. get subsurface(): NodeMaterialConnectionPoint;
  67741. autoConfigure(material: NodeMaterial): void;
  67742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67743. /**
  67744. * Gets the main code of the block (fragment side)
  67745. * @param state current state of the node material building
  67746. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67747. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67748. * @param worldPosVarName name of the variable holding the world position
  67749. * @returns the shader code
  67750. */
  67751. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67752. protected _buildBlock(state: NodeMaterialBuildState): this;
  67753. }
  67754. }
  67755. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67759. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67760. import { Light } from "babylonjs/Lights/light";
  67761. import { Nullable } from "babylonjs/types";
  67762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67763. import { Effect } from "babylonjs/Materials/effect";
  67764. import { Mesh } from "babylonjs/Meshes/mesh";
  67765. import { Scene } from "babylonjs/scene";
  67766. /**
  67767. * Block used to implement the PBR metallic/roughness model
  67768. */
  67769. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67770. /**
  67771. * Gets or sets the light associated with this block
  67772. */
  67773. light: Nullable<Light>;
  67774. private _lightId;
  67775. private _scene;
  67776. private _environmentBRDFTexture;
  67777. private _environmentBrdfSamplerName;
  67778. private _vNormalWName;
  67779. private _invertNormalName;
  67780. /**
  67781. * Create a new ReflectionBlock
  67782. * @param name defines the block name
  67783. */
  67784. constructor(name: string);
  67785. /**
  67786. * Intensity of the direct lights e.g. the four lights available in your scene.
  67787. * This impacts both the direct diffuse and specular highlights.
  67788. */
  67789. directIntensity: number;
  67790. /**
  67791. * Intensity of the environment e.g. how much the environment will light the object
  67792. * either through harmonics for rough material or through the refelction for shiny ones.
  67793. */
  67794. environmentIntensity: number;
  67795. /**
  67796. * This is a special control allowing the reduction of the specular highlights coming from the
  67797. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67798. */
  67799. specularIntensity: number;
  67800. /**
  67801. * Defines the falloff type used in this material.
  67802. * It by default is Physical.
  67803. */
  67804. lightFalloff: number;
  67805. /**
  67806. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67807. */
  67808. useAlphaFromAlbedoTexture: boolean;
  67809. /**
  67810. * Specifies that alpha test should be used
  67811. */
  67812. useAlphaTest: boolean;
  67813. /**
  67814. * Defines the alpha limits in alpha test mode.
  67815. */
  67816. alphaTestCutoff: number;
  67817. /**
  67818. * Specifies that alpha blending should be used
  67819. */
  67820. useAlphaBlending: boolean;
  67821. /**
  67822. * Defines if the alpha value should be determined via the rgb values.
  67823. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67824. */
  67825. opacityRGB: boolean;
  67826. /**
  67827. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67828. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67829. */
  67830. useRadianceOverAlpha: boolean;
  67831. /**
  67832. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67833. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67834. */
  67835. useSpecularOverAlpha: boolean;
  67836. /**
  67837. * Enables specular anti aliasing in the PBR shader.
  67838. * It will both interacts on the Geometry for analytical and IBL lighting.
  67839. * It also prefilter the roughness map based on the bump values.
  67840. */
  67841. enableSpecularAntiAliasing: boolean;
  67842. /**
  67843. * Enables realtime filtering on the texture.
  67844. */
  67845. realTimeFiltering: boolean;
  67846. /**
  67847. * Quality switch for realtime filtering
  67848. */
  67849. realTimeFilteringQuality: number;
  67850. /**
  67851. * Defines if the material uses energy conservation.
  67852. */
  67853. useEnergyConservation: boolean;
  67854. /**
  67855. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67856. * too much the area relying on ambient texture to define their ambient occlusion.
  67857. */
  67858. useRadianceOcclusion: boolean;
  67859. /**
  67860. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67861. * makes the reflect vector face the model (under horizon).
  67862. */
  67863. useHorizonOcclusion: boolean;
  67864. /**
  67865. * If set to true, no lighting calculations will be applied.
  67866. */
  67867. unlit: boolean;
  67868. /**
  67869. * Force normal to face away from face.
  67870. */
  67871. forceNormalForward: boolean;
  67872. /**
  67873. * Defines the material debug mode.
  67874. * It helps seeing only some components of the material while troubleshooting.
  67875. */
  67876. debugMode: number;
  67877. /**
  67878. * Specify from where on screen the debug mode should start.
  67879. * The value goes from -1 (full screen) to 1 (not visible)
  67880. * It helps with side by side comparison against the final render
  67881. * This defaults to 0
  67882. */
  67883. debugLimit: number;
  67884. /**
  67885. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67886. * You can use the factor to better multiply the final value.
  67887. */
  67888. debugFactor: number;
  67889. /**
  67890. * Initialize the block and prepare the context for build
  67891. * @param state defines the state that will be used for the build
  67892. */
  67893. initialize(state: NodeMaterialBuildState): void;
  67894. /**
  67895. * Gets the current class name
  67896. * @returns the class name
  67897. */
  67898. getClassName(): string;
  67899. /**
  67900. * Gets the world position input component
  67901. */
  67902. get worldPosition(): NodeMaterialConnectionPoint;
  67903. /**
  67904. * Gets the world normal input component
  67905. */
  67906. get worldNormal(): NodeMaterialConnectionPoint;
  67907. /**
  67908. * Gets the perturbed normal input component
  67909. */
  67910. get perturbedNormal(): NodeMaterialConnectionPoint;
  67911. /**
  67912. * Gets the camera position input component
  67913. */
  67914. get cameraPosition(): NodeMaterialConnectionPoint;
  67915. /**
  67916. * Gets the base color input component
  67917. */
  67918. get baseColor(): NodeMaterialConnectionPoint;
  67919. /**
  67920. * Gets the opacity texture input component
  67921. */
  67922. get opacityTexture(): NodeMaterialConnectionPoint;
  67923. /**
  67924. * Gets the ambient color input component
  67925. */
  67926. get ambientColor(): NodeMaterialConnectionPoint;
  67927. /**
  67928. * Gets the reflectivity object parameters
  67929. */
  67930. get reflectivity(): NodeMaterialConnectionPoint;
  67931. /**
  67932. * Gets the ambient occlusion object parameters
  67933. */
  67934. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67935. /**
  67936. * Gets the reflection object parameters
  67937. */
  67938. get reflection(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the sheen object parameters
  67941. */
  67942. get sheen(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the clear coat object parameters
  67945. */
  67946. get clearcoat(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the sub surface object parameters
  67949. */
  67950. get subsurface(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the anisotropy object parameters
  67953. */
  67954. get anisotropy(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the ambient output component
  67957. */
  67958. get ambient(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the diffuse output component
  67961. */
  67962. get diffuse(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the specular output component
  67965. */
  67966. get specular(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the sheen output component
  67969. */
  67970. get sheenDir(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the clear coat output component
  67973. */
  67974. get clearcoatDir(): NodeMaterialConnectionPoint;
  67975. /**
  67976. * Gets the indirect diffuse output component
  67977. */
  67978. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67979. /**
  67980. * Gets the indirect specular output component
  67981. */
  67982. get specularIndirect(): NodeMaterialConnectionPoint;
  67983. /**
  67984. * Gets the indirect sheen output component
  67985. */
  67986. get sheenIndirect(): NodeMaterialConnectionPoint;
  67987. /**
  67988. * Gets the indirect clear coat output component
  67989. */
  67990. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67991. /**
  67992. * Gets the refraction output component
  67993. */
  67994. get refraction(): NodeMaterialConnectionPoint;
  67995. /**
  67996. * Gets the global lighting output component
  67997. */
  67998. get lighting(): NodeMaterialConnectionPoint;
  67999. /**
  68000. * Gets the shadow output component
  68001. */
  68002. get shadow(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the alpha output component
  68005. */
  68006. get alpha(): NodeMaterialConnectionPoint;
  68007. autoConfigure(material: NodeMaterial): void;
  68008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68009. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68011. private _injectVertexCode;
  68012. /**
  68013. * Gets the code corresponding to the albedo/opacity module
  68014. * @returns the shader code
  68015. */
  68016. getAlbedoOpacityCode(): string;
  68017. protected _buildBlock(state: NodeMaterialBuildState): this;
  68018. protected _dumpPropertiesCode(): string;
  68019. serialize(): any;
  68020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68021. }
  68022. }
  68023. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68024. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68025. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68026. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68027. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68028. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68029. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68030. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68031. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68032. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68033. }
  68034. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68035. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68036. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68037. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68038. }
  68039. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68043. /**
  68044. * Block used to compute value of one parameter modulo another
  68045. */
  68046. export class ModBlock extends NodeMaterialBlock {
  68047. /**
  68048. * Creates a new ModBlock
  68049. * @param name defines the block name
  68050. */
  68051. constructor(name: string);
  68052. /**
  68053. * Gets the current class name
  68054. * @returns the class name
  68055. */
  68056. getClassName(): string;
  68057. /**
  68058. * Gets the left operand input component
  68059. */
  68060. get left(): NodeMaterialConnectionPoint;
  68061. /**
  68062. * Gets the right operand input component
  68063. */
  68064. get right(): NodeMaterialConnectionPoint;
  68065. /**
  68066. * Gets the output component
  68067. */
  68068. get output(): NodeMaterialConnectionPoint;
  68069. protected _buildBlock(state: NodeMaterialBuildState): this;
  68070. }
  68071. }
  68072. declare module "babylonjs/Materials/Node/Blocks/index" {
  68073. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68074. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68075. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68076. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68077. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68078. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68079. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68080. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68081. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68082. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68083. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68084. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68085. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68086. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68087. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68088. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68089. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68090. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68091. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68092. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68093. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68094. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68095. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68096. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68097. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68098. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68099. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68100. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68101. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68102. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68103. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68104. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68105. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68106. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68107. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68108. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68109. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68110. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68111. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68112. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68113. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68114. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68115. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68116. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68117. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68118. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68119. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68120. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68121. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68122. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68123. }
  68124. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68125. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68126. }
  68127. declare module "babylonjs/Materials/Node/index" {
  68128. export * from "babylonjs/Materials/Node/Enums/index";
  68129. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68130. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68131. export * from "babylonjs/Materials/Node/nodeMaterial";
  68132. export * from "babylonjs/Materials/Node/Blocks/index";
  68133. export * from "babylonjs/Materials/Node/Optimizers/index";
  68134. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68135. }
  68136. declare module "babylonjs/Materials/index" {
  68137. export * from "babylonjs/Materials/Background/index";
  68138. export * from "babylonjs/Materials/colorCurves";
  68139. export * from "babylonjs/Materials/iEffectFallbacks";
  68140. export * from "babylonjs/Materials/effectFallbacks";
  68141. export * from "babylonjs/Materials/effect";
  68142. export * from "babylonjs/Materials/fresnelParameters";
  68143. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68144. export * from "babylonjs/Materials/material";
  68145. export * from "babylonjs/Materials/materialDefines";
  68146. export * from "babylonjs/Materials/thinMaterialHelper";
  68147. export * from "babylonjs/Materials/materialHelper";
  68148. export * from "babylonjs/Materials/multiMaterial";
  68149. export * from "babylonjs/Materials/PBR/index";
  68150. export * from "babylonjs/Materials/pushMaterial";
  68151. export * from "babylonjs/Materials/shaderMaterial";
  68152. export * from "babylonjs/Materials/standardMaterial";
  68153. export * from "babylonjs/Materials/Textures/index";
  68154. export * from "babylonjs/Materials/uniformBuffer";
  68155. export * from "babylonjs/Materials/materialFlags";
  68156. export * from "babylonjs/Materials/Node/index";
  68157. export * from "babylonjs/Materials/effectRenderer";
  68158. export * from "babylonjs/Materials/shadowDepthWrapper";
  68159. }
  68160. declare module "babylonjs/Maths/index" {
  68161. export * from "babylonjs/Maths/math.scalar";
  68162. export * from "babylonjs/Maths/math";
  68163. export * from "babylonjs/Maths/sphericalPolynomial";
  68164. }
  68165. declare module "babylonjs/Misc/workerPool" {
  68166. import { IDisposable } from "babylonjs/scene";
  68167. /**
  68168. * Helper class to push actions to a pool of workers.
  68169. */
  68170. export class WorkerPool implements IDisposable {
  68171. private _workerInfos;
  68172. private _pendingActions;
  68173. /**
  68174. * Constructor
  68175. * @param workers Array of workers to use for actions
  68176. */
  68177. constructor(workers: Array<Worker>);
  68178. /**
  68179. * Terminates all workers and clears any pending actions.
  68180. */
  68181. dispose(): void;
  68182. /**
  68183. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68184. * pended until a worker has completed its action.
  68185. * @param action The action to perform. Call onComplete when the action is complete.
  68186. */
  68187. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68188. private _execute;
  68189. }
  68190. }
  68191. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68192. import { IDisposable } from "babylonjs/scene";
  68193. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68194. /**
  68195. * Configuration for Draco compression
  68196. */
  68197. export interface IDracoCompressionConfiguration {
  68198. /**
  68199. * Configuration for the decoder.
  68200. */
  68201. decoder: {
  68202. /**
  68203. * The url to the WebAssembly module.
  68204. */
  68205. wasmUrl?: string;
  68206. /**
  68207. * The url to the WebAssembly binary.
  68208. */
  68209. wasmBinaryUrl?: string;
  68210. /**
  68211. * The url to the fallback JavaScript module.
  68212. */
  68213. fallbackUrl?: string;
  68214. };
  68215. }
  68216. /**
  68217. * Draco compression (https://google.github.io/draco/)
  68218. *
  68219. * This class wraps the Draco module.
  68220. *
  68221. * **Encoder**
  68222. *
  68223. * The encoder is not currently implemented.
  68224. *
  68225. * **Decoder**
  68226. *
  68227. * 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.
  68228. *
  68229. * To update the configuration, use the following code:
  68230. * ```javascript
  68231. * DracoCompression.Configuration = {
  68232. * decoder: {
  68233. * wasmUrl: "<url to the WebAssembly library>",
  68234. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68235. * fallbackUrl: "<url to the fallback JavaScript library>",
  68236. * }
  68237. * };
  68238. * ```
  68239. *
  68240. * 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.
  68241. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68242. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68243. *
  68244. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68245. * ```javascript
  68246. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68247. * ```
  68248. *
  68249. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68250. */
  68251. export class DracoCompression implements IDisposable {
  68252. private _workerPoolPromise?;
  68253. private _decoderModulePromise?;
  68254. /**
  68255. * The configuration. Defaults to the following urls:
  68256. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68257. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68258. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68259. */
  68260. static Configuration: IDracoCompressionConfiguration;
  68261. /**
  68262. * Returns true if the decoder configuration is available.
  68263. */
  68264. static get DecoderAvailable(): boolean;
  68265. /**
  68266. * Default number of workers to create when creating the draco compression object.
  68267. */
  68268. static DefaultNumWorkers: number;
  68269. private static GetDefaultNumWorkers;
  68270. private static _Default;
  68271. /**
  68272. * Default instance for the draco compression object.
  68273. */
  68274. static get Default(): DracoCompression;
  68275. /**
  68276. * Constructor
  68277. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68278. */
  68279. constructor(numWorkers?: number);
  68280. /**
  68281. * Stop all async operations and release resources.
  68282. */
  68283. dispose(): void;
  68284. /**
  68285. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68286. * @returns a promise that resolves when ready
  68287. */
  68288. whenReadyAsync(): Promise<void>;
  68289. /**
  68290. * Decode Draco compressed mesh data to vertex data.
  68291. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68292. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68293. * @returns A promise that resolves with the decoded vertex data
  68294. */
  68295. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68296. [kind: string]: number;
  68297. }): Promise<VertexData>;
  68298. }
  68299. }
  68300. declare module "babylonjs/Meshes/Compression/index" {
  68301. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68302. }
  68303. declare module "babylonjs/Meshes/csg" {
  68304. import { Nullable } from "babylonjs/types";
  68305. import { Scene } from "babylonjs/scene";
  68306. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68307. import { Mesh } from "babylonjs/Meshes/mesh";
  68308. import { Material } from "babylonjs/Materials/material";
  68309. /**
  68310. * Class for building Constructive Solid Geometry
  68311. */
  68312. export class CSG {
  68313. private polygons;
  68314. /**
  68315. * The world matrix
  68316. */
  68317. matrix: Matrix;
  68318. /**
  68319. * Stores the position
  68320. */
  68321. position: Vector3;
  68322. /**
  68323. * Stores the rotation
  68324. */
  68325. rotation: Vector3;
  68326. /**
  68327. * Stores the rotation quaternion
  68328. */
  68329. rotationQuaternion: Nullable<Quaternion>;
  68330. /**
  68331. * Stores the scaling vector
  68332. */
  68333. scaling: Vector3;
  68334. /**
  68335. * Convert the Mesh to CSG
  68336. * @param mesh The Mesh to convert to CSG
  68337. * @returns A new CSG from the Mesh
  68338. */
  68339. static FromMesh(mesh: Mesh): CSG;
  68340. /**
  68341. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68342. * @param polygons Polygons used to construct a CSG solid
  68343. */
  68344. private static FromPolygons;
  68345. /**
  68346. * Clones, or makes a deep copy, of the CSG
  68347. * @returns A new CSG
  68348. */
  68349. clone(): CSG;
  68350. /**
  68351. * Unions this CSG with another CSG
  68352. * @param csg The CSG to union against this CSG
  68353. * @returns The unioned CSG
  68354. */
  68355. union(csg: CSG): CSG;
  68356. /**
  68357. * Unions this CSG with another CSG in place
  68358. * @param csg The CSG to union against this CSG
  68359. */
  68360. unionInPlace(csg: CSG): void;
  68361. /**
  68362. * Subtracts this CSG with another CSG
  68363. * @param csg The CSG to subtract against this CSG
  68364. * @returns A new CSG
  68365. */
  68366. subtract(csg: CSG): CSG;
  68367. /**
  68368. * Subtracts this CSG with another CSG in place
  68369. * @param csg The CSG to subtact against this CSG
  68370. */
  68371. subtractInPlace(csg: CSG): void;
  68372. /**
  68373. * Intersect this CSG with another CSG
  68374. * @param csg The CSG to intersect against this CSG
  68375. * @returns A new CSG
  68376. */
  68377. intersect(csg: CSG): CSG;
  68378. /**
  68379. * Intersects this CSG with another CSG in place
  68380. * @param csg The CSG to intersect against this CSG
  68381. */
  68382. intersectInPlace(csg: CSG): void;
  68383. /**
  68384. * Return a new CSG solid with solid and empty space switched. This solid is
  68385. * not modified.
  68386. * @returns A new CSG solid with solid and empty space switched
  68387. */
  68388. inverse(): CSG;
  68389. /**
  68390. * Inverses the CSG in place
  68391. */
  68392. inverseInPlace(): void;
  68393. /**
  68394. * This is used to keep meshes transformations so they can be restored
  68395. * when we build back a Babylon Mesh
  68396. * NB : All CSG operations are performed in world coordinates
  68397. * @param csg The CSG to copy the transform attributes from
  68398. * @returns This CSG
  68399. */
  68400. copyTransformAttributes(csg: CSG): CSG;
  68401. /**
  68402. * Build Raw mesh from CSG
  68403. * Coordinates here are in world space
  68404. * @param name The name of the mesh geometry
  68405. * @param scene The Scene
  68406. * @param keepSubMeshes Specifies if the submeshes should be kept
  68407. * @returns A new Mesh
  68408. */
  68409. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68410. /**
  68411. * Build Mesh from CSG taking material and transforms into account
  68412. * @param name The name of the Mesh
  68413. * @param material The material of the Mesh
  68414. * @param scene The Scene
  68415. * @param keepSubMeshes Specifies if submeshes should be kept
  68416. * @returns The new Mesh
  68417. */
  68418. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68419. }
  68420. }
  68421. declare module "babylonjs/Meshes/trailMesh" {
  68422. import { Mesh } from "babylonjs/Meshes/mesh";
  68423. import { Scene } from "babylonjs/scene";
  68424. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68425. /**
  68426. * Class used to create a trail following a mesh
  68427. */
  68428. export class TrailMesh extends Mesh {
  68429. private _generator;
  68430. private _autoStart;
  68431. private _running;
  68432. private _diameter;
  68433. private _length;
  68434. private _sectionPolygonPointsCount;
  68435. private _sectionVectors;
  68436. private _sectionNormalVectors;
  68437. private _beforeRenderObserver;
  68438. /**
  68439. * @constructor
  68440. * @param name The value used by scene.getMeshByName() to do a lookup.
  68441. * @param generator The mesh or transform node to generate a trail.
  68442. * @param scene The scene to add this mesh to.
  68443. * @param diameter Diameter of trailing mesh. Default is 1.
  68444. * @param length Length of trailing mesh. Default is 60.
  68445. * @param autoStart Automatically start trailing mesh. Default true.
  68446. */
  68447. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68448. /**
  68449. * "TrailMesh"
  68450. * @returns "TrailMesh"
  68451. */
  68452. getClassName(): string;
  68453. private _createMesh;
  68454. /**
  68455. * Start trailing mesh.
  68456. */
  68457. start(): void;
  68458. /**
  68459. * Stop trailing mesh.
  68460. */
  68461. stop(): void;
  68462. /**
  68463. * Update trailing mesh geometry.
  68464. */
  68465. update(): void;
  68466. /**
  68467. * Returns a new TrailMesh object.
  68468. * @param name is a string, the name given to the new mesh
  68469. * @param newGenerator use new generator object for cloned trail mesh
  68470. * @returns a new mesh
  68471. */
  68472. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68473. /**
  68474. * Serializes this trail mesh
  68475. * @param serializationObject object to write serialization to
  68476. */
  68477. serialize(serializationObject: any): void;
  68478. /**
  68479. * Parses a serialized trail mesh
  68480. * @param parsedMesh the serialized mesh
  68481. * @param scene the scene to create the trail mesh in
  68482. * @returns the created trail mesh
  68483. */
  68484. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68485. }
  68486. }
  68487. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68488. import { Nullable } from "babylonjs/types";
  68489. import { Scene } from "babylonjs/scene";
  68490. import { Vector4 } from "babylonjs/Maths/math.vector";
  68491. import { Color4 } from "babylonjs/Maths/math.color";
  68492. import { Mesh } from "babylonjs/Meshes/mesh";
  68493. /**
  68494. * Class containing static functions to help procedurally build meshes
  68495. */
  68496. export class TiledBoxBuilder {
  68497. /**
  68498. * Creates a box mesh
  68499. * 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)
  68500. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68504. * @param name defines the name of the mesh
  68505. * @param options defines the options used to create the mesh
  68506. * @param scene defines the hosting scene
  68507. * @returns the box mesh
  68508. */
  68509. static CreateTiledBox(name: string, options: {
  68510. pattern?: number;
  68511. width?: number;
  68512. height?: number;
  68513. depth?: number;
  68514. tileSize?: number;
  68515. tileWidth?: number;
  68516. tileHeight?: number;
  68517. alignHorizontal?: number;
  68518. alignVertical?: number;
  68519. faceUV?: Vector4[];
  68520. faceColors?: Color4[];
  68521. sideOrientation?: number;
  68522. updatable?: boolean;
  68523. }, scene?: Nullable<Scene>): Mesh;
  68524. }
  68525. }
  68526. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68527. import { Vector4 } from "babylonjs/Maths/math.vector";
  68528. import { Mesh } from "babylonjs/Meshes/mesh";
  68529. /**
  68530. * Class containing static functions to help procedurally build meshes
  68531. */
  68532. export class TorusKnotBuilder {
  68533. /**
  68534. * Creates a torus knot mesh
  68535. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68536. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68537. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68538. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68542. * @param name defines the name of the mesh
  68543. * @param options defines the options used to create the mesh
  68544. * @param scene defines the hosting scene
  68545. * @returns the torus knot mesh
  68546. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68547. */
  68548. static CreateTorusKnot(name: string, options: {
  68549. radius?: number;
  68550. tube?: number;
  68551. radialSegments?: number;
  68552. tubularSegments?: number;
  68553. p?: number;
  68554. q?: number;
  68555. updatable?: boolean;
  68556. sideOrientation?: number;
  68557. frontUVs?: Vector4;
  68558. backUVs?: Vector4;
  68559. }, scene: any): Mesh;
  68560. }
  68561. }
  68562. declare module "babylonjs/Meshes/polygonMesh" {
  68563. import { Scene } from "babylonjs/scene";
  68564. import { Vector2 } from "babylonjs/Maths/math.vector";
  68565. import { Mesh } from "babylonjs/Meshes/mesh";
  68566. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68567. import { Path2 } from "babylonjs/Maths/math.path";
  68568. /**
  68569. * Polygon
  68570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68571. */
  68572. export class Polygon {
  68573. /**
  68574. * Creates a rectangle
  68575. * @param xmin bottom X coord
  68576. * @param ymin bottom Y coord
  68577. * @param xmax top X coord
  68578. * @param ymax top Y coord
  68579. * @returns points that make the resulting rectation
  68580. */
  68581. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68582. /**
  68583. * Creates a circle
  68584. * @param radius radius of circle
  68585. * @param cx scale in x
  68586. * @param cy scale in y
  68587. * @param numberOfSides number of sides that make up the circle
  68588. * @returns points that make the resulting circle
  68589. */
  68590. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68591. /**
  68592. * Creates a polygon from input string
  68593. * @param input Input polygon data
  68594. * @returns the parsed points
  68595. */
  68596. static Parse(input: string): Vector2[];
  68597. /**
  68598. * Starts building a polygon from x and y coordinates
  68599. * @param x x coordinate
  68600. * @param y y coordinate
  68601. * @returns the started path2
  68602. */
  68603. static StartingAt(x: number, y: number): Path2;
  68604. }
  68605. /**
  68606. * Builds a polygon
  68607. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68608. */
  68609. export class PolygonMeshBuilder {
  68610. private _points;
  68611. private _outlinepoints;
  68612. private _holes;
  68613. private _name;
  68614. private _scene;
  68615. private _epoints;
  68616. private _eholes;
  68617. private _addToepoint;
  68618. /**
  68619. * Babylon reference to the earcut plugin.
  68620. */
  68621. bjsEarcut: any;
  68622. /**
  68623. * Creates a PolygonMeshBuilder
  68624. * @param name name of the builder
  68625. * @param contours Path of the polygon
  68626. * @param scene scene to add to when creating the mesh
  68627. * @param earcutInjection can be used to inject your own earcut reference
  68628. */
  68629. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68630. /**
  68631. * Adds a whole within the polygon
  68632. * @param hole Array of points defining the hole
  68633. * @returns this
  68634. */
  68635. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68636. /**
  68637. * Creates the polygon
  68638. * @param updatable If the mesh should be updatable
  68639. * @param depth The depth of the mesh created
  68640. * @returns the created mesh
  68641. */
  68642. build(updatable?: boolean, depth?: number): Mesh;
  68643. /**
  68644. * Creates the polygon
  68645. * @param depth The depth of the mesh created
  68646. * @returns the created VertexData
  68647. */
  68648. buildVertexData(depth?: number): VertexData;
  68649. /**
  68650. * Adds a side to the polygon
  68651. * @param positions points that make the polygon
  68652. * @param normals normals of the polygon
  68653. * @param uvs uvs of the polygon
  68654. * @param indices indices of the polygon
  68655. * @param bounds bounds of the polygon
  68656. * @param points points of the polygon
  68657. * @param depth depth of the polygon
  68658. * @param flip flip of the polygon
  68659. */
  68660. private addSide;
  68661. }
  68662. }
  68663. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68664. import { Scene } from "babylonjs/scene";
  68665. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68666. import { Color4 } from "babylonjs/Maths/math.color";
  68667. import { Mesh } from "babylonjs/Meshes/mesh";
  68668. import { Nullable } from "babylonjs/types";
  68669. /**
  68670. * Class containing static functions to help procedurally build meshes
  68671. */
  68672. export class PolygonBuilder {
  68673. /**
  68674. * Creates a polygon mesh
  68675. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68676. * * 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
  68677. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68680. * * Remember you can only change the shape positions, not their number when updating a polygon
  68681. * @param name defines the name of the mesh
  68682. * @param options defines the options used to create the mesh
  68683. * @param scene defines the hosting scene
  68684. * @param earcutInjection can be used to inject your own earcut reference
  68685. * @returns the polygon mesh
  68686. */
  68687. static CreatePolygon(name: string, options: {
  68688. shape: Vector3[];
  68689. holes?: Vector3[][];
  68690. depth?: number;
  68691. faceUV?: Vector4[];
  68692. faceColors?: Color4[];
  68693. updatable?: boolean;
  68694. sideOrientation?: number;
  68695. frontUVs?: Vector4;
  68696. backUVs?: Vector4;
  68697. wrap?: boolean;
  68698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68699. /**
  68700. * Creates an extruded polygon mesh, with depth in the Y direction.
  68701. * * 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)
  68702. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68703. * @param name defines the name of the mesh
  68704. * @param options defines the options used to create the mesh
  68705. * @param scene defines the hosting scene
  68706. * @param earcutInjection can be used to inject your own earcut reference
  68707. * @returns the polygon mesh
  68708. */
  68709. static ExtrudePolygon(name: string, options: {
  68710. shape: Vector3[];
  68711. holes?: Vector3[][];
  68712. depth?: number;
  68713. faceUV?: Vector4[];
  68714. faceColors?: Color4[];
  68715. updatable?: boolean;
  68716. sideOrientation?: number;
  68717. frontUVs?: Vector4;
  68718. backUVs?: Vector4;
  68719. wrap?: boolean;
  68720. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68721. }
  68722. }
  68723. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68724. import { Scene } from "babylonjs/scene";
  68725. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68726. import { Mesh } from "babylonjs/Meshes/mesh";
  68727. import { Nullable } from "babylonjs/types";
  68728. /**
  68729. * Class containing static functions to help procedurally build meshes
  68730. */
  68731. export class LatheBuilder {
  68732. /**
  68733. * Creates lathe mesh.
  68734. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68735. * * 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
  68736. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68737. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68738. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68739. * * 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
  68740. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68741. * * 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
  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 lathe mesh
  68750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68751. */
  68752. static CreateLathe(name: string, options: {
  68753. shape: Vector3[];
  68754. radius?: number;
  68755. tessellation?: number;
  68756. clip?: number;
  68757. arc?: number;
  68758. closed?: boolean;
  68759. updatable?: boolean;
  68760. sideOrientation?: number;
  68761. frontUVs?: Vector4;
  68762. backUVs?: Vector4;
  68763. cap?: number;
  68764. invertUV?: boolean;
  68765. }, scene?: Nullable<Scene>): Mesh;
  68766. }
  68767. }
  68768. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68769. import { Nullable } from "babylonjs/types";
  68770. import { Scene } from "babylonjs/scene";
  68771. import { Vector4 } from "babylonjs/Maths/math.vector";
  68772. import { Mesh } from "babylonjs/Meshes/mesh";
  68773. /**
  68774. * Class containing static functions to help procedurally build meshes
  68775. */
  68776. export class TiledPlaneBuilder {
  68777. /**
  68778. * Creates a tiled plane mesh
  68779. * * The parameter `pattern` will, depending on value, do nothing or
  68780. * * * flip (reflect about central vertical) alternate tiles across and up
  68781. * * * flip every tile on alternate rows
  68782. * * * rotate (180 degs) alternate tiles across and up
  68783. * * * rotate every tile on alternate rows
  68784. * * * flip and rotate alternate tiles across and up
  68785. * * * flip and rotate every tile on alternate rows
  68786. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68787. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68790. * * 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)
  68791. * * 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)
  68792. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68793. * @param name defines the name of the mesh
  68794. * @param options defines the options used to create the mesh
  68795. * @param scene defines the hosting scene
  68796. * @returns the box mesh
  68797. */
  68798. static CreateTiledPlane(name: string, options: {
  68799. pattern?: number;
  68800. tileSize?: number;
  68801. tileWidth?: number;
  68802. tileHeight?: number;
  68803. size?: number;
  68804. width?: number;
  68805. height?: number;
  68806. alignHorizontal?: number;
  68807. alignVertical?: number;
  68808. sideOrientation?: number;
  68809. frontUVs?: Vector4;
  68810. backUVs?: Vector4;
  68811. updatable?: boolean;
  68812. }, scene?: Nullable<Scene>): Mesh;
  68813. }
  68814. }
  68815. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68816. import { Nullable } from "babylonjs/types";
  68817. import { Scene } from "babylonjs/scene";
  68818. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68819. import { Mesh } from "babylonjs/Meshes/mesh";
  68820. /**
  68821. * Class containing static functions to help procedurally build meshes
  68822. */
  68823. export class TubeBuilder {
  68824. /**
  68825. * Creates a tube mesh.
  68826. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68827. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68828. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68829. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68830. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68831. * * 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)
  68832. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68833. * * 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
  68834. * * 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
  68835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68839. * @param name defines the name of the mesh
  68840. * @param options defines the options used to create the mesh
  68841. * @param scene defines the hosting scene
  68842. * @returns the tube mesh
  68843. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68844. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68845. */
  68846. static CreateTube(name: string, options: {
  68847. path: Vector3[];
  68848. radius?: number;
  68849. tessellation?: number;
  68850. radiusFunction?: {
  68851. (i: number, distance: number): number;
  68852. };
  68853. cap?: number;
  68854. arc?: number;
  68855. updatable?: boolean;
  68856. sideOrientation?: number;
  68857. frontUVs?: Vector4;
  68858. backUVs?: Vector4;
  68859. instance?: Mesh;
  68860. invertUV?: boolean;
  68861. }, scene?: Nullable<Scene>): Mesh;
  68862. }
  68863. }
  68864. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68865. import { Scene } from "babylonjs/scene";
  68866. import { Vector4 } from "babylonjs/Maths/math.vector";
  68867. import { Mesh } from "babylonjs/Meshes/mesh";
  68868. import { Nullable } from "babylonjs/types";
  68869. /**
  68870. * Class containing static functions to help procedurally build meshes
  68871. */
  68872. export class IcoSphereBuilder {
  68873. /**
  68874. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68875. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68876. * * 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`)
  68877. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68878. * * 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
  68879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68882. * @param name defines the name of the mesh
  68883. * @param options defines the options used to create the mesh
  68884. * @param scene defines the hosting scene
  68885. * @returns the icosahedron mesh
  68886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68887. */
  68888. static CreateIcoSphere(name: string, options: {
  68889. radius?: number;
  68890. radiusX?: number;
  68891. radiusY?: number;
  68892. radiusZ?: number;
  68893. flat?: boolean;
  68894. subdivisions?: number;
  68895. sideOrientation?: number;
  68896. frontUVs?: Vector4;
  68897. backUVs?: Vector4;
  68898. updatable?: boolean;
  68899. }, scene?: Nullable<Scene>): Mesh;
  68900. }
  68901. }
  68902. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68903. import { Vector3 } from "babylonjs/Maths/math.vector";
  68904. import { Mesh } from "babylonjs/Meshes/mesh";
  68905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68906. /**
  68907. * Class containing static functions to help procedurally build meshes
  68908. */
  68909. export class DecalBuilder {
  68910. /**
  68911. * Creates a decal mesh.
  68912. * 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
  68913. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68914. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68915. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68916. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68917. * @param name defines the name of the mesh
  68918. * @param sourceMesh defines the mesh where the decal must be applied
  68919. * @param options defines the options used to create the mesh
  68920. * @param scene defines the hosting scene
  68921. * @returns the decal mesh
  68922. * @see https://doc.babylonjs.com/how_to/decals
  68923. */
  68924. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68925. position?: Vector3;
  68926. normal?: Vector3;
  68927. size?: Vector3;
  68928. angle?: number;
  68929. }): Mesh;
  68930. }
  68931. }
  68932. declare module "babylonjs/Meshes/meshBuilder" {
  68933. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68934. import { Nullable } from "babylonjs/types";
  68935. import { Scene } from "babylonjs/scene";
  68936. import { Mesh } from "babylonjs/Meshes/mesh";
  68937. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68938. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68940. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68941. import { Plane } from "babylonjs/Maths/math.plane";
  68942. /**
  68943. * Class containing static functions to help procedurally build meshes
  68944. */
  68945. export class MeshBuilder {
  68946. /**
  68947. * Creates a box mesh
  68948. * * The parameter `size` sets the size (float) of each box side (default 1)
  68949. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68950. * * 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)
  68951. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68955. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68956. * @param name defines the name of the mesh
  68957. * @param options defines the options used to create the mesh
  68958. * @param scene defines the hosting scene
  68959. * @returns the box mesh
  68960. */
  68961. static CreateBox(name: string, options: {
  68962. size?: number;
  68963. width?: number;
  68964. height?: number;
  68965. depth?: number;
  68966. faceUV?: Vector4[];
  68967. faceColors?: Color4[];
  68968. sideOrientation?: number;
  68969. frontUVs?: Vector4;
  68970. backUVs?: Vector4;
  68971. wrap?: boolean;
  68972. topBaseAt?: number;
  68973. bottomBaseAt?: number;
  68974. updatable?: boolean;
  68975. }, scene?: Nullable<Scene>): Mesh;
  68976. /**
  68977. * Creates a tiled box mesh
  68978. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68980. * @param name defines the name of the mesh
  68981. * @param options defines the options used to create the mesh
  68982. * @param scene defines the hosting scene
  68983. * @returns the tiled box mesh
  68984. */
  68985. static CreateTiledBox(name: string, options: {
  68986. pattern?: number;
  68987. size?: number;
  68988. width?: number;
  68989. height?: number;
  68990. depth: number;
  68991. tileSize?: number;
  68992. tileWidth?: number;
  68993. tileHeight?: number;
  68994. faceUV?: Vector4[];
  68995. faceColors?: Color4[];
  68996. alignHorizontal?: number;
  68997. alignVertical?: number;
  68998. sideOrientation?: number;
  68999. updatable?: boolean;
  69000. }, scene?: Nullable<Scene>): Mesh;
  69001. /**
  69002. * Creates a sphere mesh
  69003. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69004. * * 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`)
  69005. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69006. * * 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
  69007. * * 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)
  69008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69011. * @param name defines the name of the mesh
  69012. * @param options defines the options used to create the mesh
  69013. * @param scene defines the hosting scene
  69014. * @returns the sphere mesh
  69015. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69016. */
  69017. static CreateSphere(name: string, options: {
  69018. segments?: number;
  69019. diameter?: number;
  69020. diameterX?: number;
  69021. diameterY?: number;
  69022. diameterZ?: number;
  69023. arc?: number;
  69024. slice?: number;
  69025. sideOrientation?: number;
  69026. frontUVs?: Vector4;
  69027. backUVs?: Vector4;
  69028. updatable?: boolean;
  69029. }, scene?: Nullable<Scene>): Mesh;
  69030. /**
  69031. * Creates a plane polygonal mesh. By default, this is a disc
  69032. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69033. * * 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
  69034. * * 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
  69035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69038. * @param name defines the name of the mesh
  69039. * @param options defines the options used to create the mesh
  69040. * @param scene defines the hosting scene
  69041. * @returns the plane polygonal mesh
  69042. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69043. */
  69044. static CreateDisc(name: string, options: {
  69045. radius?: number;
  69046. tessellation?: number;
  69047. arc?: number;
  69048. updatable?: boolean;
  69049. sideOrientation?: number;
  69050. frontUVs?: Vector4;
  69051. backUVs?: Vector4;
  69052. }, scene?: Nullable<Scene>): Mesh;
  69053. /**
  69054. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69055. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69056. * * 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`)
  69057. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69058. * * 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
  69059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69062. * @param name defines the name of the mesh
  69063. * @param options defines the options used to create the mesh
  69064. * @param scene defines the hosting scene
  69065. * @returns the icosahedron mesh
  69066. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69067. */
  69068. static CreateIcoSphere(name: string, options: {
  69069. radius?: number;
  69070. radiusX?: number;
  69071. radiusY?: number;
  69072. radiusZ?: number;
  69073. flat?: boolean;
  69074. subdivisions?: number;
  69075. sideOrientation?: number;
  69076. frontUVs?: Vector4;
  69077. backUVs?: Vector4;
  69078. updatable?: boolean;
  69079. }, scene?: Nullable<Scene>): Mesh;
  69080. /**
  69081. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69082. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69083. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69084. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69085. * * 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
  69086. * * 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
  69087. * * 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
  69088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69091. * * 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
  69092. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69093. * * 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
  69094. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69096. * @param name defines the name of the mesh
  69097. * @param options defines the options used to create the mesh
  69098. * @param scene defines the hosting scene
  69099. * @returns the ribbon mesh
  69100. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69102. */
  69103. static CreateRibbon(name: string, options: {
  69104. pathArray: Vector3[][];
  69105. closeArray?: boolean;
  69106. closePath?: boolean;
  69107. offset?: number;
  69108. updatable?: boolean;
  69109. sideOrientation?: number;
  69110. frontUVs?: Vector4;
  69111. backUVs?: Vector4;
  69112. instance?: Mesh;
  69113. invertUV?: boolean;
  69114. uvs?: Vector2[];
  69115. colors?: Color4[];
  69116. }, scene?: Nullable<Scene>): Mesh;
  69117. /**
  69118. * Creates a cylinder or a cone mesh
  69119. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69120. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69121. * * 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.
  69122. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69123. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69124. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69125. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69126. * * 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).
  69127. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69128. * * 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).
  69129. * * 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
  69130. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69131. * * 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
  69132. * * 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.
  69133. * * If `enclose` is false, a ring surface is one element.
  69134. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69135. * * 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
  69136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69139. * @param name defines the name of the mesh
  69140. * @param options defines the options used to create the mesh
  69141. * @param scene defines the hosting scene
  69142. * @returns the cylinder mesh
  69143. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69144. */
  69145. static CreateCylinder(name: string, options: {
  69146. height?: number;
  69147. diameterTop?: number;
  69148. diameterBottom?: number;
  69149. diameter?: number;
  69150. tessellation?: number;
  69151. subdivisions?: number;
  69152. arc?: number;
  69153. faceColors?: Color4[];
  69154. faceUV?: Vector4[];
  69155. updatable?: boolean;
  69156. hasRings?: boolean;
  69157. enclose?: boolean;
  69158. cap?: number;
  69159. sideOrientation?: number;
  69160. frontUVs?: Vector4;
  69161. backUVs?: Vector4;
  69162. }, scene?: Nullable<Scene>): Mesh;
  69163. /**
  69164. * Creates a torus mesh
  69165. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69166. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69167. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69171. * @param name defines the name of the mesh
  69172. * @param options defines the options used to create the mesh
  69173. * @param scene defines the hosting scene
  69174. * @returns the torus mesh
  69175. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69176. */
  69177. static CreateTorus(name: string, options: {
  69178. diameter?: number;
  69179. thickness?: number;
  69180. tessellation?: number;
  69181. updatable?: boolean;
  69182. sideOrientation?: number;
  69183. frontUVs?: Vector4;
  69184. backUVs?: Vector4;
  69185. }, scene?: Nullable<Scene>): Mesh;
  69186. /**
  69187. * Creates a torus knot mesh
  69188. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69189. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69190. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69191. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69195. * @param name defines the name of the mesh
  69196. * @param options defines the options used to create the mesh
  69197. * @param scene defines the hosting scene
  69198. * @returns the torus knot mesh
  69199. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69200. */
  69201. static CreateTorusKnot(name: string, options: {
  69202. radius?: number;
  69203. tube?: number;
  69204. radialSegments?: number;
  69205. tubularSegments?: number;
  69206. p?: number;
  69207. q?: number;
  69208. updatable?: boolean;
  69209. sideOrientation?: number;
  69210. frontUVs?: Vector4;
  69211. backUVs?: Vector4;
  69212. }, scene?: Nullable<Scene>): Mesh;
  69213. /**
  69214. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69215. * * 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
  69216. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69217. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69218. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69219. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69220. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69221. * * 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
  69222. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69225. * @param name defines the name of the new line system
  69226. * @param options defines the options used to create the line system
  69227. * @param scene defines the hosting scene
  69228. * @returns a new line system mesh
  69229. */
  69230. static CreateLineSystem(name: string, options: {
  69231. lines: Vector3[][];
  69232. updatable?: boolean;
  69233. instance?: Nullable<LinesMesh>;
  69234. colors?: Nullable<Color4[][]>;
  69235. useVertexAlpha?: boolean;
  69236. }, scene: Nullable<Scene>): LinesMesh;
  69237. /**
  69238. * Creates a line mesh
  69239. * 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
  69240. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69241. * * The parameter `points` is an array successive Vector3
  69242. * * 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
  69243. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69244. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69245. * * When updating an instance, remember that only point positions can change, not the number of points
  69246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69248. * @param name defines the name of the new line system
  69249. * @param options defines the options used to create the line system
  69250. * @param scene defines the hosting scene
  69251. * @returns a new line mesh
  69252. */
  69253. static CreateLines(name: string, options: {
  69254. points: Vector3[];
  69255. updatable?: boolean;
  69256. instance?: Nullable<LinesMesh>;
  69257. colors?: Color4[];
  69258. useVertexAlpha?: boolean;
  69259. }, scene?: Nullable<Scene>): LinesMesh;
  69260. /**
  69261. * Creates a dashed line mesh
  69262. * * 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
  69263. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69264. * * The parameter `points` is an array successive Vector3
  69265. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69266. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69267. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69268. * * 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
  69269. * * When updating an instance, remember that only point positions can change, not the number of points
  69270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69271. * @param name defines the name of the mesh
  69272. * @param options defines the options used to create the mesh
  69273. * @param scene defines the hosting scene
  69274. * @returns the dashed line mesh
  69275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69276. */
  69277. static CreateDashedLines(name: string, options: {
  69278. points: Vector3[];
  69279. dashSize?: number;
  69280. gapSize?: number;
  69281. dashNb?: number;
  69282. updatable?: boolean;
  69283. instance?: LinesMesh;
  69284. }, scene?: Nullable<Scene>): LinesMesh;
  69285. /**
  69286. * 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.
  69287. * * 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.
  69288. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69289. * * 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.
  69290. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69291. * * 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
  69292. * * 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
  69293. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69298. * @param name defines the name of the mesh
  69299. * @param options defines the options used to create the mesh
  69300. * @param scene defines the hosting scene
  69301. * @returns the extruded shape mesh
  69302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69304. */
  69305. static ExtrudeShape(name: string, options: {
  69306. shape: Vector3[];
  69307. path: Vector3[];
  69308. scale?: number;
  69309. rotation?: number;
  69310. cap?: number;
  69311. updatable?: boolean;
  69312. sideOrientation?: number;
  69313. frontUVs?: Vector4;
  69314. backUVs?: Vector4;
  69315. instance?: Mesh;
  69316. invertUV?: boolean;
  69317. }, scene?: Nullable<Scene>): Mesh;
  69318. /**
  69319. * Creates an custom extruded shape mesh.
  69320. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69321. * * 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.
  69322. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69323. * * 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
  69324. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69325. * * 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
  69326. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69327. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69328. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69329. * * 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
  69330. * * 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
  69331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69336. * @param name defines the name of the mesh
  69337. * @param options defines the options used to create the mesh
  69338. * @param scene defines the hosting scene
  69339. * @returns the custom extruded shape mesh
  69340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69343. */
  69344. static ExtrudeShapeCustom(name: string, options: {
  69345. shape: Vector3[];
  69346. path: Vector3[];
  69347. scaleFunction?: any;
  69348. rotationFunction?: any;
  69349. ribbonCloseArray?: boolean;
  69350. ribbonClosePath?: boolean;
  69351. cap?: number;
  69352. updatable?: boolean;
  69353. sideOrientation?: number;
  69354. frontUVs?: Vector4;
  69355. backUVs?: Vector4;
  69356. instance?: Mesh;
  69357. invertUV?: boolean;
  69358. }, scene?: Nullable<Scene>): Mesh;
  69359. /**
  69360. * Creates lathe mesh.
  69361. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69362. * * 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
  69363. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69364. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69365. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69366. * * 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
  69367. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69368. * * 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
  69369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69373. * @param name defines the name of the mesh
  69374. * @param options defines the options used to create the mesh
  69375. * @param scene defines the hosting scene
  69376. * @returns the lathe mesh
  69377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69378. */
  69379. static CreateLathe(name: string, options: {
  69380. shape: Vector3[];
  69381. radius?: number;
  69382. tessellation?: number;
  69383. clip?: number;
  69384. arc?: number;
  69385. closed?: boolean;
  69386. updatable?: boolean;
  69387. sideOrientation?: number;
  69388. frontUVs?: Vector4;
  69389. backUVs?: Vector4;
  69390. cap?: number;
  69391. invertUV?: boolean;
  69392. }, scene?: Nullable<Scene>): Mesh;
  69393. /**
  69394. * Creates a tiled plane mesh
  69395. * * You can set a limited pattern arrangement with the tiles
  69396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69399. * @param name defines the name of the mesh
  69400. * @param options defines the options used to create the mesh
  69401. * @param scene defines the hosting scene
  69402. * @returns the plane mesh
  69403. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69404. */
  69405. static CreateTiledPlane(name: string, options: {
  69406. pattern?: number;
  69407. tileSize?: number;
  69408. tileWidth?: number;
  69409. tileHeight?: number;
  69410. size?: number;
  69411. width?: number;
  69412. height?: number;
  69413. alignHorizontal?: number;
  69414. alignVertical?: number;
  69415. sideOrientation?: number;
  69416. frontUVs?: Vector4;
  69417. backUVs?: Vector4;
  69418. updatable?: boolean;
  69419. }, scene?: Nullable<Scene>): Mesh;
  69420. /**
  69421. * Creates a plane mesh
  69422. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69423. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69424. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69428. * @param name defines the name of the mesh
  69429. * @param options defines the options used to create the mesh
  69430. * @param scene defines the hosting scene
  69431. * @returns the plane mesh
  69432. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69433. */
  69434. static CreatePlane(name: string, options: {
  69435. size?: number;
  69436. width?: number;
  69437. height?: number;
  69438. sideOrientation?: number;
  69439. frontUVs?: Vector4;
  69440. backUVs?: Vector4;
  69441. updatable?: boolean;
  69442. sourcePlane?: Plane;
  69443. }, scene?: Nullable<Scene>): Mesh;
  69444. /**
  69445. * Creates a ground mesh
  69446. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69447. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69449. * @param name defines the name of the mesh
  69450. * @param options defines the options used to create the mesh
  69451. * @param scene defines the hosting scene
  69452. * @returns the ground mesh
  69453. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69454. */
  69455. static CreateGround(name: string, options: {
  69456. width?: number;
  69457. height?: number;
  69458. subdivisions?: number;
  69459. subdivisionsX?: number;
  69460. subdivisionsY?: number;
  69461. updatable?: boolean;
  69462. }, scene?: Nullable<Scene>): Mesh;
  69463. /**
  69464. * Creates a tiled ground mesh
  69465. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69466. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69467. * * 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
  69468. * * 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
  69469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69470. * @param name defines the name of the mesh
  69471. * @param options defines the options used to create the mesh
  69472. * @param scene defines the hosting scene
  69473. * @returns the tiled ground mesh
  69474. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69475. */
  69476. static CreateTiledGround(name: string, options: {
  69477. xmin: number;
  69478. zmin: number;
  69479. xmax: number;
  69480. zmax: number;
  69481. subdivisions?: {
  69482. w: number;
  69483. h: number;
  69484. };
  69485. precision?: {
  69486. w: number;
  69487. h: number;
  69488. };
  69489. updatable?: boolean;
  69490. }, scene?: Nullable<Scene>): Mesh;
  69491. /**
  69492. * Creates a ground mesh from a height map
  69493. * * The parameter `url` sets the URL of the height map image resource.
  69494. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69495. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69496. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69497. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69498. * * 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.
  69499. * * 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).
  69500. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69502. * @param name defines the name of the mesh
  69503. * @param url defines the url to the height map
  69504. * @param options defines the options used to create the mesh
  69505. * @param scene defines the hosting scene
  69506. * @returns the ground mesh
  69507. * @see https://doc.babylonjs.com/babylon101/height_map
  69508. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69509. */
  69510. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69511. width?: number;
  69512. height?: number;
  69513. subdivisions?: number;
  69514. minHeight?: number;
  69515. maxHeight?: number;
  69516. colorFilter?: Color3;
  69517. alphaFilter?: number;
  69518. updatable?: boolean;
  69519. onReady?: (mesh: GroundMesh) => void;
  69520. }, scene?: Nullable<Scene>): GroundMesh;
  69521. /**
  69522. * Creates a polygon mesh
  69523. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69524. * * 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
  69525. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69528. * * Remember you can only change the shape positions, not their number when updating a polygon
  69529. * @param name defines the name of the mesh
  69530. * @param options defines the options used to create the mesh
  69531. * @param scene defines the hosting scene
  69532. * @param earcutInjection can be used to inject your own earcut reference
  69533. * @returns the polygon mesh
  69534. */
  69535. static CreatePolygon(name: string, options: {
  69536. shape: Vector3[];
  69537. holes?: Vector3[][];
  69538. depth?: number;
  69539. faceUV?: Vector4[];
  69540. faceColors?: Color4[];
  69541. updatable?: boolean;
  69542. sideOrientation?: number;
  69543. frontUVs?: Vector4;
  69544. backUVs?: Vector4;
  69545. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69546. /**
  69547. * Creates an extruded polygon mesh, with depth in the Y direction.
  69548. * * 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)
  69549. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69550. * @param name defines the name of the mesh
  69551. * @param options defines the options used to create the mesh
  69552. * @param scene defines the hosting scene
  69553. * @param earcutInjection can be used to inject your own earcut reference
  69554. * @returns the polygon mesh
  69555. */
  69556. static ExtrudePolygon(name: string, options: {
  69557. shape: Vector3[];
  69558. holes?: Vector3[][];
  69559. depth?: number;
  69560. faceUV?: Vector4[];
  69561. faceColors?: Color4[];
  69562. updatable?: boolean;
  69563. sideOrientation?: number;
  69564. frontUVs?: Vector4;
  69565. backUVs?: Vector4;
  69566. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69567. /**
  69568. * Creates a tube mesh.
  69569. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69570. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69571. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69572. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69573. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69574. * * 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)
  69575. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69576. * * 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
  69577. * * 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
  69578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69582. * @param name defines the name of the mesh
  69583. * @param options defines the options used to create the mesh
  69584. * @param scene defines the hosting scene
  69585. * @returns the tube mesh
  69586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69587. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69588. */
  69589. static CreateTube(name: string, options: {
  69590. path: Vector3[];
  69591. radius?: number;
  69592. tessellation?: number;
  69593. radiusFunction?: {
  69594. (i: number, distance: number): number;
  69595. };
  69596. cap?: number;
  69597. arc?: number;
  69598. updatable?: boolean;
  69599. sideOrientation?: number;
  69600. frontUVs?: Vector4;
  69601. backUVs?: Vector4;
  69602. instance?: Mesh;
  69603. invertUV?: boolean;
  69604. }, scene?: Nullable<Scene>): Mesh;
  69605. /**
  69606. * Creates a polyhedron mesh
  69607. * * 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
  69608. * * The parameter `size` (positive float, default 1) sets the polygon size
  69609. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69610. * * 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`
  69611. * * 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
  69612. * * 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)`)
  69613. * * 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
  69614. * * 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
  69615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69618. * @param name defines the name of the mesh
  69619. * @param options defines the options used to create the mesh
  69620. * @param scene defines the hosting scene
  69621. * @returns the polyhedron mesh
  69622. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69623. */
  69624. static CreatePolyhedron(name: string, options: {
  69625. type?: number;
  69626. size?: number;
  69627. sizeX?: number;
  69628. sizeY?: number;
  69629. sizeZ?: number;
  69630. custom?: any;
  69631. faceUV?: Vector4[];
  69632. faceColors?: Color4[];
  69633. flat?: boolean;
  69634. updatable?: boolean;
  69635. sideOrientation?: number;
  69636. frontUVs?: Vector4;
  69637. backUVs?: Vector4;
  69638. }, scene?: Nullable<Scene>): Mesh;
  69639. /**
  69640. * Creates a decal mesh.
  69641. * 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
  69642. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69643. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69644. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69645. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69646. * @param name defines the name of the mesh
  69647. * @param sourceMesh defines the mesh where the decal must be applied
  69648. * @param options defines the options used to create the mesh
  69649. * @param scene defines the hosting scene
  69650. * @returns the decal mesh
  69651. * @see https://doc.babylonjs.com/how_to/decals
  69652. */
  69653. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69654. position?: Vector3;
  69655. normal?: Vector3;
  69656. size?: Vector3;
  69657. angle?: number;
  69658. }): Mesh;
  69659. }
  69660. }
  69661. declare module "babylonjs/Meshes/meshSimplification" {
  69662. import { Mesh } from "babylonjs/Meshes/mesh";
  69663. /**
  69664. * A simplifier interface for future simplification implementations
  69665. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69666. */
  69667. export interface ISimplifier {
  69668. /**
  69669. * Simplification of a given mesh according to the given settings.
  69670. * Since this requires computation, it is assumed that the function runs async.
  69671. * @param settings The settings of the simplification, including quality and distance
  69672. * @param successCallback A callback that will be called after the mesh was simplified.
  69673. * @param errorCallback in case of an error, this callback will be called. optional.
  69674. */
  69675. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69676. }
  69677. /**
  69678. * Expected simplification settings.
  69679. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69680. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69681. */
  69682. export interface ISimplificationSettings {
  69683. /**
  69684. * Gets or sets the expected quality
  69685. */
  69686. quality: number;
  69687. /**
  69688. * Gets or sets the distance when this optimized version should be used
  69689. */
  69690. distance: number;
  69691. /**
  69692. * Gets an already optimized mesh
  69693. */
  69694. optimizeMesh?: boolean;
  69695. }
  69696. /**
  69697. * Class used to specify simplification options
  69698. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69699. */
  69700. export class SimplificationSettings implements ISimplificationSettings {
  69701. /** expected quality */
  69702. quality: number;
  69703. /** distance when this optimized version should be used */
  69704. distance: number;
  69705. /** already optimized mesh */
  69706. optimizeMesh?: boolean | undefined;
  69707. /**
  69708. * Creates a SimplificationSettings
  69709. * @param quality expected quality
  69710. * @param distance distance when this optimized version should be used
  69711. * @param optimizeMesh already optimized mesh
  69712. */
  69713. constructor(
  69714. /** expected quality */
  69715. quality: number,
  69716. /** distance when this optimized version should be used */
  69717. distance: number,
  69718. /** already optimized mesh */
  69719. optimizeMesh?: boolean | undefined);
  69720. }
  69721. /**
  69722. * Interface used to define a simplification task
  69723. */
  69724. export interface ISimplificationTask {
  69725. /**
  69726. * Array of settings
  69727. */
  69728. settings: Array<ISimplificationSettings>;
  69729. /**
  69730. * Simplification type
  69731. */
  69732. simplificationType: SimplificationType;
  69733. /**
  69734. * Mesh to simplify
  69735. */
  69736. mesh: Mesh;
  69737. /**
  69738. * Callback called on success
  69739. */
  69740. successCallback?: () => void;
  69741. /**
  69742. * Defines if parallel processing can be used
  69743. */
  69744. parallelProcessing: boolean;
  69745. }
  69746. /**
  69747. * Queue used to order the simplification tasks
  69748. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69749. */
  69750. export class SimplificationQueue {
  69751. private _simplificationArray;
  69752. /**
  69753. * Gets a boolean indicating that the process is still running
  69754. */
  69755. running: boolean;
  69756. /**
  69757. * Creates a new queue
  69758. */
  69759. constructor();
  69760. /**
  69761. * Adds a new simplification task
  69762. * @param task defines a task to add
  69763. */
  69764. addTask(task: ISimplificationTask): void;
  69765. /**
  69766. * Execute next task
  69767. */
  69768. executeNext(): void;
  69769. /**
  69770. * Execute a simplification task
  69771. * @param task defines the task to run
  69772. */
  69773. runSimplification(task: ISimplificationTask): void;
  69774. private getSimplifier;
  69775. }
  69776. /**
  69777. * The implemented types of simplification
  69778. * At the moment only Quadratic Error Decimation is implemented
  69779. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69780. */
  69781. export enum SimplificationType {
  69782. /** Quadratic error decimation */
  69783. QUADRATIC = 0
  69784. }
  69785. /**
  69786. * An implementation of the Quadratic Error simplification algorithm.
  69787. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69788. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69789. * @author RaananW
  69790. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69791. */
  69792. export class QuadraticErrorSimplification implements ISimplifier {
  69793. private _mesh;
  69794. private triangles;
  69795. private vertices;
  69796. private references;
  69797. private _reconstructedMesh;
  69798. /** Gets or sets the number pf sync interations */
  69799. syncIterations: number;
  69800. /** Gets or sets the aggressiveness of the simplifier */
  69801. aggressiveness: number;
  69802. /** Gets or sets the number of allowed iterations for decimation */
  69803. decimationIterations: number;
  69804. /** Gets or sets the espilon to use for bounding box computation */
  69805. boundingBoxEpsilon: number;
  69806. /**
  69807. * Creates a new QuadraticErrorSimplification
  69808. * @param _mesh defines the target mesh
  69809. */
  69810. constructor(_mesh: Mesh);
  69811. /**
  69812. * Simplification of a given mesh according to the given settings.
  69813. * Since this requires computation, it is assumed that the function runs async.
  69814. * @param settings The settings of the simplification, including quality and distance
  69815. * @param successCallback A callback that will be called after the mesh was simplified.
  69816. */
  69817. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69818. private runDecimation;
  69819. private initWithMesh;
  69820. private init;
  69821. private reconstructMesh;
  69822. private initDecimatedMesh;
  69823. private isFlipped;
  69824. private updateTriangles;
  69825. private identifyBorder;
  69826. private updateMesh;
  69827. private vertexError;
  69828. private calculateError;
  69829. }
  69830. }
  69831. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69832. import { Scene } from "babylonjs/scene";
  69833. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69834. import { ISceneComponent } from "babylonjs/sceneComponent";
  69835. module "babylonjs/scene" {
  69836. interface Scene {
  69837. /** @hidden (Backing field) */
  69838. _simplificationQueue: SimplificationQueue;
  69839. /**
  69840. * Gets or sets the simplification queue attached to the scene
  69841. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69842. */
  69843. simplificationQueue: SimplificationQueue;
  69844. }
  69845. }
  69846. module "babylonjs/Meshes/mesh" {
  69847. interface Mesh {
  69848. /**
  69849. * Simplify the mesh according to the given array of settings.
  69850. * Function will return immediately and will simplify async
  69851. * @param settings a collection of simplification settings
  69852. * @param parallelProcessing should all levels calculate parallel or one after the other
  69853. * @param simplificationType the type of simplification to run
  69854. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69855. * @returns the current mesh
  69856. */
  69857. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69858. }
  69859. }
  69860. /**
  69861. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69862. * created in a scene
  69863. */
  69864. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69865. /**
  69866. * The component name helpfull to identify the component in the list of scene components.
  69867. */
  69868. readonly name: string;
  69869. /**
  69870. * The scene the component belongs to.
  69871. */
  69872. scene: Scene;
  69873. /**
  69874. * Creates a new instance of the component for the given scene
  69875. * @param scene Defines the scene to register the component in
  69876. */
  69877. constructor(scene: Scene);
  69878. /**
  69879. * Registers the component in a given scene
  69880. */
  69881. register(): void;
  69882. /**
  69883. * Rebuilds the elements related to this component in case of
  69884. * context lost for instance.
  69885. */
  69886. rebuild(): void;
  69887. /**
  69888. * Disposes the component and the associated ressources
  69889. */
  69890. dispose(): void;
  69891. private _beforeCameraUpdate;
  69892. }
  69893. }
  69894. declare module "babylonjs/Meshes/Builders/index" {
  69895. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69896. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69897. export * from "babylonjs/Meshes/Builders/discBuilder";
  69898. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69899. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69900. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69901. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69902. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69903. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69904. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69905. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69906. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69907. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69908. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69909. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69910. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69911. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69912. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69913. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69914. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69915. }
  69916. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69917. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69918. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69919. import { Matrix } from "babylonjs/Maths/math.vector";
  69920. module "babylonjs/Meshes/mesh" {
  69921. interface Mesh {
  69922. /**
  69923. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69924. */
  69925. thinInstanceEnablePicking: boolean;
  69926. /**
  69927. * Creates a new thin instance
  69928. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69929. * @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
  69930. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69931. */
  69932. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69933. /**
  69934. * Adds the transformation (matrix) of the current mesh as a thin instance
  69935. * @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
  69936. * @returns the thin instance index number
  69937. */
  69938. thinInstanceAddSelf(refresh: boolean): number;
  69939. /**
  69940. * Registers a custom attribute to be used with thin instances
  69941. * @param kind name of the attribute
  69942. * @param stride size in floats of the attribute
  69943. */
  69944. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69945. /**
  69946. * Sets the matrix of a thin instance
  69947. * @param index index of the thin instance
  69948. * @param matrix matrix to set
  69949. * @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
  69950. */
  69951. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69952. /**
  69953. * Sets the value of a custom attribute for a thin instance
  69954. * @param kind name of the attribute
  69955. * @param index index of the thin instance
  69956. * @param value value to set
  69957. * @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
  69958. */
  69959. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69960. /**
  69961. * 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.
  69962. */
  69963. thinInstanceCount: number;
  69964. /**
  69965. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69966. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69967. * @param buffer buffer to set
  69968. * @param stride size in floats of each value of the buffer
  69969. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69970. */
  69971. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69972. /**
  69973. * Gets the list of world matrices
  69974. * @return an array containing all the world matrices from the thin instances
  69975. */
  69976. thinInstanceGetWorldMatrices(): Matrix[];
  69977. /**
  69978. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69979. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69980. */
  69981. thinInstanceBufferUpdated(kind: string): void;
  69982. /**
  69983. * Refreshes the bounding info, taking into account all the thin instances defined
  69984. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69985. */
  69986. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69987. /** @hidden */
  69988. _thinInstanceInitializeUserStorage(): void;
  69989. /** @hidden */
  69990. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69991. /** @hidden */
  69992. _userThinInstanceBuffersStorage: {
  69993. data: {
  69994. [key: string]: Float32Array;
  69995. };
  69996. sizes: {
  69997. [key: string]: number;
  69998. };
  69999. vertexBuffers: {
  70000. [key: string]: Nullable<VertexBuffer>;
  70001. };
  70002. strides: {
  70003. [key: string]: number;
  70004. };
  70005. };
  70006. }
  70007. }
  70008. }
  70009. declare module "babylonjs/Meshes/index" {
  70010. export * from "babylonjs/Meshes/abstractMesh";
  70011. export * from "babylonjs/Meshes/buffer";
  70012. export * from "babylonjs/Meshes/Compression/index";
  70013. export * from "babylonjs/Meshes/csg";
  70014. export * from "babylonjs/Meshes/geometry";
  70015. export * from "babylonjs/Meshes/groundMesh";
  70016. export * from "babylonjs/Meshes/trailMesh";
  70017. export * from "babylonjs/Meshes/instancedMesh";
  70018. export * from "babylonjs/Meshes/linesMesh";
  70019. export * from "babylonjs/Meshes/mesh";
  70020. export * from "babylonjs/Meshes/mesh.vertexData";
  70021. export * from "babylonjs/Meshes/meshBuilder";
  70022. export * from "babylonjs/Meshes/meshSimplification";
  70023. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70024. export * from "babylonjs/Meshes/polygonMesh";
  70025. export * from "babylonjs/Meshes/subMesh";
  70026. export * from "babylonjs/Meshes/meshLODLevel";
  70027. export * from "babylonjs/Meshes/transformNode";
  70028. export * from "babylonjs/Meshes/Builders/index";
  70029. export * from "babylonjs/Meshes/dataBuffer";
  70030. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70031. import "babylonjs/Meshes/thinInstanceMesh";
  70032. export * from "babylonjs/Meshes/thinInstanceMesh";
  70033. }
  70034. declare module "babylonjs/Morph/index" {
  70035. export * from "babylonjs/Morph/morphTarget";
  70036. export * from "babylonjs/Morph/morphTargetManager";
  70037. }
  70038. declare module "babylonjs/Navigation/INavigationEngine" {
  70039. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70040. import { Vector3 } from "babylonjs/Maths/math";
  70041. import { Mesh } from "babylonjs/Meshes/mesh";
  70042. import { Scene } from "babylonjs/scene";
  70043. /**
  70044. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70045. */
  70046. export interface INavigationEnginePlugin {
  70047. /**
  70048. * plugin name
  70049. */
  70050. name: string;
  70051. /**
  70052. * Creates a navigation mesh
  70053. * @param meshes array of all the geometry used to compute the navigatio mesh
  70054. * @param parameters bunch of parameters used to filter geometry
  70055. */
  70056. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70057. /**
  70058. * Create a navigation mesh debug mesh
  70059. * @param scene is where the mesh will be added
  70060. * @returns debug display mesh
  70061. */
  70062. createDebugNavMesh(scene: Scene): Mesh;
  70063. /**
  70064. * Get a navigation mesh constrained position, closest to the parameter position
  70065. * @param position world position
  70066. * @returns the closest point to position constrained by the navigation mesh
  70067. */
  70068. getClosestPoint(position: Vector3): Vector3;
  70069. /**
  70070. * Get a navigation mesh constrained position, closest to the parameter position
  70071. * @param position world position
  70072. * @param result output the closest point to position constrained by the navigation mesh
  70073. */
  70074. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70075. /**
  70076. * Get a navigation mesh constrained position, within a particular radius
  70077. * @param position world position
  70078. * @param maxRadius the maximum distance to the constrained world position
  70079. * @returns the closest point to position constrained by the navigation mesh
  70080. */
  70081. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70082. /**
  70083. * Get a navigation mesh constrained position, within a particular radius
  70084. * @param position world position
  70085. * @param maxRadius the maximum distance to the constrained world position
  70086. * @param result output the closest point to position constrained by the navigation mesh
  70087. */
  70088. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70089. /**
  70090. * Compute the final position from a segment made of destination-position
  70091. * @param position world position
  70092. * @param destination world position
  70093. * @returns the resulting point along the navmesh
  70094. */
  70095. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70096. /**
  70097. * Compute the final position from a segment made of destination-position
  70098. * @param position world position
  70099. * @param destination world position
  70100. * @param result output the resulting point along the navmesh
  70101. */
  70102. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70103. /**
  70104. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70105. * @param start world position
  70106. * @param end world position
  70107. * @returns array containing world position composing the path
  70108. */
  70109. computePath(start: Vector3, end: Vector3): Vector3[];
  70110. /**
  70111. * If this plugin is supported
  70112. * @returns true if plugin is supported
  70113. */
  70114. isSupported(): boolean;
  70115. /**
  70116. * Create a new Crowd so you can add agents
  70117. * @param maxAgents the maximum agent count in the crowd
  70118. * @param maxAgentRadius the maximum radius an agent can have
  70119. * @param scene to attach the crowd to
  70120. * @returns the crowd you can add agents to
  70121. */
  70122. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70123. /**
  70124. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70125. * The queries will try to find a solution within those bounds
  70126. * default is (1,1,1)
  70127. * @param extent x,y,z value that define the extent around the queries point of reference
  70128. */
  70129. setDefaultQueryExtent(extent: Vector3): void;
  70130. /**
  70131. * Get the Bounding box extent specified by setDefaultQueryExtent
  70132. * @returns the box extent values
  70133. */
  70134. getDefaultQueryExtent(): Vector3;
  70135. /**
  70136. * build the navmesh from a previously saved state using getNavmeshData
  70137. * @param data the Uint8Array returned by getNavmeshData
  70138. */
  70139. buildFromNavmeshData(data: Uint8Array): void;
  70140. /**
  70141. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70142. * @returns data the Uint8Array that can be saved and reused
  70143. */
  70144. getNavmeshData(): Uint8Array;
  70145. /**
  70146. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70147. * @param result output the box extent values
  70148. */
  70149. getDefaultQueryExtentToRef(result: Vector3): void;
  70150. /**
  70151. * Release all resources
  70152. */
  70153. dispose(): void;
  70154. }
  70155. /**
  70156. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70157. */
  70158. export interface ICrowd {
  70159. /**
  70160. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70161. * You can attach anything to that node. The node position is updated in the scene update tick.
  70162. * @param pos world position that will be constrained by the navigation mesh
  70163. * @param parameters agent parameters
  70164. * @param transform hooked to the agent that will be update by the scene
  70165. * @returns agent index
  70166. */
  70167. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70168. /**
  70169. * Returns the agent position in world space
  70170. * @param index agent index returned by addAgent
  70171. * @returns world space position
  70172. */
  70173. getAgentPosition(index: number): Vector3;
  70174. /**
  70175. * Gets the agent position result in world space
  70176. * @param index agent index returned by addAgent
  70177. * @param result output world space position
  70178. */
  70179. getAgentPositionToRef(index: number, result: Vector3): void;
  70180. /**
  70181. * Gets the agent velocity in world space
  70182. * @param index agent index returned by addAgent
  70183. * @returns world space velocity
  70184. */
  70185. getAgentVelocity(index: number): Vector3;
  70186. /**
  70187. * Gets the agent velocity result in world space
  70188. * @param index agent index returned by addAgent
  70189. * @param result output world space velocity
  70190. */
  70191. getAgentVelocityToRef(index: number, result: Vector3): void;
  70192. /**
  70193. * remove a particular agent previously created
  70194. * @param index agent index returned by addAgent
  70195. */
  70196. removeAgent(index: number): void;
  70197. /**
  70198. * get the list of all agents attached to this crowd
  70199. * @returns list of agent indices
  70200. */
  70201. getAgents(): number[];
  70202. /**
  70203. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70204. * @param deltaTime in seconds
  70205. */
  70206. update(deltaTime: number): void;
  70207. /**
  70208. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70209. * @param index agent index returned by addAgent
  70210. * @param destination targeted world position
  70211. */
  70212. agentGoto(index: number, destination: Vector3): void;
  70213. /**
  70214. * Teleport the agent to a new position
  70215. * @param index agent index returned by addAgent
  70216. * @param destination targeted world position
  70217. */
  70218. agentTeleport(index: number, destination: Vector3): void;
  70219. /**
  70220. * Update agent parameters
  70221. * @param index agent index returned by addAgent
  70222. * @param parameters agent parameters
  70223. */
  70224. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70225. /**
  70226. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70227. * The queries will try to find a solution within those bounds
  70228. * default is (1,1,1)
  70229. * @param extent x,y,z value that define the extent around the queries point of reference
  70230. */
  70231. setDefaultQueryExtent(extent: Vector3): void;
  70232. /**
  70233. * Get the Bounding box extent specified by setDefaultQueryExtent
  70234. * @returns the box extent values
  70235. */
  70236. getDefaultQueryExtent(): Vector3;
  70237. /**
  70238. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70239. * @param result output the box extent values
  70240. */
  70241. getDefaultQueryExtentToRef(result: Vector3): void;
  70242. /**
  70243. * Release all resources
  70244. */
  70245. dispose(): void;
  70246. }
  70247. /**
  70248. * Configures an agent
  70249. */
  70250. export interface IAgentParameters {
  70251. /**
  70252. * Agent radius. [Limit: >= 0]
  70253. */
  70254. radius: number;
  70255. /**
  70256. * Agent height. [Limit: > 0]
  70257. */
  70258. height: number;
  70259. /**
  70260. * Maximum allowed acceleration. [Limit: >= 0]
  70261. */
  70262. maxAcceleration: number;
  70263. /**
  70264. * Maximum allowed speed. [Limit: >= 0]
  70265. */
  70266. maxSpeed: number;
  70267. /**
  70268. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70269. */
  70270. collisionQueryRange: number;
  70271. /**
  70272. * The path visibility optimization range. [Limit: > 0]
  70273. */
  70274. pathOptimizationRange: number;
  70275. /**
  70276. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70277. */
  70278. separationWeight: number;
  70279. }
  70280. /**
  70281. * Configures the navigation mesh creation
  70282. */
  70283. export interface INavMeshParameters {
  70284. /**
  70285. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70286. */
  70287. cs: number;
  70288. /**
  70289. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70290. */
  70291. ch: number;
  70292. /**
  70293. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70294. */
  70295. walkableSlopeAngle: number;
  70296. /**
  70297. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70298. * be considered walkable. [Limit: >= 3] [Units: vx]
  70299. */
  70300. walkableHeight: number;
  70301. /**
  70302. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70303. */
  70304. walkableClimb: number;
  70305. /**
  70306. * The distance to erode/shrink the walkable area of the heightfield away from
  70307. * obstructions. [Limit: >=0] [Units: vx]
  70308. */
  70309. walkableRadius: number;
  70310. /**
  70311. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70312. */
  70313. maxEdgeLen: number;
  70314. /**
  70315. * The maximum distance a simplfied contour's border edges should deviate
  70316. * the original raw contour. [Limit: >=0] [Units: vx]
  70317. */
  70318. maxSimplificationError: number;
  70319. /**
  70320. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70321. */
  70322. minRegionArea: number;
  70323. /**
  70324. * Any regions with a span count smaller than this value will, if possible,
  70325. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70326. */
  70327. mergeRegionArea: number;
  70328. /**
  70329. * The maximum number of vertices allowed for polygons generated during the
  70330. * contour to polygon conversion process. [Limit: >= 3]
  70331. */
  70332. maxVertsPerPoly: number;
  70333. /**
  70334. * Sets the sampling distance to use when generating the detail mesh.
  70335. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70336. */
  70337. detailSampleDist: number;
  70338. /**
  70339. * The maximum distance the detail mesh surface should deviate from heightfield
  70340. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70341. */
  70342. detailSampleMaxError: number;
  70343. }
  70344. }
  70345. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70346. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70347. import { Mesh } from "babylonjs/Meshes/mesh";
  70348. import { Scene } from "babylonjs/scene";
  70349. import { Vector3 } from "babylonjs/Maths/math";
  70350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70351. /**
  70352. * RecastJS navigation plugin
  70353. */
  70354. export class RecastJSPlugin implements INavigationEnginePlugin {
  70355. /**
  70356. * Reference to the Recast library
  70357. */
  70358. bjsRECAST: any;
  70359. /**
  70360. * plugin name
  70361. */
  70362. name: string;
  70363. /**
  70364. * the first navmesh created. We might extend this to support multiple navmeshes
  70365. */
  70366. navMesh: any;
  70367. /**
  70368. * Initializes the recastJS plugin
  70369. * @param recastInjection can be used to inject your own recast reference
  70370. */
  70371. constructor(recastInjection?: any);
  70372. /**
  70373. * Creates a navigation mesh
  70374. * @param meshes array of all the geometry used to compute the navigatio mesh
  70375. * @param parameters bunch of parameters used to filter geometry
  70376. */
  70377. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70378. /**
  70379. * Create a navigation mesh debug mesh
  70380. * @param scene is where the mesh will be added
  70381. * @returns debug display mesh
  70382. */
  70383. createDebugNavMesh(scene: Scene): Mesh;
  70384. /**
  70385. * Get a navigation mesh constrained position, closest to the parameter position
  70386. * @param position world position
  70387. * @returns the closest point to position constrained by the navigation mesh
  70388. */
  70389. getClosestPoint(position: Vector3): Vector3;
  70390. /**
  70391. * Get a navigation mesh constrained position, closest to the parameter position
  70392. * @param position world position
  70393. * @param result output the closest point to position constrained by the navigation mesh
  70394. */
  70395. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70396. /**
  70397. * Get a navigation mesh constrained position, within a particular radius
  70398. * @param position world position
  70399. * @param maxRadius the maximum distance to the constrained world position
  70400. * @returns the closest point to position constrained by the navigation mesh
  70401. */
  70402. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70403. /**
  70404. * Get a navigation mesh constrained position, within a particular radius
  70405. * @param position world position
  70406. * @param maxRadius the maximum distance to the constrained world position
  70407. * @param result output the closest point to position constrained by the navigation mesh
  70408. */
  70409. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70410. /**
  70411. * Compute the final position from a segment made of destination-position
  70412. * @param position world position
  70413. * @param destination world position
  70414. * @returns the resulting point along the navmesh
  70415. */
  70416. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70417. /**
  70418. * Compute the final position from a segment made of destination-position
  70419. * @param position world position
  70420. * @param destination world position
  70421. * @param result output the resulting point along the navmesh
  70422. */
  70423. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70424. /**
  70425. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70426. * @param start world position
  70427. * @param end world position
  70428. * @returns array containing world position composing the path
  70429. */
  70430. computePath(start: Vector3, end: Vector3): Vector3[];
  70431. /**
  70432. * Create a new Crowd so you can add agents
  70433. * @param maxAgents the maximum agent count in the crowd
  70434. * @param maxAgentRadius the maximum radius an agent can have
  70435. * @param scene to attach the crowd to
  70436. * @returns the crowd you can add agents to
  70437. */
  70438. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70439. /**
  70440. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70441. * The queries will try to find a solution within those bounds
  70442. * default is (1,1,1)
  70443. * @param extent x,y,z value that define the extent around the queries point of reference
  70444. */
  70445. setDefaultQueryExtent(extent: Vector3): void;
  70446. /**
  70447. * Get the Bounding box extent specified by setDefaultQueryExtent
  70448. * @returns the box extent values
  70449. */
  70450. getDefaultQueryExtent(): Vector3;
  70451. /**
  70452. * build the navmesh from a previously saved state using getNavmeshData
  70453. * @param data the Uint8Array returned by getNavmeshData
  70454. */
  70455. buildFromNavmeshData(data: Uint8Array): void;
  70456. /**
  70457. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70458. * @returns data the Uint8Array that can be saved and reused
  70459. */
  70460. getNavmeshData(): Uint8Array;
  70461. /**
  70462. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70463. * @param result output the box extent values
  70464. */
  70465. getDefaultQueryExtentToRef(result: Vector3): void;
  70466. /**
  70467. * Disposes
  70468. */
  70469. dispose(): void;
  70470. /**
  70471. * If this plugin is supported
  70472. * @returns true if plugin is supported
  70473. */
  70474. isSupported(): boolean;
  70475. }
  70476. /**
  70477. * Recast detour crowd implementation
  70478. */
  70479. export class RecastJSCrowd implements ICrowd {
  70480. /**
  70481. * Recast/detour plugin
  70482. */
  70483. bjsRECASTPlugin: RecastJSPlugin;
  70484. /**
  70485. * Link to the detour crowd
  70486. */
  70487. recastCrowd: any;
  70488. /**
  70489. * One transform per agent
  70490. */
  70491. transforms: TransformNode[];
  70492. /**
  70493. * All agents created
  70494. */
  70495. agents: number[];
  70496. /**
  70497. * Link to the scene is kept to unregister the crowd from the scene
  70498. */
  70499. private _scene;
  70500. /**
  70501. * Observer for crowd updates
  70502. */
  70503. private _onBeforeAnimationsObserver;
  70504. /**
  70505. * Constructor
  70506. * @param plugin recastJS plugin
  70507. * @param maxAgents the maximum agent count in the crowd
  70508. * @param maxAgentRadius the maximum radius an agent can have
  70509. * @param scene to attach the crowd to
  70510. * @returns the crowd you can add agents to
  70511. */
  70512. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70513. /**
  70514. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70515. * You can attach anything to that node. The node position is updated in the scene update tick.
  70516. * @param pos world position that will be constrained by the navigation mesh
  70517. * @param parameters agent parameters
  70518. * @param transform hooked to the agent that will be update by the scene
  70519. * @returns agent index
  70520. */
  70521. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70522. /**
  70523. * Returns the agent position in world space
  70524. * @param index agent index returned by addAgent
  70525. * @returns world space position
  70526. */
  70527. getAgentPosition(index: number): Vector3;
  70528. /**
  70529. * Returns the agent position result in world space
  70530. * @param index agent index returned by addAgent
  70531. * @param result output world space position
  70532. */
  70533. getAgentPositionToRef(index: number, result: Vector3): void;
  70534. /**
  70535. * Returns the agent velocity in world space
  70536. * @param index agent index returned by addAgent
  70537. * @returns world space velocity
  70538. */
  70539. getAgentVelocity(index: number): Vector3;
  70540. /**
  70541. * Returns the agent velocity result in world space
  70542. * @param index agent index returned by addAgent
  70543. * @param result output world space velocity
  70544. */
  70545. getAgentVelocityToRef(index: number, result: Vector3): void;
  70546. /**
  70547. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70548. * @param index agent index returned by addAgent
  70549. * @param destination targeted world position
  70550. */
  70551. agentGoto(index: number, destination: Vector3): void;
  70552. /**
  70553. * Teleport the agent to a new position
  70554. * @param index agent index returned by addAgent
  70555. * @param destination targeted world position
  70556. */
  70557. agentTeleport(index: number, destination: Vector3): void;
  70558. /**
  70559. * Update agent parameters
  70560. * @param index agent index returned by addAgent
  70561. * @param parameters agent parameters
  70562. */
  70563. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70564. /**
  70565. * remove a particular agent previously created
  70566. * @param index agent index returned by addAgent
  70567. */
  70568. removeAgent(index: number): void;
  70569. /**
  70570. * get the list of all agents attached to this crowd
  70571. * @returns list of agent indices
  70572. */
  70573. getAgents(): number[];
  70574. /**
  70575. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70576. * @param deltaTime in seconds
  70577. */
  70578. update(deltaTime: number): void;
  70579. /**
  70580. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70581. * The queries will try to find a solution within those bounds
  70582. * default is (1,1,1)
  70583. * @param extent x,y,z value that define the extent around the queries point of reference
  70584. */
  70585. setDefaultQueryExtent(extent: Vector3): void;
  70586. /**
  70587. * Get the Bounding box extent specified by setDefaultQueryExtent
  70588. * @returns the box extent values
  70589. */
  70590. getDefaultQueryExtent(): Vector3;
  70591. /**
  70592. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70593. * @param result output the box extent values
  70594. */
  70595. getDefaultQueryExtentToRef(result: Vector3): void;
  70596. /**
  70597. * Release all resources
  70598. */
  70599. dispose(): void;
  70600. }
  70601. }
  70602. declare module "babylonjs/Navigation/Plugins/index" {
  70603. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70604. }
  70605. declare module "babylonjs/Navigation/index" {
  70606. export * from "babylonjs/Navigation/INavigationEngine";
  70607. export * from "babylonjs/Navigation/Plugins/index";
  70608. }
  70609. declare module "babylonjs/Offline/database" {
  70610. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70611. /**
  70612. * Class used to enable access to IndexedDB
  70613. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70614. */
  70615. export class Database implements IOfflineProvider {
  70616. private _callbackManifestChecked;
  70617. private _currentSceneUrl;
  70618. private _db;
  70619. private _enableSceneOffline;
  70620. private _enableTexturesOffline;
  70621. private _manifestVersionFound;
  70622. private _mustUpdateRessources;
  70623. private _hasReachedQuota;
  70624. private _isSupported;
  70625. private _idbFactory;
  70626. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70627. private static IsUASupportingBlobStorage;
  70628. /**
  70629. * Gets a boolean indicating if Database storate is enabled (off by default)
  70630. */
  70631. static IDBStorageEnabled: boolean;
  70632. /**
  70633. * Gets a boolean indicating if scene must be saved in the database
  70634. */
  70635. get enableSceneOffline(): boolean;
  70636. /**
  70637. * Gets a boolean indicating if textures must be saved in the database
  70638. */
  70639. get enableTexturesOffline(): boolean;
  70640. /**
  70641. * Creates a new Database
  70642. * @param urlToScene defines the url to load the scene
  70643. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70644. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70645. */
  70646. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70647. private static _ParseURL;
  70648. private static _ReturnFullUrlLocation;
  70649. private _checkManifestFile;
  70650. /**
  70651. * Open the database and make it available
  70652. * @param successCallback defines the callback to call on success
  70653. * @param errorCallback defines the callback to call on error
  70654. */
  70655. open(successCallback: () => void, errorCallback: () => void): void;
  70656. /**
  70657. * Loads an image from the database
  70658. * @param url defines the url to load from
  70659. * @param image defines the target DOM image
  70660. */
  70661. loadImage(url: string, image: HTMLImageElement): void;
  70662. private _loadImageFromDBAsync;
  70663. private _saveImageIntoDBAsync;
  70664. private _checkVersionFromDB;
  70665. private _loadVersionFromDBAsync;
  70666. private _saveVersionIntoDBAsync;
  70667. /**
  70668. * Loads a file from database
  70669. * @param url defines the URL to load from
  70670. * @param sceneLoaded defines a callback to call on success
  70671. * @param progressCallBack defines a callback to call when progress changed
  70672. * @param errorCallback defines a callback to call on error
  70673. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70674. */
  70675. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70676. private _loadFileAsync;
  70677. private _saveFileAsync;
  70678. /**
  70679. * Validates if xhr data is correct
  70680. * @param xhr defines the request to validate
  70681. * @param dataType defines the expected data type
  70682. * @returns true if data is correct
  70683. */
  70684. private static _ValidateXHRData;
  70685. }
  70686. }
  70687. declare module "babylonjs/Offline/index" {
  70688. export * from "babylonjs/Offline/database";
  70689. export * from "babylonjs/Offline/IOfflineProvider";
  70690. }
  70691. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70692. /** @hidden */
  70693. export var gpuUpdateParticlesPixelShader: {
  70694. name: string;
  70695. shader: string;
  70696. };
  70697. }
  70698. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70699. /** @hidden */
  70700. export var gpuUpdateParticlesVertexShader: {
  70701. name: string;
  70702. shader: string;
  70703. };
  70704. }
  70705. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70706. /** @hidden */
  70707. export var clipPlaneFragmentDeclaration2: {
  70708. name: string;
  70709. shader: string;
  70710. };
  70711. }
  70712. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70713. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70714. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70718. /** @hidden */
  70719. export var gpuRenderParticlesPixelShader: {
  70720. name: string;
  70721. shader: string;
  70722. };
  70723. }
  70724. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70725. /** @hidden */
  70726. export var clipPlaneVertexDeclaration2: {
  70727. name: string;
  70728. shader: string;
  70729. };
  70730. }
  70731. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70734. /** @hidden */
  70735. export var gpuRenderParticlesVertexShader: {
  70736. name: string;
  70737. shader: string;
  70738. };
  70739. }
  70740. declare module "babylonjs/Particles/gpuParticleSystem" {
  70741. import { Nullable } from "babylonjs/types";
  70742. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70743. import { Observable } from "babylonjs/Misc/observable";
  70744. import { Matrix } from "babylonjs/Maths/math.vector";
  70745. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70746. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70747. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70748. import { IDisposable } from "babylonjs/scene";
  70749. import { Effect } from "babylonjs/Materials/effect";
  70750. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70752. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70753. import { Scene } from "babylonjs/scene";
  70754. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70755. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70756. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70757. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70758. /**
  70759. * This represents a GPU particle system in Babylon
  70760. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70761. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70762. */
  70763. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70764. /**
  70765. * The layer mask we are rendering the particles through.
  70766. */
  70767. layerMask: number;
  70768. private _capacity;
  70769. private _activeCount;
  70770. private _currentActiveCount;
  70771. private _accumulatedCount;
  70772. private _renderEffect;
  70773. private _updateEffect;
  70774. private _buffer0;
  70775. private _buffer1;
  70776. private _spriteBuffer;
  70777. private _updateVAO;
  70778. private _renderVAO;
  70779. private _targetIndex;
  70780. private _sourceBuffer;
  70781. private _targetBuffer;
  70782. private _currentRenderId;
  70783. private _started;
  70784. private _stopped;
  70785. private _timeDelta;
  70786. private _randomTexture;
  70787. private _randomTexture2;
  70788. private _attributesStrideSize;
  70789. private _updateEffectOptions;
  70790. private _randomTextureSize;
  70791. private _actualFrame;
  70792. private _customEffect;
  70793. private readonly _rawTextureWidth;
  70794. /**
  70795. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70796. */
  70797. static get IsSupported(): boolean;
  70798. /**
  70799. * An event triggered when the system is disposed.
  70800. */
  70801. onDisposeObservable: Observable<IParticleSystem>;
  70802. /**
  70803. * Gets the maximum number of particles active at the same time.
  70804. * @returns The max number of active particles.
  70805. */
  70806. getCapacity(): number;
  70807. /**
  70808. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70809. * to override the particles.
  70810. */
  70811. forceDepthWrite: boolean;
  70812. /**
  70813. * Gets or set the number of active particles
  70814. */
  70815. get activeParticleCount(): number;
  70816. set activeParticleCount(value: number);
  70817. private _preWarmDone;
  70818. /**
  70819. * Specifies if the particles are updated in emitter local space or world space.
  70820. */
  70821. isLocal: boolean;
  70822. /** Gets or sets a matrix to use to compute projection */
  70823. defaultProjectionMatrix: Matrix;
  70824. /**
  70825. * Is this system ready to be used/rendered
  70826. * @return true if the system is ready
  70827. */
  70828. isReady(): boolean;
  70829. /**
  70830. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70831. * @returns True if it has been started, otherwise false.
  70832. */
  70833. isStarted(): boolean;
  70834. /**
  70835. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70836. * @returns True if it has been stopped, otherwise false.
  70837. */
  70838. isStopped(): boolean;
  70839. /**
  70840. * Gets a boolean indicating that the system is stopping
  70841. * @returns true if the system is currently stopping
  70842. */
  70843. isStopping(): boolean;
  70844. /**
  70845. * Gets the number of particles active at the same time.
  70846. * @returns The number of active particles.
  70847. */
  70848. getActiveCount(): number;
  70849. /**
  70850. * Starts the particle system and begins to emit
  70851. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70852. */
  70853. start(delay?: number): void;
  70854. /**
  70855. * Stops the particle system.
  70856. */
  70857. stop(): void;
  70858. /**
  70859. * Remove all active particles
  70860. */
  70861. reset(): void;
  70862. /**
  70863. * Returns the string "GPUParticleSystem"
  70864. * @returns a string containing the class name
  70865. */
  70866. getClassName(): string;
  70867. /**
  70868. * Gets the custom effect used to render the particles
  70869. * @param blendMode Blend mode for which the effect should be retrieved
  70870. * @returns The effect
  70871. */
  70872. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70873. /**
  70874. * Sets the custom effect used to render the particles
  70875. * @param effect The effect to set
  70876. * @param blendMode Blend mode for which the effect should be set
  70877. */
  70878. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70879. /** @hidden */
  70880. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70881. /**
  70882. * Observable that will be called just before the particles are drawn
  70883. */
  70884. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70885. /**
  70886. * Gets the name of the particle vertex shader
  70887. */
  70888. get vertexShaderName(): string;
  70889. private _colorGradientsTexture;
  70890. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70891. /**
  70892. * Adds a new color gradient
  70893. * @param gradient defines the gradient to use (between 0 and 1)
  70894. * @param color1 defines the color to affect to the specified gradient
  70895. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70896. * @returns the current particle system
  70897. */
  70898. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70899. private _refreshColorGradient;
  70900. /** Force the system to rebuild all gradients that need to be resync */
  70901. forceRefreshGradients(): void;
  70902. /**
  70903. * Remove a specific color gradient
  70904. * @param gradient defines the gradient to remove
  70905. * @returns the current particle system
  70906. */
  70907. removeColorGradient(gradient: number): GPUParticleSystem;
  70908. private _angularSpeedGradientsTexture;
  70909. private _sizeGradientsTexture;
  70910. private _velocityGradientsTexture;
  70911. private _limitVelocityGradientsTexture;
  70912. private _dragGradientsTexture;
  70913. private _addFactorGradient;
  70914. /**
  70915. * Adds a new size gradient
  70916. * @param gradient defines the gradient to use (between 0 and 1)
  70917. * @param factor defines the size factor to affect to the specified gradient
  70918. * @returns the current particle system
  70919. */
  70920. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70921. /**
  70922. * Remove a specific size gradient
  70923. * @param gradient defines the gradient to remove
  70924. * @returns the current particle system
  70925. */
  70926. removeSizeGradient(gradient: number): GPUParticleSystem;
  70927. private _refreshFactorGradient;
  70928. /**
  70929. * Adds a new angular speed gradient
  70930. * @param gradient defines the gradient to use (between 0 and 1)
  70931. * @param factor defines the angular speed to affect to the specified gradient
  70932. * @returns the current particle system
  70933. */
  70934. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70935. /**
  70936. * Remove a specific angular speed gradient
  70937. * @param gradient defines the gradient to remove
  70938. * @returns the current particle system
  70939. */
  70940. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70941. /**
  70942. * Adds a new velocity gradient
  70943. * @param gradient defines the gradient to use (between 0 and 1)
  70944. * @param factor defines the velocity to affect to the specified gradient
  70945. * @returns the current particle system
  70946. */
  70947. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70948. /**
  70949. * Remove a specific velocity gradient
  70950. * @param gradient defines the gradient to remove
  70951. * @returns the current particle system
  70952. */
  70953. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70954. /**
  70955. * Adds a new limit velocity gradient
  70956. * @param gradient defines the gradient to use (between 0 and 1)
  70957. * @param factor defines the limit velocity value to affect to the specified gradient
  70958. * @returns the current particle system
  70959. */
  70960. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70961. /**
  70962. * Remove a specific limit velocity gradient
  70963. * @param gradient defines the gradient to remove
  70964. * @returns the current particle system
  70965. */
  70966. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70967. /**
  70968. * Adds a new drag gradient
  70969. * @param gradient defines the gradient to use (between 0 and 1)
  70970. * @param factor defines the drag value to affect to the specified gradient
  70971. * @returns the current particle system
  70972. */
  70973. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70974. /**
  70975. * Remove a specific drag gradient
  70976. * @param gradient defines the gradient to remove
  70977. * @returns the current particle system
  70978. */
  70979. removeDragGradient(gradient: number): GPUParticleSystem;
  70980. /**
  70981. * Not supported by GPUParticleSystem
  70982. * @param gradient defines the gradient to use (between 0 and 1)
  70983. * @param factor defines the emit rate value to affect to the specified gradient
  70984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70985. * @returns the current particle system
  70986. */
  70987. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70988. /**
  70989. * Not supported by GPUParticleSystem
  70990. * @param gradient defines the gradient to remove
  70991. * @returns the current particle system
  70992. */
  70993. removeEmitRateGradient(gradient: number): IParticleSystem;
  70994. /**
  70995. * Not supported by GPUParticleSystem
  70996. * @param gradient defines the gradient to use (between 0 and 1)
  70997. * @param factor defines the start size value to affect to the specified gradient
  70998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70999. * @returns the current particle system
  71000. */
  71001. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71002. /**
  71003. * Not supported by GPUParticleSystem
  71004. * @param gradient defines the gradient to remove
  71005. * @returns the current particle system
  71006. */
  71007. removeStartSizeGradient(gradient: number): IParticleSystem;
  71008. /**
  71009. * Not supported by GPUParticleSystem
  71010. * @param gradient defines the gradient to use (between 0 and 1)
  71011. * @param min defines the color remap minimal range
  71012. * @param max defines the color remap maximal range
  71013. * @returns the current particle system
  71014. */
  71015. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71016. /**
  71017. * Not supported by GPUParticleSystem
  71018. * @param gradient defines the gradient to remove
  71019. * @returns the current particle system
  71020. */
  71021. removeColorRemapGradient(): IParticleSystem;
  71022. /**
  71023. * Not supported by GPUParticleSystem
  71024. * @param gradient defines the gradient to use (between 0 and 1)
  71025. * @param min defines the alpha remap minimal range
  71026. * @param max defines the alpha remap maximal range
  71027. * @returns the current particle system
  71028. */
  71029. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71030. /**
  71031. * Not supported by GPUParticleSystem
  71032. * @param gradient defines the gradient to remove
  71033. * @returns the current particle system
  71034. */
  71035. removeAlphaRemapGradient(): IParticleSystem;
  71036. /**
  71037. * Not supported by GPUParticleSystem
  71038. * @param gradient defines the gradient to use (between 0 and 1)
  71039. * @param color defines the color to affect to the specified gradient
  71040. * @returns the current particle system
  71041. */
  71042. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71043. /**
  71044. * Not supported by GPUParticleSystem
  71045. * @param gradient defines the gradient to remove
  71046. * @returns the current particle system
  71047. */
  71048. removeRampGradient(): IParticleSystem;
  71049. /**
  71050. * Not supported by GPUParticleSystem
  71051. * @returns the list of ramp gradients
  71052. */
  71053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71054. /**
  71055. * Not supported by GPUParticleSystem
  71056. * Gets or sets a boolean indicating that ramp gradients must be used
  71057. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71058. */
  71059. get useRampGradients(): boolean;
  71060. set useRampGradients(value: boolean);
  71061. /**
  71062. * Not supported by GPUParticleSystem
  71063. * @param gradient defines the gradient to use (between 0 and 1)
  71064. * @param factor defines the life time factor to affect to the specified gradient
  71065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71066. * @returns the current particle system
  71067. */
  71068. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71069. /**
  71070. * Not supported by GPUParticleSystem
  71071. * @param gradient defines the gradient to remove
  71072. * @returns the current particle system
  71073. */
  71074. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71075. /**
  71076. * Instantiates a GPU particle system.
  71077. * 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.
  71078. * @param name The name of the particle system
  71079. * @param options The options used to create the system
  71080. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71081. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71082. * @param customEffect a custom effect used to change the way particles are rendered by default
  71083. */
  71084. constructor(name: string, options: Partial<{
  71085. capacity: number;
  71086. randomTextureSize: number;
  71087. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71088. protected _reset(): void;
  71089. private _createUpdateVAO;
  71090. private _createRenderVAO;
  71091. private _initialize;
  71092. /** @hidden */
  71093. _recreateUpdateEffect(): void;
  71094. private _getEffect;
  71095. /**
  71096. * Fill the defines array according to the current settings of the particle system
  71097. * @param defines Array to be updated
  71098. * @param blendMode blend mode to take into account when updating the array
  71099. */
  71100. fillDefines(defines: Array<string>, blendMode?: number): void;
  71101. /**
  71102. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71103. * @param uniforms Uniforms array to fill
  71104. * @param attributes Attributes array to fill
  71105. * @param samplers Samplers array to fill
  71106. */
  71107. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71108. /** @hidden */
  71109. _recreateRenderEffect(): Effect;
  71110. /**
  71111. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71112. * @param preWarm defines if we are in the pre-warmimg phase
  71113. */
  71114. animate(preWarm?: boolean): void;
  71115. private _createFactorGradientTexture;
  71116. private _createSizeGradientTexture;
  71117. private _createAngularSpeedGradientTexture;
  71118. private _createVelocityGradientTexture;
  71119. private _createLimitVelocityGradientTexture;
  71120. private _createDragGradientTexture;
  71121. private _createColorGradientTexture;
  71122. /**
  71123. * Renders the particle system in its current state
  71124. * @param preWarm defines if the system should only update the particles but not render them
  71125. * @returns the current number of particles
  71126. */
  71127. render(preWarm?: boolean): number;
  71128. /**
  71129. * Rebuilds the particle system
  71130. */
  71131. rebuild(): void;
  71132. private _releaseBuffers;
  71133. private _releaseVAOs;
  71134. /**
  71135. * Disposes the particle system and free the associated resources
  71136. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71137. */
  71138. dispose(disposeTexture?: boolean): void;
  71139. /**
  71140. * Clones the particle system.
  71141. * @param name The name of the cloned object
  71142. * @param newEmitter The new emitter to use
  71143. * @returns the cloned particle system
  71144. */
  71145. clone(name: string, newEmitter: any): GPUParticleSystem;
  71146. /**
  71147. * Serializes the particle system to a JSON object
  71148. * @param serializeTexture defines if the texture must be serialized as well
  71149. * @returns the JSON object
  71150. */
  71151. serialize(serializeTexture?: boolean): any;
  71152. /**
  71153. * Parses a JSON object to create a GPU particle system.
  71154. * @param parsedParticleSystem The JSON object to parse
  71155. * @param sceneOrEngine The scene or the engine to create the particle system in
  71156. * @param rootUrl The root url to use to load external dependencies like texture
  71157. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71158. * @returns the parsed GPU particle system
  71159. */
  71160. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71161. }
  71162. }
  71163. declare module "babylonjs/Particles/particleSystemSet" {
  71164. import { Nullable } from "babylonjs/types";
  71165. import { Color3 } from "babylonjs/Maths/math.color";
  71166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71168. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71169. import { Scene, IDisposable } from "babylonjs/scene";
  71170. /**
  71171. * Represents a set of particle systems working together to create a specific effect
  71172. */
  71173. export class ParticleSystemSet implements IDisposable {
  71174. /**
  71175. * Gets or sets base Assets URL
  71176. */
  71177. static BaseAssetsUrl: string;
  71178. private _emitterCreationOptions;
  71179. private _emitterNode;
  71180. /**
  71181. * Gets the particle system list
  71182. */
  71183. systems: IParticleSystem[];
  71184. /**
  71185. * Gets the emitter node used with this set
  71186. */
  71187. get emitterNode(): Nullable<TransformNode>;
  71188. /**
  71189. * Creates a new emitter mesh as a sphere
  71190. * @param options defines the options used to create the sphere
  71191. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71192. * @param scene defines the hosting scene
  71193. */
  71194. setEmitterAsSphere(options: {
  71195. diameter: number;
  71196. segments: number;
  71197. color: Color3;
  71198. }, renderingGroupId: number, scene: Scene): void;
  71199. /**
  71200. * Starts all particle systems of the set
  71201. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71202. */
  71203. start(emitter?: AbstractMesh): void;
  71204. /**
  71205. * Release all associated resources
  71206. */
  71207. dispose(): void;
  71208. /**
  71209. * Serialize the set into a JSON compatible object
  71210. * @param serializeTexture defines if the texture must be serialized as well
  71211. * @returns a JSON compatible representation of the set
  71212. */
  71213. serialize(serializeTexture?: boolean): any;
  71214. /**
  71215. * Parse a new ParticleSystemSet from a serialized source
  71216. * @param data defines a JSON compatible representation of the set
  71217. * @param scene defines the hosting scene
  71218. * @param gpu defines if we want GPU particles or CPU particles
  71219. * @returns a new ParticleSystemSet
  71220. */
  71221. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71222. }
  71223. }
  71224. declare module "babylonjs/Particles/particleHelper" {
  71225. import { Nullable } from "babylonjs/types";
  71226. import { Scene } from "babylonjs/scene";
  71227. import { Vector3 } from "babylonjs/Maths/math.vector";
  71228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71229. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71230. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71231. /**
  71232. * This class is made for on one-liner static method to help creating particle system set.
  71233. */
  71234. export class ParticleHelper {
  71235. /**
  71236. * Gets or sets base Assets URL
  71237. */
  71238. static BaseAssetsUrl: string;
  71239. /** Define the Url to load snippets */
  71240. static SnippetUrl: string;
  71241. /**
  71242. * Create a default particle system that you can tweak
  71243. * @param emitter defines the emitter to use
  71244. * @param capacity defines the system capacity (default is 500 particles)
  71245. * @param scene defines the hosting scene
  71246. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71247. * @returns the new Particle system
  71248. */
  71249. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71250. /**
  71251. * This is the main static method (one-liner) of this helper to create different particle systems
  71252. * @param type This string represents the type to the particle system to create
  71253. * @param scene The scene where the particle system should live
  71254. * @param gpu If the system will use gpu
  71255. * @returns the ParticleSystemSet created
  71256. */
  71257. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71258. /**
  71259. * Static function used to export a particle system to a ParticleSystemSet variable.
  71260. * Please note that the emitter shape is not exported
  71261. * @param systems defines the particle systems to export
  71262. * @returns the created particle system set
  71263. */
  71264. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71265. /**
  71266. * Creates a particle system from a snippet saved in a remote file
  71267. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71268. * @param url defines the url to load from
  71269. * @param scene defines the hosting scene
  71270. * @param gpu If the system will use gpu
  71271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71272. * @returns a promise that will resolve to the new particle system
  71273. */
  71274. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71275. /**
  71276. * Creates a particle system from a snippet saved by the particle system editor
  71277. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71278. * @param scene defines the hosting scene
  71279. * @param gpu If the system will use gpu
  71280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71281. * @returns a promise that will resolve to the new particle system
  71282. */
  71283. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71284. }
  71285. }
  71286. declare module "babylonjs/Particles/particleSystemComponent" {
  71287. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71288. import { Effect } from "babylonjs/Materials/effect";
  71289. import "babylonjs/Shaders/particles.vertex";
  71290. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71291. module "babylonjs/Engines/engine" {
  71292. interface Engine {
  71293. /**
  71294. * Create an effect to use with particle systems.
  71295. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71296. * the particle system for which you want to create a custom effect in the last parameter
  71297. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71298. * @param uniformsNames defines a list of attribute names
  71299. * @param samplers defines an array of string used to represent textures
  71300. * @param defines defines the string containing the defines to use to compile the shaders
  71301. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71302. * @param onCompiled defines a function to call when the effect creation is successful
  71303. * @param onError defines a function to call when the effect creation has failed
  71304. * @param particleSystem the particle system you want to create the effect for
  71305. * @returns the new Effect
  71306. */
  71307. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71308. }
  71309. }
  71310. module "babylonjs/Meshes/mesh" {
  71311. interface Mesh {
  71312. /**
  71313. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71314. * @returns an array of IParticleSystem
  71315. */
  71316. getEmittedParticleSystems(): IParticleSystem[];
  71317. /**
  71318. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71319. * @returns an array of IParticleSystem
  71320. */
  71321. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71322. }
  71323. }
  71324. }
  71325. declare module "babylonjs/Particles/pointsCloudSystem" {
  71326. import { Color4 } from "babylonjs/Maths/math";
  71327. import { Mesh } from "babylonjs/Meshes/mesh";
  71328. import { Scene, IDisposable } from "babylonjs/scene";
  71329. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71330. /** Defines the 4 color options */
  71331. export enum PointColor {
  71332. /** color value */
  71333. Color = 2,
  71334. /** uv value */
  71335. UV = 1,
  71336. /** random value */
  71337. Random = 0,
  71338. /** stated value */
  71339. Stated = 3
  71340. }
  71341. /**
  71342. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71343. * 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.
  71344. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71345. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71346. *
  71347. * Full documentation here : TO BE ENTERED
  71348. */
  71349. export class PointsCloudSystem implements IDisposable {
  71350. /**
  71351. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71352. * Example : var p = SPS.particles[i];
  71353. */
  71354. particles: CloudPoint[];
  71355. /**
  71356. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71357. */
  71358. nbParticles: number;
  71359. /**
  71360. * This a counter for your own usage. It's not set by any SPS functions.
  71361. */
  71362. counter: number;
  71363. /**
  71364. * The PCS name. This name is also given to the underlying mesh.
  71365. */
  71366. name: string;
  71367. /**
  71368. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71369. */
  71370. mesh: Mesh;
  71371. /**
  71372. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71373. * Please read :
  71374. */
  71375. vars: any;
  71376. /**
  71377. * @hidden
  71378. */
  71379. _size: number;
  71380. private _scene;
  71381. private _promises;
  71382. private _positions;
  71383. private _indices;
  71384. private _normals;
  71385. private _colors;
  71386. private _uvs;
  71387. private _indices32;
  71388. private _positions32;
  71389. private _colors32;
  71390. private _uvs32;
  71391. private _updatable;
  71392. private _isVisibilityBoxLocked;
  71393. private _alwaysVisible;
  71394. private _groups;
  71395. private _groupCounter;
  71396. private _computeParticleColor;
  71397. private _computeParticleTexture;
  71398. private _computeParticleRotation;
  71399. private _computeBoundingBox;
  71400. private _isReady;
  71401. /**
  71402. * Creates a PCS (Points Cloud System) object
  71403. * @param name (String) is the PCS name, this will be the underlying mesh name
  71404. * @param pointSize (number) is the size for each point
  71405. * @param scene (Scene) is the scene in which the PCS is added
  71406. * @param options defines the options of the PCS e.g.
  71407. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71408. */
  71409. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71410. updatable?: boolean;
  71411. });
  71412. /**
  71413. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71414. * If no points were added to the PCS, the returned mesh is just a single point.
  71415. * @returns a promise for the created mesh
  71416. */
  71417. buildMeshAsync(): Promise<Mesh>;
  71418. /**
  71419. * @hidden
  71420. */
  71421. private _buildMesh;
  71422. private _addParticle;
  71423. private _randomUnitVector;
  71424. private _getColorIndicesForCoord;
  71425. private _setPointsColorOrUV;
  71426. private _colorFromTexture;
  71427. private _calculateDensity;
  71428. /**
  71429. * Adds points to the PCS in random positions within a unit sphere
  71430. * @param nb (positive integer) the number of particles to be created from this model
  71431. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71432. * @returns the number of groups in the system
  71433. */
  71434. addPoints(nb: number, pointFunction?: any): number;
  71435. /**
  71436. * Adds points to the PCS from the surface of the model shape
  71437. * @param mesh is any Mesh object that will be used as a surface model for the points
  71438. * @param nb (positive integer) the number of particles to be created from this model
  71439. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71440. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71441. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71442. * @returns the number of groups in the system
  71443. */
  71444. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71445. /**
  71446. * Adds points to the PCS inside the model shape
  71447. * @param mesh is any Mesh object that will be used as a surface model for the points
  71448. * @param nb (positive integer) the number of particles to be created from this model
  71449. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71450. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71451. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71452. * @returns the number of groups in the system
  71453. */
  71454. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71455. /**
  71456. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71457. * This method calls `updateParticle()` for each particle of the SPS.
  71458. * For an animated SPS, it is usually called within the render loop.
  71459. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71460. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71461. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71462. * @returns the PCS.
  71463. */
  71464. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71465. /**
  71466. * Disposes the PCS.
  71467. */
  71468. dispose(): void;
  71469. /**
  71470. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71471. * doc :
  71472. * @returns the PCS.
  71473. */
  71474. refreshVisibleSize(): PointsCloudSystem;
  71475. /**
  71476. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71477. * @param size the size (float) of the visibility box
  71478. * note : this doesn't lock the PCS mesh bounding box.
  71479. * doc :
  71480. */
  71481. setVisibilityBox(size: number): void;
  71482. /**
  71483. * Gets whether the PCS is always visible or not
  71484. * doc :
  71485. */
  71486. get isAlwaysVisible(): boolean;
  71487. /**
  71488. * Sets the PCS as always visible or not
  71489. * doc :
  71490. */
  71491. set isAlwaysVisible(val: boolean);
  71492. /**
  71493. * Tells to `setParticles()` to compute the particle rotations or not
  71494. * Default value : false. The PCS is faster when it's set to false
  71495. * Note : particle rotations are only applied to parent particles
  71496. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71497. */
  71498. set computeParticleRotation(val: boolean);
  71499. /**
  71500. * Tells to `setParticles()` to compute the particle colors or not.
  71501. * Default value : true. The PCS is faster when it's set to false.
  71502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71503. */
  71504. set computeParticleColor(val: boolean);
  71505. set computeParticleTexture(val: boolean);
  71506. /**
  71507. * Gets if `setParticles()` computes the particle colors or not.
  71508. * Default value : false. The PCS is faster when it's set to false.
  71509. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71510. */
  71511. get computeParticleColor(): boolean;
  71512. /**
  71513. * Gets if `setParticles()` computes the particle textures or not.
  71514. * Default value : false. The PCS is faster when it's set to false.
  71515. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71516. */
  71517. get computeParticleTexture(): boolean;
  71518. /**
  71519. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71520. */
  71521. set computeBoundingBox(val: boolean);
  71522. /**
  71523. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71524. */
  71525. get computeBoundingBox(): boolean;
  71526. /**
  71527. * This function does nothing. It may be overwritten to set all the particle first values.
  71528. * The PCS doesn't call this function, you may have to call it by your own.
  71529. * doc :
  71530. */
  71531. initParticles(): void;
  71532. /**
  71533. * This function does nothing. It may be overwritten to recycle a particle
  71534. * The PCS doesn't call this function, you can to call it
  71535. * doc :
  71536. * @param particle The particle to recycle
  71537. * @returns the recycled particle
  71538. */
  71539. recycleParticle(particle: CloudPoint): CloudPoint;
  71540. /**
  71541. * Updates a particle : this function should be overwritten by the user.
  71542. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71543. * doc :
  71544. * @example : just set a particle position or velocity and recycle conditions
  71545. * @param particle The particle to update
  71546. * @returns the updated particle
  71547. */
  71548. updateParticle(particle: CloudPoint): CloudPoint;
  71549. /**
  71550. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71551. * This does nothing and may be overwritten by the user.
  71552. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71554. * @param update the boolean update value actually passed to setParticles()
  71555. */
  71556. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71557. /**
  71558. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71559. * This will be passed three parameters.
  71560. * This does nothing and may be overwritten by the user.
  71561. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71562. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71563. * @param update the boolean update value actually passed to setParticles()
  71564. */
  71565. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71566. }
  71567. }
  71568. declare module "babylonjs/Particles/cloudPoint" {
  71569. import { Nullable } from "babylonjs/types";
  71570. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71571. import { Mesh } from "babylonjs/Meshes/mesh";
  71572. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71573. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71574. /**
  71575. * Represents one particle of a points cloud system.
  71576. */
  71577. export class CloudPoint {
  71578. /**
  71579. * particle global index
  71580. */
  71581. idx: number;
  71582. /**
  71583. * The color of the particle
  71584. */
  71585. color: Nullable<Color4>;
  71586. /**
  71587. * The world space position of the particle.
  71588. */
  71589. position: Vector3;
  71590. /**
  71591. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71592. */
  71593. rotation: Vector3;
  71594. /**
  71595. * The world space rotation quaternion of the particle.
  71596. */
  71597. rotationQuaternion: Nullable<Quaternion>;
  71598. /**
  71599. * The uv of the particle.
  71600. */
  71601. uv: Nullable<Vector2>;
  71602. /**
  71603. * The current speed of the particle.
  71604. */
  71605. velocity: Vector3;
  71606. /**
  71607. * The pivot point in the particle local space.
  71608. */
  71609. pivot: Vector3;
  71610. /**
  71611. * Must the particle be translated from its pivot point in its local space ?
  71612. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71613. * Default : false
  71614. */
  71615. translateFromPivot: boolean;
  71616. /**
  71617. * Index of this particle in the global "positions" array (Internal use)
  71618. * @hidden
  71619. */
  71620. _pos: number;
  71621. /**
  71622. * @hidden Index of this particle in the global "indices" array (Internal use)
  71623. */
  71624. _ind: number;
  71625. /**
  71626. * Group this particle belongs to
  71627. */
  71628. _group: PointsGroup;
  71629. /**
  71630. * Group id of this particle
  71631. */
  71632. groupId: number;
  71633. /**
  71634. * Index of the particle in its group id (Internal use)
  71635. */
  71636. idxInGroup: number;
  71637. /**
  71638. * @hidden Particle BoundingInfo object (Internal use)
  71639. */
  71640. _boundingInfo: BoundingInfo;
  71641. /**
  71642. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71643. */
  71644. _pcs: PointsCloudSystem;
  71645. /**
  71646. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71647. */
  71648. _stillInvisible: boolean;
  71649. /**
  71650. * @hidden Last computed particle rotation matrix
  71651. */
  71652. _rotationMatrix: number[];
  71653. /**
  71654. * Parent particle Id, if any.
  71655. * Default null.
  71656. */
  71657. parentId: Nullable<number>;
  71658. /**
  71659. * @hidden Internal global position in the PCS.
  71660. */
  71661. _globalPosition: Vector3;
  71662. /**
  71663. * Creates a Point Cloud object.
  71664. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71665. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71666. * @param group (PointsGroup) is the group the particle belongs to
  71667. * @param groupId (integer) is the group identifier in the PCS.
  71668. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71669. * @param pcs defines the PCS it is associated to
  71670. */
  71671. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71672. /**
  71673. * get point size
  71674. */
  71675. get size(): Vector3;
  71676. /**
  71677. * Set point size
  71678. */
  71679. set size(scale: Vector3);
  71680. /**
  71681. * Legacy support, changed quaternion to rotationQuaternion
  71682. */
  71683. get quaternion(): Nullable<Quaternion>;
  71684. /**
  71685. * Legacy support, changed quaternion to rotationQuaternion
  71686. */
  71687. set quaternion(q: Nullable<Quaternion>);
  71688. /**
  71689. * Returns a boolean. True if the particle intersects a mesh, else false
  71690. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71691. * @param target is the object (point or mesh) what the intersection is computed against
  71692. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71693. * @returns true if it intersects
  71694. */
  71695. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71696. /**
  71697. * get the rotation matrix of the particle
  71698. * @hidden
  71699. */
  71700. getRotationMatrix(m: Matrix): void;
  71701. }
  71702. /**
  71703. * Represents a group of points in a points cloud system
  71704. * * PCS internal tool, don't use it manually.
  71705. */
  71706. export class PointsGroup {
  71707. /**
  71708. * The group id
  71709. * @hidden
  71710. */
  71711. groupID: number;
  71712. /**
  71713. * image data for group (internal use)
  71714. * @hidden
  71715. */
  71716. _groupImageData: Nullable<ArrayBufferView>;
  71717. /**
  71718. * Image Width (internal use)
  71719. * @hidden
  71720. */
  71721. _groupImgWidth: number;
  71722. /**
  71723. * Image Height (internal use)
  71724. * @hidden
  71725. */
  71726. _groupImgHeight: number;
  71727. /**
  71728. * Custom position function (internal use)
  71729. * @hidden
  71730. */
  71731. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71732. /**
  71733. * density per facet for surface points
  71734. * @hidden
  71735. */
  71736. _groupDensity: number[];
  71737. /**
  71738. * Only when points are colored by texture carries pointer to texture list array
  71739. * @hidden
  71740. */
  71741. _textureNb: number;
  71742. /**
  71743. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71744. * PCS internal tool, don't use it manually.
  71745. * @hidden
  71746. */
  71747. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71748. }
  71749. }
  71750. declare module "babylonjs/Particles/index" {
  71751. export * from "babylonjs/Particles/baseParticleSystem";
  71752. export * from "babylonjs/Particles/EmitterTypes/index";
  71753. export * from "babylonjs/Particles/gpuParticleSystem";
  71754. export * from "babylonjs/Particles/IParticleSystem";
  71755. export * from "babylonjs/Particles/particle";
  71756. export * from "babylonjs/Particles/particleHelper";
  71757. export * from "babylonjs/Particles/particleSystem";
  71758. import "babylonjs/Particles/particleSystemComponent";
  71759. export * from "babylonjs/Particles/particleSystemComponent";
  71760. export * from "babylonjs/Particles/particleSystemSet";
  71761. export * from "babylonjs/Particles/solidParticle";
  71762. export * from "babylonjs/Particles/solidParticleSystem";
  71763. export * from "babylonjs/Particles/cloudPoint";
  71764. export * from "babylonjs/Particles/pointsCloudSystem";
  71765. export * from "babylonjs/Particles/subEmitter";
  71766. }
  71767. declare module "babylonjs/Physics/physicsEngineComponent" {
  71768. import { Nullable } from "babylonjs/types";
  71769. import { Observable, Observer } from "babylonjs/Misc/observable";
  71770. import { Vector3 } from "babylonjs/Maths/math.vector";
  71771. import { Mesh } from "babylonjs/Meshes/mesh";
  71772. import { ISceneComponent } from "babylonjs/sceneComponent";
  71773. import { Scene } from "babylonjs/scene";
  71774. import { Node } from "babylonjs/node";
  71775. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71776. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71777. module "babylonjs/scene" {
  71778. interface Scene {
  71779. /** @hidden (Backing field) */
  71780. _physicsEngine: Nullable<IPhysicsEngine>;
  71781. /** @hidden */
  71782. _physicsTimeAccumulator: number;
  71783. /**
  71784. * Gets the current physics engine
  71785. * @returns a IPhysicsEngine or null if none attached
  71786. */
  71787. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71788. /**
  71789. * Enables physics to the current scene
  71790. * @param gravity defines the scene's gravity for the physics engine
  71791. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71792. * @return a boolean indicating if the physics engine was initialized
  71793. */
  71794. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71795. /**
  71796. * Disables and disposes the physics engine associated with the scene
  71797. */
  71798. disablePhysicsEngine(): void;
  71799. /**
  71800. * Gets a boolean indicating if there is an active physics engine
  71801. * @returns a boolean indicating if there is an active physics engine
  71802. */
  71803. isPhysicsEnabled(): boolean;
  71804. /**
  71805. * Deletes a physics compound impostor
  71806. * @param compound defines the compound to delete
  71807. */
  71808. deleteCompoundImpostor(compound: any): void;
  71809. /**
  71810. * An event triggered when physic simulation is about to be run
  71811. */
  71812. onBeforePhysicsObservable: Observable<Scene>;
  71813. /**
  71814. * An event triggered when physic simulation has been done
  71815. */
  71816. onAfterPhysicsObservable: Observable<Scene>;
  71817. }
  71818. }
  71819. module "babylonjs/Meshes/abstractMesh" {
  71820. interface AbstractMesh {
  71821. /** @hidden */
  71822. _physicsImpostor: Nullable<PhysicsImpostor>;
  71823. /**
  71824. * Gets or sets impostor used for physic simulation
  71825. * @see https://doc.babylonjs.com/features/physics_engine
  71826. */
  71827. physicsImpostor: Nullable<PhysicsImpostor>;
  71828. /**
  71829. * Gets the current physics impostor
  71830. * @see https://doc.babylonjs.com/features/physics_engine
  71831. * @returns a physics impostor or null
  71832. */
  71833. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71834. /** Apply a physic impulse to the mesh
  71835. * @param force defines the force to apply
  71836. * @param contactPoint defines where to apply the force
  71837. * @returns the current mesh
  71838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71839. */
  71840. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71841. /**
  71842. * Creates a physic joint between two meshes
  71843. * @param otherMesh defines the other mesh to use
  71844. * @param pivot1 defines the pivot to use on this mesh
  71845. * @param pivot2 defines the pivot to use on the other mesh
  71846. * @param options defines additional options (can be plugin dependent)
  71847. * @returns the current mesh
  71848. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71849. */
  71850. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71851. /** @hidden */
  71852. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71853. }
  71854. }
  71855. /**
  71856. * Defines the physics engine scene component responsible to manage a physics engine
  71857. */
  71858. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71859. /**
  71860. * The component name helpful to identify the component in the list of scene components.
  71861. */
  71862. readonly name: string;
  71863. /**
  71864. * The scene the component belongs to.
  71865. */
  71866. scene: Scene;
  71867. /**
  71868. * Creates a new instance of the component for the given scene
  71869. * @param scene Defines the scene to register the component in
  71870. */
  71871. constructor(scene: Scene);
  71872. /**
  71873. * Registers the component in a given scene
  71874. */
  71875. register(): void;
  71876. /**
  71877. * Rebuilds the elements related to this component in case of
  71878. * context lost for instance.
  71879. */
  71880. rebuild(): void;
  71881. /**
  71882. * Disposes the component and the associated ressources
  71883. */
  71884. dispose(): void;
  71885. }
  71886. }
  71887. declare module "babylonjs/Physics/physicsHelper" {
  71888. import { Nullable } from "babylonjs/types";
  71889. import { Vector3 } from "babylonjs/Maths/math.vector";
  71890. import { Mesh } from "babylonjs/Meshes/mesh";
  71891. import { Scene } from "babylonjs/scene";
  71892. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71893. /**
  71894. * A helper for physics simulations
  71895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71896. */
  71897. export class PhysicsHelper {
  71898. private _scene;
  71899. private _physicsEngine;
  71900. /**
  71901. * Initializes the Physics helper
  71902. * @param scene Babylon.js scene
  71903. */
  71904. constructor(scene: Scene);
  71905. /**
  71906. * Applies a radial explosion impulse
  71907. * @param origin the origin of the explosion
  71908. * @param radiusOrEventOptions the radius or the options of radial explosion
  71909. * @param strength the explosion strength
  71910. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71911. * @returns A physics radial explosion event, or null
  71912. */
  71913. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71914. /**
  71915. * Applies a radial explosion force
  71916. * @param origin the origin of the explosion
  71917. * @param radiusOrEventOptions the radius or the options of radial explosion
  71918. * @param strength the explosion strength
  71919. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71920. * @returns A physics radial explosion event, or null
  71921. */
  71922. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71923. /**
  71924. * Creates a gravitational field
  71925. * @param origin the origin of the explosion
  71926. * @param radiusOrEventOptions the radius or the options of radial explosion
  71927. * @param strength the explosion strength
  71928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71929. * @returns A physics gravitational field event, or null
  71930. */
  71931. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71932. /**
  71933. * Creates a physics updraft event
  71934. * @param origin the origin of the updraft
  71935. * @param radiusOrEventOptions the radius or the options of the updraft
  71936. * @param strength the strength of the updraft
  71937. * @param height the height of the updraft
  71938. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71939. * @returns A physics updraft event, or null
  71940. */
  71941. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71942. /**
  71943. * Creates a physics vortex event
  71944. * @param origin the of the vortex
  71945. * @param radiusOrEventOptions the radius or the options of the vortex
  71946. * @param strength the strength of the vortex
  71947. * @param height the height of the vortex
  71948. * @returns a Physics vortex event, or null
  71949. * A physics vortex event or null
  71950. */
  71951. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71952. }
  71953. /**
  71954. * Represents a physics radial explosion event
  71955. */
  71956. class PhysicsRadialExplosionEvent {
  71957. private _scene;
  71958. private _options;
  71959. private _sphere;
  71960. private _dataFetched;
  71961. /**
  71962. * Initializes a radial explosioin event
  71963. * @param _scene BabylonJS scene
  71964. * @param _options The options for the vortex event
  71965. */
  71966. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71967. /**
  71968. * Returns the data related to the radial explosion event (sphere).
  71969. * @returns The radial explosion event data
  71970. */
  71971. getData(): PhysicsRadialExplosionEventData;
  71972. /**
  71973. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71974. * @param impostor A physics imposter
  71975. * @param origin the origin of the explosion
  71976. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71977. */
  71978. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71979. /**
  71980. * Triggers affecterd impostors callbacks
  71981. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71982. */
  71983. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71984. /**
  71985. * Disposes the sphere.
  71986. * @param force Specifies if the sphere should be disposed by force
  71987. */
  71988. dispose(force?: boolean): void;
  71989. /*** Helpers ***/
  71990. private _prepareSphere;
  71991. private _intersectsWithSphere;
  71992. }
  71993. /**
  71994. * Represents a gravitational field event
  71995. */
  71996. class PhysicsGravitationalFieldEvent {
  71997. private _physicsHelper;
  71998. private _scene;
  71999. private _origin;
  72000. private _options;
  72001. private _tickCallback;
  72002. private _sphere;
  72003. private _dataFetched;
  72004. /**
  72005. * Initializes the physics gravitational field event
  72006. * @param _physicsHelper A physics helper
  72007. * @param _scene BabylonJS scene
  72008. * @param _origin The origin position of the gravitational field event
  72009. * @param _options The options for the vortex event
  72010. */
  72011. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72012. /**
  72013. * Returns the data related to the gravitational field event (sphere).
  72014. * @returns A gravitational field event
  72015. */
  72016. getData(): PhysicsGravitationalFieldEventData;
  72017. /**
  72018. * Enables the gravitational field.
  72019. */
  72020. enable(): void;
  72021. /**
  72022. * Disables the gravitational field.
  72023. */
  72024. disable(): void;
  72025. /**
  72026. * Disposes the sphere.
  72027. * @param force The force to dispose from the gravitational field event
  72028. */
  72029. dispose(force?: boolean): void;
  72030. private _tick;
  72031. }
  72032. /**
  72033. * Represents a physics updraft event
  72034. */
  72035. class PhysicsUpdraftEvent {
  72036. private _scene;
  72037. private _origin;
  72038. private _options;
  72039. private _physicsEngine;
  72040. private _originTop;
  72041. private _originDirection;
  72042. private _tickCallback;
  72043. private _cylinder;
  72044. private _cylinderPosition;
  72045. private _dataFetched;
  72046. /**
  72047. * Initializes the physics updraft event
  72048. * @param _scene BabylonJS scene
  72049. * @param _origin The origin position of the updraft
  72050. * @param _options The options for the updraft event
  72051. */
  72052. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72053. /**
  72054. * Returns the data related to the updraft event (cylinder).
  72055. * @returns A physics updraft event
  72056. */
  72057. getData(): PhysicsUpdraftEventData;
  72058. /**
  72059. * Enables the updraft.
  72060. */
  72061. enable(): void;
  72062. /**
  72063. * Disables the updraft.
  72064. */
  72065. disable(): void;
  72066. /**
  72067. * Disposes the cylinder.
  72068. * @param force Specifies if the updraft should be disposed by force
  72069. */
  72070. dispose(force?: boolean): void;
  72071. private getImpostorHitData;
  72072. private _tick;
  72073. /*** Helpers ***/
  72074. private _prepareCylinder;
  72075. private _intersectsWithCylinder;
  72076. }
  72077. /**
  72078. * Represents a physics vortex event
  72079. */
  72080. class PhysicsVortexEvent {
  72081. private _scene;
  72082. private _origin;
  72083. private _options;
  72084. private _physicsEngine;
  72085. private _originTop;
  72086. private _tickCallback;
  72087. private _cylinder;
  72088. private _cylinderPosition;
  72089. private _dataFetched;
  72090. /**
  72091. * Initializes the physics vortex event
  72092. * @param _scene The BabylonJS scene
  72093. * @param _origin The origin position of the vortex
  72094. * @param _options The options for the vortex event
  72095. */
  72096. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72097. /**
  72098. * Returns the data related to the vortex event (cylinder).
  72099. * @returns The physics vortex event data
  72100. */
  72101. getData(): PhysicsVortexEventData;
  72102. /**
  72103. * Enables the vortex.
  72104. */
  72105. enable(): void;
  72106. /**
  72107. * Disables the cortex.
  72108. */
  72109. disable(): void;
  72110. /**
  72111. * Disposes the sphere.
  72112. * @param force
  72113. */
  72114. dispose(force?: boolean): void;
  72115. private getImpostorHitData;
  72116. private _tick;
  72117. /*** Helpers ***/
  72118. private _prepareCylinder;
  72119. private _intersectsWithCylinder;
  72120. }
  72121. /**
  72122. * Options fot the radial explosion event
  72123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72124. */
  72125. export class PhysicsRadialExplosionEventOptions {
  72126. /**
  72127. * The radius of the sphere for the radial explosion.
  72128. */
  72129. radius: number;
  72130. /**
  72131. * The strenth of the explosion.
  72132. */
  72133. strength: number;
  72134. /**
  72135. * The strenght of the force in correspondence to the distance of the affected object
  72136. */
  72137. falloff: PhysicsRadialImpulseFalloff;
  72138. /**
  72139. * Sphere options for the radial explosion.
  72140. */
  72141. sphere: {
  72142. segments: number;
  72143. diameter: number;
  72144. };
  72145. /**
  72146. * Sphere options for the radial explosion.
  72147. */
  72148. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72149. }
  72150. /**
  72151. * Options fot the updraft event
  72152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72153. */
  72154. export class PhysicsUpdraftEventOptions {
  72155. /**
  72156. * The radius of the cylinder for the vortex
  72157. */
  72158. radius: number;
  72159. /**
  72160. * The strenth of the updraft.
  72161. */
  72162. strength: number;
  72163. /**
  72164. * The height of the cylinder for the updraft.
  72165. */
  72166. height: number;
  72167. /**
  72168. * The mode for the the updraft.
  72169. */
  72170. updraftMode: PhysicsUpdraftMode;
  72171. }
  72172. /**
  72173. * Options fot the vortex event
  72174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72175. */
  72176. export class PhysicsVortexEventOptions {
  72177. /**
  72178. * The radius of the cylinder for the vortex
  72179. */
  72180. radius: number;
  72181. /**
  72182. * The strenth of the vortex.
  72183. */
  72184. strength: number;
  72185. /**
  72186. * The height of the cylinder for the vortex.
  72187. */
  72188. height: number;
  72189. /**
  72190. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72191. */
  72192. centripetalForceThreshold: number;
  72193. /**
  72194. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72195. */
  72196. centripetalForceMultiplier: number;
  72197. /**
  72198. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72199. */
  72200. centrifugalForceMultiplier: number;
  72201. /**
  72202. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72203. */
  72204. updraftForceMultiplier: number;
  72205. }
  72206. /**
  72207. * The strenght of the force in correspondence to the distance of the affected object
  72208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72209. */
  72210. export enum PhysicsRadialImpulseFalloff {
  72211. /** Defines that impulse is constant in strength across it's whole radius */
  72212. Constant = 0,
  72213. /** Defines that impulse gets weaker if it's further from the origin */
  72214. Linear = 1
  72215. }
  72216. /**
  72217. * The strength of the force in correspondence to the distance of the affected object
  72218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72219. */
  72220. export enum PhysicsUpdraftMode {
  72221. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72222. Center = 0,
  72223. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72224. Perpendicular = 1
  72225. }
  72226. /**
  72227. * Interface for a physics hit data
  72228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72229. */
  72230. export interface PhysicsHitData {
  72231. /**
  72232. * The force applied at the contact point
  72233. */
  72234. force: Vector3;
  72235. /**
  72236. * The contact point
  72237. */
  72238. contactPoint: Vector3;
  72239. /**
  72240. * The distance from the origin to the contact point
  72241. */
  72242. distanceFromOrigin: number;
  72243. }
  72244. /**
  72245. * Interface for radial explosion event data
  72246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72247. */
  72248. export interface PhysicsRadialExplosionEventData {
  72249. /**
  72250. * A sphere used for the radial explosion event
  72251. */
  72252. sphere: Mesh;
  72253. }
  72254. /**
  72255. * Interface for gravitational field event data
  72256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72257. */
  72258. export interface PhysicsGravitationalFieldEventData {
  72259. /**
  72260. * A sphere mesh used for the gravitational field event
  72261. */
  72262. sphere: Mesh;
  72263. }
  72264. /**
  72265. * Interface for updraft event data
  72266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72267. */
  72268. export interface PhysicsUpdraftEventData {
  72269. /**
  72270. * A cylinder used for the updraft event
  72271. */
  72272. cylinder: Mesh;
  72273. }
  72274. /**
  72275. * Interface for vortex event data
  72276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72277. */
  72278. export interface PhysicsVortexEventData {
  72279. /**
  72280. * A cylinder used for the vortex event
  72281. */
  72282. cylinder: Mesh;
  72283. }
  72284. /**
  72285. * Interface for an affected physics impostor
  72286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72287. */
  72288. export interface PhysicsAffectedImpostorWithData {
  72289. /**
  72290. * The impostor affected by the effect
  72291. */
  72292. impostor: PhysicsImpostor;
  72293. /**
  72294. * The data about the hit/horce from the explosion
  72295. */
  72296. hitData: PhysicsHitData;
  72297. }
  72298. }
  72299. declare module "babylonjs/Physics/Plugins/index" {
  72300. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72301. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72302. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72303. }
  72304. declare module "babylonjs/Physics/index" {
  72305. export * from "babylonjs/Physics/IPhysicsEngine";
  72306. export * from "babylonjs/Physics/physicsEngine";
  72307. export * from "babylonjs/Physics/physicsEngineComponent";
  72308. export * from "babylonjs/Physics/physicsHelper";
  72309. export * from "babylonjs/Physics/physicsImpostor";
  72310. export * from "babylonjs/Physics/physicsJoint";
  72311. export * from "babylonjs/Physics/Plugins/index";
  72312. }
  72313. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72314. /** @hidden */
  72315. export var blackAndWhitePixelShader: {
  72316. name: string;
  72317. shader: string;
  72318. };
  72319. }
  72320. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72321. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72322. import { Camera } from "babylonjs/Cameras/camera";
  72323. import { Engine } from "babylonjs/Engines/engine";
  72324. import "babylonjs/Shaders/blackAndWhite.fragment";
  72325. /**
  72326. * Post process used to render in black and white
  72327. */
  72328. export class BlackAndWhitePostProcess extends PostProcess {
  72329. /**
  72330. * Linear about to convert he result to black and white (default: 1)
  72331. */
  72332. degree: number;
  72333. /**
  72334. * Creates a black and white post process
  72335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72336. * @param name The name of the effect.
  72337. * @param options The required width/height ratio to downsize to before computing the render pass.
  72338. * @param camera The camera to apply the render pass to.
  72339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72340. * @param engine The engine which the post process will be applied. (default: current engine)
  72341. * @param reusable If the post process can be reused on the same frame. (default: false)
  72342. */
  72343. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72344. }
  72345. }
  72346. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72347. import { Nullable } from "babylonjs/types";
  72348. import { Camera } from "babylonjs/Cameras/camera";
  72349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72350. import { Engine } from "babylonjs/Engines/engine";
  72351. /**
  72352. * This represents a set of one or more post processes in Babylon.
  72353. * A post process can be used to apply a shader to a texture after it is rendered.
  72354. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72355. */
  72356. export class PostProcessRenderEffect {
  72357. private _postProcesses;
  72358. private _getPostProcesses;
  72359. private _singleInstance;
  72360. private _cameras;
  72361. private _indicesForCamera;
  72362. /**
  72363. * Name of the effect
  72364. * @hidden
  72365. */
  72366. _name: string;
  72367. /**
  72368. * Instantiates a post process render effect.
  72369. * A post process can be used to apply a shader to a texture after it is rendered.
  72370. * @param engine The engine the effect is tied to
  72371. * @param name The name of the effect
  72372. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72373. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72374. */
  72375. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72376. /**
  72377. * Checks if all the post processes in the effect are supported.
  72378. */
  72379. get isSupported(): boolean;
  72380. /**
  72381. * Updates the current state of the effect
  72382. * @hidden
  72383. */
  72384. _update(): void;
  72385. /**
  72386. * Attaches the effect on cameras
  72387. * @param cameras The camera to attach to.
  72388. * @hidden
  72389. */
  72390. _attachCameras(cameras: Camera): void;
  72391. /**
  72392. * Attaches the effect on cameras
  72393. * @param cameras The camera to attach to.
  72394. * @hidden
  72395. */
  72396. _attachCameras(cameras: Camera[]): void;
  72397. /**
  72398. * Detaches the effect on cameras
  72399. * @param cameras The camera to detatch from.
  72400. * @hidden
  72401. */
  72402. _detachCameras(cameras: Camera): void;
  72403. /**
  72404. * Detatches the effect on cameras
  72405. * @param cameras The camera to detatch from.
  72406. * @hidden
  72407. */
  72408. _detachCameras(cameras: Camera[]): void;
  72409. /**
  72410. * Enables the effect on given cameras
  72411. * @param cameras The camera to enable.
  72412. * @hidden
  72413. */
  72414. _enable(cameras: Camera): void;
  72415. /**
  72416. * Enables the effect on given cameras
  72417. * @param cameras The camera to enable.
  72418. * @hidden
  72419. */
  72420. _enable(cameras: Nullable<Camera[]>): void;
  72421. /**
  72422. * Disables the effect on the given cameras
  72423. * @param cameras The camera to disable.
  72424. * @hidden
  72425. */
  72426. _disable(cameras: Camera): void;
  72427. /**
  72428. * Disables the effect on the given cameras
  72429. * @param cameras The camera to disable.
  72430. * @hidden
  72431. */
  72432. _disable(cameras: Nullable<Camera[]>): void;
  72433. /**
  72434. * Gets a list of the post processes contained in the effect.
  72435. * @param camera The camera to get the post processes on.
  72436. * @returns The list of the post processes in the effect.
  72437. */
  72438. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72439. }
  72440. }
  72441. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72443. /** @hidden */
  72444. export var extractHighlightsPixelShader: {
  72445. name: string;
  72446. shader: string;
  72447. };
  72448. }
  72449. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72450. import { Nullable } from "babylonjs/types";
  72451. import { Camera } from "babylonjs/Cameras/camera";
  72452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72453. import { Engine } from "babylonjs/Engines/engine";
  72454. import "babylonjs/Shaders/extractHighlights.fragment";
  72455. /**
  72456. * 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.
  72457. */
  72458. export class ExtractHighlightsPostProcess extends PostProcess {
  72459. /**
  72460. * The luminance threshold, pixels below this value will be set to black.
  72461. */
  72462. threshold: number;
  72463. /** @hidden */
  72464. _exposure: number;
  72465. /**
  72466. * Post process which has the input texture to be used when performing highlight extraction
  72467. * @hidden
  72468. */
  72469. _inputPostProcess: Nullable<PostProcess>;
  72470. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72471. }
  72472. }
  72473. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72474. /** @hidden */
  72475. export var bloomMergePixelShader: {
  72476. name: string;
  72477. shader: string;
  72478. };
  72479. }
  72480. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72482. import { Nullable } from "babylonjs/types";
  72483. import { Engine } from "babylonjs/Engines/engine";
  72484. import { Camera } from "babylonjs/Cameras/camera";
  72485. import "babylonjs/Shaders/bloomMerge.fragment";
  72486. /**
  72487. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72488. */
  72489. export class BloomMergePostProcess extends PostProcess {
  72490. /** Weight of the bloom to be added to the original input. */
  72491. weight: number;
  72492. /**
  72493. * Creates a new instance of @see BloomMergePostProcess
  72494. * @param name The name of the effect.
  72495. * @param originalFromInput Post process which's input will be used for the merge.
  72496. * @param blurred Blurred highlights post process which's output will be used.
  72497. * @param weight Weight of the bloom to be added to the original input.
  72498. * @param options The required width/height ratio to downsize to before computing the render pass.
  72499. * @param camera The camera to apply the render pass to.
  72500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72501. * @param engine The engine which the post process will be applied. (default: current engine)
  72502. * @param reusable If the post process can be reused on the same frame. (default: false)
  72503. * @param textureType Type of textures used when performing the post process. (default: 0)
  72504. * @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)
  72505. */
  72506. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72507. /** Weight of the bloom to be added to the original input. */
  72508. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72509. }
  72510. }
  72511. declare module "babylonjs/PostProcesses/bloomEffect" {
  72512. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72514. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72515. import { Camera } from "babylonjs/Cameras/camera";
  72516. import { Scene } from "babylonjs/scene";
  72517. /**
  72518. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72519. */
  72520. export class BloomEffect extends PostProcessRenderEffect {
  72521. private bloomScale;
  72522. /**
  72523. * @hidden Internal
  72524. */
  72525. _effects: Array<PostProcess>;
  72526. /**
  72527. * @hidden Internal
  72528. */
  72529. _downscale: ExtractHighlightsPostProcess;
  72530. private _blurX;
  72531. private _blurY;
  72532. private _merge;
  72533. /**
  72534. * The luminance threshold to find bright areas of the image to bloom.
  72535. */
  72536. get threshold(): number;
  72537. set threshold(value: number);
  72538. /**
  72539. * The strength of the bloom.
  72540. */
  72541. get weight(): number;
  72542. set weight(value: number);
  72543. /**
  72544. * Specifies the size of the bloom blur kernel, relative to the final output size
  72545. */
  72546. get kernel(): number;
  72547. set kernel(value: number);
  72548. /**
  72549. * Creates a new instance of @see BloomEffect
  72550. * @param scene The scene the effect belongs to.
  72551. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72552. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72553. * @param bloomWeight The the strength of bloom.
  72554. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72555. * @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)
  72556. */
  72557. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72558. /**
  72559. * Disposes each of the internal effects for a given camera.
  72560. * @param camera The camera to dispose the effect on.
  72561. */
  72562. disposeEffects(camera: Camera): void;
  72563. /**
  72564. * @hidden Internal
  72565. */
  72566. _updateEffects(): void;
  72567. /**
  72568. * Internal
  72569. * @returns if all the contained post processes are ready.
  72570. * @hidden
  72571. */
  72572. _isReady(): boolean;
  72573. }
  72574. }
  72575. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72576. /** @hidden */
  72577. export var chromaticAberrationPixelShader: {
  72578. name: string;
  72579. shader: string;
  72580. };
  72581. }
  72582. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72583. import { Vector2 } from "babylonjs/Maths/math.vector";
  72584. import { Nullable } from "babylonjs/types";
  72585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72586. import { Camera } from "babylonjs/Cameras/camera";
  72587. import { Engine } from "babylonjs/Engines/engine";
  72588. import "babylonjs/Shaders/chromaticAberration.fragment";
  72589. /**
  72590. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72591. */
  72592. export class ChromaticAberrationPostProcess extends PostProcess {
  72593. /**
  72594. * The amount of seperation of rgb channels (default: 30)
  72595. */
  72596. aberrationAmount: number;
  72597. /**
  72598. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72599. */
  72600. radialIntensity: number;
  72601. /**
  72602. * 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))
  72603. */
  72604. direction: Vector2;
  72605. /**
  72606. * 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))
  72607. */
  72608. centerPosition: Vector2;
  72609. /**
  72610. * Creates a new instance ChromaticAberrationPostProcess
  72611. * @param name The name of the effect.
  72612. * @param screenWidth The width of the screen to apply the effect on.
  72613. * @param screenHeight The height of the screen to apply the effect on.
  72614. * @param options The required width/height ratio to downsize to before computing the render pass.
  72615. * @param camera The camera to apply the render pass to.
  72616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72617. * @param engine The engine which the post process will be applied. (default: current engine)
  72618. * @param reusable If the post process can be reused on the same frame. (default: false)
  72619. * @param textureType Type of textures used when performing the post process. (default: 0)
  72620. * @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)
  72621. */
  72622. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72623. }
  72624. }
  72625. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72626. /** @hidden */
  72627. export var circleOfConfusionPixelShader: {
  72628. name: string;
  72629. shader: string;
  72630. };
  72631. }
  72632. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72633. import { Nullable } from "babylonjs/types";
  72634. import { Engine } from "babylonjs/Engines/engine";
  72635. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72636. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72637. import { Camera } from "babylonjs/Cameras/camera";
  72638. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72639. /**
  72640. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72641. */
  72642. export class CircleOfConfusionPostProcess extends PostProcess {
  72643. /**
  72644. * 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.
  72645. */
  72646. lensSize: number;
  72647. /**
  72648. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72649. */
  72650. fStop: number;
  72651. /**
  72652. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72653. */
  72654. focusDistance: number;
  72655. /**
  72656. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72657. */
  72658. focalLength: number;
  72659. private _depthTexture;
  72660. /**
  72661. * Creates a new instance CircleOfConfusionPostProcess
  72662. * @param name The name of the effect.
  72663. * @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.
  72664. * @param options The required width/height ratio to downsize to before computing the render pass.
  72665. * @param camera The camera to apply the render pass to.
  72666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72667. * @param engine The engine which the post process will be applied. (default: current engine)
  72668. * @param reusable If the post process can be reused on the same frame. (default: false)
  72669. * @param textureType Type of textures used when performing the post process. (default: 0)
  72670. * @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)
  72671. */
  72672. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72673. /**
  72674. * 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.
  72675. */
  72676. set depthTexture(value: RenderTargetTexture);
  72677. }
  72678. }
  72679. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72680. /** @hidden */
  72681. export var colorCorrectionPixelShader: {
  72682. name: string;
  72683. shader: string;
  72684. };
  72685. }
  72686. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72688. import { Engine } from "babylonjs/Engines/engine";
  72689. import { Camera } from "babylonjs/Cameras/camera";
  72690. import "babylonjs/Shaders/colorCorrection.fragment";
  72691. /**
  72692. *
  72693. * This post-process allows the modification of rendered colors by using
  72694. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72695. *
  72696. * The object needs to be provided an url to a texture containing the color
  72697. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72698. * Use an image editing software to tweak the LUT to match your needs.
  72699. *
  72700. * For an example of a color LUT, see here:
  72701. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72702. * For explanations on color grading, see here:
  72703. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72704. *
  72705. */
  72706. export class ColorCorrectionPostProcess extends PostProcess {
  72707. private _colorTableTexture;
  72708. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72709. }
  72710. }
  72711. declare module "babylonjs/Shaders/convolution.fragment" {
  72712. /** @hidden */
  72713. export var convolutionPixelShader: {
  72714. name: string;
  72715. shader: string;
  72716. };
  72717. }
  72718. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72720. import { Nullable } from "babylonjs/types";
  72721. import { Camera } from "babylonjs/Cameras/camera";
  72722. import { Engine } from "babylonjs/Engines/engine";
  72723. import "babylonjs/Shaders/convolution.fragment";
  72724. /**
  72725. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72726. * input texture to perform effects such as edge detection or sharpening
  72727. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72728. */
  72729. export class ConvolutionPostProcess extends PostProcess {
  72730. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72731. kernel: number[];
  72732. /**
  72733. * Creates a new instance ConvolutionPostProcess
  72734. * @param name The name of the effect.
  72735. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72736. * @param options The required width/height ratio to downsize to before computing the render pass.
  72737. * @param camera The camera to apply the render pass to.
  72738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72739. * @param engine The engine which the post process will be applied. (default: current engine)
  72740. * @param reusable If the post process can be reused on the same frame. (default: false)
  72741. * @param textureType Type of textures used when performing the post process. (default: 0)
  72742. */
  72743. constructor(name: string,
  72744. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72745. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72746. /**
  72747. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72748. */
  72749. static EdgeDetect0Kernel: number[];
  72750. /**
  72751. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72752. */
  72753. static EdgeDetect1Kernel: number[];
  72754. /**
  72755. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72756. */
  72757. static EdgeDetect2Kernel: number[];
  72758. /**
  72759. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72760. */
  72761. static SharpenKernel: number[];
  72762. /**
  72763. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72764. */
  72765. static EmbossKernel: number[];
  72766. /**
  72767. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72768. */
  72769. static GaussianKernel: number[];
  72770. }
  72771. }
  72772. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72773. import { Nullable } from "babylonjs/types";
  72774. import { Vector2 } from "babylonjs/Maths/math.vector";
  72775. import { Camera } from "babylonjs/Cameras/camera";
  72776. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72777. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72778. import { Engine } from "babylonjs/Engines/engine";
  72779. import { Scene } from "babylonjs/scene";
  72780. /**
  72781. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72782. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72783. * based on samples that have a large difference in distance than the center pixel.
  72784. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72785. */
  72786. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72787. direction: Vector2;
  72788. /**
  72789. * Creates a new instance CircleOfConfusionPostProcess
  72790. * @param name The name of the effect.
  72791. * @param scene The scene the effect belongs to.
  72792. * @param direction The direction the blur should be applied.
  72793. * @param kernel The size of the kernel used to blur.
  72794. * @param options The required width/height ratio to downsize to before computing the render pass.
  72795. * @param camera The camera to apply the render pass to.
  72796. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72797. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72799. * @param engine The engine which the post process will be applied. (default: current engine)
  72800. * @param reusable If the post process can be reused on the same frame. (default: false)
  72801. * @param textureType Type of textures used when performing the post process. (default: 0)
  72802. * @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)
  72803. */
  72804. 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);
  72805. }
  72806. }
  72807. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72808. /** @hidden */
  72809. export var depthOfFieldMergePixelShader: {
  72810. name: string;
  72811. shader: string;
  72812. };
  72813. }
  72814. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72815. import { Nullable } from "babylonjs/types";
  72816. import { Camera } from "babylonjs/Cameras/camera";
  72817. import { Effect } from "babylonjs/Materials/effect";
  72818. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72819. import { Engine } from "babylonjs/Engines/engine";
  72820. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72821. /**
  72822. * Options to be set when merging outputs from the default pipeline.
  72823. */
  72824. export class DepthOfFieldMergePostProcessOptions {
  72825. /**
  72826. * The original image to merge on top of
  72827. */
  72828. originalFromInput: PostProcess;
  72829. /**
  72830. * Parameters to perform the merge of the depth of field effect
  72831. */
  72832. depthOfField?: {
  72833. circleOfConfusion: PostProcess;
  72834. blurSteps: Array<PostProcess>;
  72835. };
  72836. /**
  72837. * Parameters to perform the merge of bloom effect
  72838. */
  72839. bloom?: {
  72840. blurred: PostProcess;
  72841. weight: number;
  72842. };
  72843. }
  72844. /**
  72845. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72846. */
  72847. export class DepthOfFieldMergePostProcess extends PostProcess {
  72848. private blurSteps;
  72849. /**
  72850. * Creates a new instance of DepthOfFieldMergePostProcess
  72851. * @param name The name of the effect.
  72852. * @param originalFromInput Post process which's input will be used for the merge.
  72853. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72854. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72855. * @param options The required width/height ratio to downsize to before computing the render pass.
  72856. * @param camera The camera to apply the render pass to.
  72857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72858. * @param engine The engine which the post process will be applied. (default: current engine)
  72859. * @param reusable If the post process can be reused on the same frame. (default: false)
  72860. * @param textureType Type of textures used when performing the post process. (default: 0)
  72861. * @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)
  72862. */
  72863. 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);
  72864. /**
  72865. * Updates the effect with the current post process compile time values and recompiles the shader.
  72866. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72867. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72868. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72869. * @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
  72870. * @param onCompiled Called when the shader has been compiled.
  72871. * @param onError Called if there is an error when compiling a shader.
  72872. */
  72873. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72874. }
  72875. }
  72876. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72877. import { Nullable } from "babylonjs/types";
  72878. import { Camera } from "babylonjs/Cameras/camera";
  72879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72880. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72881. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72882. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72883. import { Scene } from "babylonjs/scene";
  72884. /**
  72885. * Specifies the level of max blur that should be applied when using the depth of field effect
  72886. */
  72887. export enum DepthOfFieldEffectBlurLevel {
  72888. /**
  72889. * Subtle blur
  72890. */
  72891. Low = 0,
  72892. /**
  72893. * Medium blur
  72894. */
  72895. Medium = 1,
  72896. /**
  72897. * Large blur
  72898. */
  72899. High = 2
  72900. }
  72901. /**
  72902. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72903. */
  72904. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72905. private _circleOfConfusion;
  72906. /**
  72907. * @hidden Internal, blurs from high to low
  72908. */
  72909. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72910. private _depthOfFieldBlurY;
  72911. private _dofMerge;
  72912. /**
  72913. * @hidden Internal post processes in depth of field effect
  72914. */
  72915. _effects: Array<PostProcess>;
  72916. /**
  72917. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72918. */
  72919. set focalLength(value: number);
  72920. get focalLength(): number;
  72921. /**
  72922. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72923. */
  72924. set fStop(value: number);
  72925. get fStop(): number;
  72926. /**
  72927. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72928. */
  72929. set focusDistance(value: number);
  72930. get focusDistance(): number;
  72931. /**
  72932. * 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.
  72933. */
  72934. set lensSize(value: number);
  72935. get lensSize(): number;
  72936. /**
  72937. * Creates a new instance DepthOfFieldEffect
  72938. * @param scene The scene the effect belongs to.
  72939. * @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.
  72940. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72941. * @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)
  72942. */
  72943. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72944. /**
  72945. * Get the current class name of the current effet
  72946. * @returns "DepthOfFieldEffect"
  72947. */
  72948. getClassName(): string;
  72949. /**
  72950. * 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.
  72951. */
  72952. set depthTexture(value: RenderTargetTexture);
  72953. /**
  72954. * Disposes each of the internal effects for a given camera.
  72955. * @param camera The camera to dispose the effect on.
  72956. */
  72957. disposeEffects(camera: Camera): void;
  72958. /**
  72959. * @hidden Internal
  72960. */
  72961. _updateEffects(): void;
  72962. /**
  72963. * Internal
  72964. * @returns if all the contained post processes are ready.
  72965. * @hidden
  72966. */
  72967. _isReady(): boolean;
  72968. }
  72969. }
  72970. declare module "babylonjs/Shaders/displayPass.fragment" {
  72971. /** @hidden */
  72972. export var displayPassPixelShader: {
  72973. name: string;
  72974. shader: string;
  72975. };
  72976. }
  72977. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72978. import { Nullable } from "babylonjs/types";
  72979. import { Camera } from "babylonjs/Cameras/camera";
  72980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72981. import { Engine } from "babylonjs/Engines/engine";
  72982. import "babylonjs/Shaders/displayPass.fragment";
  72983. /**
  72984. * DisplayPassPostProcess which produces an output the same as it's input
  72985. */
  72986. export class DisplayPassPostProcess extends PostProcess {
  72987. /**
  72988. * Creates the DisplayPassPostProcess
  72989. * @param name The name of the effect.
  72990. * @param options The required width/height ratio to downsize to before computing the render pass.
  72991. * @param camera The camera to apply the render pass to.
  72992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72993. * @param engine The engine which the post process will be applied. (default: current engine)
  72994. * @param reusable If the post process can be reused on the same frame. (default: false)
  72995. */
  72996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72997. }
  72998. }
  72999. declare module "babylonjs/Shaders/filter.fragment" {
  73000. /** @hidden */
  73001. export var filterPixelShader: {
  73002. name: string;
  73003. shader: string;
  73004. };
  73005. }
  73006. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73007. import { Nullable } from "babylonjs/types";
  73008. import { Matrix } from "babylonjs/Maths/math.vector";
  73009. import { Camera } from "babylonjs/Cameras/camera";
  73010. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73011. import { Engine } from "babylonjs/Engines/engine";
  73012. import "babylonjs/Shaders/filter.fragment";
  73013. /**
  73014. * Applies a kernel filter to the image
  73015. */
  73016. export class FilterPostProcess extends PostProcess {
  73017. /** The matrix to be applied to the image */
  73018. kernelMatrix: Matrix;
  73019. /**
  73020. *
  73021. * @param name The name of the effect.
  73022. * @param kernelMatrix The matrix to be applied to the image
  73023. * @param options The required width/height ratio to downsize to before computing the render pass.
  73024. * @param camera The camera to apply the render pass to.
  73025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73026. * @param engine The engine which the post process will be applied. (default: current engine)
  73027. * @param reusable If the post process can be reused on the same frame. (default: false)
  73028. */
  73029. constructor(name: string,
  73030. /** The matrix to be applied to the image */
  73031. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73032. }
  73033. }
  73034. declare module "babylonjs/Shaders/fxaa.fragment" {
  73035. /** @hidden */
  73036. export var fxaaPixelShader: {
  73037. name: string;
  73038. shader: string;
  73039. };
  73040. }
  73041. declare module "babylonjs/Shaders/fxaa.vertex" {
  73042. /** @hidden */
  73043. export var fxaaVertexShader: {
  73044. name: string;
  73045. shader: string;
  73046. };
  73047. }
  73048. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73049. import { Nullable } from "babylonjs/types";
  73050. import { Camera } from "babylonjs/Cameras/camera";
  73051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73052. import { Engine } from "babylonjs/Engines/engine";
  73053. import "babylonjs/Shaders/fxaa.fragment";
  73054. import "babylonjs/Shaders/fxaa.vertex";
  73055. /**
  73056. * Fxaa post process
  73057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73058. */
  73059. export class FxaaPostProcess extends PostProcess {
  73060. /** @hidden */
  73061. texelWidth: number;
  73062. /** @hidden */
  73063. texelHeight: number;
  73064. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73065. private _getDefines;
  73066. }
  73067. }
  73068. declare module "babylonjs/Shaders/grain.fragment" {
  73069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73070. /** @hidden */
  73071. export var grainPixelShader: {
  73072. name: string;
  73073. shader: string;
  73074. };
  73075. }
  73076. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73077. import { Nullable } from "babylonjs/types";
  73078. import { Camera } from "babylonjs/Cameras/camera";
  73079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73080. import { Engine } from "babylonjs/Engines/engine";
  73081. import "babylonjs/Shaders/grain.fragment";
  73082. /**
  73083. * The GrainPostProcess adds noise to the image at mid luminance levels
  73084. */
  73085. export class GrainPostProcess extends PostProcess {
  73086. /**
  73087. * The intensity of the grain added (default: 30)
  73088. */
  73089. intensity: number;
  73090. /**
  73091. * If the grain should be randomized on every frame
  73092. */
  73093. animated: boolean;
  73094. /**
  73095. * Creates a new instance of @see GrainPostProcess
  73096. * @param name The name of the effect.
  73097. * @param options The required width/height ratio to downsize to before computing the render pass.
  73098. * @param camera The camera to apply the render pass to.
  73099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73100. * @param engine The engine which the post process will be applied. (default: current engine)
  73101. * @param reusable If the post process can be reused on the same frame. (default: false)
  73102. * @param textureType Type of textures used when performing the post process. (default: 0)
  73103. * @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)
  73104. */
  73105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73106. }
  73107. }
  73108. declare module "babylonjs/Shaders/highlights.fragment" {
  73109. /** @hidden */
  73110. export var highlightsPixelShader: {
  73111. name: string;
  73112. shader: string;
  73113. };
  73114. }
  73115. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73116. import { Nullable } from "babylonjs/types";
  73117. import { Camera } from "babylonjs/Cameras/camera";
  73118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73119. import { Engine } from "babylonjs/Engines/engine";
  73120. import "babylonjs/Shaders/highlights.fragment";
  73121. /**
  73122. * Extracts highlights from the image
  73123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73124. */
  73125. export class HighlightsPostProcess extends PostProcess {
  73126. /**
  73127. * Extracts highlights from the image
  73128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73129. * @param name The name of the effect.
  73130. * @param options The required width/height ratio to downsize to before computing the render pass.
  73131. * @param camera The camera to apply the render pass to.
  73132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73133. * @param engine The engine which the post process will be applied. (default: current engine)
  73134. * @param reusable If the post process can be reused on the same frame. (default: false)
  73135. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73136. */
  73137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73138. }
  73139. }
  73140. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73141. /** @hidden */
  73142. export var mrtFragmentDeclaration: {
  73143. name: string;
  73144. shader: string;
  73145. };
  73146. }
  73147. declare module "babylonjs/Shaders/geometry.fragment" {
  73148. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73149. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73150. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73151. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73152. /** @hidden */
  73153. export var geometryPixelShader: {
  73154. name: string;
  73155. shader: string;
  73156. };
  73157. }
  73158. declare module "babylonjs/Shaders/geometry.vertex" {
  73159. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73160. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73162. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73164. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73165. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73166. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73167. /** @hidden */
  73168. export var geometryVertexShader: {
  73169. name: string;
  73170. shader: string;
  73171. };
  73172. }
  73173. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73174. import { Matrix } from "babylonjs/Maths/math.vector";
  73175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73176. import { Mesh } from "babylonjs/Meshes/mesh";
  73177. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73178. import { Effect } from "babylonjs/Materials/effect";
  73179. import { Scene } from "babylonjs/scene";
  73180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73181. import "babylonjs/Shaders/geometry.fragment";
  73182. import "babylonjs/Shaders/geometry.vertex";
  73183. /** @hidden */
  73184. interface ISavedTransformationMatrix {
  73185. world: Matrix;
  73186. viewProjection: Matrix;
  73187. }
  73188. /**
  73189. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73190. */
  73191. export class GeometryBufferRenderer {
  73192. /**
  73193. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73194. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73195. */
  73196. static readonly POSITION_TEXTURE_TYPE: number;
  73197. /**
  73198. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73199. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73200. */
  73201. static readonly VELOCITY_TEXTURE_TYPE: number;
  73202. /**
  73203. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73204. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73205. */
  73206. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73207. /**
  73208. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73209. * in order to compute objects velocities when enableVelocity is set to "true"
  73210. * @hidden
  73211. */
  73212. _previousTransformationMatrices: {
  73213. [index: number]: ISavedTransformationMatrix;
  73214. };
  73215. /**
  73216. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73217. * in order to compute objects velocities when enableVelocity is set to "true"
  73218. * @hidden
  73219. */
  73220. _previousBonesTransformationMatrices: {
  73221. [index: number]: Float32Array;
  73222. };
  73223. /**
  73224. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73225. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73226. */
  73227. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73228. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73229. renderTransparentMeshes: boolean;
  73230. private _scene;
  73231. private _resizeObserver;
  73232. private _multiRenderTarget;
  73233. private _ratio;
  73234. private _enablePosition;
  73235. private _enableVelocity;
  73236. private _enableReflectivity;
  73237. private _positionIndex;
  73238. private _velocityIndex;
  73239. private _reflectivityIndex;
  73240. protected _effect: Effect;
  73241. protected _cachedDefines: string;
  73242. /**
  73243. * Set the render list (meshes to be rendered) used in the G buffer.
  73244. */
  73245. set renderList(meshes: Mesh[]);
  73246. /**
  73247. * Gets wether or not G buffer are supported by the running hardware.
  73248. * This requires draw buffer supports
  73249. */
  73250. get isSupported(): boolean;
  73251. /**
  73252. * Returns the index of the given texture type in the G-Buffer textures array
  73253. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73254. * @returns the index of the given texture type in the G-Buffer textures array
  73255. */
  73256. getTextureIndex(textureType: number): number;
  73257. /**
  73258. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73259. */
  73260. get enablePosition(): boolean;
  73261. /**
  73262. * Sets whether or not objects positions are enabled for the G buffer.
  73263. */
  73264. set enablePosition(enable: boolean);
  73265. /**
  73266. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73267. */
  73268. get enableVelocity(): boolean;
  73269. /**
  73270. * Sets wether or not objects velocities are enabled for the G buffer.
  73271. */
  73272. set enableVelocity(enable: boolean);
  73273. /**
  73274. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73275. */
  73276. get enableReflectivity(): boolean;
  73277. /**
  73278. * Sets wether or not objects roughness are enabled for the G buffer.
  73279. */
  73280. set enableReflectivity(enable: boolean);
  73281. /**
  73282. * Gets the scene associated with the buffer.
  73283. */
  73284. get scene(): Scene;
  73285. /**
  73286. * Gets the ratio used by the buffer during its creation.
  73287. * How big is the buffer related to the main canvas.
  73288. */
  73289. get ratio(): number;
  73290. /** @hidden */
  73291. static _SceneComponentInitialization: (scene: Scene) => void;
  73292. /**
  73293. * Creates a new G Buffer for the scene
  73294. * @param scene The scene the buffer belongs to
  73295. * @param ratio How big is the buffer related to the main canvas.
  73296. */
  73297. constructor(scene: Scene, ratio?: number);
  73298. /**
  73299. * Checks wether everything is ready to render a submesh to the G buffer.
  73300. * @param subMesh the submesh to check readiness for
  73301. * @param useInstances is the mesh drawn using instance or not
  73302. * @returns true if ready otherwise false
  73303. */
  73304. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73305. /**
  73306. * Gets the current underlying G Buffer.
  73307. * @returns the buffer
  73308. */
  73309. getGBuffer(): MultiRenderTarget;
  73310. /**
  73311. * Gets the number of samples used to render the buffer (anti aliasing).
  73312. */
  73313. get samples(): number;
  73314. /**
  73315. * Sets the number of samples used to render the buffer (anti aliasing).
  73316. */
  73317. set samples(value: number);
  73318. /**
  73319. * Disposes the renderer and frees up associated resources.
  73320. */
  73321. dispose(): void;
  73322. protected _createRenderTargets(): void;
  73323. private _copyBonesTransformationMatrices;
  73324. }
  73325. }
  73326. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73327. import { Nullable } from "babylonjs/types";
  73328. import { Scene } from "babylonjs/scene";
  73329. import { ISceneComponent } from "babylonjs/sceneComponent";
  73330. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73331. module "babylonjs/scene" {
  73332. interface Scene {
  73333. /** @hidden (Backing field) */
  73334. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73335. /**
  73336. * Gets or Sets the current geometry buffer associated to the scene.
  73337. */
  73338. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73339. /**
  73340. * Enables a GeometryBufferRender and associates it with the scene
  73341. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73342. * @returns the GeometryBufferRenderer
  73343. */
  73344. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73345. /**
  73346. * Disables the GeometryBufferRender associated with the scene
  73347. */
  73348. disableGeometryBufferRenderer(): void;
  73349. }
  73350. }
  73351. /**
  73352. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73353. * in several rendering techniques.
  73354. */
  73355. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73356. /**
  73357. * The component name helpful to identify the component in the list of scene components.
  73358. */
  73359. readonly name: string;
  73360. /**
  73361. * The scene the component belongs to.
  73362. */
  73363. scene: Scene;
  73364. /**
  73365. * Creates a new instance of the component for the given scene
  73366. * @param scene Defines the scene to register the component in
  73367. */
  73368. constructor(scene: Scene);
  73369. /**
  73370. * Registers the component in a given scene
  73371. */
  73372. register(): void;
  73373. /**
  73374. * Rebuilds the elements related to this component in case of
  73375. * context lost for instance.
  73376. */
  73377. rebuild(): void;
  73378. /**
  73379. * Disposes the component and the associated ressources
  73380. */
  73381. dispose(): void;
  73382. private _gatherRenderTargets;
  73383. }
  73384. }
  73385. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73386. /** @hidden */
  73387. export var motionBlurPixelShader: {
  73388. name: string;
  73389. shader: string;
  73390. };
  73391. }
  73392. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73393. import { Nullable } from "babylonjs/types";
  73394. import { Camera } from "babylonjs/Cameras/camera";
  73395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73396. import { Scene } from "babylonjs/scene";
  73397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73398. import "babylonjs/Animations/animatable";
  73399. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73400. import "babylonjs/Shaders/motionBlur.fragment";
  73401. import { Engine } from "babylonjs/Engines/engine";
  73402. /**
  73403. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73404. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73405. * As an example, all you have to do is to create the post-process:
  73406. * var mb = new BABYLON.MotionBlurPostProcess(
  73407. * 'mb', // The name of the effect.
  73408. * scene, // The scene containing the objects to blur according to their velocity.
  73409. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73410. * camera // The camera to apply the render pass to.
  73411. * );
  73412. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73413. */
  73414. export class MotionBlurPostProcess extends PostProcess {
  73415. /**
  73416. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73417. */
  73418. motionStrength: number;
  73419. /**
  73420. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73421. */
  73422. get motionBlurSamples(): number;
  73423. /**
  73424. * Sets the number of iterations to be used for motion blur quality
  73425. */
  73426. set motionBlurSamples(samples: number);
  73427. private _motionBlurSamples;
  73428. private _geometryBufferRenderer;
  73429. /**
  73430. * Creates a new instance MotionBlurPostProcess
  73431. * @param name The name of the effect.
  73432. * @param scene The scene containing the objects to blur according to their velocity.
  73433. * @param options The required width/height ratio to downsize to before computing the render pass.
  73434. * @param camera The camera to apply the render pass to.
  73435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73436. * @param engine The engine which the post process will be applied. (default: current engine)
  73437. * @param reusable If the post process can be reused on the same frame. (default: false)
  73438. * @param textureType Type of textures used when performing the post process. (default: 0)
  73439. * @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)
  73440. */
  73441. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73442. /**
  73443. * Excludes the given skinned mesh from computing bones velocities.
  73444. * 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.
  73445. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73446. */
  73447. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73448. /**
  73449. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73450. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73451. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73452. */
  73453. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73454. /**
  73455. * Disposes the post process.
  73456. * @param camera The camera to dispose the post process on.
  73457. */
  73458. dispose(camera?: Camera): void;
  73459. }
  73460. }
  73461. declare module "babylonjs/Shaders/refraction.fragment" {
  73462. /** @hidden */
  73463. export var refractionPixelShader: {
  73464. name: string;
  73465. shader: string;
  73466. };
  73467. }
  73468. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73469. import { Color3 } from "babylonjs/Maths/math.color";
  73470. import { Camera } from "babylonjs/Cameras/camera";
  73471. import { Texture } from "babylonjs/Materials/Textures/texture";
  73472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73473. import { Engine } from "babylonjs/Engines/engine";
  73474. import "babylonjs/Shaders/refraction.fragment";
  73475. /**
  73476. * Post process which applies a refractin texture
  73477. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73478. */
  73479. export class RefractionPostProcess extends PostProcess {
  73480. /** the base color of the refraction (used to taint the rendering) */
  73481. color: Color3;
  73482. /** simulated refraction depth */
  73483. depth: number;
  73484. /** the coefficient of the base color (0 to remove base color tainting) */
  73485. colorLevel: number;
  73486. private _refTexture;
  73487. private _ownRefractionTexture;
  73488. /**
  73489. * Gets or sets the refraction texture
  73490. * Please note that you are responsible for disposing the texture if you set it manually
  73491. */
  73492. get refractionTexture(): Texture;
  73493. set refractionTexture(value: Texture);
  73494. /**
  73495. * Initializes the RefractionPostProcess
  73496. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73497. * @param name The name of the effect.
  73498. * @param refractionTextureUrl Url of the refraction texture to use
  73499. * @param color the base color of the refraction (used to taint the rendering)
  73500. * @param depth simulated refraction depth
  73501. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73502. * @param camera The camera to apply the render pass to.
  73503. * @param options The required width/height ratio to downsize to before computing the render pass.
  73504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73505. * @param engine The engine which the post process will be applied. (default: current engine)
  73506. * @param reusable If the post process can be reused on the same frame. (default: false)
  73507. */
  73508. constructor(name: string, refractionTextureUrl: string,
  73509. /** the base color of the refraction (used to taint the rendering) */
  73510. color: Color3,
  73511. /** simulated refraction depth */
  73512. depth: number,
  73513. /** the coefficient of the base color (0 to remove base color tainting) */
  73514. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73515. /**
  73516. * Disposes of the post process
  73517. * @param camera Camera to dispose post process on
  73518. */
  73519. dispose(camera: Camera): void;
  73520. }
  73521. }
  73522. declare module "babylonjs/Shaders/sharpen.fragment" {
  73523. /** @hidden */
  73524. export var sharpenPixelShader: {
  73525. name: string;
  73526. shader: string;
  73527. };
  73528. }
  73529. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73530. import { Nullable } from "babylonjs/types";
  73531. import { Camera } from "babylonjs/Cameras/camera";
  73532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73533. import "babylonjs/Shaders/sharpen.fragment";
  73534. import { Engine } from "babylonjs/Engines/engine";
  73535. /**
  73536. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73537. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73538. */
  73539. export class SharpenPostProcess extends PostProcess {
  73540. /**
  73541. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73542. */
  73543. colorAmount: number;
  73544. /**
  73545. * How much sharpness should be applied (default: 0.3)
  73546. */
  73547. edgeAmount: number;
  73548. /**
  73549. * Creates a new instance ConvolutionPostProcess
  73550. * @param name The name of the effect.
  73551. * @param options The required width/height ratio to downsize to before computing the render pass.
  73552. * @param camera The camera to apply the render pass to.
  73553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73554. * @param engine The engine which the post process will be applied. (default: current engine)
  73555. * @param reusable If the post process can be reused on the same frame. (default: false)
  73556. * @param textureType Type of textures used when performing the post process. (default: 0)
  73557. * @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)
  73558. */
  73559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73560. }
  73561. }
  73562. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73563. import { Nullable } from "babylonjs/types";
  73564. import { Camera } from "babylonjs/Cameras/camera";
  73565. import { Engine } from "babylonjs/Engines/engine";
  73566. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73567. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73568. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73569. /**
  73570. * PostProcessRenderPipeline
  73571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73572. */
  73573. export class PostProcessRenderPipeline {
  73574. private engine;
  73575. private _renderEffects;
  73576. private _renderEffectsForIsolatedPass;
  73577. /**
  73578. * List of inspectable custom properties (used by the Inspector)
  73579. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73580. */
  73581. inspectableCustomProperties: IInspectable[];
  73582. /**
  73583. * @hidden
  73584. */
  73585. protected _cameras: Camera[];
  73586. /** @hidden */
  73587. _name: string;
  73588. /**
  73589. * Gets pipeline name
  73590. */
  73591. get name(): string;
  73592. /** Gets the list of attached cameras */
  73593. get cameras(): Camera[];
  73594. /**
  73595. * Initializes a PostProcessRenderPipeline
  73596. * @param engine engine to add the pipeline to
  73597. * @param name name of the pipeline
  73598. */
  73599. constructor(engine: Engine, name: string);
  73600. /**
  73601. * Gets the class name
  73602. * @returns "PostProcessRenderPipeline"
  73603. */
  73604. getClassName(): string;
  73605. /**
  73606. * If all the render effects in the pipeline are supported
  73607. */
  73608. get isSupported(): boolean;
  73609. /**
  73610. * Adds an effect to the pipeline
  73611. * @param renderEffect the effect to add
  73612. */
  73613. addEffect(renderEffect: PostProcessRenderEffect): void;
  73614. /** @hidden */
  73615. _rebuild(): void;
  73616. /** @hidden */
  73617. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73618. /** @hidden */
  73619. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73620. /** @hidden */
  73621. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73622. /** @hidden */
  73623. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73624. /** @hidden */
  73625. _attachCameras(cameras: Camera, unique: boolean): void;
  73626. /** @hidden */
  73627. _attachCameras(cameras: Camera[], unique: boolean): void;
  73628. /** @hidden */
  73629. _detachCameras(cameras: Camera): void;
  73630. /** @hidden */
  73631. _detachCameras(cameras: Nullable<Camera[]>): void;
  73632. /** @hidden */
  73633. _update(): void;
  73634. /** @hidden */
  73635. _reset(): void;
  73636. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73637. /**
  73638. * Sets the required values to the prepass renderer.
  73639. * @param prePassRenderer defines the prepass renderer to setup.
  73640. * @returns true if the pre pass is needed.
  73641. */
  73642. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73643. /**
  73644. * Disposes of the pipeline
  73645. */
  73646. dispose(): void;
  73647. }
  73648. }
  73649. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73650. import { Camera } from "babylonjs/Cameras/camera";
  73651. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73652. /**
  73653. * PostProcessRenderPipelineManager class
  73654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73655. */
  73656. export class PostProcessRenderPipelineManager {
  73657. private _renderPipelines;
  73658. /**
  73659. * Initializes a PostProcessRenderPipelineManager
  73660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73661. */
  73662. constructor();
  73663. /**
  73664. * Gets the list of supported render pipelines
  73665. */
  73666. get supportedPipelines(): PostProcessRenderPipeline[];
  73667. /**
  73668. * Adds a pipeline to the manager
  73669. * @param renderPipeline The pipeline to add
  73670. */
  73671. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73672. /**
  73673. * Attaches a camera to the pipeline
  73674. * @param renderPipelineName The name of the pipeline to attach to
  73675. * @param cameras the camera to attach
  73676. * @param unique if the camera can be attached multiple times to the pipeline
  73677. */
  73678. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73679. /**
  73680. * Detaches a camera from the pipeline
  73681. * @param renderPipelineName The name of the pipeline to detach from
  73682. * @param cameras the camera to detach
  73683. */
  73684. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73685. /**
  73686. * Enables an effect by name on a pipeline
  73687. * @param renderPipelineName the name of the pipeline to enable the effect in
  73688. * @param renderEffectName the name of the effect to enable
  73689. * @param cameras the cameras that the effect should be enabled on
  73690. */
  73691. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73692. /**
  73693. * Disables an effect by name on a pipeline
  73694. * @param renderPipelineName the name of the pipeline to disable the effect in
  73695. * @param renderEffectName the name of the effect to disable
  73696. * @param cameras the cameras that the effect should be disabled on
  73697. */
  73698. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73699. /**
  73700. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73701. */
  73702. update(): void;
  73703. /** @hidden */
  73704. _rebuild(): void;
  73705. /**
  73706. * Disposes of the manager and pipelines
  73707. */
  73708. dispose(): void;
  73709. }
  73710. }
  73711. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73712. import { ISceneComponent } from "babylonjs/sceneComponent";
  73713. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73714. import { Scene } from "babylonjs/scene";
  73715. module "babylonjs/scene" {
  73716. interface Scene {
  73717. /** @hidden (Backing field) */
  73718. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73719. /**
  73720. * Gets the postprocess render pipeline manager
  73721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73722. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73723. */
  73724. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73725. }
  73726. }
  73727. /**
  73728. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73729. */
  73730. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73731. /**
  73732. * The component name helpfull to identify the component in the list of scene components.
  73733. */
  73734. readonly name: string;
  73735. /**
  73736. * The scene the component belongs to.
  73737. */
  73738. scene: Scene;
  73739. /**
  73740. * Creates a new instance of the component for the given scene
  73741. * @param scene Defines the scene to register the component in
  73742. */
  73743. constructor(scene: Scene);
  73744. /**
  73745. * Registers the component in a given scene
  73746. */
  73747. register(): void;
  73748. /**
  73749. * Rebuilds the elements related to this component in case of
  73750. * context lost for instance.
  73751. */
  73752. rebuild(): void;
  73753. /**
  73754. * Disposes the component and the associated ressources
  73755. */
  73756. dispose(): void;
  73757. private _gatherRenderTargets;
  73758. }
  73759. }
  73760. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73761. import { Nullable } from "babylonjs/types";
  73762. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73763. import { Camera } from "babylonjs/Cameras/camera";
  73764. import { IDisposable } from "babylonjs/scene";
  73765. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73766. import { Scene } from "babylonjs/scene";
  73767. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73768. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73769. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73770. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73771. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73772. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73773. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73774. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73775. import { Animation } from "babylonjs/Animations/animation";
  73776. /**
  73777. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73778. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73779. */
  73780. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73781. private _scene;
  73782. private _camerasToBeAttached;
  73783. /**
  73784. * ID of the sharpen post process,
  73785. */
  73786. private readonly SharpenPostProcessId;
  73787. /**
  73788. * @ignore
  73789. * ID of the image processing post process;
  73790. */
  73791. readonly ImageProcessingPostProcessId: string;
  73792. /**
  73793. * @ignore
  73794. * ID of the Fast Approximate Anti-Aliasing post process;
  73795. */
  73796. readonly FxaaPostProcessId: string;
  73797. /**
  73798. * ID of the chromatic aberration post process,
  73799. */
  73800. private readonly ChromaticAberrationPostProcessId;
  73801. /**
  73802. * ID of the grain post process
  73803. */
  73804. private readonly GrainPostProcessId;
  73805. /**
  73806. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73807. */
  73808. sharpen: SharpenPostProcess;
  73809. private _sharpenEffect;
  73810. private bloom;
  73811. /**
  73812. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73813. */
  73814. depthOfField: DepthOfFieldEffect;
  73815. /**
  73816. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73817. */
  73818. fxaa: FxaaPostProcess;
  73819. /**
  73820. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73821. */
  73822. imageProcessing: ImageProcessingPostProcess;
  73823. /**
  73824. * Chromatic aberration post process which will shift rgb colors in the image
  73825. */
  73826. chromaticAberration: ChromaticAberrationPostProcess;
  73827. private _chromaticAberrationEffect;
  73828. /**
  73829. * Grain post process which add noise to the image
  73830. */
  73831. grain: GrainPostProcess;
  73832. private _grainEffect;
  73833. /**
  73834. * Glow post process which adds a glow to emissive areas of the image
  73835. */
  73836. private _glowLayer;
  73837. /**
  73838. * Animations which can be used to tweak settings over a period of time
  73839. */
  73840. animations: Animation[];
  73841. private _imageProcessingConfigurationObserver;
  73842. private _sharpenEnabled;
  73843. private _bloomEnabled;
  73844. private _depthOfFieldEnabled;
  73845. private _depthOfFieldBlurLevel;
  73846. private _fxaaEnabled;
  73847. private _imageProcessingEnabled;
  73848. private _defaultPipelineTextureType;
  73849. private _bloomScale;
  73850. private _chromaticAberrationEnabled;
  73851. private _grainEnabled;
  73852. private _buildAllowed;
  73853. /**
  73854. * Gets active scene
  73855. */
  73856. get scene(): Scene;
  73857. /**
  73858. * Enable or disable the sharpen process from the pipeline
  73859. */
  73860. set sharpenEnabled(enabled: boolean);
  73861. get sharpenEnabled(): boolean;
  73862. private _resizeObserver;
  73863. private _hardwareScaleLevel;
  73864. private _bloomKernel;
  73865. /**
  73866. * Specifies the size of the bloom blur kernel, relative to the final output size
  73867. */
  73868. get bloomKernel(): number;
  73869. set bloomKernel(value: number);
  73870. /**
  73871. * Specifies the weight of the bloom in the final rendering
  73872. */
  73873. private _bloomWeight;
  73874. /**
  73875. * Specifies the luma threshold for the area that will be blurred by the bloom
  73876. */
  73877. private _bloomThreshold;
  73878. private _hdr;
  73879. /**
  73880. * The strength of the bloom.
  73881. */
  73882. set bloomWeight(value: number);
  73883. get bloomWeight(): number;
  73884. /**
  73885. * The strength of the bloom.
  73886. */
  73887. set bloomThreshold(value: number);
  73888. get bloomThreshold(): number;
  73889. /**
  73890. * The scale of the bloom, lower value will provide better performance.
  73891. */
  73892. set bloomScale(value: number);
  73893. get bloomScale(): number;
  73894. /**
  73895. * Enable or disable the bloom from the pipeline
  73896. */
  73897. set bloomEnabled(enabled: boolean);
  73898. get bloomEnabled(): boolean;
  73899. private _rebuildBloom;
  73900. /**
  73901. * If the depth of field is enabled.
  73902. */
  73903. get depthOfFieldEnabled(): boolean;
  73904. set depthOfFieldEnabled(enabled: boolean);
  73905. /**
  73906. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73907. */
  73908. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73909. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73910. /**
  73911. * If the anti aliasing is enabled.
  73912. */
  73913. set fxaaEnabled(enabled: boolean);
  73914. get fxaaEnabled(): boolean;
  73915. private _samples;
  73916. /**
  73917. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73918. */
  73919. set samples(sampleCount: number);
  73920. get samples(): number;
  73921. /**
  73922. * If image processing is enabled.
  73923. */
  73924. set imageProcessingEnabled(enabled: boolean);
  73925. get imageProcessingEnabled(): boolean;
  73926. /**
  73927. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73928. */
  73929. set glowLayerEnabled(enabled: boolean);
  73930. get glowLayerEnabled(): boolean;
  73931. /**
  73932. * Gets the glow layer (or null if not defined)
  73933. */
  73934. get glowLayer(): Nullable<GlowLayer>;
  73935. /**
  73936. * Enable or disable the chromaticAberration process from the pipeline
  73937. */
  73938. set chromaticAberrationEnabled(enabled: boolean);
  73939. get chromaticAberrationEnabled(): boolean;
  73940. /**
  73941. * Enable or disable the grain process from the pipeline
  73942. */
  73943. set grainEnabled(enabled: boolean);
  73944. get grainEnabled(): boolean;
  73945. /**
  73946. * @constructor
  73947. * @param name - The rendering pipeline name (default: "")
  73948. * @param hdr - If high dynamic range textures should be used (default: true)
  73949. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73950. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73951. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73952. */
  73953. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73954. /**
  73955. * Get the class name
  73956. * @returns "DefaultRenderingPipeline"
  73957. */
  73958. getClassName(): string;
  73959. /**
  73960. * Force the compilation of the entire pipeline.
  73961. */
  73962. prepare(): void;
  73963. private _hasCleared;
  73964. private _prevPostProcess;
  73965. private _prevPrevPostProcess;
  73966. private _setAutoClearAndTextureSharing;
  73967. private _depthOfFieldSceneObserver;
  73968. private _buildPipeline;
  73969. private _disposePostProcesses;
  73970. /**
  73971. * Adds a camera to the pipeline
  73972. * @param camera the camera to be added
  73973. */
  73974. addCamera(camera: Camera): void;
  73975. /**
  73976. * Removes a camera from the pipeline
  73977. * @param camera the camera to remove
  73978. */
  73979. removeCamera(camera: Camera): void;
  73980. /**
  73981. * Dispose of the pipeline and stop all post processes
  73982. */
  73983. dispose(): void;
  73984. /**
  73985. * Serialize the rendering pipeline (Used when exporting)
  73986. * @returns the serialized object
  73987. */
  73988. serialize(): any;
  73989. /**
  73990. * Parse the serialized pipeline
  73991. * @param source Source pipeline.
  73992. * @param scene The scene to load the pipeline to.
  73993. * @param rootUrl The URL of the serialized pipeline.
  73994. * @returns An instantiated pipeline from the serialized object.
  73995. */
  73996. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73997. }
  73998. }
  73999. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74000. /** @hidden */
  74001. export var lensHighlightsPixelShader: {
  74002. name: string;
  74003. shader: string;
  74004. };
  74005. }
  74006. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74007. /** @hidden */
  74008. export var depthOfFieldPixelShader: {
  74009. name: string;
  74010. shader: string;
  74011. };
  74012. }
  74013. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74014. import { Camera } from "babylonjs/Cameras/camera";
  74015. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74016. import { Scene } from "babylonjs/scene";
  74017. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74018. import "babylonjs/Shaders/chromaticAberration.fragment";
  74019. import "babylonjs/Shaders/lensHighlights.fragment";
  74020. import "babylonjs/Shaders/depthOfField.fragment";
  74021. /**
  74022. * BABYLON.JS Chromatic Aberration GLSL Shader
  74023. * Author: Olivier Guyot
  74024. * Separates very slightly R, G and B colors on the edges of the screen
  74025. * Inspired by Francois Tarlier & Martins Upitis
  74026. */
  74027. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74028. /**
  74029. * @ignore
  74030. * The chromatic aberration PostProcess id in the pipeline
  74031. */
  74032. LensChromaticAberrationEffect: string;
  74033. /**
  74034. * @ignore
  74035. * The highlights enhancing PostProcess id in the pipeline
  74036. */
  74037. HighlightsEnhancingEffect: string;
  74038. /**
  74039. * @ignore
  74040. * The depth-of-field PostProcess id in the pipeline
  74041. */
  74042. LensDepthOfFieldEffect: string;
  74043. private _scene;
  74044. private _depthTexture;
  74045. private _grainTexture;
  74046. private _chromaticAberrationPostProcess;
  74047. private _highlightsPostProcess;
  74048. private _depthOfFieldPostProcess;
  74049. private _edgeBlur;
  74050. private _grainAmount;
  74051. private _chromaticAberration;
  74052. private _distortion;
  74053. private _highlightsGain;
  74054. private _highlightsThreshold;
  74055. private _dofDistance;
  74056. private _dofAperture;
  74057. private _dofDarken;
  74058. private _dofPentagon;
  74059. private _blurNoise;
  74060. /**
  74061. * @constructor
  74062. *
  74063. * Effect parameters are as follow:
  74064. * {
  74065. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74066. * edge_blur: number; // from 0 to x (1 for realism)
  74067. * distortion: number; // from 0 to x (1 for realism)
  74068. * grain_amount: number; // from 0 to 1
  74069. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74070. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74071. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74072. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74073. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74074. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74075. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74076. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74077. * }
  74078. * Note: if an effect parameter is unset, effect is disabled
  74079. *
  74080. * @param name The rendering pipeline name
  74081. * @param parameters - An object containing all parameters (see above)
  74082. * @param scene The scene linked to this pipeline
  74083. * @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)
  74084. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74085. */
  74086. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74087. /**
  74088. * Get the class name
  74089. * @returns "LensRenderingPipeline"
  74090. */
  74091. getClassName(): string;
  74092. /**
  74093. * Gets associated scene
  74094. */
  74095. get scene(): Scene;
  74096. /**
  74097. * Gets or sets the edge blur
  74098. */
  74099. get edgeBlur(): number;
  74100. set edgeBlur(value: number);
  74101. /**
  74102. * Gets or sets the grain amount
  74103. */
  74104. get grainAmount(): number;
  74105. set grainAmount(value: number);
  74106. /**
  74107. * Gets or sets the chromatic aberration amount
  74108. */
  74109. get chromaticAberration(): number;
  74110. set chromaticAberration(value: number);
  74111. /**
  74112. * Gets or sets the depth of field aperture
  74113. */
  74114. get dofAperture(): number;
  74115. set dofAperture(value: number);
  74116. /**
  74117. * Gets or sets the edge distortion
  74118. */
  74119. get edgeDistortion(): number;
  74120. set edgeDistortion(value: number);
  74121. /**
  74122. * Gets or sets the depth of field distortion
  74123. */
  74124. get dofDistortion(): number;
  74125. set dofDistortion(value: number);
  74126. /**
  74127. * Gets or sets the darken out of focus amount
  74128. */
  74129. get darkenOutOfFocus(): number;
  74130. set darkenOutOfFocus(value: number);
  74131. /**
  74132. * Gets or sets a boolean indicating if blur noise is enabled
  74133. */
  74134. get blurNoise(): boolean;
  74135. set blurNoise(value: boolean);
  74136. /**
  74137. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74138. */
  74139. get pentagonBokeh(): boolean;
  74140. set pentagonBokeh(value: boolean);
  74141. /**
  74142. * Gets or sets the highlight grain amount
  74143. */
  74144. get highlightsGain(): number;
  74145. set highlightsGain(value: number);
  74146. /**
  74147. * Gets or sets the highlight threshold
  74148. */
  74149. get highlightsThreshold(): number;
  74150. set highlightsThreshold(value: number);
  74151. /**
  74152. * Sets the amount of blur at the edges
  74153. * @param amount blur amount
  74154. */
  74155. setEdgeBlur(amount: number): void;
  74156. /**
  74157. * Sets edge blur to 0
  74158. */
  74159. disableEdgeBlur(): void;
  74160. /**
  74161. * Sets the amout of grain
  74162. * @param amount Amount of grain
  74163. */
  74164. setGrainAmount(amount: number): void;
  74165. /**
  74166. * Set grain amount to 0
  74167. */
  74168. disableGrain(): void;
  74169. /**
  74170. * Sets the chromatic aberration amount
  74171. * @param amount amount of chromatic aberration
  74172. */
  74173. setChromaticAberration(amount: number): void;
  74174. /**
  74175. * Sets chromatic aberration amount to 0
  74176. */
  74177. disableChromaticAberration(): void;
  74178. /**
  74179. * Sets the EdgeDistortion amount
  74180. * @param amount amount of EdgeDistortion
  74181. */
  74182. setEdgeDistortion(amount: number): void;
  74183. /**
  74184. * Sets edge distortion to 0
  74185. */
  74186. disableEdgeDistortion(): void;
  74187. /**
  74188. * Sets the FocusDistance amount
  74189. * @param amount amount of FocusDistance
  74190. */
  74191. setFocusDistance(amount: number): void;
  74192. /**
  74193. * Disables depth of field
  74194. */
  74195. disableDepthOfField(): void;
  74196. /**
  74197. * Sets the Aperture amount
  74198. * @param amount amount of Aperture
  74199. */
  74200. setAperture(amount: number): void;
  74201. /**
  74202. * Sets the DarkenOutOfFocus amount
  74203. * @param amount amount of DarkenOutOfFocus
  74204. */
  74205. setDarkenOutOfFocus(amount: number): void;
  74206. private _pentagonBokehIsEnabled;
  74207. /**
  74208. * Creates a pentagon bokeh effect
  74209. */
  74210. enablePentagonBokeh(): void;
  74211. /**
  74212. * Disables the pentagon bokeh effect
  74213. */
  74214. disablePentagonBokeh(): void;
  74215. /**
  74216. * Enables noise blur
  74217. */
  74218. enableNoiseBlur(): void;
  74219. /**
  74220. * Disables noise blur
  74221. */
  74222. disableNoiseBlur(): void;
  74223. /**
  74224. * Sets the HighlightsGain amount
  74225. * @param amount amount of HighlightsGain
  74226. */
  74227. setHighlightsGain(amount: number): void;
  74228. /**
  74229. * Sets the HighlightsThreshold amount
  74230. * @param amount amount of HighlightsThreshold
  74231. */
  74232. setHighlightsThreshold(amount: number): void;
  74233. /**
  74234. * Disables highlights
  74235. */
  74236. disableHighlights(): void;
  74237. /**
  74238. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74239. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74240. */
  74241. dispose(disableDepthRender?: boolean): void;
  74242. private _createChromaticAberrationPostProcess;
  74243. private _createHighlightsPostProcess;
  74244. private _createDepthOfFieldPostProcess;
  74245. private _createGrainTexture;
  74246. }
  74247. }
  74248. declare module "babylonjs/Shaders/ssao2.fragment" {
  74249. /** @hidden */
  74250. export var ssao2PixelShader: {
  74251. name: string;
  74252. shader: string;
  74253. };
  74254. }
  74255. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74256. /** @hidden */
  74257. export var ssaoCombinePixelShader: {
  74258. name: string;
  74259. shader: string;
  74260. };
  74261. }
  74262. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74263. import { Camera } from "babylonjs/Cameras/camera";
  74264. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74265. import { Scene } from "babylonjs/scene";
  74266. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74267. import "babylonjs/Shaders/ssao2.fragment";
  74268. import "babylonjs/Shaders/ssaoCombine.fragment";
  74269. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74270. /**
  74271. * Render pipeline to produce ssao effect
  74272. */
  74273. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74274. /**
  74275. * @ignore
  74276. * The PassPostProcess id in the pipeline that contains the original scene color
  74277. */
  74278. SSAOOriginalSceneColorEffect: string;
  74279. /**
  74280. * @ignore
  74281. * The SSAO PostProcess id in the pipeline
  74282. */
  74283. SSAORenderEffect: string;
  74284. /**
  74285. * @ignore
  74286. * The horizontal blur PostProcess id in the pipeline
  74287. */
  74288. SSAOBlurHRenderEffect: string;
  74289. /**
  74290. * @ignore
  74291. * The vertical blur PostProcess id in the pipeline
  74292. */
  74293. SSAOBlurVRenderEffect: string;
  74294. /**
  74295. * @ignore
  74296. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74297. */
  74298. SSAOCombineRenderEffect: string;
  74299. /**
  74300. * The output strength of the SSAO post-process. Default value is 1.0.
  74301. */
  74302. totalStrength: number;
  74303. /**
  74304. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74305. */
  74306. maxZ: number;
  74307. /**
  74308. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74309. */
  74310. minZAspect: number;
  74311. private _samples;
  74312. /**
  74313. * Number of samples used for the SSAO calculations. Default value is 8
  74314. */
  74315. set samples(n: number);
  74316. get samples(): number;
  74317. private _textureSamples;
  74318. /**
  74319. * Number of samples to use for antialiasing
  74320. */
  74321. set textureSamples(n: number);
  74322. get textureSamples(): number;
  74323. /**
  74324. * Force rendering the geometry through geometry buffer
  74325. */
  74326. private _forceGeometryBuffer;
  74327. /**
  74328. * Ratio object used for SSAO ratio and blur ratio
  74329. */
  74330. private _ratio;
  74331. /**
  74332. * Dynamically generated sphere sampler.
  74333. */
  74334. private _sampleSphere;
  74335. /**
  74336. * Blur filter offsets
  74337. */
  74338. private _samplerOffsets;
  74339. private _expensiveBlur;
  74340. /**
  74341. * If bilateral blur should be used
  74342. */
  74343. set expensiveBlur(b: boolean);
  74344. get expensiveBlur(): boolean;
  74345. /**
  74346. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74347. */
  74348. radius: number;
  74349. /**
  74350. * The base color of the SSAO post-process
  74351. * The final result is "base + ssao" between [0, 1]
  74352. */
  74353. base: number;
  74354. /**
  74355. * Support test.
  74356. */
  74357. static get IsSupported(): boolean;
  74358. private _scene;
  74359. private _randomTexture;
  74360. private _originalColorPostProcess;
  74361. private _ssaoPostProcess;
  74362. private _blurHPostProcess;
  74363. private _blurVPostProcess;
  74364. private _ssaoCombinePostProcess;
  74365. private _prePassRenderer;
  74366. /**
  74367. * Gets active scene
  74368. */
  74369. get scene(): Scene;
  74370. /**
  74371. * @constructor
  74372. * @param name The rendering pipeline name
  74373. * @param scene The scene linked to this pipeline
  74374. * @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 }
  74375. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74376. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74377. */
  74378. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74379. /**
  74380. * Get the class name
  74381. * @returns "SSAO2RenderingPipeline"
  74382. */
  74383. getClassName(): string;
  74384. /**
  74385. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74386. */
  74387. dispose(disableGeometryBufferRenderer?: boolean): void;
  74388. private _createBlurPostProcess;
  74389. /** @hidden */
  74390. _rebuild(): void;
  74391. private _bits;
  74392. private _radicalInverse_VdC;
  74393. private _hammersley;
  74394. private _hemisphereSample_uniform;
  74395. private _generateHemisphere;
  74396. private _getDefinesForSSAO;
  74397. private _createSSAOPostProcess;
  74398. private _createSSAOCombinePostProcess;
  74399. private _createRandomTexture;
  74400. /**
  74401. * Serialize the rendering pipeline (Used when exporting)
  74402. * @returns the serialized object
  74403. */
  74404. serialize(): any;
  74405. /**
  74406. * Parse the serialized pipeline
  74407. * @param source Source pipeline.
  74408. * @param scene The scene to load the pipeline to.
  74409. * @param rootUrl The URL of the serialized pipeline.
  74410. * @returns An instantiated pipeline from the serialized object.
  74411. */
  74412. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74413. /**
  74414. * Sets the required values to the prepass renderer.
  74415. * @param prePassRenderer defines the prepass renderer to setup
  74416. * @returns true if the pre pass is needed.
  74417. */
  74418. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74419. }
  74420. }
  74421. declare module "babylonjs/Shaders/ssao.fragment" {
  74422. /** @hidden */
  74423. export var ssaoPixelShader: {
  74424. name: string;
  74425. shader: string;
  74426. };
  74427. }
  74428. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74429. import { Camera } from "babylonjs/Cameras/camera";
  74430. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74431. import { Scene } from "babylonjs/scene";
  74432. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74433. import "babylonjs/Shaders/ssao.fragment";
  74434. import "babylonjs/Shaders/ssaoCombine.fragment";
  74435. /**
  74436. * Render pipeline to produce ssao effect
  74437. */
  74438. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74439. /**
  74440. * @ignore
  74441. * The PassPostProcess id in the pipeline that contains the original scene color
  74442. */
  74443. SSAOOriginalSceneColorEffect: string;
  74444. /**
  74445. * @ignore
  74446. * The SSAO PostProcess id in the pipeline
  74447. */
  74448. SSAORenderEffect: string;
  74449. /**
  74450. * @ignore
  74451. * The horizontal blur PostProcess id in the pipeline
  74452. */
  74453. SSAOBlurHRenderEffect: string;
  74454. /**
  74455. * @ignore
  74456. * The vertical blur PostProcess id in the pipeline
  74457. */
  74458. SSAOBlurVRenderEffect: string;
  74459. /**
  74460. * @ignore
  74461. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74462. */
  74463. SSAOCombineRenderEffect: string;
  74464. /**
  74465. * The output strength of the SSAO post-process. Default value is 1.0.
  74466. */
  74467. totalStrength: number;
  74468. /**
  74469. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74470. */
  74471. radius: number;
  74472. /**
  74473. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74474. * Must not be equal to fallOff and superior to fallOff.
  74475. * Default value is 0.0075
  74476. */
  74477. area: number;
  74478. /**
  74479. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74480. * Must not be equal to area and inferior to area.
  74481. * Default value is 0.000001
  74482. */
  74483. fallOff: number;
  74484. /**
  74485. * The base color of the SSAO post-process
  74486. * The final result is "base + ssao" between [0, 1]
  74487. */
  74488. base: number;
  74489. private _scene;
  74490. private _depthTexture;
  74491. private _randomTexture;
  74492. private _originalColorPostProcess;
  74493. private _ssaoPostProcess;
  74494. private _blurHPostProcess;
  74495. private _blurVPostProcess;
  74496. private _ssaoCombinePostProcess;
  74497. private _firstUpdate;
  74498. /**
  74499. * Gets active scene
  74500. */
  74501. get scene(): Scene;
  74502. /**
  74503. * @constructor
  74504. * @param name - The rendering pipeline name
  74505. * @param scene - The scene linked to this pipeline
  74506. * @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 }
  74507. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74508. */
  74509. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74510. /**
  74511. * Get the class name
  74512. * @returns "SSAORenderingPipeline"
  74513. */
  74514. getClassName(): string;
  74515. /**
  74516. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74517. */
  74518. dispose(disableDepthRender?: boolean): void;
  74519. private _createBlurPostProcess;
  74520. /** @hidden */
  74521. _rebuild(): void;
  74522. private _createSSAOPostProcess;
  74523. private _createSSAOCombinePostProcess;
  74524. private _createRandomTexture;
  74525. }
  74526. }
  74527. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74528. /** @hidden */
  74529. export var screenSpaceReflectionPixelShader: {
  74530. name: string;
  74531. shader: string;
  74532. };
  74533. }
  74534. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74535. import { Nullable } from "babylonjs/types";
  74536. import { Camera } from "babylonjs/Cameras/camera";
  74537. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74538. import { Scene } from "babylonjs/scene";
  74539. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74540. import { Engine } from "babylonjs/Engines/engine";
  74541. /**
  74542. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74543. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74544. */
  74545. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74546. /**
  74547. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74548. */
  74549. threshold: number;
  74550. /**
  74551. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74552. */
  74553. strength: number;
  74554. /**
  74555. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74556. */
  74557. reflectionSpecularFalloffExponent: number;
  74558. /**
  74559. * 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]
  74560. */
  74561. step: number;
  74562. /**
  74563. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74564. */
  74565. roughnessFactor: number;
  74566. private _geometryBufferRenderer;
  74567. private _enableSmoothReflections;
  74568. private _reflectionSamples;
  74569. private _smoothSteps;
  74570. /**
  74571. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74572. * @param name The name of the effect.
  74573. * @param scene The scene containing the objects to calculate reflections.
  74574. * @param options The required width/height ratio to downsize to before computing the render pass.
  74575. * @param camera The camera to apply the render pass to.
  74576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74577. * @param engine The engine which the post process will be applied. (default: current engine)
  74578. * @param reusable If the post process can be reused on the same frame. (default: false)
  74579. * @param textureType Type of textures used when performing the post process. (default: 0)
  74580. * @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)
  74581. */
  74582. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74583. /**
  74584. * Gets wether or not smoothing reflections is enabled.
  74585. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74586. */
  74587. get enableSmoothReflections(): boolean;
  74588. /**
  74589. * Sets wether or not smoothing reflections is enabled.
  74590. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74591. */
  74592. set enableSmoothReflections(enabled: boolean);
  74593. /**
  74594. * Gets the number of samples taken while computing reflections. More samples count is high,
  74595. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74596. */
  74597. get reflectionSamples(): number;
  74598. /**
  74599. * Sets the number of samples taken while computing reflections. More samples count is high,
  74600. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74601. */
  74602. set reflectionSamples(samples: number);
  74603. /**
  74604. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74605. * more the post-process will require GPU power and can generate a drop in FPS.
  74606. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74607. */
  74608. get smoothSteps(): number;
  74609. set smoothSteps(steps: number);
  74610. private _updateEffectDefines;
  74611. }
  74612. }
  74613. declare module "babylonjs/Shaders/standard.fragment" {
  74614. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74615. /** @hidden */
  74616. export var standardPixelShader: {
  74617. name: string;
  74618. shader: string;
  74619. };
  74620. }
  74621. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74622. import { Nullable } from "babylonjs/types";
  74623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74624. import { Camera } from "babylonjs/Cameras/camera";
  74625. import { Texture } from "babylonjs/Materials/Textures/texture";
  74626. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74627. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74628. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74629. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74630. import { IDisposable } from "babylonjs/scene";
  74631. import { SpotLight } from "babylonjs/Lights/spotLight";
  74632. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74633. import { Scene } from "babylonjs/scene";
  74634. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74635. import { Animation } from "babylonjs/Animations/animation";
  74636. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74637. import "babylonjs/Shaders/standard.fragment";
  74638. /**
  74639. * Standard rendering pipeline
  74640. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74641. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74642. */
  74643. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74644. /**
  74645. * Public members
  74646. */
  74647. /**
  74648. * Post-process which contains the original scene color before the pipeline applies all the effects
  74649. */
  74650. originalPostProcess: Nullable<PostProcess>;
  74651. /**
  74652. * Post-process used to down scale an image x4
  74653. */
  74654. downSampleX4PostProcess: Nullable<PostProcess>;
  74655. /**
  74656. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74657. */
  74658. brightPassPostProcess: Nullable<PostProcess>;
  74659. /**
  74660. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74661. */
  74662. blurHPostProcesses: PostProcess[];
  74663. /**
  74664. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74665. */
  74666. blurVPostProcesses: PostProcess[];
  74667. /**
  74668. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74669. */
  74670. textureAdderPostProcess: Nullable<PostProcess>;
  74671. /**
  74672. * Post-process used to create volumetric lighting effect
  74673. */
  74674. volumetricLightPostProcess: Nullable<PostProcess>;
  74675. /**
  74676. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74677. */
  74678. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74679. /**
  74680. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74681. */
  74682. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74683. /**
  74684. * Post-process used to merge the volumetric light effect and the real scene color
  74685. */
  74686. volumetricLightMergePostProces: Nullable<PostProcess>;
  74687. /**
  74688. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74689. */
  74690. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74691. /**
  74692. * Base post-process used to calculate the average luminance of the final image for HDR
  74693. */
  74694. luminancePostProcess: Nullable<PostProcess>;
  74695. /**
  74696. * Post-processes used to create down sample post-processes in order to get
  74697. * the average luminance of the final image for HDR
  74698. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74699. */
  74700. luminanceDownSamplePostProcesses: PostProcess[];
  74701. /**
  74702. * Post-process used to create a HDR effect (light adaptation)
  74703. */
  74704. hdrPostProcess: Nullable<PostProcess>;
  74705. /**
  74706. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74707. */
  74708. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74709. /**
  74710. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74711. */
  74712. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74713. /**
  74714. * Post-process used to merge the final HDR post-process and the real scene color
  74715. */
  74716. hdrFinalPostProcess: Nullable<PostProcess>;
  74717. /**
  74718. * Post-process used to create a lens flare effect
  74719. */
  74720. lensFlarePostProcess: Nullable<PostProcess>;
  74721. /**
  74722. * Post-process that merges the result of the lens flare post-process and the real scene color
  74723. */
  74724. lensFlareComposePostProcess: Nullable<PostProcess>;
  74725. /**
  74726. * Post-process used to create a motion blur effect
  74727. */
  74728. motionBlurPostProcess: Nullable<PostProcess>;
  74729. /**
  74730. * Post-process used to create a depth of field effect
  74731. */
  74732. depthOfFieldPostProcess: Nullable<PostProcess>;
  74733. /**
  74734. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74735. */
  74736. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74737. /**
  74738. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74739. */
  74740. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74741. /**
  74742. * Represents the brightness threshold in order to configure the illuminated surfaces
  74743. */
  74744. brightThreshold: number;
  74745. /**
  74746. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74747. */
  74748. blurWidth: number;
  74749. /**
  74750. * Sets if the blur for highlighted surfaces must be only horizontal
  74751. */
  74752. horizontalBlur: boolean;
  74753. /**
  74754. * Gets the overall exposure used by the pipeline
  74755. */
  74756. get exposure(): number;
  74757. /**
  74758. * Sets the overall exposure used by the pipeline
  74759. */
  74760. set exposure(value: number);
  74761. /**
  74762. * Texture used typically to simulate "dirty" on camera lens
  74763. */
  74764. lensTexture: Nullable<Texture>;
  74765. /**
  74766. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74767. */
  74768. volumetricLightCoefficient: number;
  74769. /**
  74770. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74771. */
  74772. volumetricLightPower: number;
  74773. /**
  74774. * Used the set the blur intensity to smooth the volumetric lights
  74775. */
  74776. volumetricLightBlurScale: number;
  74777. /**
  74778. * Light (spot or directional) used to generate the volumetric lights rays
  74779. * The source light must have a shadow generate so the pipeline can get its
  74780. * depth map
  74781. */
  74782. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74783. /**
  74784. * For eye adaptation, represents the minimum luminance the eye can see
  74785. */
  74786. hdrMinimumLuminance: number;
  74787. /**
  74788. * For eye adaptation, represents the decrease luminance speed
  74789. */
  74790. hdrDecreaseRate: number;
  74791. /**
  74792. * For eye adaptation, represents the increase luminance speed
  74793. */
  74794. hdrIncreaseRate: number;
  74795. /**
  74796. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74797. */
  74798. get hdrAutoExposure(): boolean;
  74799. /**
  74800. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74801. */
  74802. set hdrAutoExposure(value: boolean);
  74803. /**
  74804. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74805. */
  74806. lensColorTexture: Nullable<Texture>;
  74807. /**
  74808. * The overall strengh for the lens flare effect
  74809. */
  74810. lensFlareStrength: number;
  74811. /**
  74812. * Dispersion coefficient for lens flare ghosts
  74813. */
  74814. lensFlareGhostDispersal: number;
  74815. /**
  74816. * Main lens flare halo width
  74817. */
  74818. lensFlareHaloWidth: number;
  74819. /**
  74820. * Based on the lens distortion effect, defines how much the lens flare result
  74821. * is distorted
  74822. */
  74823. lensFlareDistortionStrength: number;
  74824. /**
  74825. * Configures the blur intensity used for for lens flare (halo)
  74826. */
  74827. lensFlareBlurWidth: number;
  74828. /**
  74829. * Lens star texture must be used to simulate rays on the flares and is available
  74830. * in the documentation
  74831. */
  74832. lensStarTexture: Nullable<Texture>;
  74833. /**
  74834. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74835. * flare effect by taking account of the dirt texture
  74836. */
  74837. lensFlareDirtTexture: Nullable<Texture>;
  74838. /**
  74839. * Represents the focal length for the depth of field effect
  74840. */
  74841. depthOfFieldDistance: number;
  74842. /**
  74843. * Represents the blur intensity for the blurred part of the depth of field effect
  74844. */
  74845. depthOfFieldBlurWidth: number;
  74846. /**
  74847. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74848. */
  74849. get motionStrength(): number;
  74850. /**
  74851. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74852. */
  74853. set motionStrength(strength: number);
  74854. /**
  74855. * Gets wether or not the motion blur post-process is object based or screen based.
  74856. */
  74857. get objectBasedMotionBlur(): boolean;
  74858. /**
  74859. * Sets wether or not the motion blur post-process should be object based or screen based
  74860. */
  74861. set objectBasedMotionBlur(value: boolean);
  74862. /**
  74863. * List of animations for the pipeline (IAnimatable implementation)
  74864. */
  74865. animations: Animation[];
  74866. /**
  74867. * Private members
  74868. */
  74869. private _scene;
  74870. private _currentDepthOfFieldSource;
  74871. private _basePostProcess;
  74872. private _fixedExposure;
  74873. private _currentExposure;
  74874. private _hdrAutoExposure;
  74875. private _hdrCurrentLuminance;
  74876. private _motionStrength;
  74877. private _isObjectBasedMotionBlur;
  74878. private _floatTextureType;
  74879. private _camerasToBeAttached;
  74880. private _ratio;
  74881. private _bloomEnabled;
  74882. private _depthOfFieldEnabled;
  74883. private _vlsEnabled;
  74884. private _lensFlareEnabled;
  74885. private _hdrEnabled;
  74886. private _motionBlurEnabled;
  74887. private _fxaaEnabled;
  74888. private _screenSpaceReflectionsEnabled;
  74889. private _motionBlurSamples;
  74890. private _volumetricLightStepsCount;
  74891. private _samples;
  74892. /**
  74893. * @ignore
  74894. * Specifies if the bloom pipeline is enabled
  74895. */
  74896. get BloomEnabled(): boolean;
  74897. set BloomEnabled(enabled: boolean);
  74898. /**
  74899. * @ignore
  74900. * Specifies if the depth of field pipeline is enabed
  74901. */
  74902. get DepthOfFieldEnabled(): boolean;
  74903. set DepthOfFieldEnabled(enabled: boolean);
  74904. /**
  74905. * @ignore
  74906. * Specifies if the lens flare pipeline is enabed
  74907. */
  74908. get LensFlareEnabled(): boolean;
  74909. set LensFlareEnabled(enabled: boolean);
  74910. /**
  74911. * @ignore
  74912. * Specifies if the HDR pipeline is enabled
  74913. */
  74914. get HDREnabled(): boolean;
  74915. set HDREnabled(enabled: boolean);
  74916. /**
  74917. * @ignore
  74918. * Specifies if the volumetric lights scattering effect is enabled
  74919. */
  74920. get VLSEnabled(): boolean;
  74921. set VLSEnabled(enabled: boolean);
  74922. /**
  74923. * @ignore
  74924. * Specifies if the motion blur effect is enabled
  74925. */
  74926. get MotionBlurEnabled(): boolean;
  74927. set MotionBlurEnabled(enabled: boolean);
  74928. /**
  74929. * Specifies if anti-aliasing is enabled
  74930. */
  74931. get fxaaEnabled(): boolean;
  74932. set fxaaEnabled(enabled: boolean);
  74933. /**
  74934. * Specifies if screen space reflections are enabled.
  74935. */
  74936. get screenSpaceReflectionsEnabled(): boolean;
  74937. set screenSpaceReflectionsEnabled(enabled: boolean);
  74938. /**
  74939. * Specifies the number of steps used to calculate the volumetric lights
  74940. * Typically in interval [50, 200]
  74941. */
  74942. get volumetricLightStepsCount(): number;
  74943. set volumetricLightStepsCount(count: number);
  74944. /**
  74945. * Specifies the number of samples used for the motion blur effect
  74946. * Typically in interval [16, 64]
  74947. */
  74948. get motionBlurSamples(): number;
  74949. set motionBlurSamples(samples: number);
  74950. /**
  74951. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74952. */
  74953. get samples(): number;
  74954. set samples(sampleCount: number);
  74955. /**
  74956. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74957. * @constructor
  74958. * @param name The rendering pipeline name
  74959. * @param scene The scene linked to this pipeline
  74960. * @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)
  74961. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74962. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74963. */
  74964. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74965. private _buildPipeline;
  74966. private _createDownSampleX4PostProcess;
  74967. private _createBrightPassPostProcess;
  74968. private _createBlurPostProcesses;
  74969. private _createTextureAdderPostProcess;
  74970. private _createVolumetricLightPostProcess;
  74971. private _createLuminancePostProcesses;
  74972. private _createHdrPostProcess;
  74973. private _createLensFlarePostProcess;
  74974. private _createDepthOfFieldPostProcess;
  74975. private _createMotionBlurPostProcess;
  74976. private _getDepthTexture;
  74977. private _disposePostProcesses;
  74978. /**
  74979. * Dispose of the pipeline and stop all post processes
  74980. */
  74981. dispose(): void;
  74982. /**
  74983. * Serialize the rendering pipeline (Used when exporting)
  74984. * @returns the serialized object
  74985. */
  74986. serialize(): any;
  74987. /**
  74988. * Parse the serialized pipeline
  74989. * @param source Source pipeline.
  74990. * @param scene The scene to load the pipeline to.
  74991. * @param rootUrl The URL of the serialized pipeline.
  74992. * @returns An instantiated pipeline from the serialized object.
  74993. */
  74994. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74995. /**
  74996. * Luminance steps
  74997. */
  74998. static LuminanceSteps: number;
  74999. }
  75000. }
  75001. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75002. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75003. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75004. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75005. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75006. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75007. }
  75008. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75009. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75010. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75011. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75012. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75013. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75014. }
  75015. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75016. /** @hidden */
  75017. export var stereoscopicInterlacePixelShader: {
  75018. name: string;
  75019. shader: string;
  75020. };
  75021. }
  75022. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75023. import { Camera } from "babylonjs/Cameras/camera";
  75024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75025. import { Engine } from "babylonjs/Engines/engine";
  75026. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75027. /**
  75028. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75029. */
  75030. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75031. private _stepSize;
  75032. private _passedProcess;
  75033. /**
  75034. * Initializes a StereoscopicInterlacePostProcessI
  75035. * @param name The name of the effect.
  75036. * @param rigCameras The rig cameras to be appled to the post process
  75037. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75038. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75040. * @param engine The engine which the post process will be applied. (default: current engine)
  75041. * @param reusable If the post process can be reused on the same frame. (default: false)
  75042. */
  75043. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75044. }
  75045. /**
  75046. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75047. */
  75048. export class StereoscopicInterlacePostProcess extends PostProcess {
  75049. private _stepSize;
  75050. private _passedProcess;
  75051. /**
  75052. * Initializes a StereoscopicInterlacePostProcess
  75053. * @param name The name of the effect.
  75054. * @param rigCameras The rig cameras to be appled to the post process
  75055. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75057. * @param engine The engine which the post process will be applied. (default: current engine)
  75058. * @param reusable If the post process can be reused on the same frame. (default: false)
  75059. */
  75060. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75061. }
  75062. }
  75063. declare module "babylonjs/Shaders/tonemap.fragment" {
  75064. /** @hidden */
  75065. export var tonemapPixelShader: {
  75066. name: string;
  75067. shader: string;
  75068. };
  75069. }
  75070. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75071. import { Camera } from "babylonjs/Cameras/camera";
  75072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75073. import "babylonjs/Shaders/tonemap.fragment";
  75074. import { Engine } from "babylonjs/Engines/engine";
  75075. /** Defines operator used for tonemapping */
  75076. export enum TonemappingOperator {
  75077. /** Hable */
  75078. Hable = 0,
  75079. /** Reinhard */
  75080. Reinhard = 1,
  75081. /** HejiDawson */
  75082. HejiDawson = 2,
  75083. /** Photographic */
  75084. Photographic = 3
  75085. }
  75086. /**
  75087. * Defines a post process to apply tone mapping
  75088. */
  75089. export class TonemapPostProcess extends PostProcess {
  75090. private _operator;
  75091. /** Defines the required exposure adjustement */
  75092. exposureAdjustment: number;
  75093. /**
  75094. * Creates a new TonemapPostProcess
  75095. * @param name defines the name of the postprocess
  75096. * @param _operator defines the operator to use
  75097. * @param exposureAdjustment defines the required exposure adjustement
  75098. * @param camera defines the camera to use (can be null)
  75099. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75100. * @param engine defines the hosting engine (can be ignore if camera is set)
  75101. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75102. */
  75103. constructor(name: string, _operator: TonemappingOperator,
  75104. /** Defines the required exposure adjustement */
  75105. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75106. }
  75107. }
  75108. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75109. /** @hidden */
  75110. export var volumetricLightScatteringPixelShader: {
  75111. name: string;
  75112. shader: string;
  75113. };
  75114. }
  75115. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75116. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75117. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75118. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75119. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75121. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75122. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75123. /** @hidden */
  75124. export var volumetricLightScatteringPassVertexShader: {
  75125. name: string;
  75126. shader: string;
  75127. };
  75128. }
  75129. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75130. /** @hidden */
  75131. export var volumetricLightScatteringPassPixelShader: {
  75132. name: string;
  75133. shader: string;
  75134. };
  75135. }
  75136. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75137. import { Vector3 } from "babylonjs/Maths/math.vector";
  75138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75139. import { Mesh } from "babylonjs/Meshes/mesh";
  75140. import { Camera } from "babylonjs/Cameras/camera";
  75141. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75142. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75143. import { Scene } from "babylonjs/scene";
  75144. import "babylonjs/Meshes/Builders/planeBuilder";
  75145. import "babylonjs/Shaders/depth.vertex";
  75146. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75147. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75148. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75149. import { Engine } from "babylonjs/Engines/engine";
  75150. /**
  75151. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75152. */
  75153. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75154. private _volumetricLightScatteringPass;
  75155. private _volumetricLightScatteringRTT;
  75156. private _viewPort;
  75157. private _screenCoordinates;
  75158. private _cachedDefines;
  75159. /**
  75160. * If not undefined, the mesh position is computed from the attached node position
  75161. */
  75162. attachedNode: {
  75163. position: Vector3;
  75164. };
  75165. /**
  75166. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75167. */
  75168. customMeshPosition: Vector3;
  75169. /**
  75170. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75171. */
  75172. useCustomMeshPosition: boolean;
  75173. /**
  75174. * If the post-process should inverse the light scattering direction
  75175. */
  75176. invert: boolean;
  75177. /**
  75178. * The internal mesh used by the post-process
  75179. */
  75180. mesh: Mesh;
  75181. /**
  75182. * @hidden
  75183. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75184. */
  75185. get useDiffuseColor(): boolean;
  75186. set useDiffuseColor(useDiffuseColor: boolean);
  75187. /**
  75188. * Array containing the excluded meshes not rendered in the internal pass
  75189. */
  75190. excludedMeshes: AbstractMesh[];
  75191. /**
  75192. * Controls the overall intensity of the post-process
  75193. */
  75194. exposure: number;
  75195. /**
  75196. * Dissipates each sample's contribution in range [0, 1]
  75197. */
  75198. decay: number;
  75199. /**
  75200. * Controls the overall intensity of each sample
  75201. */
  75202. weight: number;
  75203. /**
  75204. * Controls the density of each sample
  75205. */
  75206. density: number;
  75207. /**
  75208. * @constructor
  75209. * @param name The post-process name
  75210. * @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)
  75211. * @param camera The camera that the post-process will be attached to
  75212. * @param mesh The mesh used to create the light scattering
  75213. * @param samples The post-process quality, default 100
  75214. * @param samplingModeThe post-process filtering mode
  75215. * @param engine The babylon engine
  75216. * @param reusable If the post-process is reusable
  75217. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75218. */
  75219. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75220. /**
  75221. * Returns the string "VolumetricLightScatteringPostProcess"
  75222. * @returns "VolumetricLightScatteringPostProcess"
  75223. */
  75224. getClassName(): string;
  75225. private _isReady;
  75226. /**
  75227. * Sets the new light position for light scattering effect
  75228. * @param position The new custom light position
  75229. */
  75230. setCustomMeshPosition(position: Vector3): void;
  75231. /**
  75232. * Returns the light position for light scattering effect
  75233. * @return Vector3 The custom light position
  75234. */
  75235. getCustomMeshPosition(): Vector3;
  75236. /**
  75237. * Disposes the internal assets and detaches the post-process from the camera
  75238. */
  75239. dispose(camera: Camera): void;
  75240. /**
  75241. * Returns the render target texture used by the post-process
  75242. * @return the render target texture used by the post-process
  75243. */
  75244. getPass(): RenderTargetTexture;
  75245. private _meshExcluded;
  75246. private _createPass;
  75247. private _updateMeshScreenCoordinates;
  75248. /**
  75249. * Creates a default mesh for the Volumeric Light Scattering post-process
  75250. * @param name The mesh name
  75251. * @param scene The scene where to create the mesh
  75252. * @return the default mesh
  75253. */
  75254. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75255. }
  75256. }
  75257. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75258. /** @hidden */
  75259. export var screenSpaceCurvaturePixelShader: {
  75260. name: string;
  75261. shader: string;
  75262. };
  75263. }
  75264. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75265. import { Nullable } from "babylonjs/types";
  75266. import { Camera } from "babylonjs/Cameras/camera";
  75267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75268. import { Scene } from "babylonjs/scene";
  75269. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75270. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75271. import { Engine } from "babylonjs/Engines/engine";
  75272. /**
  75273. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75274. */
  75275. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75276. /**
  75277. * Defines how much ridge the curvature effect displays.
  75278. */
  75279. ridge: number;
  75280. /**
  75281. * Defines how much valley the curvature effect displays.
  75282. */
  75283. valley: number;
  75284. private _geometryBufferRenderer;
  75285. /**
  75286. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75287. * @param name The name of the effect.
  75288. * @param scene The scene containing the objects to blur according to their velocity.
  75289. * @param options The required width/height ratio to downsize to before computing the render pass.
  75290. * @param camera The camera to apply the render pass to.
  75291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75292. * @param engine The engine which the post process will be applied. (default: current engine)
  75293. * @param reusable If the post process can be reused on the same frame. (default: false)
  75294. * @param textureType Type of textures used when performing the post process. (default: 0)
  75295. * @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)
  75296. */
  75297. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75298. /**
  75299. * Support test.
  75300. */
  75301. static get IsSupported(): boolean;
  75302. }
  75303. }
  75304. declare module "babylonjs/PostProcesses/index" {
  75305. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75306. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75307. export * from "babylonjs/PostProcesses/bloomEffect";
  75308. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75309. export * from "babylonjs/PostProcesses/blurPostProcess";
  75310. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75311. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75312. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75313. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75314. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75315. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75316. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75317. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75318. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75319. export * from "babylonjs/PostProcesses/filterPostProcess";
  75320. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75321. export * from "babylonjs/PostProcesses/grainPostProcess";
  75322. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75323. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75324. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75325. export * from "babylonjs/PostProcesses/passPostProcess";
  75326. export * from "babylonjs/PostProcesses/postProcess";
  75327. export * from "babylonjs/PostProcesses/postProcessManager";
  75328. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75329. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75330. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75331. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75332. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75333. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75334. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75335. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75336. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75337. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75338. }
  75339. declare module "babylonjs/Probes/index" {
  75340. export * from "babylonjs/Probes/reflectionProbe";
  75341. }
  75342. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75343. import { Scene } from "babylonjs/scene";
  75344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75345. import { SmartArray } from "babylonjs/Misc/smartArray";
  75346. import { ISceneComponent } from "babylonjs/sceneComponent";
  75347. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75348. import "babylonjs/Meshes/Builders/boxBuilder";
  75349. import "babylonjs/Shaders/color.fragment";
  75350. import "babylonjs/Shaders/color.vertex";
  75351. import { Color3 } from "babylonjs/Maths/math.color";
  75352. import { Observable } from "babylonjs/Misc/observable";
  75353. module "babylonjs/scene" {
  75354. interface Scene {
  75355. /** @hidden (Backing field) */
  75356. _boundingBoxRenderer: BoundingBoxRenderer;
  75357. /** @hidden (Backing field) */
  75358. _forceShowBoundingBoxes: boolean;
  75359. /**
  75360. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75361. */
  75362. forceShowBoundingBoxes: boolean;
  75363. /**
  75364. * Gets the bounding box renderer associated with the scene
  75365. * @returns a BoundingBoxRenderer
  75366. */
  75367. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75368. }
  75369. }
  75370. module "babylonjs/Meshes/abstractMesh" {
  75371. interface AbstractMesh {
  75372. /** @hidden (Backing field) */
  75373. _showBoundingBox: boolean;
  75374. /**
  75375. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75376. */
  75377. showBoundingBox: boolean;
  75378. }
  75379. }
  75380. /**
  75381. * Component responsible of rendering the bounding box of the meshes in a scene.
  75382. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75383. */
  75384. export class BoundingBoxRenderer implements ISceneComponent {
  75385. /**
  75386. * The component name helpfull to identify the component in the list of scene components.
  75387. */
  75388. readonly name: string;
  75389. /**
  75390. * The scene the component belongs to.
  75391. */
  75392. scene: Scene;
  75393. /**
  75394. * Color of the bounding box lines placed in front of an object
  75395. */
  75396. frontColor: Color3;
  75397. /**
  75398. * Color of the bounding box lines placed behind an object
  75399. */
  75400. backColor: Color3;
  75401. /**
  75402. * Defines if the renderer should show the back lines or not
  75403. */
  75404. showBackLines: boolean;
  75405. /**
  75406. * Observable raised before rendering a bounding box
  75407. */
  75408. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75409. /**
  75410. * Observable raised after rendering a bounding box
  75411. */
  75412. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75413. /**
  75414. * @hidden
  75415. */
  75416. renderList: SmartArray<BoundingBox>;
  75417. private _colorShader;
  75418. private _vertexBuffers;
  75419. private _indexBuffer;
  75420. private _fillIndexBuffer;
  75421. private _fillIndexData;
  75422. /**
  75423. * Instantiates a new bounding box renderer in a scene.
  75424. * @param scene the scene the renderer renders in
  75425. */
  75426. constructor(scene: Scene);
  75427. /**
  75428. * Registers the component in a given scene
  75429. */
  75430. register(): void;
  75431. private _evaluateSubMesh;
  75432. private _activeMesh;
  75433. private _prepareRessources;
  75434. private _createIndexBuffer;
  75435. /**
  75436. * Rebuilds the elements related to this component in case of
  75437. * context lost for instance.
  75438. */
  75439. rebuild(): void;
  75440. /**
  75441. * @hidden
  75442. */
  75443. reset(): void;
  75444. /**
  75445. * Render the bounding boxes of a specific rendering group
  75446. * @param renderingGroupId defines the rendering group to render
  75447. */
  75448. render(renderingGroupId: number): void;
  75449. /**
  75450. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75451. * @param mesh Define the mesh to render the occlusion bounding box for
  75452. */
  75453. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75454. /**
  75455. * Dispose and release the resources attached to this renderer.
  75456. */
  75457. dispose(): void;
  75458. }
  75459. }
  75460. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75461. import { Nullable } from "babylonjs/types";
  75462. import { Scene } from "babylonjs/scene";
  75463. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75464. import { Camera } from "babylonjs/Cameras/camera";
  75465. import { ISceneComponent } from "babylonjs/sceneComponent";
  75466. module "babylonjs/scene" {
  75467. interface Scene {
  75468. /** @hidden (Backing field) */
  75469. _depthRenderer: {
  75470. [id: string]: DepthRenderer;
  75471. };
  75472. /**
  75473. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75474. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75475. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75476. * @returns the created depth renderer
  75477. */
  75478. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75479. /**
  75480. * Disables a depth renderer for a given camera
  75481. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75482. */
  75483. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75484. }
  75485. }
  75486. /**
  75487. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75488. * in several rendering techniques.
  75489. */
  75490. export class DepthRendererSceneComponent implements ISceneComponent {
  75491. /**
  75492. * The component name helpfull to identify the component in the list of scene components.
  75493. */
  75494. readonly name: string;
  75495. /**
  75496. * The scene the component belongs to.
  75497. */
  75498. scene: Scene;
  75499. /**
  75500. * Creates a new instance of the component for the given scene
  75501. * @param scene Defines the scene to register the component in
  75502. */
  75503. constructor(scene: Scene);
  75504. /**
  75505. * Registers the component in a given scene
  75506. */
  75507. register(): void;
  75508. /**
  75509. * Rebuilds the elements related to this component in case of
  75510. * context lost for instance.
  75511. */
  75512. rebuild(): void;
  75513. /**
  75514. * Disposes the component and the associated ressources
  75515. */
  75516. dispose(): void;
  75517. private _gatherRenderTargets;
  75518. private _gatherActiveCameraRenderTargets;
  75519. }
  75520. }
  75521. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75522. import { Nullable } from "babylonjs/types";
  75523. import { Scene } from "babylonjs/scene";
  75524. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75525. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75526. import { AbstractScene } from "babylonjs/abstractScene";
  75527. module "babylonjs/abstractScene" {
  75528. interface AbstractScene {
  75529. /** @hidden (Backing field) */
  75530. _prePassRenderer: Nullable<PrePassRenderer>;
  75531. /**
  75532. * Gets or Sets the current prepass renderer associated to the scene.
  75533. */
  75534. prePassRenderer: Nullable<PrePassRenderer>;
  75535. /**
  75536. * Enables the prepass and associates it with the scene
  75537. * @returns the PrePassRenderer
  75538. */
  75539. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75540. /**
  75541. * Disables the prepass associated with the scene
  75542. */
  75543. disablePrePassRenderer(): void;
  75544. }
  75545. }
  75546. /**
  75547. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75548. * in several rendering techniques.
  75549. */
  75550. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75551. /**
  75552. * The component name helpful to identify the component in the list of scene components.
  75553. */
  75554. readonly name: string;
  75555. /**
  75556. * The scene the component belongs to.
  75557. */
  75558. scene: Scene;
  75559. /**
  75560. * Creates a new instance of the component for the given scene
  75561. * @param scene Defines the scene to register the component in
  75562. */
  75563. constructor(scene: Scene);
  75564. /**
  75565. * Registers the component in a given scene
  75566. */
  75567. register(): void;
  75568. private _beforeCameraDraw;
  75569. private _afterCameraDraw;
  75570. private _beforeClearStage;
  75571. /**
  75572. * Serializes the component data to the specified json object
  75573. * @param serializationObject The object to serialize to
  75574. */
  75575. serialize(serializationObject: any): void;
  75576. /**
  75577. * Adds all the elements from the container to the scene
  75578. * @param container the container holding the elements
  75579. */
  75580. addFromContainer(container: AbstractScene): void;
  75581. /**
  75582. * Removes all the elements in the container from the scene
  75583. * @param container contains the elements to remove
  75584. * @param dispose if the removed element should be disposed (default: false)
  75585. */
  75586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75587. /**
  75588. * Rebuilds the elements related to this component in case of
  75589. * context lost for instance.
  75590. */
  75591. rebuild(): void;
  75592. /**
  75593. * Disposes the component and the associated ressources
  75594. */
  75595. dispose(): void;
  75596. }
  75597. }
  75598. declare module "babylonjs/Shaders/outline.fragment" {
  75599. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75600. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75601. /** @hidden */
  75602. export var outlinePixelShader: {
  75603. name: string;
  75604. shader: string;
  75605. };
  75606. }
  75607. declare module "babylonjs/Shaders/outline.vertex" {
  75608. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75609. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75610. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75612. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75613. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75614. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75615. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75616. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75617. /** @hidden */
  75618. export var outlineVertexShader: {
  75619. name: string;
  75620. shader: string;
  75621. };
  75622. }
  75623. declare module "babylonjs/Rendering/outlineRenderer" {
  75624. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75625. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75626. import { Scene } from "babylonjs/scene";
  75627. import { ISceneComponent } from "babylonjs/sceneComponent";
  75628. import "babylonjs/Shaders/outline.fragment";
  75629. import "babylonjs/Shaders/outline.vertex";
  75630. module "babylonjs/scene" {
  75631. interface Scene {
  75632. /** @hidden */
  75633. _outlineRenderer: OutlineRenderer;
  75634. /**
  75635. * Gets the outline renderer associated with the scene
  75636. * @returns a OutlineRenderer
  75637. */
  75638. getOutlineRenderer(): OutlineRenderer;
  75639. }
  75640. }
  75641. module "babylonjs/Meshes/abstractMesh" {
  75642. interface AbstractMesh {
  75643. /** @hidden (Backing field) */
  75644. _renderOutline: boolean;
  75645. /**
  75646. * Gets or sets a boolean indicating if the outline must be rendered as well
  75647. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75648. */
  75649. renderOutline: boolean;
  75650. /** @hidden (Backing field) */
  75651. _renderOverlay: boolean;
  75652. /**
  75653. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75654. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75655. */
  75656. renderOverlay: boolean;
  75657. }
  75658. }
  75659. /**
  75660. * This class is responsible to draw bothe outline/overlay of meshes.
  75661. * It should not be used directly but through the available method on mesh.
  75662. */
  75663. export class OutlineRenderer implements ISceneComponent {
  75664. /**
  75665. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75666. */
  75667. private static _StencilReference;
  75668. /**
  75669. * The name of the component. Each component must have a unique name.
  75670. */
  75671. name: string;
  75672. /**
  75673. * The scene the component belongs to.
  75674. */
  75675. scene: Scene;
  75676. /**
  75677. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75678. */
  75679. zOffset: number;
  75680. private _engine;
  75681. private _effect;
  75682. private _cachedDefines;
  75683. private _savedDepthWrite;
  75684. /**
  75685. * Instantiates a new outline renderer. (There could be only one per scene).
  75686. * @param scene Defines the scene it belongs to
  75687. */
  75688. constructor(scene: Scene);
  75689. /**
  75690. * Register the component to one instance of a scene.
  75691. */
  75692. register(): void;
  75693. /**
  75694. * Rebuilds the elements related to this component in case of
  75695. * context lost for instance.
  75696. */
  75697. rebuild(): void;
  75698. /**
  75699. * Disposes the component and the associated ressources.
  75700. */
  75701. dispose(): void;
  75702. /**
  75703. * Renders the outline in the canvas.
  75704. * @param subMesh Defines the sumesh to render
  75705. * @param batch Defines the batch of meshes in case of instances
  75706. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75707. */
  75708. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75709. /**
  75710. * Returns whether or not the outline renderer is ready for a given submesh.
  75711. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75712. * @param subMesh Defines the submesh to check readyness for
  75713. * @param useInstances Defines wheter wee are trying to render instances or not
  75714. * @returns true if ready otherwise false
  75715. */
  75716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75717. private _beforeRenderingMesh;
  75718. private _afterRenderingMesh;
  75719. }
  75720. }
  75721. declare module "babylonjs/Rendering/index" {
  75722. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75723. export * from "babylonjs/Rendering/depthRenderer";
  75724. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75725. export * from "babylonjs/Rendering/edgesRenderer";
  75726. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75727. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75728. export * from "babylonjs/Rendering/prePassRenderer";
  75729. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75730. export * from "babylonjs/Rendering/outlineRenderer";
  75731. export * from "babylonjs/Rendering/renderingGroup";
  75732. export * from "babylonjs/Rendering/renderingManager";
  75733. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75734. }
  75735. declare module "babylonjs/Sprites/ISprites" {
  75736. /**
  75737. * Defines the basic options interface of a Sprite Frame Source Size.
  75738. */
  75739. export interface ISpriteJSONSpriteSourceSize {
  75740. /**
  75741. * number of the original width of the Frame
  75742. */
  75743. w: number;
  75744. /**
  75745. * number of the original height of the Frame
  75746. */
  75747. h: number;
  75748. }
  75749. /**
  75750. * Defines the basic options interface of a Sprite Frame Data.
  75751. */
  75752. export interface ISpriteJSONSpriteFrameData {
  75753. /**
  75754. * number of the x offset of the Frame
  75755. */
  75756. x: number;
  75757. /**
  75758. * number of the y offset of the Frame
  75759. */
  75760. y: number;
  75761. /**
  75762. * number of the width of the Frame
  75763. */
  75764. w: number;
  75765. /**
  75766. * number of the height of the Frame
  75767. */
  75768. h: number;
  75769. }
  75770. /**
  75771. * Defines the basic options interface of a JSON Sprite.
  75772. */
  75773. export interface ISpriteJSONSprite {
  75774. /**
  75775. * string name of the Frame
  75776. */
  75777. filename: string;
  75778. /**
  75779. * ISpriteJSONSpriteFrame basic object of the frame data
  75780. */
  75781. frame: ISpriteJSONSpriteFrameData;
  75782. /**
  75783. * boolean to flag is the frame was rotated.
  75784. */
  75785. rotated: boolean;
  75786. /**
  75787. * boolean to flag is the frame was trimmed.
  75788. */
  75789. trimmed: boolean;
  75790. /**
  75791. * ISpriteJSONSpriteFrame basic object of the source data
  75792. */
  75793. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75794. /**
  75795. * ISpriteJSONSpriteFrame basic object of the source data
  75796. */
  75797. sourceSize: ISpriteJSONSpriteSourceSize;
  75798. }
  75799. /**
  75800. * Defines the basic options interface of a JSON atlas.
  75801. */
  75802. export interface ISpriteJSONAtlas {
  75803. /**
  75804. * Array of objects that contain the frame data.
  75805. */
  75806. frames: Array<ISpriteJSONSprite>;
  75807. /**
  75808. * object basic object containing the sprite meta data.
  75809. */
  75810. meta?: object;
  75811. }
  75812. }
  75813. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75814. /** @hidden */
  75815. export var spriteMapPixelShader: {
  75816. name: string;
  75817. shader: string;
  75818. };
  75819. }
  75820. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75821. /** @hidden */
  75822. export var spriteMapVertexShader: {
  75823. name: string;
  75824. shader: string;
  75825. };
  75826. }
  75827. declare module "babylonjs/Sprites/spriteMap" {
  75828. import { IDisposable, Scene } from "babylonjs/scene";
  75829. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75830. import { Texture } from "babylonjs/Materials/Textures/texture";
  75831. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75832. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75833. import "babylonjs/Meshes/Builders/planeBuilder";
  75834. import "babylonjs/Shaders/spriteMap.fragment";
  75835. import "babylonjs/Shaders/spriteMap.vertex";
  75836. /**
  75837. * Defines the basic options interface of a SpriteMap
  75838. */
  75839. export interface ISpriteMapOptions {
  75840. /**
  75841. * Vector2 of the number of cells in the grid.
  75842. */
  75843. stageSize?: Vector2;
  75844. /**
  75845. * Vector2 of the size of the output plane in World Units.
  75846. */
  75847. outputSize?: Vector2;
  75848. /**
  75849. * Vector3 of the position of the output plane in World Units.
  75850. */
  75851. outputPosition?: Vector3;
  75852. /**
  75853. * Vector3 of the rotation of the output plane.
  75854. */
  75855. outputRotation?: Vector3;
  75856. /**
  75857. * number of layers that the system will reserve in resources.
  75858. */
  75859. layerCount?: number;
  75860. /**
  75861. * number of max animation frames a single cell will reserve in resources.
  75862. */
  75863. maxAnimationFrames?: number;
  75864. /**
  75865. * number cell index of the base tile when the system compiles.
  75866. */
  75867. baseTile?: number;
  75868. /**
  75869. * boolean flip the sprite after its been repositioned by the framing data.
  75870. */
  75871. flipU?: boolean;
  75872. /**
  75873. * Vector3 scalar of the global RGB values of the SpriteMap.
  75874. */
  75875. colorMultiply?: Vector3;
  75876. }
  75877. /**
  75878. * Defines the IDisposable interface in order to be cleanable from resources.
  75879. */
  75880. export interface ISpriteMap extends IDisposable {
  75881. /**
  75882. * String name of the SpriteMap.
  75883. */
  75884. name: string;
  75885. /**
  75886. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75887. */
  75888. atlasJSON: ISpriteJSONAtlas;
  75889. /**
  75890. * Texture of the SpriteMap.
  75891. */
  75892. spriteSheet: Texture;
  75893. /**
  75894. * The parameters to initialize the SpriteMap with.
  75895. */
  75896. options: ISpriteMapOptions;
  75897. }
  75898. /**
  75899. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75900. */
  75901. export class SpriteMap implements ISpriteMap {
  75902. /** The Name of the spriteMap */
  75903. name: string;
  75904. /** The JSON file with the frame and meta data */
  75905. atlasJSON: ISpriteJSONAtlas;
  75906. /** The systems Sprite Sheet Texture */
  75907. spriteSheet: Texture;
  75908. /** Arguments passed with the Constructor */
  75909. options: ISpriteMapOptions;
  75910. /** Public Sprite Storage array, parsed from atlasJSON */
  75911. sprites: Array<ISpriteJSONSprite>;
  75912. /** Returns the Number of Sprites in the System */
  75913. get spriteCount(): number;
  75914. /** Returns the Position of Output Plane*/
  75915. get position(): Vector3;
  75916. /** Returns the Position of Output Plane*/
  75917. set position(v: Vector3);
  75918. /** Returns the Rotation of Output Plane*/
  75919. get rotation(): Vector3;
  75920. /** Returns the Rotation of Output Plane*/
  75921. set rotation(v: Vector3);
  75922. /** Sets the AnimationMap*/
  75923. get animationMap(): RawTexture;
  75924. /** Sets the AnimationMap*/
  75925. set animationMap(v: RawTexture);
  75926. /** Scene that the SpriteMap was created in */
  75927. private _scene;
  75928. /** Texture Buffer of Float32 that holds tile frame data*/
  75929. private _frameMap;
  75930. /** Texture Buffers of Float32 that holds tileMap data*/
  75931. private _tileMaps;
  75932. /** Texture Buffer of Float32 that holds Animation Data*/
  75933. private _animationMap;
  75934. /** Custom ShaderMaterial Central to the System*/
  75935. private _material;
  75936. /** Custom ShaderMaterial Central to the System*/
  75937. private _output;
  75938. /** Systems Time Ticker*/
  75939. private _time;
  75940. /**
  75941. * Creates a new SpriteMap
  75942. * @param name defines the SpriteMaps Name
  75943. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75944. * @param spriteSheet is the Texture that the Sprites are on.
  75945. * @param options a basic deployment configuration
  75946. * @param scene The Scene that the map is deployed on
  75947. */
  75948. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75949. /**
  75950. * Returns tileID location
  75951. * @returns Vector2 the cell position ID
  75952. */
  75953. getTileID(): Vector2;
  75954. /**
  75955. * Gets the UV location of the mouse over the SpriteMap.
  75956. * @returns Vector2 the UV position of the mouse interaction
  75957. */
  75958. getMousePosition(): Vector2;
  75959. /**
  75960. * Creates the "frame" texture Buffer
  75961. * -------------------------------------
  75962. * Structure of frames
  75963. * "filename": "Falling-Water-2.png",
  75964. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75965. * "rotated": true,
  75966. * "trimmed": true,
  75967. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75968. * "sourceSize": {"w":32,"h":32}
  75969. * @returns RawTexture of the frameMap
  75970. */
  75971. private _createFrameBuffer;
  75972. /**
  75973. * Creates the tileMap texture Buffer
  75974. * @param buffer normally and array of numbers, or a false to generate from scratch
  75975. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75976. * @returns RawTexture of the tileMap
  75977. */
  75978. private _createTileBuffer;
  75979. /**
  75980. * Modifies the data of the tileMaps
  75981. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75982. * @param pos is the iVector2 Coordinates of the Tile
  75983. * @param tile The SpriteIndex of the new Tile
  75984. */
  75985. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75986. /**
  75987. * Creates the animationMap texture Buffer
  75988. * @param buffer normally and array of numbers, or a false to generate from scratch
  75989. * @returns RawTexture of the animationMap
  75990. */
  75991. private _createTileAnimationBuffer;
  75992. /**
  75993. * Modifies the data of the animationMap
  75994. * @param cellID is the Index of the Sprite
  75995. * @param _frame is the target Animation frame
  75996. * @param toCell is the Target Index of the next frame of the animation
  75997. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75998. * @param speed is a global scalar of the time variable on the map.
  75999. */
  76000. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76001. /**
  76002. * Exports the .tilemaps file
  76003. */
  76004. saveTileMaps(): void;
  76005. /**
  76006. * Imports the .tilemaps file
  76007. * @param url of the .tilemaps file
  76008. */
  76009. loadTileMaps(url: string): void;
  76010. /**
  76011. * Release associated resources
  76012. */
  76013. dispose(): void;
  76014. }
  76015. }
  76016. declare module "babylonjs/Sprites/spritePackedManager" {
  76017. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76018. import { Scene } from "babylonjs/scene";
  76019. /**
  76020. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76021. * @see https://doc.babylonjs.com/babylon101/sprites
  76022. */
  76023. export class SpritePackedManager extends SpriteManager {
  76024. /** defines the packed manager's name */
  76025. name: string;
  76026. /**
  76027. * Creates a new sprite manager from a packed sprite sheet
  76028. * @param name defines the manager's name
  76029. * @param imgUrl defines the sprite sheet url
  76030. * @param capacity defines the maximum allowed number of sprites
  76031. * @param scene defines the hosting scene
  76032. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76033. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76034. * @param samplingMode defines the smapling mode to use with spritesheet
  76035. * @param fromPacked set to true; do not alter
  76036. */
  76037. constructor(
  76038. /** defines the packed manager's name */
  76039. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76040. }
  76041. }
  76042. declare module "babylonjs/Sprites/index" {
  76043. export * from "babylonjs/Sprites/sprite";
  76044. export * from "babylonjs/Sprites/ISprites";
  76045. export * from "babylonjs/Sprites/spriteManager";
  76046. export * from "babylonjs/Sprites/spriteMap";
  76047. export * from "babylonjs/Sprites/spritePackedManager";
  76048. export * from "babylonjs/Sprites/spriteSceneComponent";
  76049. }
  76050. declare module "babylonjs/States/index" {
  76051. export * from "babylonjs/States/alphaCullingState";
  76052. export * from "babylonjs/States/depthCullingState";
  76053. export * from "babylonjs/States/stencilState";
  76054. }
  76055. declare module "babylonjs/Misc/assetsManager" {
  76056. import { Scene } from "babylonjs/scene";
  76057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76058. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76059. import { Skeleton } from "babylonjs/Bones/skeleton";
  76060. import { Observable } from "babylonjs/Misc/observable";
  76061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76062. import { Texture } from "babylonjs/Materials/Textures/texture";
  76063. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76064. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76065. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76066. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76067. import { AssetContainer } from "babylonjs/assetContainer";
  76068. /**
  76069. * Defines the list of states available for a task inside a AssetsManager
  76070. */
  76071. export enum AssetTaskState {
  76072. /**
  76073. * Initialization
  76074. */
  76075. INIT = 0,
  76076. /**
  76077. * Running
  76078. */
  76079. RUNNING = 1,
  76080. /**
  76081. * Done
  76082. */
  76083. DONE = 2,
  76084. /**
  76085. * Error
  76086. */
  76087. ERROR = 3
  76088. }
  76089. /**
  76090. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76091. */
  76092. export abstract class AbstractAssetTask {
  76093. /**
  76094. * Task name
  76095. */ name: string;
  76096. /**
  76097. * Callback called when the task is successful
  76098. */
  76099. onSuccess: (task: any) => void;
  76100. /**
  76101. * Callback called when the task is not successful
  76102. */
  76103. onError: (task: any, message?: string, exception?: any) => void;
  76104. /**
  76105. * Creates a new AssetsManager
  76106. * @param name defines the name of the task
  76107. */
  76108. constructor(
  76109. /**
  76110. * Task name
  76111. */ name: string);
  76112. private _isCompleted;
  76113. private _taskState;
  76114. private _errorObject;
  76115. /**
  76116. * Get if the task is completed
  76117. */
  76118. get isCompleted(): boolean;
  76119. /**
  76120. * Gets the current state of the task
  76121. */
  76122. get taskState(): AssetTaskState;
  76123. /**
  76124. * Gets the current error object (if task is in error)
  76125. */
  76126. get errorObject(): {
  76127. message?: string;
  76128. exception?: any;
  76129. };
  76130. /**
  76131. * Internal only
  76132. * @hidden
  76133. */
  76134. _setErrorObject(message?: string, exception?: any): void;
  76135. /**
  76136. * Execute the current task
  76137. * @param scene defines the scene where you want your assets to be loaded
  76138. * @param onSuccess is a callback called when the task is successfully executed
  76139. * @param onError is a callback called if an error occurs
  76140. */
  76141. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76142. /**
  76143. * Execute the current task
  76144. * @param scene defines the scene where you want your assets to be loaded
  76145. * @param onSuccess is a callback called when the task is successfully executed
  76146. * @param onError is a callback called if an error occurs
  76147. */
  76148. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76149. /**
  76150. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76151. * This can be used with failed tasks that have the reason for failure fixed.
  76152. */
  76153. reset(): void;
  76154. private onErrorCallback;
  76155. private onDoneCallback;
  76156. }
  76157. /**
  76158. * Define the interface used by progress events raised during assets loading
  76159. */
  76160. export interface IAssetsProgressEvent {
  76161. /**
  76162. * Defines the number of remaining tasks to process
  76163. */
  76164. remainingCount: number;
  76165. /**
  76166. * Defines the total number of tasks
  76167. */
  76168. totalCount: number;
  76169. /**
  76170. * Defines the task that was just processed
  76171. */
  76172. task: AbstractAssetTask;
  76173. }
  76174. /**
  76175. * Class used to share progress information about assets loading
  76176. */
  76177. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76178. /**
  76179. * Defines the number of remaining tasks to process
  76180. */
  76181. remainingCount: number;
  76182. /**
  76183. * Defines the total number of tasks
  76184. */
  76185. totalCount: number;
  76186. /**
  76187. * Defines the task that was just processed
  76188. */
  76189. task: AbstractAssetTask;
  76190. /**
  76191. * Creates a AssetsProgressEvent
  76192. * @param remainingCount defines the number of remaining tasks to process
  76193. * @param totalCount defines the total number of tasks
  76194. * @param task defines the task that was just processed
  76195. */
  76196. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76197. }
  76198. /**
  76199. * Define a task used by AssetsManager to load assets into a container
  76200. */
  76201. export class ContainerAssetTask extends AbstractAssetTask {
  76202. /**
  76203. * Defines the name of the task
  76204. */
  76205. name: string;
  76206. /**
  76207. * Defines the list of mesh's names you want to load
  76208. */
  76209. meshesNames: any;
  76210. /**
  76211. * Defines the root url to use as a base to load your meshes and associated resources
  76212. */
  76213. rootUrl: string;
  76214. /**
  76215. * Defines the filename or File of the scene to load from
  76216. */
  76217. sceneFilename: string | File;
  76218. /**
  76219. * Get the loaded asset container
  76220. */
  76221. loadedContainer: AssetContainer;
  76222. /**
  76223. * Gets the list of loaded meshes
  76224. */
  76225. loadedMeshes: Array<AbstractMesh>;
  76226. /**
  76227. * Gets the list of loaded particle systems
  76228. */
  76229. loadedParticleSystems: Array<IParticleSystem>;
  76230. /**
  76231. * Gets the list of loaded skeletons
  76232. */
  76233. loadedSkeletons: Array<Skeleton>;
  76234. /**
  76235. * Gets the list of loaded animation groups
  76236. */
  76237. loadedAnimationGroups: Array<AnimationGroup>;
  76238. /**
  76239. * Callback called when the task is successful
  76240. */
  76241. onSuccess: (task: ContainerAssetTask) => void;
  76242. /**
  76243. * Callback called when the task is successful
  76244. */
  76245. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76246. /**
  76247. * Creates a new ContainerAssetTask
  76248. * @param name defines the name of the task
  76249. * @param meshesNames defines the list of mesh's names you want to load
  76250. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76251. * @param sceneFilename defines the filename or File of the scene to load from
  76252. */
  76253. constructor(
  76254. /**
  76255. * Defines the name of the task
  76256. */
  76257. name: string,
  76258. /**
  76259. * Defines the list of mesh's names you want to load
  76260. */
  76261. meshesNames: any,
  76262. /**
  76263. * Defines the root url to use as a base to load your meshes and associated resources
  76264. */
  76265. rootUrl: string,
  76266. /**
  76267. * Defines the filename or File of the scene to load from
  76268. */
  76269. sceneFilename: string | File);
  76270. /**
  76271. * Execute the current task
  76272. * @param scene defines the scene where you want your assets to be loaded
  76273. * @param onSuccess is a callback called when the task is successfully executed
  76274. * @param onError is a callback called if an error occurs
  76275. */
  76276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76277. }
  76278. /**
  76279. * Define a task used by AssetsManager to load meshes
  76280. */
  76281. export class MeshAssetTask extends AbstractAssetTask {
  76282. /**
  76283. * Defines the name of the task
  76284. */
  76285. name: string;
  76286. /**
  76287. * Defines the list of mesh's names you want to load
  76288. */
  76289. meshesNames: any;
  76290. /**
  76291. * Defines the root url to use as a base to load your meshes and associated resources
  76292. */
  76293. rootUrl: string;
  76294. /**
  76295. * Defines the filename or File of the scene to load from
  76296. */
  76297. sceneFilename: string | File;
  76298. /**
  76299. * Gets the list of loaded meshes
  76300. */
  76301. loadedMeshes: Array<AbstractMesh>;
  76302. /**
  76303. * Gets the list of loaded particle systems
  76304. */
  76305. loadedParticleSystems: Array<IParticleSystem>;
  76306. /**
  76307. * Gets the list of loaded skeletons
  76308. */
  76309. loadedSkeletons: Array<Skeleton>;
  76310. /**
  76311. * Gets the list of loaded animation groups
  76312. */
  76313. loadedAnimationGroups: Array<AnimationGroup>;
  76314. /**
  76315. * Callback called when the task is successful
  76316. */
  76317. onSuccess: (task: MeshAssetTask) => void;
  76318. /**
  76319. * Callback called when the task is successful
  76320. */
  76321. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76322. /**
  76323. * Creates a new MeshAssetTask
  76324. * @param name defines the name of the task
  76325. * @param meshesNames defines the list of mesh's names you want to load
  76326. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76327. * @param sceneFilename defines the filename or File of the scene to load from
  76328. */
  76329. constructor(
  76330. /**
  76331. * Defines the name of the task
  76332. */
  76333. name: string,
  76334. /**
  76335. * Defines the list of mesh's names you want to load
  76336. */
  76337. meshesNames: any,
  76338. /**
  76339. * Defines the root url to use as a base to load your meshes and associated resources
  76340. */
  76341. rootUrl: string,
  76342. /**
  76343. * Defines the filename or File of the scene to load from
  76344. */
  76345. sceneFilename: string | File);
  76346. /**
  76347. * Execute the current task
  76348. * @param scene defines the scene where you want your assets to be loaded
  76349. * @param onSuccess is a callback called when the task is successfully executed
  76350. * @param onError is a callback called if an error occurs
  76351. */
  76352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76353. }
  76354. /**
  76355. * Define a task used by AssetsManager to load text content
  76356. */
  76357. export class TextFileAssetTask extends AbstractAssetTask {
  76358. /**
  76359. * Defines the name of the task
  76360. */
  76361. name: string;
  76362. /**
  76363. * Defines the location of the file to load
  76364. */
  76365. url: string;
  76366. /**
  76367. * Gets the loaded text string
  76368. */
  76369. text: string;
  76370. /**
  76371. * Callback called when the task is successful
  76372. */
  76373. onSuccess: (task: TextFileAssetTask) => void;
  76374. /**
  76375. * Callback called when the task is successful
  76376. */
  76377. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76378. /**
  76379. * Creates a new TextFileAssetTask object
  76380. * @param name defines the name of the task
  76381. * @param url defines the location of the file to load
  76382. */
  76383. constructor(
  76384. /**
  76385. * Defines the name of the task
  76386. */
  76387. name: string,
  76388. /**
  76389. * Defines the location of the file to load
  76390. */
  76391. url: string);
  76392. /**
  76393. * Execute the current task
  76394. * @param scene defines the scene where you want your assets to be loaded
  76395. * @param onSuccess is a callback called when the task is successfully executed
  76396. * @param onError is a callback called if an error occurs
  76397. */
  76398. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76399. }
  76400. /**
  76401. * Define a task used by AssetsManager to load binary data
  76402. */
  76403. export class BinaryFileAssetTask extends AbstractAssetTask {
  76404. /**
  76405. * Defines the name of the task
  76406. */
  76407. name: string;
  76408. /**
  76409. * Defines the location of the file to load
  76410. */
  76411. url: string;
  76412. /**
  76413. * Gets the lodaded data (as an array buffer)
  76414. */
  76415. data: ArrayBuffer;
  76416. /**
  76417. * Callback called when the task is successful
  76418. */
  76419. onSuccess: (task: BinaryFileAssetTask) => void;
  76420. /**
  76421. * Callback called when the task is successful
  76422. */
  76423. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76424. /**
  76425. * Creates a new BinaryFileAssetTask object
  76426. * @param name defines the name of the new task
  76427. * @param url defines the location of the file to load
  76428. */
  76429. constructor(
  76430. /**
  76431. * Defines the name of the task
  76432. */
  76433. name: string,
  76434. /**
  76435. * Defines the location of the file to load
  76436. */
  76437. url: string);
  76438. /**
  76439. * Execute the current task
  76440. * @param scene defines the scene where you want your assets to be loaded
  76441. * @param onSuccess is a callback called when the task is successfully executed
  76442. * @param onError is a callback called if an error occurs
  76443. */
  76444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76445. }
  76446. /**
  76447. * Define a task used by AssetsManager to load images
  76448. */
  76449. export class ImageAssetTask extends AbstractAssetTask {
  76450. /**
  76451. * Defines the name of the task
  76452. */
  76453. name: string;
  76454. /**
  76455. * Defines the location of the image to load
  76456. */
  76457. url: string;
  76458. /**
  76459. * Gets the loaded images
  76460. */
  76461. image: HTMLImageElement;
  76462. /**
  76463. * Callback called when the task is successful
  76464. */
  76465. onSuccess: (task: ImageAssetTask) => void;
  76466. /**
  76467. * Callback called when the task is successful
  76468. */
  76469. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76470. /**
  76471. * Creates a new ImageAssetTask
  76472. * @param name defines the name of the task
  76473. * @param url defines the location of the image to load
  76474. */
  76475. constructor(
  76476. /**
  76477. * Defines the name of the task
  76478. */
  76479. name: string,
  76480. /**
  76481. * Defines the location of the image to load
  76482. */
  76483. url: string);
  76484. /**
  76485. * Execute the current task
  76486. * @param scene defines the scene where you want your assets to be loaded
  76487. * @param onSuccess is a callback called when the task is successfully executed
  76488. * @param onError is a callback called if an error occurs
  76489. */
  76490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76491. }
  76492. /**
  76493. * Defines the interface used by texture loading tasks
  76494. */
  76495. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76496. /**
  76497. * Gets the loaded texture
  76498. */
  76499. texture: TEX;
  76500. }
  76501. /**
  76502. * Define a task used by AssetsManager to load 2D textures
  76503. */
  76504. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76505. /**
  76506. * Defines the name of the task
  76507. */
  76508. name: string;
  76509. /**
  76510. * Defines the location of the file to load
  76511. */
  76512. url: string;
  76513. /**
  76514. * Defines if mipmap should not be generated (default is false)
  76515. */
  76516. noMipmap?: boolean | undefined;
  76517. /**
  76518. * Defines if texture must be inverted on Y axis (default is true)
  76519. */
  76520. invertY: boolean;
  76521. /**
  76522. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76523. */
  76524. samplingMode: number;
  76525. /**
  76526. * Gets the loaded texture
  76527. */
  76528. texture: Texture;
  76529. /**
  76530. * Callback called when the task is successful
  76531. */
  76532. onSuccess: (task: TextureAssetTask) => void;
  76533. /**
  76534. * Callback called when the task is successful
  76535. */
  76536. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76537. /**
  76538. * Creates a new TextureAssetTask object
  76539. * @param name defines the name of the task
  76540. * @param url defines the location of the file to load
  76541. * @param noMipmap defines if mipmap should not be generated (default is false)
  76542. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76543. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76544. */
  76545. constructor(
  76546. /**
  76547. * Defines the name of the task
  76548. */
  76549. name: string,
  76550. /**
  76551. * Defines the location of the file to load
  76552. */
  76553. url: string,
  76554. /**
  76555. * Defines if mipmap should not be generated (default is false)
  76556. */
  76557. noMipmap?: boolean | undefined,
  76558. /**
  76559. * Defines if texture must be inverted on Y axis (default is true)
  76560. */
  76561. invertY?: boolean,
  76562. /**
  76563. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76564. */
  76565. samplingMode?: number);
  76566. /**
  76567. * Execute the current task
  76568. * @param scene defines the scene where you want your assets to be loaded
  76569. * @param onSuccess is a callback called when the task is successfully executed
  76570. * @param onError is a callback called if an error occurs
  76571. */
  76572. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76573. }
  76574. /**
  76575. * Define a task used by AssetsManager to load cube textures
  76576. */
  76577. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76578. /**
  76579. * Defines the name of the task
  76580. */
  76581. name: string;
  76582. /**
  76583. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76584. */
  76585. url: string;
  76586. /**
  76587. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76588. */
  76589. extensions?: string[] | undefined;
  76590. /**
  76591. * Defines if mipmaps should not be generated (default is false)
  76592. */
  76593. noMipmap?: boolean | undefined;
  76594. /**
  76595. * Defines the explicit list of files (undefined by default)
  76596. */
  76597. files?: string[] | undefined;
  76598. /**
  76599. * Gets the loaded texture
  76600. */
  76601. texture: CubeTexture;
  76602. /**
  76603. * Callback called when the task is successful
  76604. */
  76605. onSuccess: (task: CubeTextureAssetTask) => void;
  76606. /**
  76607. * Callback called when the task is successful
  76608. */
  76609. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76610. /**
  76611. * Creates a new CubeTextureAssetTask
  76612. * @param name defines the name of the task
  76613. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76614. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76616. * @param files defines the explicit list of files (undefined by default)
  76617. */
  76618. constructor(
  76619. /**
  76620. * Defines the name of the task
  76621. */
  76622. name: string,
  76623. /**
  76624. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76625. */
  76626. url: string,
  76627. /**
  76628. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76629. */
  76630. extensions?: string[] | undefined,
  76631. /**
  76632. * Defines if mipmaps should not be generated (default is false)
  76633. */
  76634. noMipmap?: boolean | undefined,
  76635. /**
  76636. * Defines the explicit list of files (undefined by default)
  76637. */
  76638. files?: string[] | undefined);
  76639. /**
  76640. * Execute the current task
  76641. * @param scene defines the scene where you want your assets to be loaded
  76642. * @param onSuccess is a callback called when the task is successfully executed
  76643. * @param onError is a callback called if an error occurs
  76644. */
  76645. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76646. }
  76647. /**
  76648. * Define a task used by AssetsManager to load HDR cube textures
  76649. */
  76650. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76651. /**
  76652. * Defines the name of the task
  76653. */
  76654. name: string;
  76655. /**
  76656. * Defines the location of the file to load
  76657. */
  76658. url: string;
  76659. /**
  76660. * Defines the desired size (the more it increases the longer the generation will be)
  76661. */
  76662. size: number;
  76663. /**
  76664. * Defines if mipmaps should not be generated (default is false)
  76665. */
  76666. noMipmap: boolean;
  76667. /**
  76668. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76669. */
  76670. generateHarmonics: boolean;
  76671. /**
  76672. * 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)
  76673. */
  76674. gammaSpace: boolean;
  76675. /**
  76676. * Internal Use Only
  76677. */
  76678. reserved: boolean;
  76679. /**
  76680. * Gets the loaded texture
  76681. */
  76682. texture: HDRCubeTexture;
  76683. /**
  76684. * Callback called when the task is successful
  76685. */
  76686. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76687. /**
  76688. * Callback called when the task is successful
  76689. */
  76690. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76691. /**
  76692. * Creates a new HDRCubeTextureAssetTask object
  76693. * @param name defines the name of the task
  76694. * @param url defines the location of the file to load
  76695. * @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.
  76696. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76697. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76698. * @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)
  76699. * @param reserved Internal use only
  76700. */
  76701. constructor(
  76702. /**
  76703. * Defines the name of the task
  76704. */
  76705. name: string,
  76706. /**
  76707. * Defines the location of the file to load
  76708. */
  76709. url: string,
  76710. /**
  76711. * Defines the desired size (the more it increases the longer the generation will be)
  76712. */
  76713. size: number,
  76714. /**
  76715. * Defines if mipmaps should not be generated (default is false)
  76716. */
  76717. noMipmap?: boolean,
  76718. /**
  76719. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76720. */
  76721. generateHarmonics?: boolean,
  76722. /**
  76723. * 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)
  76724. */
  76725. gammaSpace?: boolean,
  76726. /**
  76727. * Internal Use Only
  76728. */
  76729. reserved?: boolean);
  76730. /**
  76731. * Execute the current task
  76732. * @param scene defines the scene where you want your assets to be loaded
  76733. * @param onSuccess is a callback called when the task is successfully executed
  76734. * @param onError is a callback called if an error occurs
  76735. */
  76736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76737. }
  76738. /**
  76739. * Define a task used by AssetsManager to load Equirectangular cube textures
  76740. */
  76741. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76742. /**
  76743. * Defines the name of the task
  76744. */
  76745. name: string;
  76746. /**
  76747. * Defines the location of the file to load
  76748. */
  76749. url: string;
  76750. /**
  76751. * Defines the desired size (the more it increases the longer the generation will be)
  76752. */
  76753. size: number;
  76754. /**
  76755. * Defines if mipmaps should not be generated (default is false)
  76756. */
  76757. noMipmap: boolean;
  76758. /**
  76759. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76760. * but the standard material would require them in Gamma space) (default is true)
  76761. */
  76762. gammaSpace: boolean;
  76763. /**
  76764. * Gets the loaded texture
  76765. */
  76766. texture: EquiRectangularCubeTexture;
  76767. /**
  76768. * Callback called when the task is successful
  76769. */
  76770. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76771. /**
  76772. * Callback called when the task is successful
  76773. */
  76774. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76775. /**
  76776. * Creates a new EquiRectangularCubeTextureAssetTask object
  76777. * @param name defines the name of the task
  76778. * @param url defines the location of the file to load
  76779. * @param size defines the desired size (the more it increases the longer the generation will be)
  76780. * If the size is omitted this implies you are using a preprocessed cubemap.
  76781. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76782. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76783. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76784. * (default is true)
  76785. */
  76786. constructor(
  76787. /**
  76788. * Defines the name of the task
  76789. */
  76790. name: string,
  76791. /**
  76792. * Defines the location of the file to load
  76793. */
  76794. url: string,
  76795. /**
  76796. * Defines the desired size (the more it increases the longer the generation will be)
  76797. */
  76798. size: number,
  76799. /**
  76800. * Defines if mipmaps should not be generated (default is false)
  76801. */
  76802. noMipmap?: boolean,
  76803. /**
  76804. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76805. * but the standard material would require them in Gamma space) (default is true)
  76806. */
  76807. gammaSpace?: boolean);
  76808. /**
  76809. * Execute the current task
  76810. * @param scene defines the scene where you want your assets to be loaded
  76811. * @param onSuccess is a callback called when the task is successfully executed
  76812. * @param onError is a callback called if an error occurs
  76813. */
  76814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76815. }
  76816. /**
  76817. * This class can be used to easily import assets into a scene
  76818. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76819. */
  76820. export class AssetsManager {
  76821. private _scene;
  76822. private _isLoading;
  76823. protected _tasks: AbstractAssetTask[];
  76824. protected _waitingTasksCount: number;
  76825. protected _totalTasksCount: number;
  76826. /**
  76827. * Callback called when all tasks are processed
  76828. */
  76829. onFinish: (tasks: AbstractAssetTask[]) => void;
  76830. /**
  76831. * Callback called when a task is successful
  76832. */
  76833. onTaskSuccess: (task: AbstractAssetTask) => void;
  76834. /**
  76835. * Callback called when a task had an error
  76836. */
  76837. onTaskError: (task: AbstractAssetTask) => void;
  76838. /**
  76839. * Callback called when a task is done (whatever the result is)
  76840. */
  76841. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76842. /**
  76843. * Observable called when all tasks are processed
  76844. */
  76845. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76846. /**
  76847. * Observable called when a task had an error
  76848. */
  76849. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76850. /**
  76851. * Observable called when all tasks were executed
  76852. */
  76853. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76854. /**
  76855. * Observable called when a task is done (whatever the result is)
  76856. */
  76857. onProgressObservable: Observable<IAssetsProgressEvent>;
  76858. /**
  76859. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76860. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76861. */
  76862. useDefaultLoadingScreen: boolean;
  76863. /**
  76864. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76865. * when all assets have been downloaded.
  76866. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76867. */
  76868. autoHideLoadingUI: boolean;
  76869. /**
  76870. * Creates a new AssetsManager
  76871. * @param scene defines the scene to work on
  76872. */
  76873. constructor(scene: Scene);
  76874. /**
  76875. * Add a ContainerAssetTask to the list of active tasks
  76876. * @param taskName defines the name of the new task
  76877. * @param meshesNames defines the name of meshes to load
  76878. * @param rootUrl defines the root url to use to locate files
  76879. * @param sceneFilename defines the filename of the scene file
  76880. * @returns a new ContainerAssetTask object
  76881. */
  76882. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76883. /**
  76884. * Add a MeshAssetTask to the list of active tasks
  76885. * @param taskName defines the name of the new task
  76886. * @param meshesNames defines the name of meshes to load
  76887. * @param rootUrl defines the root url to use to locate files
  76888. * @param sceneFilename defines the filename of the scene file
  76889. * @returns a new MeshAssetTask object
  76890. */
  76891. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76892. /**
  76893. * Add a TextFileAssetTask to the list of active tasks
  76894. * @param taskName defines the name of the new task
  76895. * @param url defines the url of the file to load
  76896. * @returns a new TextFileAssetTask object
  76897. */
  76898. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76899. /**
  76900. * Add a BinaryFileAssetTask to the list of active tasks
  76901. * @param taskName defines the name of the new task
  76902. * @param url defines the url of the file to load
  76903. * @returns a new BinaryFileAssetTask object
  76904. */
  76905. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76906. /**
  76907. * Add a ImageAssetTask to the list of active tasks
  76908. * @param taskName defines the name of the new task
  76909. * @param url defines the url of the file to load
  76910. * @returns a new ImageAssetTask object
  76911. */
  76912. addImageTask(taskName: string, url: string): ImageAssetTask;
  76913. /**
  76914. * Add a TextureAssetTask to the list of active tasks
  76915. * @param taskName defines the name of the new task
  76916. * @param url defines the url of the file to load
  76917. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76918. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76919. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76920. * @returns a new TextureAssetTask object
  76921. */
  76922. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76923. /**
  76924. * Add a CubeTextureAssetTask to the list of active tasks
  76925. * @param taskName defines the name of the new task
  76926. * @param url defines the url of the file to load
  76927. * @param extensions defines the extension to use to load the cube map (can be null)
  76928. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76929. * @param files defines the list of files to load (can be null)
  76930. * @returns a new CubeTextureAssetTask object
  76931. */
  76932. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76933. /**
  76934. *
  76935. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76936. * @param taskName defines the name of the new task
  76937. * @param url defines the url of the file to load
  76938. * @param size defines the size you want for the cubemap (can be null)
  76939. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76940. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76941. * @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)
  76942. * @param reserved Internal use only
  76943. * @returns a new HDRCubeTextureAssetTask object
  76944. */
  76945. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76946. /**
  76947. *
  76948. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76949. * @param taskName defines the name of the new task
  76950. * @param url defines the url of the file to load
  76951. * @param size defines the size you want for the cubemap (can be null)
  76952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76953. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76954. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76955. * @returns a new EquiRectangularCubeTextureAssetTask object
  76956. */
  76957. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76958. /**
  76959. * Remove a task from the assets manager.
  76960. * @param task the task to remove
  76961. */
  76962. removeTask(task: AbstractAssetTask): void;
  76963. private _decreaseWaitingTasksCount;
  76964. private _runTask;
  76965. /**
  76966. * Reset the AssetsManager and remove all tasks
  76967. * @return the current instance of the AssetsManager
  76968. */
  76969. reset(): AssetsManager;
  76970. /**
  76971. * Start the loading process
  76972. * @return the current instance of the AssetsManager
  76973. */
  76974. load(): AssetsManager;
  76975. /**
  76976. * Start the loading process as an async operation
  76977. * @return a promise returning the list of failed tasks
  76978. */
  76979. loadAsync(): Promise<void>;
  76980. }
  76981. }
  76982. declare module "babylonjs/Misc/deferred" {
  76983. /**
  76984. * Wrapper class for promise with external resolve and reject.
  76985. */
  76986. export class Deferred<T> {
  76987. /**
  76988. * The promise associated with this deferred object.
  76989. */
  76990. readonly promise: Promise<T>;
  76991. private _resolve;
  76992. private _reject;
  76993. /**
  76994. * The resolve method of the promise associated with this deferred object.
  76995. */
  76996. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76997. /**
  76998. * The reject method of the promise associated with this deferred object.
  76999. */
  77000. get reject(): (reason?: any) => void;
  77001. /**
  77002. * Constructor for this deferred object.
  77003. */
  77004. constructor();
  77005. }
  77006. }
  77007. declare module "babylonjs/Misc/meshExploder" {
  77008. import { Mesh } from "babylonjs/Meshes/mesh";
  77009. /**
  77010. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77011. */
  77012. export class MeshExploder {
  77013. private _centerMesh;
  77014. private _meshes;
  77015. private _meshesOrigins;
  77016. private _toCenterVectors;
  77017. private _scaledDirection;
  77018. private _newPosition;
  77019. private _centerPosition;
  77020. /**
  77021. * Explodes meshes from a center mesh.
  77022. * @param meshes The meshes to explode.
  77023. * @param centerMesh The mesh to be center of explosion.
  77024. */
  77025. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77026. private _setCenterMesh;
  77027. /**
  77028. * Get class name
  77029. * @returns "MeshExploder"
  77030. */
  77031. getClassName(): string;
  77032. /**
  77033. * "Exploded meshes"
  77034. * @returns Array of meshes with the centerMesh at index 0.
  77035. */
  77036. getMeshes(): Array<Mesh>;
  77037. /**
  77038. * Explodes meshes giving a specific direction
  77039. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77040. */
  77041. explode(direction?: number): void;
  77042. }
  77043. }
  77044. declare module "babylonjs/Misc/filesInput" {
  77045. import { Engine } from "babylonjs/Engines/engine";
  77046. import { Scene } from "babylonjs/scene";
  77047. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77048. import { Nullable } from "babylonjs/types";
  77049. /**
  77050. * Class used to help managing file picking and drag'n'drop
  77051. */
  77052. export class FilesInput {
  77053. /**
  77054. * List of files ready to be loaded
  77055. */
  77056. static get FilesToLoad(): {
  77057. [key: string]: File;
  77058. };
  77059. /**
  77060. * Callback called when a file is processed
  77061. */
  77062. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77063. private _engine;
  77064. private _currentScene;
  77065. private _sceneLoadedCallback;
  77066. private _progressCallback;
  77067. private _additionalRenderLoopLogicCallback;
  77068. private _textureLoadingCallback;
  77069. private _startingProcessingFilesCallback;
  77070. private _onReloadCallback;
  77071. private _errorCallback;
  77072. private _elementToMonitor;
  77073. private _sceneFileToLoad;
  77074. private _filesToLoad;
  77075. /**
  77076. * Creates a new FilesInput
  77077. * @param engine defines the rendering engine
  77078. * @param scene defines the hosting scene
  77079. * @param sceneLoadedCallback callback called when scene is loaded
  77080. * @param progressCallback callback called to track progress
  77081. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77082. * @param textureLoadingCallback callback called when a texture is loading
  77083. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77084. * @param onReloadCallback callback called when a reload is requested
  77085. * @param errorCallback callback call if an error occurs
  77086. */
  77087. 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>);
  77088. private _dragEnterHandler;
  77089. private _dragOverHandler;
  77090. private _dropHandler;
  77091. /**
  77092. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77093. * @param elementToMonitor defines the DOM element to track
  77094. */
  77095. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77096. /** Gets the current list of files to load */
  77097. get filesToLoad(): File[];
  77098. /**
  77099. * Release all associated resources
  77100. */
  77101. dispose(): void;
  77102. private renderFunction;
  77103. private drag;
  77104. private drop;
  77105. private _traverseFolder;
  77106. private _processFiles;
  77107. /**
  77108. * Load files from a drop event
  77109. * @param event defines the drop event to use as source
  77110. */
  77111. loadFiles(event: any): void;
  77112. private _processReload;
  77113. /**
  77114. * Reload the current scene from the loaded files
  77115. */
  77116. reload(): void;
  77117. }
  77118. }
  77119. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77120. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77121. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77122. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77123. }
  77124. declare module "babylonjs/Misc/sceneOptimizer" {
  77125. import { Scene, IDisposable } from "babylonjs/scene";
  77126. import { Observable } from "babylonjs/Misc/observable";
  77127. /**
  77128. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77129. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77130. */
  77131. export class SceneOptimization {
  77132. /**
  77133. * Defines the priority of this optimization (0 by default which means first in the list)
  77134. */
  77135. priority: number;
  77136. /**
  77137. * Gets a string describing the action executed by the current optimization
  77138. * @returns description string
  77139. */
  77140. getDescription(): string;
  77141. /**
  77142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77143. * @param scene defines the current scene where to apply this optimization
  77144. * @param optimizer defines the current optimizer
  77145. * @returns true if everything that can be done was applied
  77146. */
  77147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77148. /**
  77149. * Creates the SceneOptimization object
  77150. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77151. * @param desc defines the description associated with the optimization
  77152. */
  77153. constructor(
  77154. /**
  77155. * Defines the priority of this optimization (0 by default which means first in the list)
  77156. */
  77157. priority?: number);
  77158. }
  77159. /**
  77160. * Defines an optimization used to reduce the size of render target textures
  77161. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77162. */
  77163. export class TextureOptimization extends SceneOptimization {
  77164. /**
  77165. * Defines the priority of this optimization (0 by default which means first in the list)
  77166. */
  77167. priority: number;
  77168. /**
  77169. * 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
  77170. */
  77171. maximumSize: number;
  77172. /**
  77173. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77174. */
  77175. step: number;
  77176. /**
  77177. * Gets a string describing the action executed by the current optimization
  77178. * @returns description string
  77179. */
  77180. getDescription(): string;
  77181. /**
  77182. * Creates the TextureOptimization object
  77183. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77184. * @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
  77185. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77186. */
  77187. constructor(
  77188. /**
  77189. * Defines the priority of this optimization (0 by default which means first in the list)
  77190. */
  77191. priority?: number,
  77192. /**
  77193. * 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
  77194. */
  77195. maximumSize?: number,
  77196. /**
  77197. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77198. */
  77199. step?: number);
  77200. /**
  77201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77202. * @param scene defines the current scene where to apply this optimization
  77203. * @param optimizer defines the current optimizer
  77204. * @returns true if everything that can be done was applied
  77205. */
  77206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77207. }
  77208. /**
  77209. * Defines an optimization used to increase or decrease the rendering resolution
  77210. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77211. */
  77212. export class HardwareScalingOptimization extends SceneOptimization {
  77213. /**
  77214. * Defines the priority of this optimization (0 by default which means first in the list)
  77215. */
  77216. priority: number;
  77217. /**
  77218. * Defines the maximum scale to use (2 by default)
  77219. */
  77220. maximumScale: number;
  77221. /**
  77222. * Defines the step to use between two passes (0.5 by default)
  77223. */
  77224. step: number;
  77225. private _currentScale;
  77226. private _directionOffset;
  77227. /**
  77228. * Gets a string describing the action executed by the current optimization
  77229. * @return description string
  77230. */
  77231. getDescription(): string;
  77232. /**
  77233. * Creates the HardwareScalingOptimization object
  77234. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77235. * @param maximumScale defines the maximum scale to use (2 by default)
  77236. * @param step defines the step to use between two passes (0.5 by default)
  77237. */
  77238. constructor(
  77239. /**
  77240. * Defines the priority of this optimization (0 by default which means first in the list)
  77241. */
  77242. priority?: number,
  77243. /**
  77244. * Defines the maximum scale to use (2 by default)
  77245. */
  77246. maximumScale?: number,
  77247. /**
  77248. * Defines the step to use between two passes (0.5 by default)
  77249. */
  77250. step?: number);
  77251. /**
  77252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77253. * @param scene defines the current scene where to apply this optimization
  77254. * @param optimizer defines the current optimizer
  77255. * @returns true if everything that can be done was applied
  77256. */
  77257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77258. }
  77259. /**
  77260. * Defines an optimization used to remove shadows
  77261. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77262. */
  77263. export class ShadowsOptimization extends SceneOptimization {
  77264. /**
  77265. * Gets a string describing the action executed by the current optimization
  77266. * @return description string
  77267. */
  77268. getDescription(): string;
  77269. /**
  77270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77271. * @param scene defines the current scene where to apply this optimization
  77272. * @param optimizer defines the current optimizer
  77273. * @returns true if everything that can be done was applied
  77274. */
  77275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77276. }
  77277. /**
  77278. * Defines an optimization used to turn post-processes off
  77279. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77280. */
  77281. export class PostProcessesOptimization extends SceneOptimization {
  77282. /**
  77283. * Gets a string describing the action executed by the current optimization
  77284. * @return description string
  77285. */
  77286. getDescription(): string;
  77287. /**
  77288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77289. * @param scene defines the current scene where to apply this optimization
  77290. * @param optimizer defines the current optimizer
  77291. * @returns true if everything that can be done was applied
  77292. */
  77293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77294. }
  77295. /**
  77296. * Defines an optimization used to turn lens flares off
  77297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77298. */
  77299. export class LensFlaresOptimization extends SceneOptimization {
  77300. /**
  77301. * Gets a string describing the action executed by the current optimization
  77302. * @return description string
  77303. */
  77304. getDescription(): string;
  77305. /**
  77306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77307. * @param scene defines the current scene where to apply this optimization
  77308. * @param optimizer defines the current optimizer
  77309. * @returns true if everything that can be done was applied
  77310. */
  77311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77312. }
  77313. /**
  77314. * Defines an optimization based on user defined callback.
  77315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77316. */
  77317. export class CustomOptimization extends SceneOptimization {
  77318. /**
  77319. * Callback called to apply the custom optimization.
  77320. */
  77321. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77322. /**
  77323. * Callback called to get custom description
  77324. */
  77325. onGetDescription: () => string;
  77326. /**
  77327. * Gets a string describing the action executed by the current optimization
  77328. * @returns description string
  77329. */
  77330. getDescription(): string;
  77331. /**
  77332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77333. * @param scene defines the current scene where to apply this optimization
  77334. * @param optimizer defines the current optimizer
  77335. * @returns true if everything that can be done was applied
  77336. */
  77337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77338. }
  77339. /**
  77340. * Defines an optimization used to turn particles off
  77341. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77342. */
  77343. export class ParticlesOptimization extends SceneOptimization {
  77344. /**
  77345. * Gets a string describing the action executed by the current optimization
  77346. * @return description string
  77347. */
  77348. getDescription(): string;
  77349. /**
  77350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77351. * @param scene defines the current scene where to apply this optimization
  77352. * @param optimizer defines the current optimizer
  77353. * @returns true if everything that can be done was applied
  77354. */
  77355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77356. }
  77357. /**
  77358. * Defines an optimization used to turn render targets off
  77359. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77360. */
  77361. export class RenderTargetsOptimization extends SceneOptimization {
  77362. /**
  77363. * Gets a string describing the action executed by the current optimization
  77364. * @return description string
  77365. */
  77366. getDescription(): string;
  77367. /**
  77368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77369. * @param scene defines the current scene where to apply this optimization
  77370. * @param optimizer defines the current optimizer
  77371. * @returns true if everything that can be done was applied
  77372. */
  77373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77374. }
  77375. /**
  77376. * Defines an optimization used to merge meshes with compatible materials
  77377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77378. */
  77379. export class MergeMeshesOptimization extends SceneOptimization {
  77380. private static _UpdateSelectionTree;
  77381. /**
  77382. * Gets or sets a boolean which defines if optimization octree has to be updated
  77383. */
  77384. static get UpdateSelectionTree(): boolean;
  77385. /**
  77386. * Gets or sets a boolean which defines if optimization octree has to be updated
  77387. */
  77388. static set UpdateSelectionTree(value: boolean);
  77389. /**
  77390. * Gets a string describing the action executed by the current optimization
  77391. * @return description string
  77392. */
  77393. getDescription(): string;
  77394. private _canBeMerged;
  77395. /**
  77396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77397. * @param scene defines the current scene where to apply this optimization
  77398. * @param optimizer defines the current optimizer
  77399. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77400. * @returns true if everything that can be done was applied
  77401. */
  77402. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77403. }
  77404. /**
  77405. * Defines a list of options used by SceneOptimizer
  77406. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77407. */
  77408. export class SceneOptimizerOptions {
  77409. /**
  77410. * Defines the target frame rate to reach (60 by default)
  77411. */
  77412. targetFrameRate: number;
  77413. /**
  77414. * Defines the interval between two checkes (2000ms by default)
  77415. */
  77416. trackerDuration: number;
  77417. /**
  77418. * Gets the list of optimizations to apply
  77419. */
  77420. optimizations: SceneOptimization[];
  77421. /**
  77422. * Creates a new list of options used by SceneOptimizer
  77423. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77424. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77425. */
  77426. constructor(
  77427. /**
  77428. * Defines the target frame rate to reach (60 by default)
  77429. */
  77430. targetFrameRate?: number,
  77431. /**
  77432. * Defines the interval between two checkes (2000ms by default)
  77433. */
  77434. trackerDuration?: number);
  77435. /**
  77436. * Add a new optimization
  77437. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77438. * @returns the current SceneOptimizerOptions
  77439. */
  77440. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77441. /**
  77442. * Add a new custom optimization
  77443. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77444. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77445. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77446. * @returns the current SceneOptimizerOptions
  77447. */
  77448. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77449. /**
  77450. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77451. * @param targetFrameRate defines the target frame rate (60 by default)
  77452. * @returns a SceneOptimizerOptions object
  77453. */
  77454. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77455. /**
  77456. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77457. * @param targetFrameRate defines the target frame rate (60 by default)
  77458. * @returns a SceneOptimizerOptions object
  77459. */
  77460. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77461. /**
  77462. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77463. * @param targetFrameRate defines the target frame rate (60 by default)
  77464. * @returns a SceneOptimizerOptions object
  77465. */
  77466. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77467. }
  77468. /**
  77469. * Class used to run optimizations in order to reach a target frame rate
  77470. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77471. */
  77472. export class SceneOptimizer implements IDisposable {
  77473. private _isRunning;
  77474. private _options;
  77475. private _scene;
  77476. private _currentPriorityLevel;
  77477. private _targetFrameRate;
  77478. private _trackerDuration;
  77479. private _currentFrameRate;
  77480. private _sceneDisposeObserver;
  77481. private _improvementMode;
  77482. /**
  77483. * Defines an observable called when the optimizer reaches the target frame rate
  77484. */
  77485. onSuccessObservable: Observable<SceneOptimizer>;
  77486. /**
  77487. * Defines an observable called when the optimizer enables an optimization
  77488. */
  77489. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77490. /**
  77491. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77492. */
  77493. onFailureObservable: Observable<SceneOptimizer>;
  77494. /**
  77495. * Gets a boolean indicating if the optimizer is in improvement mode
  77496. */
  77497. get isInImprovementMode(): boolean;
  77498. /**
  77499. * Gets the current priority level (0 at start)
  77500. */
  77501. get currentPriorityLevel(): number;
  77502. /**
  77503. * Gets the current frame rate checked by the SceneOptimizer
  77504. */
  77505. get currentFrameRate(): number;
  77506. /**
  77507. * Gets or sets the current target frame rate (60 by default)
  77508. */
  77509. get targetFrameRate(): number;
  77510. /**
  77511. * Gets or sets the current target frame rate (60 by default)
  77512. */
  77513. set targetFrameRate(value: number);
  77514. /**
  77515. * Gets or sets the current interval between two checks (every 2000ms by default)
  77516. */
  77517. get trackerDuration(): number;
  77518. /**
  77519. * Gets or sets the current interval between two checks (every 2000ms by default)
  77520. */
  77521. set trackerDuration(value: number);
  77522. /**
  77523. * Gets the list of active optimizations
  77524. */
  77525. get optimizations(): SceneOptimization[];
  77526. /**
  77527. * Creates a new SceneOptimizer
  77528. * @param scene defines the scene to work on
  77529. * @param options defines the options to use with the SceneOptimizer
  77530. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77531. * @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)
  77532. */
  77533. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77534. /**
  77535. * Stops the current optimizer
  77536. */
  77537. stop(): void;
  77538. /**
  77539. * Reset the optimizer to initial step (current priority level = 0)
  77540. */
  77541. reset(): void;
  77542. /**
  77543. * Start the optimizer. By default it will try to reach a specific framerate
  77544. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77545. */
  77546. start(): void;
  77547. private _checkCurrentState;
  77548. /**
  77549. * Release all resources
  77550. */
  77551. dispose(): void;
  77552. /**
  77553. * Helper function to create a SceneOptimizer with one single line of code
  77554. * @param scene defines the scene to work on
  77555. * @param options defines the options to use with the SceneOptimizer
  77556. * @param onSuccess defines a callback to call on success
  77557. * @param onFailure defines a callback to call on failure
  77558. * @returns the new SceneOptimizer object
  77559. */
  77560. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77561. }
  77562. }
  77563. declare module "babylonjs/Misc/sceneSerializer" {
  77564. import { Scene } from "babylonjs/scene";
  77565. /**
  77566. * Class used to serialize a scene into a string
  77567. */
  77568. export class SceneSerializer {
  77569. /**
  77570. * Clear cache used by a previous serialization
  77571. */
  77572. static ClearCache(): void;
  77573. /**
  77574. * Serialize a scene into a JSON compatible object
  77575. * @param scene defines the scene to serialize
  77576. * @returns a JSON compatible object
  77577. */
  77578. static Serialize(scene: Scene): any;
  77579. /**
  77580. * Serialize a mesh into a JSON compatible object
  77581. * @param toSerialize defines the mesh to serialize
  77582. * @param withParents defines if parents must be serialized as well
  77583. * @param withChildren defines if children must be serialized as well
  77584. * @returns a JSON compatible object
  77585. */
  77586. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77587. }
  77588. }
  77589. declare module "babylonjs/Misc/textureTools" {
  77590. import { Texture } from "babylonjs/Materials/Textures/texture";
  77591. /**
  77592. * Class used to host texture specific utilities
  77593. */
  77594. export class TextureTools {
  77595. /**
  77596. * Uses the GPU to create a copy texture rescaled at a given size
  77597. * @param texture Texture to copy from
  77598. * @param width defines the desired width
  77599. * @param height defines the desired height
  77600. * @param useBilinearMode defines if bilinear mode has to be used
  77601. * @return the generated texture
  77602. */
  77603. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77604. }
  77605. }
  77606. declare module "babylonjs/Misc/videoRecorder" {
  77607. import { Nullable } from "babylonjs/types";
  77608. import { Engine } from "babylonjs/Engines/engine";
  77609. /**
  77610. * This represents the different options available for the video capture.
  77611. */
  77612. export interface VideoRecorderOptions {
  77613. /** Defines the mime type of the video. */
  77614. mimeType: string;
  77615. /** Defines the FPS the video should be recorded at. */
  77616. fps: number;
  77617. /** Defines the chunk size for the recording data. */
  77618. recordChunckSize: number;
  77619. /** The audio tracks to attach to the recording. */
  77620. audioTracks?: MediaStreamTrack[];
  77621. }
  77622. /**
  77623. * This can help with recording videos from BabylonJS.
  77624. * This is based on the available WebRTC functionalities of the browser.
  77625. *
  77626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77627. */
  77628. export class VideoRecorder {
  77629. private static readonly _defaultOptions;
  77630. /**
  77631. * Returns whether or not the VideoRecorder is available in your browser.
  77632. * @param engine Defines the Babylon Engine.
  77633. * @returns true if supported otherwise false.
  77634. */
  77635. static IsSupported(engine: Engine): boolean;
  77636. private readonly _options;
  77637. private _canvas;
  77638. private _mediaRecorder;
  77639. private _recordedChunks;
  77640. private _fileName;
  77641. private _resolve;
  77642. private _reject;
  77643. /**
  77644. * True when a recording is already in progress.
  77645. */
  77646. get isRecording(): boolean;
  77647. /**
  77648. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77649. * @param engine Defines the BabylonJS Engine you wish to record.
  77650. * @param options Defines options that can be used to customize the capture.
  77651. */
  77652. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77653. /**
  77654. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77655. */
  77656. stopRecording(): void;
  77657. /**
  77658. * Starts recording the canvas for a max duration specified in parameters.
  77659. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77660. * If null no automatic download will start and you can rely on the promise to get the data back.
  77661. * @param maxDuration Defines the maximum recording time in seconds.
  77662. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77663. * @return A promise callback at the end of the recording with the video data in Blob.
  77664. */
  77665. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77666. /**
  77667. * Releases internal resources used during the recording.
  77668. */
  77669. dispose(): void;
  77670. private _handleDataAvailable;
  77671. private _handleError;
  77672. private _handleStop;
  77673. }
  77674. }
  77675. declare module "babylonjs/Misc/screenshotTools" {
  77676. import { Camera } from "babylonjs/Cameras/camera";
  77677. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77678. import { Engine } from "babylonjs/Engines/engine";
  77679. /**
  77680. * Class containing a set of static utilities functions for screenshots
  77681. */
  77682. export class ScreenshotTools {
  77683. /**
  77684. * Captures a screenshot of the current rendering
  77685. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77686. * @param engine defines the rendering engine
  77687. * @param camera defines the source camera
  77688. * @param size This parameter can be set to a single number or to an object with the
  77689. * following (optional) properties: precision, width, height. If a single number is passed,
  77690. * it will be used for both width and height. If an object is passed, the screenshot size
  77691. * will be derived from the parameters. The precision property is a multiplier allowing
  77692. * rendering at a higher or lower resolution
  77693. * @param successCallback defines the callback receives a single parameter which contains the
  77694. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77695. * src parameter of an <img> to display it
  77696. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77697. * Check your browser for supported MIME types
  77698. */
  77699. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77700. /**
  77701. * Captures a screenshot of the current rendering
  77702. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77703. * @param engine defines the rendering engine
  77704. * @param camera defines the source camera
  77705. * @param size This parameter can be set to a single number or to an object with the
  77706. * following (optional) properties: precision, width, height. If a single number is passed,
  77707. * it will be used for both width and height. If an object is passed, the screenshot size
  77708. * will be derived from the parameters. The precision property is a multiplier allowing
  77709. * rendering at a higher or lower resolution
  77710. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77711. * Check your browser for supported MIME types
  77712. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77713. * to the src parameter of an <img> to display it
  77714. */
  77715. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77716. /**
  77717. * Generates an image screenshot from the specified camera.
  77718. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77719. * @param engine The engine to use for rendering
  77720. * @param camera The camera to use for rendering
  77721. * @param size This parameter can be set to a single number or to an object with the
  77722. * following (optional) properties: precision, width, height. If a single number is passed,
  77723. * it will be used for both width and height. If an object is passed, the screenshot size
  77724. * will be derived from the parameters. The precision property is a multiplier allowing
  77725. * rendering at a higher or lower resolution
  77726. * @param successCallback The callback receives a single parameter which contains the
  77727. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77728. * src parameter of an <img> to display it
  77729. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77730. * Check your browser for supported MIME types
  77731. * @param samples Texture samples (default: 1)
  77732. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77733. * @param fileName A name for for the downloaded file.
  77734. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77735. */
  77736. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77737. /**
  77738. * Generates an image screenshot from the specified camera.
  77739. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77740. * @param engine The engine to use for rendering
  77741. * @param camera The camera to use for rendering
  77742. * @param size This parameter can be set to a single number or to an object with the
  77743. * following (optional) properties: precision, width, height. If a single number is passed,
  77744. * it will be used for both width and height. If an object is passed, the screenshot size
  77745. * will be derived from the parameters. The precision property is a multiplier allowing
  77746. * rendering at a higher or lower resolution
  77747. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77748. * Check your browser for supported MIME types
  77749. * @param samples Texture samples (default: 1)
  77750. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77751. * @param fileName A name for for the downloaded file.
  77752. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77753. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77754. * to the src parameter of an <img> to display it
  77755. */
  77756. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77757. /**
  77758. * Gets height and width for screenshot size
  77759. * @private
  77760. */
  77761. private static _getScreenshotSize;
  77762. }
  77763. }
  77764. declare module "babylonjs/Misc/dataReader" {
  77765. /**
  77766. * Interface for a data buffer
  77767. */
  77768. export interface IDataBuffer {
  77769. /**
  77770. * Reads bytes from the data buffer.
  77771. * @param byteOffset The byte offset to read
  77772. * @param byteLength The byte length to read
  77773. * @returns A promise that resolves when the bytes are read
  77774. */
  77775. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77776. /**
  77777. * The byte length of the buffer.
  77778. */
  77779. readonly byteLength: number;
  77780. }
  77781. /**
  77782. * Utility class for reading from a data buffer
  77783. */
  77784. export class DataReader {
  77785. /**
  77786. * The data buffer associated with this data reader.
  77787. */
  77788. readonly buffer: IDataBuffer;
  77789. /**
  77790. * The current byte offset from the beginning of the data buffer.
  77791. */
  77792. byteOffset: number;
  77793. private _dataView;
  77794. private _dataByteOffset;
  77795. /**
  77796. * Constructor
  77797. * @param buffer The buffer to read
  77798. */
  77799. constructor(buffer: IDataBuffer);
  77800. /**
  77801. * Loads the given byte length.
  77802. * @param byteLength The byte length to load
  77803. * @returns A promise that resolves when the load is complete
  77804. */
  77805. loadAsync(byteLength: number): Promise<void>;
  77806. /**
  77807. * Read a unsigned 32-bit integer from the currently loaded data range.
  77808. * @returns The 32-bit integer read
  77809. */
  77810. readUint32(): number;
  77811. /**
  77812. * Read a byte array from the currently loaded data range.
  77813. * @param byteLength The byte length to read
  77814. * @returns The byte array read
  77815. */
  77816. readUint8Array(byteLength: number): Uint8Array;
  77817. /**
  77818. * Read a string from the currently loaded data range.
  77819. * @param byteLength The byte length to read
  77820. * @returns The string read
  77821. */
  77822. readString(byteLength: number): string;
  77823. /**
  77824. * Skips the given byte length the currently loaded data range.
  77825. * @param byteLength The byte length to skip
  77826. */
  77827. skipBytes(byteLength: number): void;
  77828. }
  77829. }
  77830. declare module "babylonjs/Misc/dataStorage" {
  77831. /**
  77832. * Class for storing data to local storage if available or in-memory storage otherwise
  77833. */
  77834. export class DataStorage {
  77835. private static _Storage;
  77836. private static _GetStorage;
  77837. /**
  77838. * Reads a string from the data storage
  77839. * @param key The key to read
  77840. * @param defaultValue The value if the key doesn't exist
  77841. * @returns The string value
  77842. */
  77843. static ReadString(key: string, defaultValue: string): string;
  77844. /**
  77845. * Writes a string to the data storage
  77846. * @param key The key to write
  77847. * @param value The value to write
  77848. */
  77849. static WriteString(key: string, value: string): void;
  77850. /**
  77851. * Reads a boolean from the data storage
  77852. * @param key The key to read
  77853. * @param defaultValue The value if the key doesn't exist
  77854. * @returns The boolean value
  77855. */
  77856. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77857. /**
  77858. * Writes a boolean to the data storage
  77859. * @param key The key to write
  77860. * @param value The value to write
  77861. */
  77862. static WriteBoolean(key: string, value: boolean): void;
  77863. /**
  77864. * Reads a number from the data storage
  77865. * @param key The key to read
  77866. * @param defaultValue The value if the key doesn't exist
  77867. * @returns The number value
  77868. */
  77869. static ReadNumber(key: string, defaultValue: number): number;
  77870. /**
  77871. * Writes a number to the data storage
  77872. * @param key The key to write
  77873. * @param value The value to write
  77874. */
  77875. static WriteNumber(key: string, value: number): void;
  77876. }
  77877. }
  77878. declare module "babylonjs/Misc/sceneRecorder" {
  77879. import { Scene } from "babylonjs/scene";
  77880. /**
  77881. * Class used to record delta files between 2 scene states
  77882. */
  77883. export class SceneRecorder {
  77884. private _trackedScene;
  77885. private _savedJSON;
  77886. /**
  77887. * Track a given scene. This means the current scene state will be considered the original state
  77888. * @param scene defines the scene to track
  77889. */
  77890. track(scene: Scene): void;
  77891. /**
  77892. * Get the delta between current state and original state
  77893. * @returns a string containing the delta
  77894. */
  77895. getDelta(): any;
  77896. private _compareArray;
  77897. private _compareObjects;
  77898. private _compareCollections;
  77899. private static GetShadowGeneratorById;
  77900. /**
  77901. * Apply a given delta to a given scene
  77902. * @param deltaJSON defines the JSON containing the delta
  77903. * @param scene defines the scene to apply the delta to
  77904. */
  77905. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77906. private static _ApplyPropertiesToEntity;
  77907. private static _ApplyDeltaForEntity;
  77908. }
  77909. }
  77910. declare module "babylonjs/Misc/index" {
  77911. export * from "babylonjs/Misc/andOrNotEvaluator";
  77912. export * from "babylonjs/Misc/assetsManager";
  77913. export * from "babylonjs/Misc/basis";
  77914. export * from "babylonjs/Misc/dds";
  77915. export * from "babylonjs/Misc/decorators";
  77916. export * from "babylonjs/Misc/deferred";
  77917. export * from "babylonjs/Misc/environmentTextureTools";
  77918. export * from "babylonjs/Misc/meshExploder";
  77919. export * from "babylonjs/Misc/filesInput";
  77920. export * from "babylonjs/Misc/HighDynamicRange/index";
  77921. export * from "babylonjs/Misc/khronosTextureContainer";
  77922. export * from "babylonjs/Misc/observable";
  77923. export * from "babylonjs/Misc/performanceMonitor";
  77924. export * from "babylonjs/Misc/promise";
  77925. export * from "babylonjs/Misc/sceneOptimizer";
  77926. export * from "babylonjs/Misc/sceneSerializer";
  77927. export * from "babylonjs/Misc/smartArray";
  77928. export * from "babylonjs/Misc/stringDictionary";
  77929. export * from "babylonjs/Misc/tags";
  77930. export * from "babylonjs/Misc/textureTools";
  77931. export * from "babylonjs/Misc/tga";
  77932. export * from "babylonjs/Misc/tools";
  77933. export * from "babylonjs/Misc/videoRecorder";
  77934. export * from "babylonjs/Misc/virtualJoystick";
  77935. export * from "babylonjs/Misc/workerPool";
  77936. export * from "babylonjs/Misc/logger";
  77937. export * from "babylonjs/Misc/typeStore";
  77938. export * from "babylonjs/Misc/filesInputStore";
  77939. export * from "babylonjs/Misc/deepCopier";
  77940. export * from "babylonjs/Misc/pivotTools";
  77941. export * from "babylonjs/Misc/precisionDate";
  77942. export * from "babylonjs/Misc/screenshotTools";
  77943. export * from "babylonjs/Misc/typeStore";
  77944. export * from "babylonjs/Misc/webRequest";
  77945. export * from "babylonjs/Misc/iInspectable";
  77946. export * from "babylonjs/Misc/brdfTextureTools";
  77947. export * from "babylonjs/Misc/rgbdTextureTools";
  77948. export * from "babylonjs/Misc/gradients";
  77949. export * from "babylonjs/Misc/perfCounter";
  77950. export * from "babylonjs/Misc/fileRequest";
  77951. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77952. export * from "babylonjs/Misc/retryStrategy";
  77953. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77954. export * from "babylonjs/Misc/canvasGenerator";
  77955. export * from "babylonjs/Misc/fileTools";
  77956. export * from "babylonjs/Misc/stringTools";
  77957. export * from "babylonjs/Misc/dataReader";
  77958. export * from "babylonjs/Misc/minMaxReducer";
  77959. export * from "babylonjs/Misc/depthReducer";
  77960. export * from "babylonjs/Misc/dataStorage";
  77961. export * from "babylonjs/Misc/sceneRecorder";
  77962. }
  77963. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77964. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77965. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77966. import { Observable } from "babylonjs/Misc/observable";
  77967. import { Matrix } from "babylonjs/Maths/math.vector";
  77968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77969. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77970. /**
  77971. * An interface for all Hit test features
  77972. */
  77973. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77974. /**
  77975. * Triggered when new babylon (transformed) hit test results are available
  77976. */
  77977. onHitTestResultObservable: Observable<T[]>;
  77978. }
  77979. /**
  77980. * Options used for hit testing
  77981. */
  77982. export interface IWebXRLegacyHitTestOptions {
  77983. /**
  77984. * Only test when user interacted with the scene. Default - hit test every frame
  77985. */
  77986. testOnPointerDownOnly?: boolean;
  77987. /**
  77988. * The node to use to transform the local results to world coordinates
  77989. */
  77990. worldParentNode?: TransformNode;
  77991. }
  77992. /**
  77993. * Interface defining the babylon result of raycasting/hit-test
  77994. */
  77995. export interface IWebXRLegacyHitResult {
  77996. /**
  77997. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77998. */
  77999. transformationMatrix: Matrix;
  78000. /**
  78001. * The native hit test result
  78002. */
  78003. xrHitResult: XRHitResult | XRHitTestResult;
  78004. }
  78005. /**
  78006. * The currently-working hit-test module.
  78007. * Hit test (or Ray-casting) is used to interact with the real world.
  78008. * For further information read here - https://github.com/immersive-web/hit-test
  78009. */
  78010. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78011. /**
  78012. * options to use when constructing this feature
  78013. */
  78014. readonly options: IWebXRLegacyHitTestOptions;
  78015. private _direction;
  78016. private _mat;
  78017. private _onSelectEnabled;
  78018. private _origin;
  78019. /**
  78020. * The module's name
  78021. */
  78022. static readonly Name: string;
  78023. /**
  78024. * The (Babylon) version of this module.
  78025. * This is an integer representing the implementation version.
  78026. * This number does not correspond to the WebXR specs version
  78027. */
  78028. static readonly Version: number;
  78029. /**
  78030. * Populated with the last native XR Hit Results
  78031. */
  78032. lastNativeXRHitResults: XRHitResult[];
  78033. /**
  78034. * Triggered when new babylon (transformed) hit test results are available
  78035. */
  78036. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78037. /**
  78038. * Creates a new instance of the (legacy version) hit test feature
  78039. * @param _xrSessionManager an instance of WebXRSessionManager
  78040. * @param options options to use when constructing this feature
  78041. */
  78042. constructor(_xrSessionManager: WebXRSessionManager,
  78043. /**
  78044. * options to use when constructing this feature
  78045. */
  78046. options?: IWebXRLegacyHitTestOptions);
  78047. /**
  78048. * execute a hit test with an XR Ray
  78049. *
  78050. * @param xrSession a native xrSession that will execute this hit test
  78051. * @param xrRay the ray (position and direction) to use for ray-casting
  78052. * @param referenceSpace native XR reference space to use for the hit-test
  78053. * @param filter filter function that will filter the results
  78054. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78055. */
  78056. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78057. /**
  78058. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78059. * @param event the (select) event to use to select with
  78060. * @param referenceSpace the reference space to use for this hit test
  78061. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78062. */
  78063. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78064. /**
  78065. * attach this feature
  78066. * Will usually be called by the features manager
  78067. *
  78068. * @returns true if successful.
  78069. */
  78070. attach(): boolean;
  78071. /**
  78072. * detach this feature.
  78073. * Will usually be called by the features manager
  78074. *
  78075. * @returns true if successful.
  78076. */
  78077. detach(): boolean;
  78078. /**
  78079. * Dispose this feature and all of the resources attached
  78080. */
  78081. dispose(): void;
  78082. protected _onXRFrame(frame: XRFrame): void;
  78083. private _onHitTestResults;
  78084. private _onSelect;
  78085. }
  78086. }
  78087. declare module "babylonjs/XR/features/WebXRHitTest" {
  78088. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78089. import { Observable } from "babylonjs/Misc/observable";
  78090. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78091. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78092. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78093. /**
  78094. * Options used for hit testing (version 2)
  78095. */
  78096. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78097. /**
  78098. * Do not create a permanent hit test. Will usually be used when only
  78099. * transient inputs are needed.
  78100. */
  78101. disablePermanentHitTest?: boolean;
  78102. /**
  78103. * Enable transient (for example touch-based) hit test inspections
  78104. */
  78105. enableTransientHitTest?: boolean;
  78106. /**
  78107. * Offset ray for the permanent hit test
  78108. */
  78109. offsetRay?: Vector3;
  78110. /**
  78111. * Offset ray for the transient hit test
  78112. */
  78113. transientOffsetRay?: Vector3;
  78114. /**
  78115. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78116. */
  78117. useReferenceSpace?: boolean;
  78118. }
  78119. /**
  78120. * Interface defining the babylon result of hit-test
  78121. */
  78122. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78123. /**
  78124. * The input source that generated this hit test (if transient)
  78125. */
  78126. inputSource?: XRInputSource;
  78127. /**
  78128. * Is this a transient hit test
  78129. */
  78130. isTransient?: boolean;
  78131. /**
  78132. * Position of the hit test result
  78133. */
  78134. position: Vector3;
  78135. /**
  78136. * Rotation of the hit test result
  78137. */
  78138. rotationQuaternion: Quaternion;
  78139. /**
  78140. * The native hit test result
  78141. */
  78142. xrHitResult: XRHitTestResult;
  78143. }
  78144. /**
  78145. * The currently-working hit-test module.
  78146. * Hit test (or Ray-casting) is used to interact with the real world.
  78147. * For further information read here - https://github.com/immersive-web/hit-test
  78148. *
  78149. * Tested on chrome (mobile) 80.
  78150. */
  78151. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78152. /**
  78153. * options to use when constructing this feature
  78154. */
  78155. readonly options: IWebXRHitTestOptions;
  78156. private _tmpMat;
  78157. private _tmpPos;
  78158. private _tmpQuat;
  78159. private _transientXrHitTestSource;
  78160. private _xrHitTestSource;
  78161. private initHitTestSource;
  78162. /**
  78163. * The module's name
  78164. */
  78165. static readonly Name: string;
  78166. /**
  78167. * The (Babylon) version of this module.
  78168. * This is an integer representing the implementation version.
  78169. * This number does not correspond to the WebXR specs version
  78170. */
  78171. static readonly Version: number;
  78172. /**
  78173. * When set to true, each hit test will have its own position/rotation objects
  78174. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78175. * the developers will clone them or copy them as they see fit.
  78176. */
  78177. autoCloneTransformation: boolean;
  78178. /**
  78179. * Triggered when new babylon (transformed) hit test results are available
  78180. */
  78181. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78182. /**
  78183. * Use this to temporarily pause hit test checks.
  78184. */
  78185. paused: boolean;
  78186. /**
  78187. * Creates a new instance of the hit test feature
  78188. * @param _xrSessionManager an instance of WebXRSessionManager
  78189. * @param options options to use when constructing this feature
  78190. */
  78191. constructor(_xrSessionManager: WebXRSessionManager,
  78192. /**
  78193. * options to use when constructing this feature
  78194. */
  78195. options?: IWebXRHitTestOptions);
  78196. /**
  78197. * attach this feature
  78198. * Will usually be called by the features manager
  78199. *
  78200. * @returns true if successful.
  78201. */
  78202. attach(): boolean;
  78203. /**
  78204. * detach this feature.
  78205. * Will usually be called by the features manager
  78206. *
  78207. * @returns true if successful.
  78208. */
  78209. detach(): boolean;
  78210. /**
  78211. * Dispose this feature and all of the resources attached
  78212. */
  78213. dispose(): void;
  78214. protected _onXRFrame(frame: XRFrame): void;
  78215. private _processWebXRHitTestResult;
  78216. }
  78217. }
  78218. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78219. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78220. import { Observable } from "babylonjs/Misc/observable";
  78221. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78222. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78223. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78224. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78225. /**
  78226. * Configuration options of the anchor system
  78227. */
  78228. export interface IWebXRAnchorSystemOptions {
  78229. /**
  78230. * a node that will be used to convert local to world coordinates
  78231. */
  78232. worldParentNode?: TransformNode;
  78233. /**
  78234. * If set to true a reference of the created anchors will be kept until the next session starts
  78235. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78236. */
  78237. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78238. }
  78239. /**
  78240. * A babylon container for an XR Anchor
  78241. */
  78242. export interface IWebXRAnchor {
  78243. /**
  78244. * A babylon-assigned ID for this anchor
  78245. */
  78246. id: number;
  78247. /**
  78248. * Transformation matrix to apply to an object attached to this anchor
  78249. */
  78250. transformationMatrix: Matrix;
  78251. /**
  78252. * The native anchor object
  78253. */
  78254. xrAnchor: XRAnchor;
  78255. /**
  78256. * if defined, this object will be constantly updated by the anchor's position and rotation
  78257. */
  78258. attachedNode?: TransformNode;
  78259. }
  78260. /**
  78261. * An implementation of the anchor system for WebXR.
  78262. * For further information see https://github.com/immersive-web/anchors/
  78263. */
  78264. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78265. private _options;
  78266. private _lastFrameDetected;
  78267. private _trackedAnchors;
  78268. private _referenceSpaceForFrameAnchors;
  78269. private _futureAnchors;
  78270. /**
  78271. * The module's name
  78272. */
  78273. static readonly Name: string;
  78274. /**
  78275. * The (Babylon) version of this module.
  78276. * This is an integer representing the implementation version.
  78277. * This number does not correspond to the WebXR specs version
  78278. */
  78279. static readonly Version: number;
  78280. /**
  78281. * Observers registered here will be executed when a new anchor was added to the session
  78282. */
  78283. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78284. /**
  78285. * Observers registered here will be executed when an anchor was removed from the session
  78286. */
  78287. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78288. /**
  78289. * Observers registered here will be executed when an existing anchor updates
  78290. * This can execute N times every frame
  78291. */
  78292. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78293. /**
  78294. * Set the reference space to use for anchor creation, when not using a hit test.
  78295. * Will default to the session's reference space if not defined
  78296. */
  78297. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78298. /**
  78299. * constructs a new anchor system
  78300. * @param _xrSessionManager an instance of WebXRSessionManager
  78301. * @param _options configuration object for this feature
  78302. */
  78303. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78304. private _tmpVector;
  78305. private _tmpQuaternion;
  78306. private _populateTmpTransformation;
  78307. /**
  78308. * Create a new anchor point using a hit test result at a specific point in the scene
  78309. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78310. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78311. *
  78312. * @param hitTestResult The hit test result to use for this anchor creation
  78313. * @param position an optional position offset for this anchor
  78314. * @param rotationQuaternion an optional rotation offset for this anchor
  78315. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78316. */
  78317. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78318. /**
  78319. * Add a new anchor at a specific position and rotation
  78320. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78321. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78322. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78323. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78324. *
  78325. * @param position the position in which to add an anchor
  78326. * @param rotationQuaternion an optional rotation for the anchor transformation
  78327. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78328. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78329. */
  78330. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78331. /**
  78332. * detach this feature.
  78333. * Will usually be called by the features manager
  78334. *
  78335. * @returns true if successful.
  78336. */
  78337. detach(): boolean;
  78338. /**
  78339. * Dispose this feature and all of the resources attached
  78340. */
  78341. dispose(): void;
  78342. protected _onXRFrame(frame: XRFrame): void;
  78343. /**
  78344. * avoiding using Array.find for global support.
  78345. * @param xrAnchor the plane to find in the array
  78346. */
  78347. private _findIndexInAnchorArray;
  78348. private _updateAnchorWithXRFrame;
  78349. private _createAnchorAtTransformation;
  78350. }
  78351. }
  78352. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78353. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78354. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78355. import { Observable } from "babylonjs/Misc/observable";
  78356. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78357. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78358. /**
  78359. * Options used in the plane detector module
  78360. */
  78361. export interface IWebXRPlaneDetectorOptions {
  78362. /**
  78363. * The node to use to transform the local results to world coordinates
  78364. */
  78365. worldParentNode?: TransformNode;
  78366. /**
  78367. * If set to true a reference of the created planes will be kept until the next session starts
  78368. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78369. */
  78370. doNotRemovePlanesOnSessionEnded?: boolean;
  78371. }
  78372. /**
  78373. * A babylon interface for a WebXR plane.
  78374. * A Plane is actually a polygon, built from N points in space
  78375. *
  78376. * Supported in chrome 79, not supported in canary 81 ATM
  78377. */
  78378. export interface IWebXRPlane {
  78379. /**
  78380. * a babylon-assigned ID for this polygon
  78381. */
  78382. id: number;
  78383. /**
  78384. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78385. */
  78386. polygonDefinition: Array<Vector3>;
  78387. /**
  78388. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78389. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78390. */
  78391. transformationMatrix: Matrix;
  78392. /**
  78393. * the native xr-plane object
  78394. */
  78395. xrPlane: XRPlane;
  78396. }
  78397. /**
  78398. * The plane detector is used to detect planes in the real world when in AR
  78399. * For more information see https://github.com/immersive-web/real-world-geometry/
  78400. */
  78401. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78402. private _options;
  78403. private _detectedPlanes;
  78404. private _enabled;
  78405. private _lastFrameDetected;
  78406. /**
  78407. * The module's name
  78408. */
  78409. static readonly Name: string;
  78410. /**
  78411. * The (Babylon) version of this module.
  78412. * This is an integer representing the implementation version.
  78413. * This number does not correspond to the WebXR specs version
  78414. */
  78415. static readonly Version: number;
  78416. /**
  78417. * Observers registered here will be executed when a new plane was added to the session
  78418. */
  78419. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78420. /**
  78421. * Observers registered here will be executed when a plane is no longer detected in the session
  78422. */
  78423. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78424. /**
  78425. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78426. * This can execute N times every frame
  78427. */
  78428. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78429. /**
  78430. * construct a new Plane Detector
  78431. * @param _xrSessionManager an instance of xr Session manager
  78432. * @param _options configuration to use when constructing this feature
  78433. */
  78434. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78435. /**
  78436. * detach this feature.
  78437. * Will usually be called by the features manager
  78438. *
  78439. * @returns true if successful.
  78440. */
  78441. detach(): boolean;
  78442. /**
  78443. * Dispose this feature and all of the resources attached
  78444. */
  78445. dispose(): void;
  78446. protected _onXRFrame(frame: XRFrame): void;
  78447. private _init;
  78448. private _updatePlaneWithXRPlane;
  78449. /**
  78450. * avoiding using Array.find for global support.
  78451. * @param xrPlane the plane to find in the array
  78452. */
  78453. private findIndexInPlaneArray;
  78454. }
  78455. }
  78456. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78457. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78459. import { Observable } from "babylonjs/Misc/observable";
  78460. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78461. /**
  78462. * Options interface for the background remover plugin
  78463. */
  78464. export interface IWebXRBackgroundRemoverOptions {
  78465. /**
  78466. * Further background meshes to disable when entering AR
  78467. */
  78468. backgroundMeshes?: AbstractMesh[];
  78469. /**
  78470. * flags to configure the removal of the environment helper.
  78471. * If not set, the entire background will be removed. If set, flags should be set as well.
  78472. */
  78473. environmentHelperRemovalFlags?: {
  78474. /**
  78475. * Should the skybox be removed (default false)
  78476. */
  78477. skyBox?: boolean;
  78478. /**
  78479. * Should the ground be removed (default false)
  78480. */
  78481. ground?: boolean;
  78482. };
  78483. /**
  78484. * don't disable the environment helper
  78485. */
  78486. ignoreEnvironmentHelper?: boolean;
  78487. }
  78488. /**
  78489. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78490. */
  78491. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78492. /**
  78493. * read-only options to be used in this module
  78494. */
  78495. readonly options: IWebXRBackgroundRemoverOptions;
  78496. /**
  78497. * The module's name
  78498. */
  78499. static readonly Name: string;
  78500. /**
  78501. * The (Babylon) version of this module.
  78502. * This is an integer representing the implementation version.
  78503. * This number does not correspond to the WebXR specs version
  78504. */
  78505. static readonly Version: number;
  78506. /**
  78507. * registered observers will be triggered when the background state changes
  78508. */
  78509. onBackgroundStateChangedObservable: Observable<boolean>;
  78510. /**
  78511. * constructs a new background remover module
  78512. * @param _xrSessionManager the session manager for this module
  78513. * @param options read-only options to be used in this module
  78514. */
  78515. constructor(_xrSessionManager: WebXRSessionManager,
  78516. /**
  78517. * read-only options to be used in this module
  78518. */
  78519. options?: IWebXRBackgroundRemoverOptions);
  78520. /**
  78521. * attach this feature
  78522. * Will usually be called by the features manager
  78523. *
  78524. * @returns true if successful.
  78525. */
  78526. attach(): boolean;
  78527. /**
  78528. * detach this feature.
  78529. * Will usually be called by the features manager
  78530. *
  78531. * @returns true if successful.
  78532. */
  78533. detach(): boolean;
  78534. /**
  78535. * Dispose this feature and all of the resources attached
  78536. */
  78537. dispose(): void;
  78538. protected _onXRFrame(_xrFrame: XRFrame): void;
  78539. private _setBackgroundState;
  78540. }
  78541. }
  78542. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78543. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78544. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78545. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78546. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78547. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78548. import { Nullable } from "babylonjs/types";
  78549. /**
  78550. * Options for the controller physics feature
  78551. */
  78552. export class IWebXRControllerPhysicsOptions {
  78553. /**
  78554. * Should the headset get its own impostor
  78555. */
  78556. enableHeadsetImpostor?: boolean;
  78557. /**
  78558. * Optional parameters for the headset impostor
  78559. */
  78560. headsetImpostorParams?: {
  78561. /**
  78562. * The type of impostor to create. Default is sphere
  78563. */
  78564. impostorType: number;
  78565. /**
  78566. * the size of the impostor. Defaults to 10cm
  78567. */
  78568. impostorSize?: number | {
  78569. width: number;
  78570. height: number;
  78571. depth: number;
  78572. };
  78573. /**
  78574. * Friction definitions
  78575. */
  78576. friction?: number;
  78577. /**
  78578. * Restitution
  78579. */
  78580. restitution?: number;
  78581. };
  78582. /**
  78583. * The physics properties of the future impostors
  78584. */
  78585. physicsProperties?: {
  78586. /**
  78587. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78588. * Note that this requires a physics engine that supports mesh impostors!
  78589. */
  78590. useControllerMesh?: boolean;
  78591. /**
  78592. * The type of impostor to create. Default is sphere
  78593. */
  78594. impostorType?: number;
  78595. /**
  78596. * the size of the impostor. Defaults to 10cm
  78597. */
  78598. impostorSize?: number | {
  78599. width: number;
  78600. height: number;
  78601. depth: number;
  78602. };
  78603. /**
  78604. * Friction definitions
  78605. */
  78606. friction?: number;
  78607. /**
  78608. * Restitution
  78609. */
  78610. restitution?: number;
  78611. };
  78612. /**
  78613. * the xr input to use with this pointer selection
  78614. */
  78615. xrInput: WebXRInput;
  78616. }
  78617. /**
  78618. * Add physics impostor to your webxr controllers,
  78619. * including naive calculation of their linear and angular velocity
  78620. */
  78621. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78622. private readonly _options;
  78623. private _attachController;
  78624. private _controllers;
  78625. private _debugMode;
  78626. private _delta;
  78627. private _headsetImpostor?;
  78628. private _headsetMesh?;
  78629. private _lastTimestamp;
  78630. private _tmpQuaternion;
  78631. private _tmpVector;
  78632. /**
  78633. * The module's name
  78634. */
  78635. static readonly Name: string;
  78636. /**
  78637. * The (Babylon) version of this module.
  78638. * This is an integer representing the implementation version.
  78639. * This number does not correspond to the webxr specs version
  78640. */
  78641. static readonly Version: number;
  78642. /**
  78643. * Construct a new Controller Physics Feature
  78644. * @param _xrSessionManager the corresponding xr session manager
  78645. * @param _options options to create this feature with
  78646. */
  78647. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78648. /**
  78649. * @hidden
  78650. * enable debugging - will show console outputs and the impostor mesh
  78651. */
  78652. _enablePhysicsDebug(): void;
  78653. /**
  78654. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78655. * @param xrController the controller to add
  78656. */
  78657. addController(xrController: WebXRInputSource): void;
  78658. /**
  78659. * attach this feature
  78660. * Will usually be called by the features manager
  78661. *
  78662. * @returns true if successful.
  78663. */
  78664. attach(): boolean;
  78665. /**
  78666. * detach this feature.
  78667. * Will usually be called by the features manager
  78668. *
  78669. * @returns true if successful.
  78670. */
  78671. detach(): boolean;
  78672. /**
  78673. * Get the headset impostor, if enabled
  78674. * @returns the impostor
  78675. */
  78676. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78677. /**
  78678. * Get the physics impostor of a specific controller.
  78679. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78680. * @param controller the controller or the controller id of which to get the impostor
  78681. * @returns the impostor or null
  78682. */
  78683. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78684. /**
  78685. * Update the physics properties provided in the constructor
  78686. * @param newProperties the new properties object
  78687. */
  78688. setPhysicsProperties(newProperties: {
  78689. impostorType?: number;
  78690. impostorSize?: number | {
  78691. width: number;
  78692. height: number;
  78693. depth: number;
  78694. };
  78695. friction?: number;
  78696. restitution?: number;
  78697. }): void;
  78698. protected _onXRFrame(_xrFrame: any): void;
  78699. private _detachController;
  78700. }
  78701. }
  78702. declare module "babylonjs/XR/features/index" {
  78703. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78704. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78705. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78706. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78707. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78708. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78709. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78710. export * from "babylonjs/XR/features/WebXRHitTest";
  78711. }
  78712. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78713. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78715. import { Scene } from "babylonjs/scene";
  78716. /**
  78717. * The motion controller class for all microsoft mixed reality controllers
  78718. */
  78719. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78720. protected readonly _mapping: {
  78721. defaultButton: {
  78722. valueNodeName: string;
  78723. unpressedNodeName: string;
  78724. pressedNodeName: string;
  78725. };
  78726. defaultAxis: {
  78727. valueNodeName: string;
  78728. minNodeName: string;
  78729. maxNodeName: string;
  78730. };
  78731. buttons: {
  78732. "xr-standard-trigger": {
  78733. rootNodeName: string;
  78734. componentProperty: string;
  78735. states: string[];
  78736. };
  78737. "xr-standard-squeeze": {
  78738. rootNodeName: string;
  78739. componentProperty: string;
  78740. states: string[];
  78741. };
  78742. "xr-standard-touchpad": {
  78743. rootNodeName: string;
  78744. labelAnchorNodeName: string;
  78745. touchPointNodeName: string;
  78746. };
  78747. "xr-standard-thumbstick": {
  78748. rootNodeName: string;
  78749. componentProperty: string;
  78750. states: string[];
  78751. };
  78752. };
  78753. axes: {
  78754. "xr-standard-touchpad": {
  78755. "x-axis": {
  78756. rootNodeName: string;
  78757. };
  78758. "y-axis": {
  78759. rootNodeName: string;
  78760. };
  78761. };
  78762. "xr-standard-thumbstick": {
  78763. "x-axis": {
  78764. rootNodeName: string;
  78765. };
  78766. "y-axis": {
  78767. rootNodeName: string;
  78768. };
  78769. };
  78770. };
  78771. };
  78772. /**
  78773. * The base url used to load the left and right controller models
  78774. */
  78775. static MODEL_BASE_URL: string;
  78776. /**
  78777. * The name of the left controller model file
  78778. */
  78779. static MODEL_LEFT_FILENAME: string;
  78780. /**
  78781. * The name of the right controller model file
  78782. */
  78783. static MODEL_RIGHT_FILENAME: string;
  78784. profileId: string;
  78785. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78786. protected _getFilenameAndPath(): {
  78787. filename: string;
  78788. path: string;
  78789. };
  78790. protected _getModelLoadingConstraints(): boolean;
  78791. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78792. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78793. protected _updateModel(): void;
  78794. }
  78795. }
  78796. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78797. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78799. import { Scene } from "babylonjs/scene";
  78800. /**
  78801. * The motion controller class for oculus touch (quest, rift).
  78802. * This class supports legacy mapping as well the standard xr mapping
  78803. */
  78804. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78805. private _forceLegacyControllers;
  78806. private _modelRootNode;
  78807. /**
  78808. * The base url used to load the left and right controller models
  78809. */
  78810. static MODEL_BASE_URL: string;
  78811. /**
  78812. * The name of the left controller model file
  78813. */
  78814. static MODEL_LEFT_FILENAME: string;
  78815. /**
  78816. * The name of the right controller model file
  78817. */
  78818. static MODEL_RIGHT_FILENAME: string;
  78819. /**
  78820. * Base Url for the Quest controller model.
  78821. */
  78822. static QUEST_MODEL_BASE_URL: string;
  78823. profileId: string;
  78824. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78825. protected _getFilenameAndPath(): {
  78826. filename: string;
  78827. path: string;
  78828. };
  78829. protected _getModelLoadingConstraints(): boolean;
  78830. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78831. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78832. protected _updateModel(): void;
  78833. /**
  78834. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78835. * between the touch and touch 2.
  78836. */
  78837. private _isQuest;
  78838. }
  78839. }
  78840. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78841. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78842. import { Scene } from "babylonjs/scene";
  78843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78844. /**
  78845. * The motion controller class for the standard HTC-Vive controllers
  78846. */
  78847. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78848. private _modelRootNode;
  78849. /**
  78850. * The base url used to load the left and right controller models
  78851. */
  78852. static MODEL_BASE_URL: string;
  78853. /**
  78854. * File name for the controller model.
  78855. */
  78856. static MODEL_FILENAME: string;
  78857. profileId: string;
  78858. /**
  78859. * Create a new Vive motion controller object
  78860. * @param scene the scene to use to create this controller
  78861. * @param gamepadObject the corresponding gamepad object
  78862. * @param handedness the handedness of the controller
  78863. */
  78864. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78865. protected _getFilenameAndPath(): {
  78866. filename: string;
  78867. path: string;
  78868. };
  78869. protected _getModelLoadingConstraints(): boolean;
  78870. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78871. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78872. protected _updateModel(): void;
  78873. }
  78874. }
  78875. declare module "babylonjs/XR/motionController/index" {
  78876. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78877. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78878. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78879. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78880. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78881. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78882. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78883. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78884. }
  78885. declare module "babylonjs/XR/index" {
  78886. export * from "babylonjs/XR/webXRCamera";
  78887. export * from "babylonjs/XR/webXREnterExitUI";
  78888. export * from "babylonjs/XR/webXRExperienceHelper";
  78889. export * from "babylonjs/XR/webXRInput";
  78890. export * from "babylonjs/XR/webXRInputSource";
  78891. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78892. export * from "babylonjs/XR/webXRTypes";
  78893. export * from "babylonjs/XR/webXRSessionManager";
  78894. export * from "babylonjs/XR/webXRDefaultExperience";
  78895. export * from "babylonjs/XR/webXRFeaturesManager";
  78896. export * from "babylonjs/XR/features/index";
  78897. export * from "babylonjs/XR/motionController/index";
  78898. }
  78899. declare module "babylonjs/index" {
  78900. export * from "babylonjs/abstractScene";
  78901. export * from "babylonjs/Actions/index";
  78902. export * from "babylonjs/Animations/index";
  78903. export * from "babylonjs/assetContainer";
  78904. export * from "babylonjs/Audio/index";
  78905. export * from "babylonjs/Behaviors/index";
  78906. export * from "babylonjs/Bones/index";
  78907. export * from "babylonjs/Cameras/index";
  78908. export * from "babylonjs/Collisions/index";
  78909. export * from "babylonjs/Culling/index";
  78910. export * from "babylonjs/Debug/index";
  78911. export * from "babylonjs/DeviceInput/index";
  78912. export * from "babylonjs/Engines/index";
  78913. export * from "babylonjs/Events/index";
  78914. export * from "babylonjs/Gamepads/index";
  78915. export * from "babylonjs/Gizmos/index";
  78916. export * from "babylonjs/Helpers/index";
  78917. export * from "babylonjs/Instrumentation/index";
  78918. export * from "babylonjs/Layers/index";
  78919. export * from "babylonjs/LensFlares/index";
  78920. export * from "babylonjs/Lights/index";
  78921. export * from "babylonjs/Loading/index";
  78922. export * from "babylonjs/Materials/index";
  78923. export * from "babylonjs/Maths/index";
  78924. export * from "babylonjs/Meshes/index";
  78925. export * from "babylonjs/Morph/index";
  78926. export * from "babylonjs/Navigation/index";
  78927. export * from "babylonjs/node";
  78928. export * from "babylonjs/Offline/index";
  78929. export * from "babylonjs/Particles/index";
  78930. export * from "babylonjs/Physics/index";
  78931. export * from "babylonjs/PostProcesses/index";
  78932. export * from "babylonjs/Probes/index";
  78933. export * from "babylonjs/Rendering/index";
  78934. export * from "babylonjs/scene";
  78935. export * from "babylonjs/sceneComponent";
  78936. export * from "babylonjs/Sprites/index";
  78937. export * from "babylonjs/States/index";
  78938. export * from "babylonjs/Misc/index";
  78939. export * from "babylonjs/XR/index";
  78940. export * from "babylonjs/types";
  78941. }
  78942. declare module "babylonjs/Animations/pathCursor" {
  78943. import { Vector3 } from "babylonjs/Maths/math.vector";
  78944. import { Path2 } from "babylonjs/Maths/math.path";
  78945. /**
  78946. * A cursor which tracks a point on a path
  78947. */
  78948. export class PathCursor {
  78949. private path;
  78950. /**
  78951. * Stores path cursor callbacks for when an onchange event is triggered
  78952. */
  78953. private _onchange;
  78954. /**
  78955. * The value of the path cursor
  78956. */
  78957. value: number;
  78958. /**
  78959. * The animation array of the path cursor
  78960. */
  78961. animations: Animation[];
  78962. /**
  78963. * Initializes the path cursor
  78964. * @param path The path to track
  78965. */
  78966. constructor(path: Path2);
  78967. /**
  78968. * Gets the cursor point on the path
  78969. * @returns A point on the path cursor at the cursor location
  78970. */
  78971. getPoint(): Vector3;
  78972. /**
  78973. * Moves the cursor ahead by the step amount
  78974. * @param step The amount to move the cursor forward
  78975. * @returns This path cursor
  78976. */
  78977. moveAhead(step?: number): PathCursor;
  78978. /**
  78979. * Moves the cursor behind by the step amount
  78980. * @param step The amount to move the cursor back
  78981. * @returns This path cursor
  78982. */
  78983. moveBack(step?: number): PathCursor;
  78984. /**
  78985. * Moves the cursor by the step amount
  78986. * If the step amount is greater than one, an exception is thrown
  78987. * @param step The amount to move the cursor
  78988. * @returns This path cursor
  78989. */
  78990. move(step: number): PathCursor;
  78991. /**
  78992. * Ensures that the value is limited between zero and one
  78993. * @returns This path cursor
  78994. */
  78995. private ensureLimits;
  78996. /**
  78997. * Runs onchange callbacks on change (used by the animation engine)
  78998. * @returns This path cursor
  78999. */
  79000. private raiseOnChange;
  79001. /**
  79002. * Executes a function on change
  79003. * @param f A path cursor onchange callback
  79004. * @returns This path cursor
  79005. */
  79006. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79007. }
  79008. }
  79009. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79010. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79011. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79012. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79013. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79014. }
  79015. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79016. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79017. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79018. }
  79019. declare module "babylonjs/Engines/Processors/index" {
  79020. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79021. export * from "babylonjs/Engines/Processors/Expressions/index";
  79022. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79023. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79024. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79025. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79026. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79027. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79028. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79029. }
  79030. declare module "babylonjs/Legacy/legacy" {
  79031. import * as Babylon from "babylonjs/index";
  79032. export * from "babylonjs/index";
  79033. }
  79034. declare module "babylonjs/Shaders/blur.fragment" {
  79035. /** @hidden */
  79036. export var blurPixelShader: {
  79037. name: string;
  79038. shader: string;
  79039. };
  79040. }
  79041. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79042. /** @hidden */
  79043. export var pointCloudVertexDeclaration: {
  79044. name: string;
  79045. shader: string;
  79046. };
  79047. }
  79048. declare module "babylonjs" {
  79049. export * from "babylonjs/Legacy/legacy";
  79050. }
  79051. declare module BABYLON {
  79052. /** Alias type for value that can be null */
  79053. export type Nullable<T> = T | null;
  79054. /**
  79055. * Alias type for number that are floats
  79056. * @ignorenaming
  79057. */
  79058. export type float = number;
  79059. /**
  79060. * Alias type for number that are doubles.
  79061. * @ignorenaming
  79062. */
  79063. export type double = number;
  79064. /**
  79065. * Alias type for number that are integer
  79066. * @ignorenaming
  79067. */
  79068. export type int = number;
  79069. /** Alias type for number array or Float32Array */
  79070. export type FloatArray = number[] | Float32Array;
  79071. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79072. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79073. /**
  79074. * Alias for types that can be used by a Buffer or VertexBuffer.
  79075. */
  79076. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79077. /**
  79078. * Alias type for primitive types
  79079. * @ignorenaming
  79080. */
  79081. type Primitive = undefined | null | boolean | string | number | Function;
  79082. /**
  79083. * Type modifier to make all the properties of an object Readonly
  79084. */
  79085. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79086. /**
  79087. * Type modifier to make all the properties of an object Readonly recursively
  79088. */
  79089. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79090. /**
  79091. * Type modifier to make object properties readonly.
  79092. */
  79093. export type DeepImmutableObject<T> = {
  79094. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79095. };
  79096. /** @hidden */
  79097. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79098. }
  79099. }
  79100. declare module BABYLON {
  79101. /**
  79102. * A class serves as a medium between the observable and its observers
  79103. */
  79104. export class EventState {
  79105. /**
  79106. * Create a new EventState
  79107. * @param mask defines the mask associated with this state
  79108. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79109. * @param target defines the original target of the state
  79110. * @param currentTarget defines the current target of the state
  79111. */
  79112. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79113. /**
  79114. * Initialize the current event state
  79115. * @param mask defines the mask associated with this state
  79116. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79117. * @param target defines the original target of the state
  79118. * @param currentTarget defines the current target of the state
  79119. * @returns the current event state
  79120. */
  79121. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79122. /**
  79123. * An Observer can set this property to true to prevent subsequent observers of being notified
  79124. */
  79125. skipNextObservers: boolean;
  79126. /**
  79127. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79128. */
  79129. mask: number;
  79130. /**
  79131. * The object that originally notified the event
  79132. */
  79133. target?: any;
  79134. /**
  79135. * The current object in the bubbling phase
  79136. */
  79137. currentTarget?: any;
  79138. /**
  79139. * This will be populated with the return value of the last function that was executed.
  79140. * If it is the first function in the callback chain it will be the event data.
  79141. */
  79142. lastReturnValue?: any;
  79143. }
  79144. /**
  79145. * Represent an Observer registered to a given Observable object.
  79146. */
  79147. export class Observer<T> {
  79148. /**
  79149. * Defines the callback to call when the observer is notified
  79150. */
  79151. callback: (eventData: T, eventState: EventState) => void;
  79152. /**
  79153. * Defines the mask of the observer (used to filter notifications)
  79154. */
  79155. mask: number;
  79156. /**
  79157. * Defines the current scope used to restore the JS context
  79158. */
  79159. scope: any;
  79160. /** @hidden */
  79161. _willBeUnregistered: boolean;
  79162. /**
  79163. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79164. */
  79165. unregisterOnNextCall: boolean;
  79166. /**
  79167. * Creates a new observer
  79168. * @param callback defines the callback to call when the observer is notified
  79169. * @param mask defines the mask of the observer (used to filter notifications)
  79170. * @param scope defines the current scope used to restore the JS context
  79171. */
  79172. constructor(
  79173. /**
  79174. * Defines the callback to call when the observer is notified
  79175. */
  79176. callback: (eventData: T, eventState: EventState) => void,
  79177. /**
  79178. * Defines the mask of the observer (used to filter notifications)
  79179. */
  79180. mask: number,
  79181. /**
  79182. * Defines the current scope used to restore the JS context
  79183. */
  79184. scope?: any);
  79185. }
  79186. /**
  79187. * Represent a list of observers registered to multiple Observables object.
  79188. */
  79189. export class MultiObserver<T> {
  79190. private _observers;
  79191. private _observables;
  79192. /**
  79193. * Release associated resources
  79194. */
  79195. dispose(): void;
  79196. /**
  79197. * Raise a callback when one of the observable will notify
  79198. * @param observables defines a list of observables to watch
  79199. * @param callback defines the callback to call on notification
  79200. * @param mask defines the mask used to filter notifications
  79201. * @param scope defines the current scope used to restore the JS context
  79202. * @returns the new MultiObserver
  79203. */
  79204. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79205. }
  79206. /**
  79207. * The Observable class is a simple implementation of the Observable pattern.
  79208. *
  79209. * 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.
  79210. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79211. * 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).
  79212. * 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.
  79213. */
  79214. export class Observable<T> {
  79215. private _observers;
  79216. private _eventState;
  79217. private _onObserverAdded;
  79218. /**
  79219. * Gets the list of observers
  79220. */
  79221. get observers(): Array<Observer<T>>;
  79222. /**
  79223. * Creates a new observable
  79224. * @param onObserverAdded defines a callback to call when a new observer is added
  79225. */
  79226. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79227. /**
  79228. * Create a new Observer with the specified callback
  79229. * @param callback the callback that will be executed for that Observer
  79230. * @param mask the mask used to filter observers
  79231. * @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.
  79232. * @param scope optional scope for the callback to be called from
  79233. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79234. * @returns the new observer created for the callback
  79235. */
  79236. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79237. /**
  79238. * Create a new Observer with the specified callback and unregisters after the next notification
  79239. * @param callback the callback that will be executed for that Observer
  79240. * @returns the new observer created for the callback
  79241. */
  79242. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79243. /**
  79244. * Remove an Observer from the Observable object
  79245. * @param observer the instance of the Observer to remove
  79246. * @returns false if it doesn't belong to this Observable
  79247. */
  79248. remove(observer: Nullable<Observer<T>>): boolean;
  79249. /**
  79250. * Remove a callback from the Observable object
  79251. * @param callback the callback to remove
  79252. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79253. * @returns false if it doesn't belong to this Observable
  79254. */
  79255. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79256. private _deferUnregister;
  79257. private _remove;
  79258. /**
  79259. * Moves the observable to the top of the observer list making it get called first when notified
  79260. * @param observer the observer to move
  79261. */
  79262. makeObserverTopPriority(observer: Observer<T>): void;
  79263. /**
  79264. * Moves the observable to the bottom of the observer list making it get called last when notified
  79265. * @param observer the observer to move
  79266. */
  79267. makeObserverBottomPriority(observer: Observer<T>): void;
  79268. /**
  79269. * Notify all Observers by calling their respective callback with the given data
  79270. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79271. * @param eventData defines the data to send to all observers
  79272. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79273. * @param target defines the original target of the state
  79274. * @param currentTarget defines the current target of the state
  79275. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79276. */
  79277. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79278. /**
  79279. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79280. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79281. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79282. * and it is crucial that all callbacks will be executed.
  79283. * The order of the callbacks is kept, callbacks are not executed parallel.
  79284. *
  79285. * @param eventData The data to be sent to each callback
  79286. * @param mask is used to filter observers defaults to -1
  79287. * @param target defines the callback target (see EventState)
  79288. * @param currentTarget defines he current object in the bubbling phase
  79289. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79290. */
  79291. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79292. /**
  79293. * Notify a specific observer
  79294. * @param observer defines the observer to notify
  79295. * @param eventData defines the data to be sent to each callback
  79296. * @param mask is used to filter observers defaults to -1
  79297. */
  79298. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79299. /**
  79300. * Gets a boolean indicating if the observable has at least one observer
  79301. * @returns true is the Observable has at least one Observer registered
  79302. */
  79303. hasObservers(): boolean;
  79304. /**
  79305. * Clear the list of observers
  79306. */
  79307. clear(): void;
  79308. /**
  79309. * Clone the current observable
  79310. * @returns a new observable
  79311. */
  79312. clone(): Observable<T>;
  79313. /**
  79314. * Does this observable handles observer registered with a given mask
  79315. * @param mask defines the mask to be tested
  79316. * @return whether or not one observer registered with the given mask is handeled
  79317. **/
  79318. hasSpecificMask(mask?: number): boolean;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /**
  79323. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79324. * Babylon.js
  79325. */
  79326. export class DomManagement {
  79327. /**
  79328. * Checks if the window object exists
  79329. * @returns true if the window object exists
  79330. */
  79331. static IsWindowObjectExist(): boolean;
  79332. /**
  79333. * Checks if the navigator object exists
  79334. * @returns true if the navigator object exists
  79335. */
  79336. static IsNavigatorAvailable(): boolean;
  79337. /**
  79338. * Check if the document object exists
  79339. * @returns true if the document object exists
  79340. */
  79341. static IsDocumentAvailable(): boolean;
  79342. /**
  79343. * Extracts text content from a DOM element hierarchy
  79344. * @param element defines the root element
  79345. * @returns a string
  79346. */
  79347. static GetDOMTextContent(element: HTMLElement): string;
  79348. }
  79349. }
  79350. declare module BABYLON {
  79351. /**
  79352. * Logger used througouht the application to allow configuration of
  79353. * the log level required for the messages.
  79354. */
  79355. export class Logger {
  79356. /**
  79357. * No log
  79358. */
  79359. static readonly NoneLogLevel: number;
  79360. /**
  79361. * Only message logs
  79362. */
  79363. static readonly MessageLogLevel: number;
  79364. /**
  79365. * Only warning logs
  79366. */
  79367. static readonly WarningLogLevel: number;
  79368. /**
  79369. * Only error logs
  79370. */
  79371. static readonly ErrorLogLevel: number;
  79372. /**
  79373. * All logs
  79374. */
  79375. static readonly AllLogLevel: number;
  79376. private static _LogCache;
  79377. /**
  79378. * Gets a value indicating the number of loading errors
  79379. * @ignorenaming
  79380. */
  79381. static errorsCount: number;
  79382. /**
  79383. * Callback called when a new log is added
  79384. */
  79385. static OnNewCacheEntry: (entry: string) => void;
  79386. private static _AddLogEntry;
  79387. private static _FormatMessage;
  79388. private static _LogDisabled;
  79389. private static _LogEnabled;
  79390. private static _WarnDisabled;
  79391. private static _WarnEnabled;
  79392. private static _ErrorDisabled;
  79393. private static _ErrorEnabled;
  79394. /**
  79395. * Log a message to the console
  79396. */
  79397. static Log: (message: string) => void;
  79398. /**
  79399. * Write a warning message to the console
  79400. */
  79401. static Warn: (message: string) => void;
  79402. /**
  79403. * Write an error message to the console
  79404. */
  79405. static Error: (message: string) => void;
  79406. /**
  79407. * Gets current log cache (list of logs)
  79408. */
  79409. static get LogCache(): string;
  79410. /**
  79411. * Clears the log cache
  79412. */
  79413. static ClearLogCache(): void;
  79414. /**
  79415. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79416. */
  79417. static set LogLevels(level: number);
  79418. }
  79419. }
  79420. declare module BABYLON {
  79421. /** @hidden */
  79422. export class _TypeStore {
  79423. /** @hidden */
  79424. static RegisteredTypes: {
  79425. [key: string]: Object;
  79426. };
  79427. /** @hidden */
  79428. static GetClass(fqdn: string): any;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * Helper to manipulate strings
  79434. */
  79435. export class StringTools {
  79436. /**
  79437. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79438. * @param str Source string
  79439. * @param suffix Suffix to search for in the source string
  79440. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79441. */
  79442. static EndsWith(str: string, suffix: string): boolean;
  79443. /**
  79444. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79445. * @param str Source string
  79446. * @param suffix Suffix to search for in the source string
  79447. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79448. */
  79449. static StartsWith(str: string, suffix: string): boolean;
  79450. /**
  79451. * Decodes a buffer into a string
  79452. * @param buffer The buffer to decode
  79453. * @returns The decoded string
  79454. */
  79455. static Decode(buffer: Uint8Array | Uint16Array): string;
  79456. /**
  79457. * Encode a buffer to a base64 string
  79458. * @param buffer defines the buffer to encode
  79459. * @returns the encoded string
  79460. */
  79461. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79462. /**
  79463. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79464. * @param num the number to convert and pad
  79465. * @param length the expected length of the string
  79466. * @returns the padded string
  79467. */
  79468. static PadNumber(num: number, length: number): string;
  79469. }
  79470. }
  79471. declare module BABYLON {
  79472. /**
  79473. * Class containing a set of static utilities functions for deep copy.
  79474. */
  79475. export class DeepCopier {
  79476. /**
  79477. * Tries to copy an object by duplicating every property
  79478. * @param source defines the source object
  79479. * @param destination defines the target object
  79480. * @param doNotCopyList defines a list of properties to avoid
  79481. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79482. */
  79483. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79484. }
  79485. }
  79486. declare module BABYLON {
  79487. /**
  79488. * Class containing a set of static utilities functions for precision date
  79489. */
  79490. export class PrecisionDate {
  79491. /**
  79492. * Gets either window.performance.now() if supported or Date.now() else
  79493. */
  79494. static get Now(): number;
  79495. }
  79496. }
  79497. declare module BABYLON {
  79498. /** @hidden */
  79499. export class _DevTools {
  79500. static WarnImport(name: string): string;
  79501. }
  79502. }
  79503. declare module BABYLON {
  79504. /**
  79505. * Interface used to define the mechanism to get data from the network
  79506. */
  79507. export interface IWebRequest {
  79508. /**
  79509. * Returns client's response url
  79510. */
  79511. responseURL: string;
  79512. /**
  79513. * Returns client's status
  79514. */
  79515. status: number;
  79516. /**
  79517. * Returns client's status as a text
  79518. */
  79519. statusText: string;
  79520. }
  79521. }
  79522. declare module BABYLON {
  79523. /**
  79524. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79525. */
  79526. export class WebRequest implements IWebRequest {
  79527. private _xhr;
  79528. /**
  79529. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79530. * i.e. when loading files, where the server/service expects an Authorization header
  79531. */
  79532. static CustomRequestHeaders: {
  79533. [key: string]: string;
  79534. };
  79535. /**
  79536. * Add callback functions in this array to update all the requests before they get sent to the network
  79537. */
  79538. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79539. private _injectCustomRequestHeaders;
  79540. /**
  79541. * Gets or sets a function to be called when loading progress changes
  79542. */
  79543. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79544. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79545. /**
  79546. * Returns client's state
  79547. */
  79548. get readyState(): number;
  79549. /**
  79550. * Returns client's status
  79551. */
  79552. get status(): number;
  79553. /**
  79554. * Returns client's status as a text
  79555. */
  79556. get statusText(): string;
  79557. /**
  79558. * Returns client's response
  79559. */
  79560. get response(): any;
  79561. /**
  79562. * Returns client's response url
  79563. */
  79564. get responseURL(): string;
  79565. /**
  79566. * Returns client's response as text
  79567. */
  79568. get responseText(): string;
  79569. /**
  79570. * Gets or sets the expected response type
  79571. */
  79572. get responseType(): XMLHttpRequestResponseType;
  79573. set responseType(value: XMLHttpRequestResponseType);
  79574. /** @hidden */
  79575. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79576. /** @hidden */
  79577. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79578. /**
  79579. * Cancels any network activity
  79580. */
  79581. abort(): void;
  79582. /**
  79583. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79584. * @param body defines an optional request body
  79585. */
  79586. send(body?: Document | BodyInit | null): void;
  79587. /**
  79588. * Sets the request method, request URL
  79589. * @param method defines the method to use (GET, POST, etc..)
  79590. * @param url defines the url to connect with
  79591. */
  79592. open(method: string, url: string): void;
  79593. /**
  79594. * Sets the value of a request header.
  79595. * @param name The name of the header whose value is to be set
  79596. * @param value The value to set as the body of the header
  79597. */
  79598. setRequestHeader(name: string, value: string): void;
  79599. /**
  79600. * Get the string containing the text of a particular header's value.
  79601. * @param name The name of the header
  79602. * @returns The string containing the text of the given header name
  79603. */
  79604. getResponseHeader(name: string): Nullable<string>;
  79605. }
  79606. }
  79607. declare module BABYLON {
  79608. /**
  79609. * File request interface
  79610. */
  79611. export interface IFileRequest {
  79612. /**
  79613. * Raised when the request is complete (success or error).
  79614. */
  79615. onCompleteObservable: Observable<IFileRequest>;
  79616. /**
  79617. * Aborts the request for a file.
  79618. */
  79619. abort: () => void;
  79620. }
  79621. }
  79622. declare module BABYLON {
  79623. /**
  79624. * Define options used to create a render target texture
  79625. */
  79626. export class RenderTargetCreationOptions {
  79627. /**
  79628. * Specifies is mipmaps must be generated
  79629. */
  79630. generateMipMaps?: boolean;
  79631. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79632. generateDepthBuffer?: boolean;
  79633. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79634. generateStencilBuffer?: boolean;
  79635. /** Defines texture type (int by default) */
  79636. type?: number;
  79637. /** Defines sampling mode (trilinear by default) */
  79638. samplingMode?: number;
  79639. /** Defines format (RGBA by default) */
  79640. format?: number;
  79641. }
  79642. }
  79643. declare module BABYLON {
  79644. /** Defines the cross module used constants to avoid circular dependncies */
  79645. export class Constants {
  79646. /** Defines that alpha blending is disabled */
  79647. static readonly ALPHA_DISABLE: number;
  79648. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79649. static readonly ALPHA_ADD: number;
  79650. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79651. static readonly ALPHA_COMBINE: number;
  79652. /** Defines that alpha blending is DEST - SRC * DEST */
  79653. static readonly ALPHA_SUBTRACT: number;
  79654. /** Defines that alpha blending is SRC * DEST */
  79655. static readonly ALPHA_MULTIPLY: number;
  79656. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79657. static readonly ALPHA_MAXIMIZED: number;
  79658. /** Defines that alpha blending is SRC + DEST */
  79659. static readonly ALPHA_ONEONE: number;
  79660. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79661. static readonly ALPHA_PREMULTIPLIED: number;
  79662. /**
  79663. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79664. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79665. */
  79666. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79667. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79668. static readonly ALPHA_INTERPOLATE: number;
  79669. /**
  79670. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79671. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79672. */
  79673. static readonly ALPHA_SCREENMODE: number;
  79674. /**
  79675. * Defines that alpha blending is SRC + DST
  79676. * Alpha will be set to SRC ALPHA + DST ALPHA
  79677. */
  79678. static readonly ALPHA_ONEONE_ONEONE: number;
  79679. /**
  79680. * Defines that alpha blending is SRC * DST ALPHA + DST
  79681. * Alpha will be set to 0
  79682. */
  79683. static readonly ALPHA_ALPHATOCOLOR: number;
  79684. /**
  79685. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79686. */
  79687. static readonly ALPHA_REVERSEONEMINUS: number;
  79688. /**
  79689. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79690. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79691. */
  79692. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79693. /**
  79694. * Defines that alpha blending is SRC + DST
  79695. * Alpha will be set to SRC ALPHA
  79696. */
  79697. static readonly ALPHA_ONEONE_ONEZERO: number;
  79698. /**
  79699. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79700. * Alpha will be set to DST ALPHA
  79701. */
  79702. static readonly ALPHA_EXCLUSION: number;
  79703. /** Defines that alpha blending equation a SUM */
  79704. static readonly ALPHA_EQUATION_ADD: number;
  79705. /** Defines that alpha blending equation a SUBSTRACTION */
  79706. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79707. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79708. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79709. /** Defines that alpha blending equation a MAX operation */
  79710. static readonly ALPHA_EQUATION_MAX: number;
  79711. /** Defines that alpha blending equation a MIN operation */
  79712. static readonly ALPHA_EQUATION_MIN: number;
  79713. /**
  79714. * Defines that alpha blending equation a DARKEN operation:
  79715. * It takes the min of the src and sums the alpha channels.
  79716. */
  79717. static readonly ALPHA_EQUATION_DARKEN: number;
  79718. /** Defines that the ressource is not delayed*/
  79719. static readonly DELAYLOADSTATE_NONE: number;
  79720. /** Defines that the ressource was successfully delay loaded */
  79721. static readonly DELAYLOADSTATE_LOADED: number;
  79722. /** Defines that the ressource is currently delay loading */
  79723. static readonly DELAYLOADSTATE_LOADING: number;
  79724. /** Defines that the ressource is delayed and has not started loading */
  79725. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79726. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79727. static readonly NEVER: number;
  79728. /** 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 */
  79729. static readonly ALWAYS: number;
  79730. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79731. static readonly LESS: number;
  79732. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79733. static readonly EQUAL: number;
  79734. /** 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 */
  79735. static readonly LEQUAL: number;
  79736. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79737. static readonly GREATER: number;
  79738. /** 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 */
  79739. static readonly GEQUAL: number;
  79740. /** 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 */
  79741. static readonly NOTEQUAL: number;
  79742. /** Passed to stencilOperation to specify that stencil value must be kept */
  79743. static readonly KEEP: number;
  79744. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79745. static readonly REPLACE: number;
  79746. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79747. static readonly INCR: number;
  79748. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79749. static readonly DECR: number;
  79750. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79751. static readonly INVERT: number;
  79752. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79753. static readonly INCR_WRAP: number;
  79754. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79755. static readonly DECR_WRAP: number;
  79756. /** Texture is not repeating outside of 0..1 UVs */
  79757. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79758. /** Texture is repeating outside of 0..1 UVs */
  79759. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79760. /** Texture is repeating and mirrored */
  79761. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79762. /** ALPHA */
  79763. static readonly TEXTUREFORMAT_ALPHA: number;
  79764. /** LUMINANCE */
  79765. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79766. /** LUMINANCE_ALPHA */
  79767. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79768. /** RGB */
  79769. static readonly TEXTUREFORMAT_RGB: number;
  79770. /** RGBA */
  79771. static readonly TEXTUREFORMAT_RGBA: number;
  79772. /** RED */
  79773. static readonly TEXTUREFORMAT_RED: number;
  79774. /** RED (2nd reference) */
  79775. static readonly TEXTUREFORMAT_R: number;
  79776. /** RG */
  79777. static readonly TEXTUREFORMAT_RG: number;
  79778. /** RED_INTEGER */
  79779. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79780. /** RED_INTEGER (2nd reference) */
  79781. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79782. /** RG_INTEGER */
  79783. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79784. /** RGB_INTEGER */
  79785. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79786. /** RGBA_INTEGER */
  79787. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79788. /** UNSIGNED_BYTE */
  79789. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79790. /** UNSIGNED_BYTE (2nd reference) */
  79791. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79792. /** FLOAT */
  79793. static readonly TEXTURETYPE_FLOAT: number;
  79794. /** HALF_FLOAT */
  79795. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79796. /** BYTE */
  79797. static readonly TEXTURETYPE_BYTE: number;
  79798. /** SHORT */
  79799. static readonly TEXTURETYPE_SHORT: number;
  79800. /** UNSIGNED_SHORT */
  79801. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79802. /** INT */
  79803. static readonly TEXTURETYPE_INT: number;
  79804. /** UNSIGNED_INT */
  79805. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79806. /** UNSIGNED_SHORT_4_4_4_4 */
  79807. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79808. /** UNSIGNED_SHORT_5_5_5_1 */
  79809. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79810. /** UNSIGNED_SHORT_5_6_5 */
  79811. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79812. /** UNSIGNED_INT_2_10_10_10_REV */
  79813. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79814. /** UNSIGNED_INT_24_8 */
  79815. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79816. /** UNSIGNED_INT_10F_11F_11F_REV */
  79817. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79818. /** UNSIGNED_INT_5_9_9_9_REV */
  79819. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79820. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79821. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79822. /** nearest is mag = nearest and min = nearest and no mip */
  79823. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79824. /** mag = nearest and min = nearest and mip = none */
  79825. static readonly TEXTURE_NEAREST_NEAREST: number;
  79826. /** Bilinear is mag = linear and min = linear and no mip */
  79827. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79828. /** mag = linear and min = linear and mip = none */
  79829. static readonly TEXTURE_LINEAR_LINEAR: number;
  79830. /** Trilinear is mag = linear and min = linear and mip = linear */
  79831. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79832. /** Trilinear is mag = linear and min = linear and mip = linear */
  79833. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79834. /** mag = nearest and min = nearest and mip = nearest */
  79835. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79836. /** mag = nearest and min = linear and mip = nearest */
  79837. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79838. /** mag = nearest and min = linear and mip = linear */
  79839. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79840. /** mag = nearest and min = linear and mip = none */
  79841. static readonly TEXTURE_NEAREST_LINEAR: number;
  79842. /** nearest is mag = nearest and min = nearest and mip = linear */
  79843. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79844. /** mag = linear and min = nearest and mip = nearest */
  79845. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79846. /** mag = linear and min = nearest and mip = linear */
  79847. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79849. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79850. /** mag = linear and min = nearest and mip = none */
  79851. static readonly TEXTURE_LINEAR_NEAREST: number;
  79852. /** Explicit coordinates mode */
  79853. static readonly TEXTURE_EXPLICIT_MODE: number;
  79854. /** Spherical coordinates mode */
  79855. static readonly TEXTURE_SPHERICAL_MODE: number;
  79856. /** Planar coordinates mode */
  79857. static readonly TEXTURE_PLANAR_MODE: number;
  79858. /** Cubic coordinates mode */
  79859. static readonly TEXTURE_CUBIC_MODE: number;
  79860. /** Projection coordinates mode */
  79861. static readonly TEXTURE_PROJECTION_MODE: number;
  79862. /** Skybox coordinates mode */
  79863. static readonly TEXTURE_SKYBOX_MODE: number;
  79864. /** Inverse Cubic coordinates mode */
  79865. static readonly TEXTURE_INVCUBIC_MODE: number;
  79866. /** Equirectangular coordinates mode */
  79867. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79868. /** Equirectangular Fixed coordinates mode */
  79869. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79870. /** Equirectangular Fixed Mirrored coordinates mode */
  79871. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79872. /** Offline (baking) quality for texture filtering */
  79873. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79874. /** High quality for texture filtering */
  79875. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79876. /** Medium quality for texture filtering */
  79877. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79878. /** Low quality for texture filtering */
  79879. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79880. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79881. static readonly SCALEMODE_FLOOR: number;
  79882. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79883. static readonly SCALEMODE_NEAREST: number;
  79884. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79885. static readonly SCALEMODE_CEILING: number;
  79886. /**
  79887. * The dirty texture flag value
  79888. */
  79889. static readonly MATERIAL_TextureDirtyFlag: number;
  79890. /**
  79891. * The dirty light flag value
  79892. */
  79893. static readonly MATERIAL_LightDirtyFlag: number;
  79894. /**
  79895. * The dirty fresnel flag value
  79896. */
  79897. static readonly MATERIAL_FresnelDirtyFlag: number;
  79898. /**
  79899. * The dirty attribute flag value
  79900. */
  79901. static readonly MATERIAL_AttributesDirtyFlag: number;
  79902. /**
  79903. * The dirty misc flag value
  79904. */
  79905. static readonly MATERIAL_MiscDirtyFlag: number;
  79906. /**
  79907. * The all dirty flag value
  79908. */
  79909. static readonly MATERIAL_AllDirtyFlag: number;
  79910. /**
  79911. * Returns the triangle fill mode
  79912. */
  79913. static readonly MATERIAL_TriangleFillMode: number;
  79914. /**
  79915. * Returns the wireframe mode
  79916. */
  79917. static readonly MATERIAL_WireFrameFillMode: number;
  79918. /**
  79919. * Returns the point fill mode
  79920. */
  79921. static readonly MATERIAL_PointFillMode: number;
  79922. /**
  79923. * Returns the point list draw mode
  79924. */
  79925. static readonly MATERIAL_PointListDrawMode: number;
  79926. /**
  79927. * Returns the line list draw mode
  79928. */
  79929. static readonly MATERIAL_LineListDrawMode: number;
  79930. /**
  79931. * Returns the line loop draw mode
  79932. */
  79933. static readonly MATERIAL_LineLoopDrawMode: number;
  79934. /**
  79935. * Returns the line strip draw mode
  79936. */
  79937. static readonly MATERIAL_LineStripDrawMode: number;
  79938. /**
  79939. * Returns the triangle strip draw mode
  79940. */
  79941. static readonly MATERIAL_TriangleStripDrawMode: number;
  79942. /**
  79943. * Returns the triangle fan draw mode
  79944. */
  79945. static readonly MATERIAL_TriangleFanDrawMode: number;
  79946. /**
  79947. * Stores the clock-wise side orientation
  79948. */
  79949. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79950. /**
  79951. * Stores the counter clock-wise side orientation
  79952. */
  79953. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79954. /**
  79955. * Nothing
  79956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79957. */
  79958. static readonly ACTION_NothingTrigger: number;
  79959. /**
  79960. * On pick
  79961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79962. */
  79963. static readonly ACTION_OnPickTrigger: number;
  79964. /**
  79965. * On left pick
  79966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79967. */
  79968. static readonly ACTION_OnLeftPickTrigger: number;
  79969. /**
  79970. * On right pick
  79971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79972. */
  79973. static readonly ACTION_OnRightPickTrigger: number;
  79974. /**
  79975. * On center pick
  79976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79977. */
  79978. static readonly ACTION_OnCenterPickTrigger: number;
  79979. /**
  79980. * On pick down
  79981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79982. */
  79983. static readonly ACTION_OnPickDownTrigger: number;
  79984. /**
  79985. * On double pick
  79986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79987. */
  79988. static readonly ACTION_OnDoublePickTrigger: number;
  79989. /**
  79990. * On pick up
  79991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79992. */
  79993. static readonly ACTION_OnPickUpTrigger: number;
  79994. /**
  79995. * On pick out.
  79996. * This trigger will only be raised if you also declared a OnPickDown
  79997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79998. */
  79999. static readonly ACTION_OnPickOutTrigger: number;
  80000. /**
  80001. * On long press
  80002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80003. */
  80004. static readonly ACTION_OnLongPressTrigger: number;
  80005. /**
  80006. * On pointer over
  80007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80008. */
  80009. static readonly ACTION_OnPointerOverTrigger: number;
  80010. /**
  80011. * On pointer out
  80012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80013. */
  80014. static readonly ACTION_OnPointerOutTrigger: number;
  80015. /**
  80016. * On every frame
  80017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80018. */
  80019. static readonly ACTION_OnEveryFrameTrigger: number;
  80020. /**
  80021. * On intersection enter
  80022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80023. */
  80024. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80025. /**
  80026. * On intersection exit
  80027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80028. */
  80029. static readonly ACTION_OnIntersectionExitTrigger: number;
  80030. /**
  80031. * On key down
  80032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80033. */
  80034. static readonly ACTION_OnKeyDownTrigger: number;
  80035. /**
  80036. * On key up
  80037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80038. */
  80039. static readonly ACTION_OnKeyUpTrigger: number;
  80040. /**
  80041. * Billboard mode will only apply to Y axis
  80042. */
  80043. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80044. /**
  80045. * Billboard mode will apply to all axes
  80046. */
  80047. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80048. /**
  80049. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80050. */
  80051. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80052. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80053. * Test order :
  80054. * Is the bounding sphere outside the frustum ?
  80055. * If not, are the bounding box vertices outside the frustum ?
  80056. * It not, then the cullable object is in the frustum.
  80057. */
  80058. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80059. /** Culling strategy : Bounding Sphere Only.
  80060. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80061. * It's also less accurate than the standard because some not visible objects can still be selected.
  80062. * Test : is the bounding sphere outside the frustum ?
  80063. * If not, then the cullable object is in the frustum.
  80064. */
  80065. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80066. /** Culling strategy : Optimistic Inclusion.
  80067. * This in an inclusion test first, then the standard exclusion test.
  80068. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80069. * 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.
  80070. * Anyway, it's as accurate as the standard strategy.
  80071. * Test :
  80072. * Is the cullable object bounding sphere center in the frustum ?
  80073. * If not, apply the default culling strategy.
  80074. */
  80075. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80076. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80077. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80078. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80079. * 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.
  80080. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80081. * Test :
  80082. * Is the cullable object bounding sphere center in the frustum ?
  80083. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80084. */
  80085. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80086. /**
  80087. * No logging while loading
  80088. */
  80089. static readonly SCENELOADER_NO_LOGGING: number;
  80090. /**
  80091. * Minimal logging while loading
  80092. */
  80093. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80094. /**
  80095. * Summary logging while loading
  80096. */
  80097. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80098. /**
  80099. * Detailled logging while loading
  80100. */
  80101. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80102. /**
  80103. * Prepass texture index for color
  80104. */
  80105. static readonly PREPASS_COLOR_INDEX: number;
  80106. /**
  80107. * Prepass texture index for irradiance
  80108. */
  80109. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80110. /**
  80111. * Prepass texture index for depth + normal
  80112. */
  80113. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80114. /**
  80115. * Prepass texture index for albedo
  80116. */
  80117. static readonly PREPASS_ALBEDO_INDEX: number;
  80118. }
  80119. }
  80120. declare module BABYLON {
  80121. /**
  80122. * This represents the required contract to create a new type of texture loader.
  80123. */
  80124. export interface IInternalTextureLoader {
  80125. /**
  80126. * Defines wether the loader supports cascade loading the different faces.
  80127. */
  80128. supportCascades: boolean;
  80129. /**
  80130. * This returns if the loader support the current file information.
  80131. * @param extension defines the file extension of the file being loaded
  80132. * @param mimeType defines the optional mime type of the file being loaded
  80133. * @returns true if the loader can load the specified file
  80134. */
  80135. canLoad(extension: string, mimeType?: string): boolean;
  80136. /**
  80137. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80138. * @param data contains the texture data
  80139. * @param texture defines the BabylonJS internal texture
  80140. * @param createPolynomials will be true if polynomials have been requested
  80141. * @param onLoad defines the callback to trigger once the texture is ready
  80142. * @param onError defines the callback to trigger in case of error
  80143. */
  80144. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80145. /**
  80146. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80147. * @param data contains the texture data
  80148. * @param texture defines the BabylonJS internal texture
  80149. * @param callback defines the method to call once ready to upload
  80150. */
  80151. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80152. }
  80153. }
  80154. declare module BABYLON {
  80155. /**
  80156. * Class used to store and describe the pipeline context associated with an effect
  80157. */
  80158. export interface IPipelineContext {
  80159. /**
  80160. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80161. */
  80162. isAsync: boolean;
  80163. /**
  80164. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80165. */
  80166. isReady: boolean;
  80167. /** @hidden */
  80168. _getVertexShaderCode(): string | null;
  80169. /** @hidden */
  80170. _getFragmentShaderCode(): string | null;
  80171. /** @hidden */
  80172. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80173. }
  80174. }
  80175. declare module BABYLON {
  80176. /**
  80177. * Class used to store gfx data (like WebGLBuffer)
  80178. */
  80179. export class DataBuffer {
  80180. /**
  80181. * Gets or sets the number of objects referencing this buffer
  80182. */
  80183. references: number;
  80184. /** Gets or sets the size of the underlying buffer */
  80185. capacity: number;
  80186. /**
  80187. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80188. */
  80189. is32Bits: boolean;
  80190. /**
  80191. * Gets the underlying buffer
  80192. */
  80193. get underlyingResource(): any;
  80194. }
  80195. }
  80196. declare module BABYLON {
  80197. /** @hidden */
  80198. export interface IShaderProcessor {
  80199. attributeProcessor?: (attribute: string) => string;
  80200. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80201. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80202. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80203. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80204. lineProcessor?: (line: string, isFragment: boolean) => string;
  80205. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80206. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80207. }
  80208. }
  80209. declare module BABYLON {
  80210. /** @hidden */
  80211. export interface ProcessingOptions {
  80212. defines: string[];
  80213. indexParameters: any;
  80214. isFragment: boolean;
  80215. shouldUseHighPrecisionShader: boolean;
  80216. supportsUniformBuffers: boolean;
  80217. shadersRepository: string;
  80218. includesShadersStore: {
  80219. [key: string]: string;
  80220. };
  80221. processor?: IShaderProcessor;
  80222. version: string;
  80223. platformName: string;
  80224. lookForClosingBracketForUniformBuffer?: boolean;
  80225. }
  80226. }
  80227. declare module BABYLON {
  80228. /** @hidden */
  80229. export class ShaderCodeNode {
  80230. line: string;
  80231. children: ShaderCodeNode[];
  80232. additionalDefineKey?: string;
  80233. additionalDefineValue?: string;
  80234. isValid(preprocessors: {
  80235. [key: string]: string;
  80236. }): boolean;
  80237. process(preprocessors: {
  80238. [key: string]: string;
  80239. }, options: ProcessingOptions): string;
  80240. }
  80241. }
  80242. declare module BABYLON {
  80243. /** @hidden */
  80244. export class ShaderCodeCursor {
  80245. private _lines;
  80246. lineIndex: number;
  80247. get currentLine(): string;
  80248. get canRead(): boolean;
  80249. set lines(value: string[]);
  80250. }
  80251. }
  80252. declare module BABYLON {
  80253. /** @hidden */
  80254. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80255. process(preprocessors: {
  80256. [key: string]: string;
  80257. }, options: ProcessingOptions): string;
  80258. }
  80259. }
  80260. declare module BABYLON {
  80261. /** @hidden */
  80262. export class ShaderDefineExpression {
  80263. isTrue(preprocessors: {
  80264. [key: string]: string;
  80265. }): boolean;
  80266. private static _OperatorPriority;
  80267. private static _Stack;
  80268. static postfixToInfix(postfix: string[]): string;
  80269. static infixToPostfix(infix: string): string[];
  80270. }
  80271. }
  80272. declare module BABYLON {
  80273. /** @hidden */
  80274. export class ShaderCodeTestNode extends ShaderCodeNode {
  80275. testExpression: ShaderDefineExpression;
  80276. isValid(preprocessors: {
  80277. [key: string]: string;
  80278. }): boolean;
  80279. }
  80280. }
  80281. declare module BABYLON {
  80282. /** @hidden */
  80283. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80284. define: string;
  80285. not: boolean;
  80286. constructor(define: string, not?: boolean);
  80287. isTrue(preprocessors: {
  80288. [key: string]: string;
  80289. }): boolean;
  80290. }
  80291. }
  80292. declare module BABYLON {
  80293. /** @hidden */
  80294. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80295. leftOperand: ShaderDefineExpression;
  80296. rightOperand: ShaderDefineExpression;
  80297. isTrue(preprocessors: {
  80298. [key: string]: string;
  80299. }): boolean;
  80300. }
  80301. }
  80302. declare module BABYLON {
  80303. /** @hidden */
  80304. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80305. leftOperand: ShaderDefineExpression;
  80306. rightOperand: ShaderDefineExpression;
  80307. isTrue(preprocessors: {
  80308. [key: string]: string;
  80309. }): boolean;
  80310. }
  80311. }
  80312. declare module BABYLON {
  80313. /** @hidden */
  80314. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80315. define: string;
  80316. operand: string;
  80317. testValue: string;
  80318. constructor(define: string, operand: string, testValue: string);
  80319. isTrue(preprocessors: {
  80320. [key: string]: string;
  80321. }): boolean;
  80322. }
  80323. }
  80324. declare module BABYLON {
  80325. /**
  80326. * Class used to enable access to offline support
  80327. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80328. */
  80329. export interface IOfflineProvider {
  80330. /**
  80331. * Gets a boolean indicating if scene must be saved in the database
  80332. */
  80333. enableSceneOffline: boolean;
  80334. /**
  80335. * Gets a boolean indicating if textures must be saved in the database
  80336. */
  80337. enableTexturesOffline: boolean;
  80338. /**
  80339. * Open the offline support and make it available
  80340. * @param successCallback defines the callback to call on success
  80341. * @param errorCallback defines the callback to call on error
  80342. */
  80343. open(successCallback: () => void, errorCallback: () => void): void;
  80344. /**
  80345. * Loads an image from the offline support
  80346. * @param url defines the url to load from
  80347. * @param image defines the target DOM image
  80348. */
  80349. loadImage(url: string, image: HTMLImageElement): void;
  80350. /**
  80351. * Loads a file from offline support
  80352. * @param url defines the URL to load from
  80353. * @param sceneLoaded defines a callback to call on success
  80354. * @param progressCallBack defines a callback to call when progress changed
  80355. * @param errorCallback defines a callback to call on error
  80356. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80357. */
  80358. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80359. }
  80360. }
  80361. declare module BABYLON {
  80362. /**
  80363. * Class used to help managing file picking and drag'n'drop
  80364. * File Storage
  80365. */
  80366. export class FilesInputStore {
  80367. /**
  80368. * List of files ready to be loaded
  80369. */
  80370. static FilesToLoad: {
  80371. [key: string]: File;
  80372. };
  80373. }
  80374. }
  80375. declare module BABYLON {
  80376. /**
  80377. * Class used to define a retry strategy when error happens while loading assets
  80378. */
  80379. export class RetryStrategy {
  80380. /**
  80381. * Function used to defines an exponential back off strategy
  80382. * @param maxRetries defines the maximum number of retries (3 by default)
  80383. * @param baseInterval defines the interval between retries
  80384. * @returns the strategy function to use
  80385. */
  80386. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80387. }
  80388. }
  80389. declare module BABYLON {
  80390. /**
  80391. * @ignore
  80392. * Application error to support additional information when loading a file
  80393. */
  80394. export abstract class BaseError extends Error {
  80395. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80396. }
  80397. }
  80398. declare module BABYLON {
  80399. /** @ignore */
  80400. export class LoadFileError extends BaseError {
  80401. request?: WebRequest;
  80402. file?: File;
  80403. /**
  80404. * Creates a new LoadFileError
  80405. * @param message defines the message of the error
  80406. * @param request defines the optional web request
  80407. * @param file defines the optional file
  80408. */
  80409. constructor(message: string, object?: WebRequest | File);
  80410. }
  80411. /** @ignore */
  80412. export class RequestFileError extends BaseError {
  80413. request: WebRequest;
  80414. /**
  80415. * Creates a new LoadFileError
  80416. * @param message defines the message of the error
  80417. * @param request defines the optional web request
  80418. */
  80419. constructor(message: string, request: WebRequest);
  80420. }
  80421. /** @ignore */
  80422. export class ReadFileError extends BaseError {
  80423. file: File;
  80424. /**
  80425. * Creates a new ReadFileError
  80426. * @param message defines the message of the error
  80427. * @param file defines the optional file
  80428. */
  80429. constructor(message: string, file: File);
  80430. }
  80431. /**
  80432. * @hidden
  80433. */
  80434. export class FileTools {
  80435. /**
  80436. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80437. */
  80438. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80439. /**
  80440. * Gets or sets the base URL to use to load assets
  80441. */
  80442. static BaseUrl: string;
  80443. /**
  80444. * Default behaviour for cors in the application.
  80445. * It can be a string if the expected behavior is identical in the entire app.
  80446. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80447. */
  80448. static CorsBehavior: string | ((url: string | string[]) => string);
  80449. /**
  80450. * Gets or sets a function used to pre-process url before using them to load assets
  80451. */
  80452. static PreprocessUrl: (url: string) => string;
  80453. /**
  80454. * Removes unwanted characters from an url
  80455. * @param url defines the url to clean
  80456. * @returns the cleaned url
  80457. */
  80458. private static _CleanUrl;
  80459. /**
  80460. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80461. * @param url define the url we are trying
  80462. * @param element define the dom element where to configure the cors policy
  80463. */
  80464. static SetCorsBehavior(url: string | string[], element: {
  80465. crossOrigin: string | null;
  80466. }): void;
  80467. /**
  80468. * Loads an image as an HTMLImageElement.
  80469. * @param input url string, ArrayBuffer, or Blob to load
  80470. * @param onLoad callback called when the image successfully loads
  80471. * @param onError callback called when the image fails to load
  80472. * @param offlineProvider offline provider for caching
  80473. * @param mimeType optional mime type
  80474. * @returns the HTMLImageElement of the loaded image
  80475. */
  80476. 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>;
  80477. /**
  80478. * Reads a file from a File object
  80479. * @param file defines the file to load
  80480. * @param onSuccess defines the callback to call when data is loaded
  80481. * @param onProgress defines the callback to call during loading process
  80482. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80483. * @param onError defines the callback to call when an error occurs
  80484. * @returns a file request object
  80485. */
  80486. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80487. /**
  80488. * Loads a file from a url
  80489. * @param url url to load
  80490. * @param onSuccess callback called when the file successfully loads
  80491. * @param onProgress callback called while file is loading (if the server supports this mode)
  80492. * @param offlineProvider defines the offline provider for caching
  80493. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80494. * @param onError callback called when the file fails to load
  80495. * @returns a file request object
  80496. */
  80497. 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;
  80498. /**
  80499. * Loads a file
  80500. * @param url url to load
  80501. * @param onSuccess callback called when the file successfully loads
  80502. * @param onProgress callback called while file is loading (if the server supports this mode)
  80503. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80504. * @param onError callback called when the file fails to load
  80505. * @param onOpened callback called when the web request is opened
  80506. * @returns a file request object
  80507. */
  80508. 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;
  80509. /**
  80510. * Checks if the loaded document was accessed via `file:`-Protocol.
  80511. * @returns boolean
  80512. */
  80513. static IsFileURL(): boolean;
  80514. }
  80515. }
  80516. declare module BABYLON {
  80517. /** @hidden */
  80518. export class ShaderProcessor {
  80519. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80520. private static _ProcessPrecision;
  80521. private static _ExtractOperation;
  80522. private static _BuildSubExpression;
  80523. private static _BuildExpression;
  80524. private static _MoveCursorWithinIf;
  80525. private static _MoveCursor;
  80526. private static _EvaluatePreProcessors;
  80527. private static _PreparePreProcessors;
  80528. private static _ProcessShaderConversion;
  80529. private static _ProcessIncludes;
  80530. /**
  80531. * Loads a file from a url
  80532. * @param url url to load
  80533. * @param onSuccess callback called when the file successfully loads
  80534. * @param onProgress callback called while file is loading (if the server supports this mode)
  80535. * @param offlineProvider defines the offline provider for caching
  80536. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80537. * @param onError callback called when the file fails to load
  80538. * @returns a file request object
  80539. * @hidden
  80540. */
  80541. 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;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. /**
  80546. * @hidden
  80547. */
  80548. export interface IColor4Like {
  80549. r: float;
  80550. g: float;
  80551. b: float;
  80552. a: float;
  80553. }
  80554. /**
  80555. * @hidden
  80556. */
  80557. export interface IColor3Like {
  80558. r: float;
  80559. g: float;
  80560. b: float;
  80561. }
  80562. /**
  80563. * @hidden
  80564. */
  80565. export interface IVector4Like {
  80566. x: float;
  80567. y: float;
  80568. z: float;
  80569. w: float;
  80570. }
  80571. /**
  80572. * @hidden
  80573. */
  80574. export interface IVector3Like {
  80575. x: float;
  80576. y: float;
  80577. z: float;
  80578. }
  80579. /**
  80580. * @hidden
  80581. */
  80582. export interface IVector2Like {
  80583. x: float;
  80584. y: float;
  80585. }
  80586. /**
  80587. * @hidden
  80588. */
  80589. export interface IMatrixLike {
  80590. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80591. updateFlag: int;
  80592. }
  80593. /**
  80594. * @hidden
  80595. */
  80596. export interface IViewportLike {
  80597. x: float;
  80598. y: float;
  80599. width: float;
  80600. height: float;
  80601. }
  80602. /**
  80603. * @hidden
  80604. */
  80605. export interface IPlaneLike {
  80606. normal: IVector3Like;
  80607. d: float;
  80608. normalize(): void;
  80609. }
  80610. }
  80611. declare module BABYLON {
  80612. /**
  80613. * Interface used to define common properties for effect fallbacks
  80614. */
  80615. export interface IEffectFallbacks {
  80616. /**
  80617. * Removes the defines that should be removed when falling back.
  80618. * @param currentDefines defines the current define statements for the shader.
  80619. * @param effect defines the current effect we try to compile
  80620. * @returns The resulting defines with defines of the current rank removed.
  80621. */
  80622. reduce(currentDefines: string, effect: Effect): string;
  80623. /**
  80624. * Removes the fallback from the bound mesh.
  80625. */
  80626. unBindMesh(): void;
  80627. /**
  80628. * Checks to see if more fallbacks are still availible.
  80629. */
  80630. hasMoreFallbacks: boolean;
  80631. }
  80632. }
  80633. declare module BABYLON {
  80634. /**
  80635. * Class used to evalaute queries containing `and` and `or` operators
  80636. */
  80637. export class AndOrNotEvaluator {
  80638. /**
  80639. * Evaluate a query
  80640. * @param query defines the query to evaluate
  80641. * @param evaluateCallback defines the callback used to filter result
  80642. * @returns true if the query matches
  80643. */
  80644. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80645. private static _HandleParenthesisContent;
  80646. private static _SimplifyNegation;
  80647. }
  80648. }
  80649. declare module BABYLON {
  80650. /**
  80651. * Class used to store custom tags
  80652. */
  80653. export class Tags {
  80654. /**
  80655. * Adds support for tags on the given object
  80656. * @param obj defines the object to use
  80657. */
  80658. static EnableFor(obj: any): void;
  80659. /**
  80660. * Removes tags support
  80661. * @param obj defines the object to use
  80662. */
  80663. static DisableFor(obj: any): void;
  80664. /**
  80665. * Gets a boolean indicating if the given object has tags
  80666. * @param obj defines the object to use
  80667. * @returns a boolean
  80668. */
  80669. static HasTags(obj: any): boolean;
  80670. /**
  80671. * Gets the tags available on a given object
  80672. * @param obj defines the object to use
  80673. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80674. * @returns the tags
  80675. */
  80676. static GetTags(obj: any, asString?: boolean): any;
  80677. /**
  80678. * Adds tags to an object
  80679. * @param obj defines the object to use
  80680. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80681. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80682. */
  80683. static AddTagsTo(obj: any, tagsString: string): void;
  80684. /**
  80685. * @hidden
  80686. */
  80687. static _AddTagTo(obj: any, tag: string): void;
  80688. /**
  80689. * Removes specific tags from a specific object
  80690. * @param obj defines the object to use
  80691. * @param tagsString defines the tags to remove
  80692. */
  80693. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80694. /**
  80695. * @hidden
  80696. */
  80697. static _RemoveTagFrom(obj: any, tag: string): void;
  80698. /**
  80699. * Defines if tags hosted on an object match a given query
  80700. * @param obj defines the object to use
  80701. * @param tagsQuery defines the tag query
  80702. * @returns a boolean
  80703. */
  80704. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80705. }
  80706. }
  80707. declare module BABYLON {
  80708. /**
  80709. * Scalar computation library
  80710. */
  80711. export class Scalar {
  80712. /**
  80713. * Two pi constants convenient for computation.
  80714. */
  80715. static TwoPi: number;
  80716. /**
  80717. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80718. * @param a number
  80719. * @param b number
  80720. * @param epsilon (default = 1.401298E-45)
  80721. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80722. */
  80723. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80724. /**
  80725. * Returns a string : the upper case translation of the number i to hexadecimal.
  80726. * @param i number
  80727. * @returns the upper case translation of the number i to hexadecimal.
  80728. */
  80729. static ToHex(i: number): string;
  80730. /**
  80731. * Returns -1 if value is negative and +1 is value is positive.
  80732. * @param value the value
  80733. * @returns the value itself if it's equal to zero.
  80734. */
  80735. static Sign(value: number): number;
  80736. /**
  80737. * Returns the value itself if it's between min and max.
  80738. * Returns min if the value is lower than min.
  80739. * Returns max if the value is greater than max.
  80740. * @param value the value to clmap
  80741. * @param min the min value to clamp to (default: 0)
  80742. * @param max the max value to clamp to (default: 1)
  80743. * @returns the clamped value
  80744. */
  80745. static Clamp(value: number, min?: number, max?: number): number;
  80746. /**
  80747. * the log2 of value.
  80748. * @param value the value to compute log2 of
  80749. * @returns the log2 of value.
  80750. */
  80751. static Log2(value: number): number;
  80752. /**
  80753. * Loops the value, so that it is never larger than length and never smaller than 0.
  80754. *
  80755. * This is similar to the modulo operator but it works with floating point numbers.
  80756. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80757. * With t = 5 and length = 2.5, the result would be 0.0.
  80758. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80759. * @param value the value
  80760. * @param length the length
  80761. * @returns the looped value
  80762. */
  80763. static Repeat(value: number, length: number): number;
  80764. /**
  80765. * Normalize the value between 0.0 and 1.0 using min and max values
  80766. * @param value value to normalize
  80767. * @param min max to normalize between
  80768. * @param max min to normalize between
  80769. * @returns the normalized value
  80770. */
  80771. static Normalize(value: number, min: number, max: number): number;
  80772. /**
  80773. * Denormalize the value from 0.0 and 1.0 using min and max values
  80774. * @param normalized value to denormalize
  80775. * @param min max to denormalize between
  80776. * @param max min to denormalize between
  80777. * @returns the denormalized value
  80778. */
  80779. static Denormalize(normalized: number, min: number, max: number): number;
  80780. /**
  80781. * Calculates the shortest difference between two given angles given in degrees.
  80782. * @param current current angle in degrees
  80783. * @param target target angle in degrees
  80784. * @returns the delta
  80785. */
  80786. static DeltaAngle(current: number, target: number): number;
  80787. /**
  80788. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80789. * @param tx value
  80790. * @param length length
  80791. * @returns The returned value will move back and forth between 0 and length
  80792. */
  80793. static PingPong(tx: number, length: number): number;
  80794. /**
  80795. * Interpolates between min and max with smoothing at the limits.
  80796. *
  80797. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80798. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80799. * @param from from
  80800. * @param to to
  80801. * @param tx value
  80802. * @returns the smooth stepped value
  80803. */
  80804. static SmoothStep(from: number, to: number, tx: number): number;
  80805. /**
  80806. * Moves a value current towards target.
  80807. *
  80808. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80809. * Negative values of maxDelta pushes the value away from target.
  80810. * @param current current value
  80811. * @param target target value
  80812. * @param maxDelta max distance to move
  80813. * @returns resulting value
  80814. */
  80815. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80816. /**
  80817. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80818. *
  80819. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80820. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80821. * @param current current value
  80822. * @param target target value
  80823. * @param maxDelta max distance to move
  80824. * @returns resulting angle
  80825. */
  80826. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80827. /**
  80828. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80829. * @param start start value
  80830. * @param end target value
  80831. * @param amount amount to lerp between
  80832. * @returns the lerped value
  80833. */
  80834. static Lerp(start: number, end: number, amount: number): number;
  80835. /**
  80836. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80837. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80838. * @param start start value
  80839. * @param end target value
  80840. * @param amount amount to lerp between
  80841. * @returns the lerped value
  80842. */
  80843. static LerpAngle(start: number, end: number, amount: number): number;
  80844. /**
  80845. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80846. * @param a start value
  80847. * @param b target value
  80848. * @param value value between a and b
  80849. * @returns the inverseLerp value
  80850. */
  80851. static InverseLerp(a: number, b: number, value: number): number;
  80852. /**
  80853. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80854. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80855. * @param value1 spline value
  80856. * @param tangent1 spline value
  80857. * @param value2 spline value
  80858. * @param tangent2 spline value
  80859. * @param amount input value
  80860. * @returns hermite result
  80861. */
  80862. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80863. /**
  80864. * Returns a random float number between and min and max values
  80865. * @param min min value of random
  80866. * @param max max value of random
  80867. * @returns random value
  80868. */
  80869. static RandomRange(min: number, max: number): number;
  80870. /**
  80871. * This function returns percentage of a number in a given range.
  80872. *
  80873. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80874. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80875. * @param number to convert to percentage
  80876. * @param min min range
  80877. * @param max max range
  80878. * @returns the percentage
  80879. */
  80880. static RangeToPercent(number: number, min: number, max: number): number;
  80881. /**
  80882. * This function returns number that corresponds to the percentage in a given range.
  80883. *
  80884. * PercentToRange(0.34,0,100) will return 34.
  80885. * @param percent to convert to number
  80886. * @param min min range
  80887. * @param max max range
  80888. * @returns the number
  80889. */
  80890. static PercentToRange(percent: number, min: number, max: number): number;
  80891. /**
  80892. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80893. * @param angle The angle to normalize in radian.
  80894. * @return The converted angle.
  80895. */
  80896. static NormalizeRadians(angle: number): number;
  80897. }
  80898. }
  80899. declare module BABYLON {
  80900. /**
  80901. * Constant used to convert a value to gamma space
  80902. * @ignorenaming
  80903. */
  80904. export const ToGammaSpace: number;
  80905. /**
  80906. * Constant used to convert a value to linear space
  80907. * @ignorenaming
  80908. */
  80909. export const ToLinearSpace = 2.2;
  80910. /**
  80911. * Constant used to define the minimal number value in Babylon.js
  80912. * @ignorenaming
  80913. */
  80914. let Epsilon: number;
  80915. }
  80916. declare module BABYLON {
  80917. /**
  80918. * Class used to represent a viewport on screen
  80919. */
  80920. export class Viewport {
  80921. /** viewport left coordinate */
  80922. x: number;
  80923. /** viewport top coordinate */
  80924. y: number;
  80925. /**viewport width */
  80926. width: number;
  80927. /** viewport height */
  80928. height: number;
  80929. /**
  80930. * Creates a Viewport object located at (x, y) and sized (width, height)
  80931. * @param x defines viewport left coordinate
  80932. * @param y defines viewport top coordinate
  80933. * @param width defines the viewport width
  80934. * @param height defines the viewport height
  80935. */
  80936. constructor(
  80937. /** viewport left coordinate */
  80938. x: number,
  80939. /** viewport top coordinate */
  80940. y: number,
  80941. /**viewport width */
  80942. width: number,
  80943. /** viewport height */
  80944. height: number);
  80945. /**
  80946. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80947. * @param renderWidth defines the rendering width
  80948. * @param renderHeight defines the rendering height
  80949. * @returns a new Viewport
  80950. */
  80951. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80952. /**
  80953. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80954. * @param renderWidth defines the rendering width
  80955. * @param renderHeight defines the rendering height
  80956. * @param ref defines the target viewport
  80957. * @returns the current viewport
  80958. */
  80959. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80960. /**
  80961. * Returns a new Viewport copied from the current one
  80962. * @returns a new Viewport
  80963. */
  80964. clone(): Viewport;
  80965. }
  80966. }
  80967. declare module BABYLON {
  80968. /**
  80969. * Class containing a set of static utilities functions for arrays.
  80970. */
  80971. export class ArrayTools {
  80972. /**
  80973. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80974. * @param size the number of element to construct and put in the array
  80975. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80976. * @returns a new array filled with new objects
  80977. */
  80978. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80979. }
  80980. }
  80981. declare module BABYLON {
  80982. /**
  80983. * Represents a plane by the equation ax + by + cz + d = 0
  80984. */
  80985. export class Plane {
  80986. private static _TmpMatrix;
  80987. /**
  80988. * Normal of the plane (a,b,c)
  80989. */
  80990. normal: Vector3;
  80991. /**
  80992. * d component of the plane
  80993. */
  80994. d: number;
  80995. /**
  80996. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80997. * @param a a component of the plane
  80998. * @param b b component of the plane
  80999. * @param c c component of the plane
  81000. * @param d d component of the plane
  81001. */
  81002. constructor(a: number, b: number, c: number, d: number);
  81003. /**
  81004. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81005. */
  81006. asArray(): number[];
  81007. /**
  81008. * @returns a new plane copied from the current Plane.
  81009. */
  81010. clone(): Plane;
  81011. /**
  81012. * @returns the string "Plane".
  81013. */
  81014. getClassName(): string;
  81015. /**
  81016. * @returns the Plane hash code.
  81017. */
  81018. getHashCode(): number;
  81019. /**
  81020. * Normalize the current Plane in place.
  81021. * @returns the updated Plane.
  81022. */
  81023. normalize(): Plane;
  81024. /**
  81025. * Applies a transformation the plane and returns the result
  81026. * @param transformation the transformation matrix to be applied to the plane
  81027. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81028. */
  81029. transform(transformation: DeepImmutable<Matrix>): Plane;
  81030. /**
  81031. * Compute the dot product between the point and the plane normal
  81032. * @param point point to calculate the dot product with
  81033. * @returns the dot product (float) of the point coordinates and the plane normal.
  81034. */
  81035. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81036. /**
  81037. * Updates the current Plane from the plane defined by the three given points.
  81038. * @param point1 one of the points used to contruct the plane
  81039. * @param point2 one of the points used to contruct the plane
  81040. * @param point3 one of the points used to contruct the plane
  81041. * @returns the updated Plane.
  81042. */
  81043. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81044. /**
  81045. * Checks if the plane is facing a given direction
  81046. * @param direction the direction to check if the plane is facing
  81047. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81048. * @returns True is the vector "direction" is the same side than the plane normal.
  81049. */
  81050. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81051. /**
  81052. * Calculates the distance to a point
  81053. * @param point point to calculate distance to
  81054. * @returns the signed distance (float) from the given point to the Plane.
  81055. */
  81056. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81057. /**
  81058. * Creates a plane from an array
  81059. * @param array the array to create a plane from
  81060. * @returns a new Plane from the given array.
  81061. */
  81062. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81063. /**
  81064. * Creates a plane from three points
  81065. * @param point1 point used to create the plane
  81066. * @param point2 point used to create the plane
  81067. * @param point3 point used to create the plane
  81068. * @returns a new Plane defined by the three given points.
  81069. */
  81070. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81071. /**
  81072. * Creates a plane from an origin point and a normal
  81073. * @param origin origin of the plane to be constructed
  81074. * @param normal normal of the plane to be constructed
  81075. * @returns a new Plane the normal vector to this plane at the given origin point.
  81076. * Note : the vector "normal" is updated because normalized.
  81077. */
  81078. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81079. /**
  81080. * Calculates the distance from a plane and a point
  81081. * @param origin origin of the plane to be constructed
  81082. * @param normal normal of the plane to be constructed
  81083. * @param point point to calculate distance to
  81084. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81085. */
  81086. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81087. }
  81088. }
  81089. declare module BABYLON {
  81090. /** @hidden */
  81091. export class PerformanceConfigurator {
  81092. /** @hidden */
  81093. static MatrixUse64Bits: boolean;
  81094. /** @hidden */
  81095. static MatrixTrackPrecisionChange: boolean;
  81096. /** @hidden */
  81097. static MatrixCurrentType: any;
  81098. /** @hidden */
  81099. static MatrixTrackedMatrices: Array<any> | null;
  81100. /** @hidden */
  81101. static SetMatrixPrecision(use64bits: boolean): void;
  81102. }
  81103. }
  81104. declare module BABYLON {
  81105. /**
  81106. * Class representing a vector containing 2 coordinates
  81107. */
  81108. export class Vector2 {
  81109. /** defines the first coordinate */
  81110. x: number;
  81111. /** defines the second coordinate */
  81112. y: number;
  81113. /**
  81114. * Creates a new Vector2 from the given x and y coordinates
  81115. * @param x defines the first coordinate
  81116. * @param y defines the second coordinate
  81117. */
  81118. constructor(
  81119. /** defines the first coordinate */
  81120. x?: number,
  81121. /** defines the second coordinate */
  81122. y?: number);
  81123. /**
  81124. * Gets a string with the Vector2 coordinates
  81125. * @returns a string with the Vector2 coordinates
  81126. */
  81127. toString(): string;
  81128. /**
  81129. * Gets class name
  81130. * @returns the string "Vector2"
  81131. */
  81132. getClassName(): string;
  81133. /**
  81134. * Gets current vector hash code
  81135. * @returns the Vector2 hash code as a number
  81136. */
  81137. getHashCode(): number;
  81138. /**
  81139. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81140. * @param array defines the source array
  81141. * @param index defines the offset in source array
  81142. * @returns the current Vector2
  81143. */
  81144. toArray(array: FloatArray, index?: number): Vector2;
  81145. /**
  81146. * Update the current vector from an array
  81147. * @param array defines the destination array
  81148. * @param index defines the offset in the destination array
  81149. * @returns the current Vector3
  81150. */
  81151. fromArray(array: FloatArray, index?: number): Vector2;
  81152. /**
  81153. * Copy the current vector to an array
  81154. * @returns a new array with 2 elements: the Vector2 coordinates.
  81155. */
  81156. asArray(): number[];
  81157. /**
  81158. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81159. * @param source defines the source Vector2
  81160. * @returns the current updated Vector2
  81161. */
  81162. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81163. /**
  81164. * Sets the Vector2 coordinates with the given floats
  81165. * @param x defines the first coordinate
  81166. * @param y defines the second coordinate
  81167. * @returns the current updated Vector2
  81168. */
  81169. copyFromFloats(x: number, y: number): Vector2;
  81170. /**
  81171. * Sets the Vector2 coordinates with the given floats
  81172. * @param x defines the first coordinate
  81173. * @param y defines the second coordinate
  81174. * @returns the current updated Vector2
  81175. */
  81176. set(x: number, y: number): Vector2;
  81177. /**
  81178. * Add another vector with the current one
  81179. * @param otherVector defines the other vector
  81180. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81181. */
  81182. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81183. /**
  81184. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81185. * @param otherVector defines the other vector
  81186. * @param result defines the target vector
  81187. * @returns the unmodified current Vector2
  81188. */
  81189. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81190. /**
  81191. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81192. * @param otherVector defines the other vector
  81193. * @returns the current updated Vector2
  81194. */
  81195. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81196. /**
  81197. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81198. * @param otherVector defines the other vector
  81199. * @returns a new Vector2
  81200. */
  81201. addVector3(otherVector: Vector3): Vector2;
  81202. /**
  81203. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81204. * @param otherVector defines the other vector
  81205. * @returns a new Vector2
  81206. */
  81207. subtract(otherVector: Vector2): Vector2;
  81208. /**
  81209. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81210. * @param otherVector defines the other vector
  81211. * @param result defines the target vector
  81212. * @returns the unmodified current Vector2
  81213. */
  81214. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81215. /**
  81216. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81217. * @param otherVector defines the other vector
  81218. * @returns the current updated Vector2
  81219. */
  81220. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81221. /**
  81222. * Multiplies in place the current Vector2 coordinates by the given ones
  81223. * @param otherVector defines the other vector
  81224. * @returns the current updated Vector2
  81225. */
  81226. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81227. /**
  81228. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81229. * @param otherVector defines the other vector
  81230. * @returns a new Vector2
  81231. */
  81232. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81233. /**
  81234. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81235. * @param otherVector defines the other vector
  81236. * @param result defines the target vector
  81237. * @returns the unmodified current Vector2
  81238. */
  81239. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81240. /**
  81241. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81242. * @param x defines the first coordinate
  81243. * @param y defines the second coordinate
  81244. * @returns a new Vector2
  81245. */
  81246. multiplyByFloats(x: number, y: number): Vector2;
  81247. /**
  81248. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81249. * @param otherVector defines the other vector
  81250. * @returns a new Vector2
  81251. */
  81252. divide(otherVector: Vector2): Vector2;
  81253. /**
  81254. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81255. * @param otherVector defines the other vector
  81256. * @param result defines the target vector
  81257. * @returns the unmodified current Vector2
  81258. */
  81259. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81260. /**
  81261. * Divides the current Vector2 coordinates by the given ones
  81262. * @param otherVector defines the other vector
  81263. * @returns the current updated Vector2
  81264. */
  81265. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81266. /**
  81267. * Gets a new Vector2 with current Vector2 negated coordinates
  81268. * @returns a new Vector2
  81269. */
  81270. negate(): Vector2;
  81271. /**
  81272. * Negate this vector in place
  81273. * @returns this
  81274. */
  81275. negateInPlace(): Vector2;
  81276. /**
  81277. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81278. * @param result defines the Vector3 object where to store the result
  81279. * @returns the current Vector2
  81280. */
  81281. negateToRef(result: Vector2): Vector2;
  81282. /**
  81283. * Multiply the Vector2 coordinates by scale
  81284. * @param scale defines the scaling factor
  81285. * @returns the current updated Vector2
  81286. */
  81287. scaleInPlace(scale: number): Vector2;
  81288. /**
  81289. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81290. * @param scale defines the scaling factor
  81291. * @returns a new Vector2
  81292. */
  81293. scale(scale: number): Vector2;
  81294. /**
  81295. * Scale the current Vector2 values by a factor to a given Vector2
  81296. * @param scale defines the scale factor
  81297. * @param result defines the Vector2 object where to store the result
  81298. * @returns the unmodified current Vector2
  81299. */
  81300. scaleToRef(scale: number, result: Vector2): Vector2;
  81301. /**
  81302. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81303. * @param scale defines the scale factor
  81304. * @param result defines the Vector2 object where to store the result
  81305. * @returns the unmodified current Vector2
  81306. */
  81307. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81308. /**
  81309. * Gets a boolean if two vectors are equals
  81310. * @param otherVector defines the other vector
  81311. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81312. */
  81313. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81314. /**
  81315. * Gets a boolean if two vectors are equals (using an epsilon value)
  81316. * @param otherVector defines the other vector
  81317. * @param epsilon defines the minimal distance to consider equality
  81318. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81319. */
  81320. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81321. /**
  81322. * Gets a new Vector2 from current Vector2 floored values
  81323. * @returns a new Vector2
  81324. */
  81325. floor(): Vector2;
  81326. /**
  81327. * Gets a new Vector2 from current Vector2 floored values
  81328. * @returns a new Vector2
  81329. */
  81330. fract(): Vector2;
  81331. /**
  81332. * Gets the length of the vector
  81333. * @returns the vector length (float)
  81334. */
  81335. length(): number;
  81336. /**
  81337. * Gets the vector squared length
  81338. * @returns the vector squared length (float)
  81339. */
  81340. lengthSquared(): number;
  81341. /**
  81342. * Normalize the vector
  81343. * @returns the current updated Vector2
  81344. */
  81345. normalize(): Vector2;
  81346. /**
  81347. * Gets a new Vector2 copied from the Vector2
  81348. * @returns a new Vector2
  81349. */
  81350. clone(): Vector2;
  81351. /**
  81352. * Gets a new Vector2(0, 0)
  81353. * @returns a new Vector2
  81354. */
  81355. static Zero(): Vector2;
  81356. /**
  81357. * Gets a new Vector2(1, 1)
  81358. * @returns a new Vector2
  81359. */
  81360. static One(): Vector2;
  81361. /**
  81362. * Gets a new Vector2 set from the given index element of the given array
  81363. * @param array defines the data source
  81364. * @param offset defines the offset in the data source
  81365. * @returns a new Vector2
  81366. */
  81367. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81368. /**
  81369. * Sets "result" from the given index element of the given array
  81370. * @param array defines the data source
  81371. * @param offset defines the offset in the data source
  81372. * @param result defines the target vector
  81373. */
  81374. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81375. /**
  81376. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81377. * @param value1 defines 1st point of control
  81378. * @param value2 defines 2nd point of control
  81379. * @param value3 defines 3rd point of control
  81380. * @param value4 defines 4th point of control
  81381. * @param amount defines the interpolation factor
  81382. * @returns a new Vector2
  81383. */
  81384. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81385. /**
  81386. * 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".
  81387. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81388. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81389. * @param value defines the value to clamp
  81390. * @param min defines the lower limit
  81391. * @param max defines the upper limit
  81392. * @returns a new Vector2
  81393. */
  81394. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81395. /**
  81396. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81397. * @param value1 defines the 1st control point
  81398. * @param tangent1 defines the outgoing tangent
  81399. * @param value2 defines the 2nd control point
  81400. * @param tangent2 defines the incoming tangent
  81401. * @param amount defines the interpolation factor
  81402. * @returns a new Vector2
  81403. */
  81404. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81405. /**
  81406. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81407. * @param start defines the start vector
  81408. * @param end defines the end vector
  81409. * @param amount defines the interpolation factor
  81410. * @returns a new Vector2
  81411. */
  81412. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81413. /**
  81414. * Gets the dot product of the vector "left" and the vector "right"
  81415. * @param left defines first vector
  81416. * @param right defines second vector
  81417. * @returns the dot product (float)
  81418. */
  81419. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81420. /**
  81421. * Returns a new Vector2 equal to the normalized given vector
  81422. * @param vector defines the vector to normalize
  81423. * @returns a new Vector2
  81424. */
  81425. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81426. /**
  81427. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81428. * @param left defines 1st vector
  81429. * @param right defines 2nd vector
  81430. * @returns a new Vector2
  81431. */
  81432. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81433. /**
  81434. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81435. * @param left defines 1st vector
  81436. * @param right defines 2nd vector
  81437. * @returns a new Vector2
  81438. */
  81439. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81440. /**
  81441. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81442. * @param vector defines the vector to transform
  81443. * @param transformation defines the matrix to apply
  81444. * @returns a new Vector2
  81445. */
  81446. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81447. /**
  81448. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81449. * @param vector defines the vector to transform
  81450. * @param transformation defines the matrix to apply
  81451. * @param result defines the target vector
  81452. */
  81453. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81454. /**
  81455. * Determines if a given vector is included in a triangle
  81456. * @param p defines the vector to test
  81457. * @param p0 defines 1st triangle point
  81458. * @param p1 defines 2nd triangle point
  81459. * @param p2 defines 3rd triangle point
  81460. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81461. */
  81462. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81463. /**
  81464. * Gets the distance between the vectors "value1" and "value2"
  81465. * @param value1 defines first vector
  81466. * @param value2 defines second vector
  81467. * @returns the distance between vectors
  81468. */
  81469. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81470. /**
  81471. * Returns the squared distance between the vectors "value1" and "value2"
  81472. * @param value1 defines first vector
  81473. * @param value2 defines second vector
  81474. * @returns the squared distance between vectors
  81475. */
  81476. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81477. /**
  81478. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81479. * @param value1 defines first vector
  81480. * @param value2 defines second vector
  81481. * @returns a new Vector2
  81482. */
  81483. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81484. /**
  81485. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81486. * @param p defines the middle point
  81487. * @param segA defines one point of the segment
  81488. * @param segB defines the other point of the segment
  81489. * @returns the shortest distance
  81490. */
  81491. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81492. }
  81493. /**
  81494. * Class used to store (x,y,z) vector representation
  81495. * A Vector3 is the main object used in 3D geometry
  81496. * It can represent etiher the coordinates of a point the space, either a direction
  81497. * Reminder: js uses a left handed forward facing system
  81498. */
  81499. export class Vector3 {
  81500. private static _UpReadOnly;
  81501. private static _ZeroReadOnly;
  81502. /** @hidden */
  81503. _x: number;
  81504. /** @hidden */
  81505. _y: number;
  81506. /** @hidden */
  81507. _z: number;
  81508. /** @hidden */
  81509. _isDirty: boolean;
  81510. /** Gets or sets the x coordinate */
  81511. get x(): number;
  81512. set x(value: number);
  81513. /** Gets or sets the y coordinate */
  81514. get y(): number;
  81515. set y(value: number);
  81516. /** Gets or sets the z coordinate */
  81517. get z(): number;
  81518. set z(value: number);
  81519. /**
  81520. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81521. * @param x defines the first coordinates (on X axis)
  81522. * @param y defines the second coordinates (on Y axis)
  81523. * @param z defines the third coordinates (on Z axis)
  81524. */
  81525. constructor(x?: number, y?: number, z?: number);
  81526. /**
  81527. * Creates a string representation of the Vector3
  81528. * @returns a string with the Vector3 coordinates.
  81529. */
  81530. toString(): string;
  81531. /**
  81532. * Gets the class name
  81533. * @returns the string "Vector3"
  81534. */
  81535. getClassName(): string;
  81536. /**
  81537. * Creates the Vector3 hash code
  81538. * @returns a number which tends to be unique between Vector3 instances
  81539. */
  81540. getHashCode(): number;
  81541. /**
  81542. * Creates an array containing three elements : the coordinates of the Vector3
  81543. * @returns a new array of numbers
  81544. */
  81545. asArray(): number[];
  81546. /**
  81547. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81548. * @param array defines the destination array
  81549. * @param index defines the offset in the destination array
  81550. * @returns the current Vector3
  81551. */
  81552. toArray(array: FloatArray, index?: number): Vector3;
  81553. /**
  81554. * Update the current vector from an array
  81555. * @param array defines the destination array
  81556. * @param index defines the offset in the destination array
  81557. * @returns the current Vector3
  81558. */
  81559. fromArray(array: FloatArray, index?: number): Vector3;
  81560. /**
  81561. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81562. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81563. */
  81564. toQuaternion(): Quaternion;
  81565. /**
  81566. * Adds the given vector to the current Vector3
  81567. * @param otherVector defines the second operand
  81568. * @returns the current updated Vector3
  81569. */
  81570. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81571. /**
  81572. * Adds the given coordinates to the current Vector3
  81573. * @param x defines the x coordinate of the operand
  81574. * @param y defines the y coordinate of the operand
  81575. * @param z defines the z coordinate of the operand
  81576. * @returns the current updated Vector3
  81577. */
  81578. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81579. /**
  81580. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81581. * @param otherVector defines the second operand
  81582. * @returns the resulting Vector3
  81583. */
  81584. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81585. /**
  81586. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81587. * @param otherVector defines the second operand
  81588. * @param result defines the Vector3 object where to store the result
  81589. * @returns the current Vector3
  81590. */
  81591. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81592. /**
  81593. * Subtract the given vector from the current Vector3
  81594. * @param otherVector defines the second operand
  81595. * @returns the current updated Vector3
  81596. */
  81597. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81598. /**
  81599. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81600. * @param otherVector defines the second operand
  81601. * @returns the resulting Vector3
  81602. */
  81603. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81604. /**
  81605. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81606. * @param otherVector defines the second operand
  81607. * @param result defines the Vector3 object where to store the result
  81608. * @returns the current Vector3
  81609. */
  81610. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81611. /**
  81612. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81613. * @param x defines the x coordinate of the operand
  81614. * @param y defines the y coordinate of the operand
  81615. * @param z defines the z coordinate of the operand
  81616. * @returns the resulting Vector3
  81617. */
  81618. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81619. /**
  81620. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81621. * @param x defines the x coordinate of the operand
  81622. * @param y defines the y coordinate of the operand
  81623. * @param z defines the z coordinate of the operand
  81624. * @param result defines the Vector3 object where to store the result
  81625. * @returns the current Vector3
  81626. */
  81627. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81628. /**
  81629. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81630. * @returns a new Vector3
  81631. */
  81632. negate(): Vector3;
  81633. /**
  81634. * Negate this vector in place
  81635. * @returns this
  81636. */
  81637. negateInPlace(): Vector3;
  81638. /**
  81639. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81640. * @param result defines the Vector3 object where to store the result
  81641. * @returns the current Vector3
  81642. */
  81643. negateToRef(result: Vector3): Vector3;
  81644. /**
  81645. * Multiplies the Vector3 coordinates by the float "scale"
  81646. * @param scale defines the multiplier factor
  81647. * @returns the current updated Vector3
  81648. */
  81649. scaleInPlace(scale: number): Vector3;
  81650. /**
  81651. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81652. * @param scale defines the multiplier factor
  81653. * @returns a new Vector3
  81654. */
  81655. scale(scale: number): Vector3;
  81656. /**
  81657. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81658. * @param scale defines the multiplier factor
  81659. * @param result defines the Vector3 object where to store the result
  81660. * @returns the current Vector3
  81661. */
  81662. scaleToRef(scale: number, result: Vector3): Vector3;
  81663. /**
  81664. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81665. * @param scale defines the scale factor
  81666. * @param result defines the Vector3 object where to store the result
  81667. * @returns the unmodified current Vector3
  81668. */
  81669. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81670. /**
  81671. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81672. * @param origin defines the origin of the projection ray
  81673. * @param plane defines the plane to project to
  81674. * @returns the projected vector3
  81675. */
  81676. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81677. /**
  81678. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81679. * @param origin defines the origin of the projection ray
  81680. * @param plane defines the plane to project to
  81681. * @param result defines the Vector3 where to store the result
  81682. */
  81683. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81684. /**
  81685. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81686. * @param otherVector defines the second operand
  81687. * @returns true if both vectors are equals
  81688. */
  81689. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81690. /**
  81691. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81692. * @param otherVector defines the second operand
  81693. * @param epsilon defines the minimal distance to define values as equals
  81694. * @returns true if both vectors are distant less than epsilon
  81695. */
  81696. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81697. /**
  81698. * Returns true if the current Vector3 coordinates equals the given floats
  81699. * @param x defines the x coordinate of the operand
  81700. * @param y defines the y coordinate of the operand
  81701. * @param z defines the z coordinate of the operand
  81702. * @returns true if both vectors are equals
  81703. */
  81704. equalsToFloats(x: number, y: number, z: number): boolean;
  81705. /**
  81706. * Multiplies the current Vector3 coordinates by the given ones
  81707. * @param otherVector defines the second operand
  81708. * @returns the current updated Vector3
  81709. */
  81710. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81711. /**
  81712. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81713. * @param otherVector defines the second operand
  81714. * @returns the new Vector3
  81715. */
  81716. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81717. /**
  81718. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81719. * @param otherVector defines the second operand
  81720. * @param result defines the Vector3 object where to store the result
  81721. * @returns the current Vector3
  81722. */
  81723. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81724. /**
  81725. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81726. * @param x defines the x coordinate of the operand
  81727. * @param y defines the y coordinate of the operand
  81728. * @param z defines the z coordinate of the operand
  81729. * @returns the new Vector3
  81730. */
  81731. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81732. /**
  81733. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81734. * @param otherVector defines the second operand
  81735. * @returns the new Vector3
  81736. */
  81737. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81738. /**
  81739. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81740. * @param otherVector defines the second operand
  81741. * @param result defines the Vector3 object where to store the result
  81742. * @returns the current Vector3
  81743. */
  81744. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81745. /**
  81746. * Divides the current Vector3 coordinates by the given ones.
  81747. * @param otherVector defines the second operand
  81748. * @returns the current updated Vector3
  81749. */
  81750. divideInPlace(otherVector: Vector3): Vector3;
  81751. /**
  81752. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81753. * @param other defines the second operand
  81754. * @returns the current updated Vector3
  81755. */
  81756. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81757. /**
  81758. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81759. * @param other defines the second operand
  81760. * @returns the current updated Vector3
  81761. */
  81762. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81763. /**
  81764. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81765. * @param x defines the x coordinate of the operand
  81766. * @param y defines the y coordinate of the operand
  81767. * @param z defines the z coordinate of the operand
  81768. * @returns the current updated Vector3
  81769. */
  81770. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81771. /**
  81772. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81773. * @param x defines the x coordinate of the operand
  81774. * @param y defines the y coordinate of the operand
  81775. * @param z defines the z coordinate of the operand
  81776. * @returns the current updated Vector3
  81777. */
  81778. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81779. /**
  81780. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81781. * Check if is non uniform within a certain amount of decimal places to account for this
  81782. * @param epsilon the amount the values can differ
  81783. * @returns if the the vector is non uniform to a certain number of decimal places
  81784. */
  81785. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81786. /**
  81787. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81788. */
  81789. get isNonUniform(): boolean;
  81790. /**
  81791. * Gets a new Vector3 from current Vector3 floored values
  81792. * @returns a new Vector3
  81793. */
  81794. floor(): Vector3;
  81795. /**
  81796. * Gets a new Vector3 from current Vector3 floored values
  81797. * @returns a new Vector3
  81798. */
  81799. fract(): Vector3;
  81800. /**
  81801. * Gets the length of the Vector3
  81802. * @returns the length of the Vector3
  81803. */
  81804. length(): number;
  81805. /**
  81806. * Gets the squared length of the Vector3
  81807. * @returns squared length of the Vector3
  81808. */
  81809. lengthSquared(): number;
  81810. /**
  81811. * Normalize the current Vector3.
  81812. * Please note that this is an in place operation.
  81813. * @returns the current updated Vector3
  81814. */
  81815. normalize(): Vector3;
  81816. /**
  81817. * Reorders the x y z properties of the vector in place
  81818. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81819. * @returns the current updated vector
  81820. */
  81821. reorderInPlace(order: string): this;
  81822. /**
  81823. * Rotates the vector around 0,0,0 by a quaternion
  81824. * @param quaternion the rotation quaternion
  81825. * @param result vector to store the result
  81826. * @returns the resulting vector
  81827. */
  81828. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81829. /**
  81830. * Rotates a vector around a given point
  81831. * @param quaternion the rotation quaternion
  81832. * @param point the point to rotate around
  81833. * @param result vector to store the result
  81834. * @returns the resulting vector
  81835. */
  81836. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81837. /**
  81838. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81839. * The cross product is then orthogonal to both current and "other"
  81840. * @param other defines the right operand
  81841. * @returns the cross product
  81842. */
  81843. cross(other: Vector3): Vector3;
  81844. /**
  81845. * Normalize the current Vector3 with the given input length.
  81846. * Please note that this is an in place operation.
  81847. * @param len the length of the vector
  81848. * @returns the current updated Vector3
  81849. */
  81850. normalizeFromLength(len: number): Vector3;
  81851. /**
  81852. * Normalize the current Vector3 to a new vector
  81853. * @returns the new Vector3
  81854. */
  81855. normalizeToNew(): Vector3;
  81856. /**
  81857. * Normalize the current Vector3 to the reference
  81858. * @param reference define the Vector3 to update
  81859. * @returns the updated Vector3
  81860. */
  81861. normalizeToRef(reference: Vector3): Vector3;
  81862. /**
  81863. * Creates a new Vector3 copied from the current Vector3
  81864. * @returns the new Vector3
  81865. */
  81866. clone(): Vector3;
  81867. /**
  81868. * Copies the given vector coordinates to the current Vector3 ones
  81869. * @param source defines the source Vector3
  81870. * @returns the current updated Vector3
  81871. */
  81872. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81873. /**
  81874. * Copies the given floats to the current Vector3 coordinates
  81875. * @param x defines the x coordinate of the operand
  81876. * @param y defines the y coordinate of the operand
  81877. * @param z defines the z coordinate of the operand
  81878. * @returns the current updated Vector3
  81879. */
  81880. copyFromFloats(x: number, y: number, z: number): Vector3;
  81881. /**
  81882. * Copies the given floats to the current Vector3 coordinates
  81883. * @param x defines the x coordinate of the operand
  81884. * @param y defines the y coordinate of the operand
  81885. * @param z defines the z coordinate of the operand
  81886. * @returns the current updated Vector3
  81887. */
  81888. set(x: number, y: number, z: number): Vector3;
  81889. /**
  81890. * Copies the given float to the current Vector3 coordinates
  81891. * @param v defines the x, y and z coordinates of the operand
  81892. * @returns the current updated Vector3
  81893. */
  81894. setAll(v: number): Vector3;
  81895. /**
  81896. * Get the clip factor between two vectors
  81897. * @param vector0 defines the first operand
  81898. * @param vector1 defines the second operand
  81899. * @param axis defines the axis to use
  81900. * @param size defines the size along the axis
  81901. * @returns the clip factor
  81902. */
  81903. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81904. /**
  81905. * Get angle between two vectors
  81906. * @param vector0 angle between vector0 and vector1
  81907. * @param vector1 angle between vector0 and vector1
  81908. * @param normal direction of the normal
  81909. * @return the angle between vector0 and vector1
  81910. */
  81911. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81912. /**
  81913. * Returns a new Vector3 set from the index "offset" of the given array
  81914. * @param array defines the source array
  81915. * @param offset defines the offset in the source array
  81916. * @returns the new Vector3
  81917. */
  81918. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81919. /**
  81920. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81921. * @param array defines the source array
  81922. * @param offset defines the offset in the source array
  81923. * @returns the new Vector3
  81924. * @deprecated Please use FromArray instead.
  81925. */
  81926. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81927. /**
  81928. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81929. * @param array defines the source array
  81930. * @param offset defines the offset in the source array
  81931. * @param result defines the Vector3 where to store the result
  81932. */
  81933. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81934. /**
  81935. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81936. * @param array defines the source array
  81937. * @param offset defines the offset in the source array
  81938. * @param result defines the Vector3 where to store the result
  81939. * @deprecated Please use FromArrayToRef instead.
  81940. */
  81941. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81942. /**
  81943. * Sets the given vector "result" with the given floats.
  81944. * @param x defines the x coordinate of the source
  81945. * @param y defines the y coordinate of the source
  81946. * @param z defines the z coordinate of the source
  81947. * @param result defines the Vector3 where to store the result
  81948. */
  81949. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81950. /**
  81951. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81952. * @returns a new empty Vector3
  81953. */
  81954. static Zero(): Vector3;
  81955. /**
  81956. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81957. * @returns a new unit Vector3
  81958. */
  81959. static One(): Vector3;
  81960. /**
  81961. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81962. * @returns a new up Vector3
  81963. */
  81964. static Up(): Vector3;
  81965. /**
  81966. * Gets a up Vector3 that must not be updated
  81967. */
  81968. static get UpReadOnly(): DeepImmutable<Vector3>;
  81969. /**
  81970. * Gets a zero Vector3 that must not be updated
  81971. */
  81972. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81973. /**
  81974. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81975. * @returns a new down Vector3
  81976. */
  81977. static Down(): Vector3;
  81978. /**
  81979. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81980. * @param rightHandedSystem is the scene right-handed (negative z)
  81981. * @returns a new forward Vector3
  81982. */
  81983. static Forward(rightHandedSystem?: boolean): Vector3;
  81984. /**
  81985. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81986. * @param rightHandedSystem is the scene right-handed (negative-z)
  81987. * @returns a new forward Vector3
  81988. */
  81989. static Backward(rightHandedSystem?: boolean): Vector3;
  81990. /**
  81991. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81992. * @returns a new right Vector3
  81993. */
  81994. static Right(): Vector3;
  81995. /**
  81996. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81997. * @returns a new left Vector3
  81998. */
  81999. static Left(): Vector3;
  82000. /**
  82001. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82002. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82003. * @param vector defines the Vector3 to transform
  82004. * @param transformation defines the transformation matrix
  82005. * @returns the transformed Vector3
  82006. */
  82007. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82008. /**
  82009. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82010. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82011. * @param vector defines the Vector3 to transform
  82012. * @param transformation defines the transformation matrix
  82013. * @param result defines the Vector3 where to store the result
  82014. */
  82015. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82016. /**
  82017. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82018. * This method computes tranformed coordinates only, not transformed direction vectors
  82019. * @param x define the x coordinate of the source vector
  82020. * @param y define the y coordinate of the source vector
  82021. * @param z define the z coordinate of the source vector
  82022. * @param transformation defines the transformation matrix
  82023. * @param result defines the Vector3 where to store the result
  82024. */
  82025. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82026. /**
  82027. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82028. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82029. * @param vector defines the Vector3 to transform
  82030. * @param transformation defines the transformation matrix
  82031. * @returns the new Vector3
  82032. */
  82033. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82034. /**
  82035. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82036. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82037. * @param vector defines the Vector3 to transform
  82038. * @param transformation defines the transformation matrix
  82039. * @param result defines the Vector3 where to store the result
  82040. */
  82041. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82042. /**
  82043. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82044. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82045. * @param x define the x coordinate of the source vector
  82046. * @param y define the y coordinate of the source vector
  82047. * @param z define the z coordinate of the source vector
  82048. * @param transformation defines the transformation matrix
  82049. * @param result defines the Vector3 where to store the result
  82050. */
  82051. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82052. /**
  82053. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82054. * @param value1 defines the first control point
  82055. * @param value2 defines the second control point
  82056. * @param value3 defines the third control point
  82057. * @param value4 defines the fourth control point
  82058. * @param amount defines the amount on the spline to use
  82059. * @returns the new Vector3
  82060. */
  82061. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82062. /**
  82063. * 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"
  82064. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82065. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82066. * @param value defines the current value
  82067. * @param min defines the lower range value
  82068. * @param max defines the upper range value
  82069. * @returns the new Vector3
  82070. */
  82071. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82072. /**
  82073. * 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"
  82074. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82075. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82076. * @param value defines the current value
  82077. * @param min defines the lower range value
  82078. * @param max defines the upper range value
  82079. * @param result defines the Vector3 where to store the result
  82080. */
  82081. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82082. /**
  82083. * Checks if a given vector is inside a specific range
  82084. * @param v defines the vector to test
  82085. * @param min defines the minimum range
  82086. * @param max defines the maximum range
  82087. */
  82088. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82089. /**
  82090. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82091. * @param value1 defines the first control point
  82092. * @param tangent1 defines the first tangent vector
  82093. * @param value2 defines the second control point
  82094. * @param tangent2 defines the second tangent vector
  82095. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82096. * @returns the new Vector3
  82097. */
  82098. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82099. /**
  82100. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82101. * @param start defines the start value
  82102. * @param end defines the end value
  82103. * @param amount max defines amount between both (between 0 and 1)
  82104. * @returns the new Vector3
  82105. */
  82106. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82107. /**
  82108. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82109. * @param start defines the start value
  82110. * @param end defines the end value
  82111. * @param amount max defines amount between both (between 0 and 1)
  82112. * @param result defines the Vector3 where to store the result
  82113. */
  82114. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82115. /**
  82116. * Returns the dot product (float) between the vectors "left" and "right"
  82117. * @param left defines the left operand
  82118. * @param right defines the right operand
  82119. * @returns the dot product
  82120. */
  82121. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82122. /**
  82123. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82124. * The cross product is then orthogonal to both "left" and "right"
  82125. * @param left defines the left operand
  82126. * @param right defines the right operand
  82127. * @returns the cross product
  82128. */
  82129. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82130. /**
  82131. * Sets the given vector "result" with the cross product of "left" and "right"
  82132. * The cross product is then orthogonal to both "left" and "right"
  82133. * @param left defines the left operand
  82134. * @param right defines the right operand
  82135. * @param result defines the Vector3 where to store the result
  82136. */
  82137. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82138. /**
  82139. * Returns a new Vector3 as the normalization of the given vector
  82140. * @param vector defines the Vector3 to normalize
  82141. * @returns the new Vector3
  82142. */
  82143. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82144. /**
  82145. * Sets the given vector "result" with the normalization of the given first vector
  82146. * @param vector defines the Vector3 to normalize
  82147. * @param result defines the Vector3 where to store the result
  82148. */
  82149. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82150. /**
  82151. * Project a Vector3 onto screen space
  82152. * @param vector defines the Vector3 to project
  82153. * @param world defines the world matrix to use
  82154. * @param transform defines the transform (view x projection) matrix to use
  82155. * @param viewport defines the screen viewport to use
  82156. * @returns the new Vector3
  82157. */
  82158. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82159. /** @hidden */
  82160. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82161. /**
  82162. * Unproject from screen space to object space
  82163. * @param source defines the screen space Vector3 to use
  82164. * @param viewportWidth defines the current width of the viewport
  82165. * @param viewportHeight defines the current height of the viewport
  82166. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82167. * @param transform defines the transform (view x projection) matrix to use
  82168. * @returns the new Vector3
  82169. */
  82170. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82171. /**
  82172. * Unproject from screen space to object space
  82173. * @param source defines the screen space Vector3 to use
  82174. * @param viewportWidth defines the current width of the viewport
  82175. * @param viewportHeight defines the current height of the viewport
  82176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82177. * @param view defines the view matrix to use
  82178. * @param projection defines the projection matrix to use
  82179. * @returns the new Vector3
  82180. */
  82181. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82182. /**
  82183. * Unproject from screen space to object space
  82184. * @param source defines the screen space Vector3 to use
  82185. * @param viewportWidth defines the current width of the viewport
  82186. * @param viewportHeight defines the current height of the viewport
  82187. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82188. * @param view defines the view matrix to use
  82189. * @param projection defines the projection matrix to use
  82190. * @param result defines the Vector3 where to store the result
  82191. */
  82192. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82193. /**
  82194. * Unproject from screen space to object space
  82195. * @param sourceX defines the screen space x coordinate to use
  82196. * @param sourceY defines the screen space y coordinate to use
  82197. * @param sourceZ defines the screen space z coordinate to use
  82198. * @param viewportWidth defines the current width of the viewport
  82199. * @param viewportHeight defines the current height of the viewport
  82200. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82201. * @param view defines the view matrix to use
  82202. * @param projection defines the projection matrix to use
  82203. * @param result defines the Vector3 where to store the result
  82204. */
  82205. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82206. /**
  82207. * Gets the minimal coordinate values between two Vector3
  82208. * @param left defines the first operand
  82209. * @param right defines the second operand
  82210. * @returns the new Vector3
  82211. */
  82212. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82213. /**
  82214. * Gets the maximal coordinate values between two Vector3
  82215. * @param left defines the first operand
  82216. * @param right defines the second operand
  82217. * @returns the new Vector3
  82218. */
  82219. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82220. /**
  82221. * Returns the distance between the vectors "value1" and "value2"
  82222. * @param value1 defines the first operand
  82223. * @param value2 defines the second operand
  82224. * @returns the distance
  82225. */
  82226. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82227. /**
  82228. * Returns the squared distance between the vectors "value1" and "value2"
  82229. * @param value1 defines the first operand
  82230. * @param value2 defines the second operand
  82231. * @returns the squared distance
  82232. */
  82233. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82234. /**
  82235. * Returns a new Vector3 located at the center between "value1" and "value2"
  82236. * @param value1 defines the first operand
  82237. * @param value2 defines the second operand
  82238. * @returns the new Vector3
  82239. */
  82240. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82241. /**
  82242. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82243. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82244. * to something in order to rotate it from its local system to the given target system
  82245. * Note: axis1, axis2 and axis3 are normalized during this operation
  82246. * @param axis1 defines the first axis
  82247. * @param axis2 defines the second axis
  82248. * @param axis3 defines the third axis
  82249. * @returns a new Vector3
  82250. */
  82251. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82252. /**
  82253. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82254. * @param axis1 defines the first axis
  82255. * @param axis2 defines the second axis
  82256. * @param axis3 defines the third axis
  82257. * @param ref defines the Vector3 where to store the result
  82258. */
  82259. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82260. }
  82261. /**
  82262. * Vector4 class created for EulerAngle class conversion to Quaternion
  82263. */
  82264. export class Vector4 {
  82265. /** x value of the vector */
  82266. x: number;
  82267. /** y value of the vector */
  82268. y: number;
  82269. /** z value of the vector */
  82270. z: number;
  82271. /** w value of the vector */
  82272. w: number;
  82273. /**
  82274. * Creates a Vector4 object from the given floats.
  82275. * @param x x value of the vector
  82276. * @param y y value of the vector
  82277. * @param z z value of the vector
  82278. * @param w w value of the vector
  82279. */
  82280. constructor(
  82281. /** x value of the vector */
  82282. x: number,
  82283. /** y value of the vector */
  82284. y: number,
  82285. /** z value of the vector */
  82286. z: number,
  82287. /** w value of the vector */
  82288. w: number);
  82289. /**
  82290. * Returns the string with the Vector4 coordinates.
  82291. * @returns a string containing all the vector values
  82292. */
  82293. toString(): string;
  82294. /**
  82295. * Returns the string "Vector4".
  82296. * @returns "Vector4"
  82297. */
  82298. getClassName(): string;
  82299. /**
  82300. * Returns the Vector4 hash code.
  82301. * @returns a unique hash code
  82302. */
  82303. getHashCode(): number;
  82304. /**
  82305. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82306. * @returns the resulting array
  82307. */
  82308. asArray(): number[];
  82309. /**
  82310. * Populates the given array from the given index with the Vector4 coordinates.
  82311. * @param array array to populate
  82312. * @param index index of the array to start at (default: 0)
  82313. * @returns the Vector4.
  82314. */
  82315. toArray(array: FloatArray, index?: number): Vector4;
  82316. /**
  82317. * Update the current vector from an array
  82318. * @param array defines the destination array
  82319. * @param index defines the offset in the destination array
  82320. * @returns the current Vector3
  82321. */
  82322. fromArray(array: FloatArray, index?: number): Vector4;
  82323. /**
  82324. * Adds the given vector to the current Vector4.
  82325. * @param otherVector the vector to add
  82326. * @returns the updated Vector4.
  82327. */
  82328. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82329. /**
  82330. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82331. * @param otherVector the vector to add
  82332. * @returns the resulting vector
  82333. */
  82334. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82335. /**
  82336. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82337. * @param otherVector the vector to add
  82338. * @param result the vector to store the result
  82339. * @returns the current Vector4.
  82340. */
  82341. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82342. /**
  82343. * Subtract in place the given vector from the current Vector4.
  82344. * @param otherVector the vector to subtract
  82345. * @returns the updated Vector4.
  82346. */
  82347. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82348. /**
  82349. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82350. * @param otherVector the vector to add
  82351. * @returns the new vector with the result
  82352. */
  82353. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82354. /**
  82355. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82356. * @param otherVector the vector to subtract
  82357. * @param result the vector to store the result
  82358. * @returns the current Vector4.
  82359. */
  82360. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82361. /**
  82362. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82363. */
  82364. /**
  82365. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82366. * @param x value to subtract
  82367. * @param y value to subtract
  82368. * @param z value to subtract
  82369. * @param w value to subtract
  82370. * @returns new vector containing the result
  82371. */
  82372. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82373. /**
  82374. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82375. * @param x value to subtract
  82376. * @param y value to subtract
  82377. * @param z value to subtract
  82378. * @param w value to subtract
  82379. * @param result the vector to store the result in
  82380. * @returns the current Vector4.
  82381. */
  82382. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82383. /**
  82384. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82385. * @returns a new vector with the negated values
  82386. */
  82387. negate(): Vector4;
  82388. /**
  82389. * Negate this vector in place
  82390. * @returns this
  82391. */
  82392. negateInPlace(): Vector4;
  82393. /**
  82394. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82395. * @param result defines the Vector3 object where to store the result
  82396. * @returns the current Vector4
  82397. */
  82398. negateToRef(result: Vector4): Vector4;
  82399. /**
  82400. * Multiplies the current Vector4 coordinates by scale (float).
  82401. * @param scale the number to scale with
  82402. * @returns the updated Vector4.
  82403. */
  82404. scaleInPlace(scale: number): Vector4;
  82405. /**
  82406. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82407. * @param scale the number to scale with
  82408. * @returns a new vector with the result
  82409. */
  82410. scale(scale: number): Vector4;
  82411. /**
  82412. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82413. * @param scale the number to scale with
  82414. * @param result a vector to store the result in
  82415. * @returns the current Vector4.
  82416. */
  82417. scaleToRef(scale: number, result: Vector4): Vector4;
  82418. /**
  82419. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82420. * @param scale defines the scale factor
  82421. * @param result defines the Vector4 object where to store the result
  82422. * @returns the unmodified current Vector4
  82423. */
  82424. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82425. /**
  82426. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82427. * @param otherVector the vector to compare against
  82428. * @returns true if they are equal
  82429. */
  82430. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82431. /**
  82432. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82433. * @param otherVector vector to compare against
  82434. * @param epsilon (Default: very small number)
  82435. * @returns true if they are equal
  82436. */
  82437. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82438. /**
  82439. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82440. * @param x x value to compare against
  82441. * @param y y value to compare against
  82442. * @param z z value to compare against
  82443. * @param w w value to compare against
  82444. * @returns true if equal
  82445. */
  82446. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82447. /**
  82448. * Multiplies in place the current Vector4 by the given one.
  82449. * @param otherVector vector to multiple with
  82450. * @returns the updated Vector4.
  82451. */
  82452. multiplyInPlace(otherVector: Vector4): Vector4;
  82453. /**
  82454. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82455. * @param otherVector vector to multiple with
  82456. * @returns resulting new vector
  82457. */
  82458. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82459. /**
  82460. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82461. * @param otherVector vector to multiple with
  82462. * @param result vector to store the result
  82463. * @returns the current Vector4.
  82464. */
  82465. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82466. /**
  82467. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82468. * @param x x value multiply with
  82469. * @param y y value multiply with
  82470. * @param z z value multiply with
  82471. * @param w w value multiply with
  82472. * @returns resulting new vector
  82473. */
  82474. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82475. /**
  82476. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82477. * @param otherVector vector to devide with
  82478. * @returns resulting new vector
  82479. */
  82480. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82481. /**
  82482. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82483. * @param otherVector vector to devide with
  82484. * @param result vector to store the result
  82485. * @returns the current Vector4.
  82486. */
  82487. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82488. /**
  82489. * Divides the current Vector3 coordinates by the given ones.
  82490. * @param otherVector vector to devide with
  82491. * @returns the updated Vector3.
  82492. */
  82493. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82494. /**
  82495. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82496. * @param other defines the second operand
  82497. * @returns the current updated Vector4
  82498. */
  82499. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82500. /**
  82501. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82502. * @param other defines the second operand
  82503. * @returns the current updated Vector4
  82504. */
  82505. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82506. /**
  82507. * Gets a new Vector4 from current Vector4 floored values
  82508. * @returns a new Vector4
  82509. */
  82510. floor(): Vector4;
  82511. /**
  82512. * Gets a new Vector4 from current Vector3 floored values
  82513. * @returns a new Vector4
  82514. */
  82515. fract(): Vector4;
  82516. /**
  82517. * Returns the Vector4 length (float).
  82518. * @returns the length
  82519. */
  82520. length(): number;
  82521. /**
  82522. * Returns the Vector4 squared length (float).
  82523. * @returns the length squared
  82524. */
  82525. lengthSquared(): number;
  82526. /**
  82527. * Normalizes in place the Vector4.
  82528. * @returns the updated Vector4.
  82529. */
  82530. normalize(): Vector4;
  82531. /**
  82532. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82533. * @returns this converted to a new vector3
  82534. */
  82535. toVector3(): Vector3;
  82536. /**
  82537. * Returns a new Vector4 copied from the current one.
  82538. * @returns the new cloned vector
  82539. */
  82540. clone(): Vector4;
  82541. /**
  82542. * Updates the current Vector4 with the given one coordinates.
  82543. * @param source the source vector to copy from
  82544. * @returns the updated Vector4.
  82545. */
  82546. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82547. /**
  82548. * Updates the current Vector4 coordinates with the given floats.
  82549. * @param x float to copy from
  82550. * @param y float to copy from
  82551. * @param z float to copy from
  82552. * @param w float to copy from
  82553. * @returns the updated Vector4.
  82554. */
  82555. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82556. /**
  82557. * Updates the current Vector4 coordinates with the given floats.
  82558. * @param x float to set from
  82559. * @param y float to set from
  82560. * @param z float to set from
  82561. * @param w float to set from
  82562. * @returns the updated Vector4.
  82563. */
  82564. set(x: number, y: number, z: number, w: number): Vector4;
  82565. /**
  82566. * Copies the given float to the current Vector3 coordinates
  82567. * @param v defines the x, y, z and w coordinates of the operand
  82568. * @returns the current updated Vector3
  82569. */
  82570. setAll(v: number): Vector4;
  82571. /**
  82572. * Returns a new Vector4 set from the starting index of the given array.
  82573. * @param array the array to pull values from
  82574. * @param offset the offset into the array to start at
  82575. * @returns the new vector
  82576. */
  82577. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82578. /**
  82579. * Updates the given vector "result" from the starting index of the given array.
  82580. * @param array the array to pull values from
  82581. * @param offset the offset into the array to start at
  82582. * @param result the vector to store the result in
  82583. */
  82584. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82585. /**
  82586. * Updates the given vector "result" from the starting index of the given Float32Array.
  82587. * @param array the array to pull values from
  82588. * @param offset the offset into the array to start at
  82589. * @param result the vector to store the result in
  82590. */
  82591. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82592. /**
  82593. * Updates the given vector "result" coordinates from the given floats.
  82594. * @param x float to set from
  82595. * @param y float to set from
  82596. * @param z float to set from
  82597. * @param w float to set from
  82598. * @param result the vector to the floats in
  82599. */
  82600. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82601. /**
  82602. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82603. * @returns the new vector
  82604. */
  82605. static Zero(): Vector4;
  82606. /**
  82607. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82608. * @returns the new vector
  82609. */
  82610. static One(): Vector4;
  82611. /**
  82612. * Returns a new normalized Vector4 from the given one.
  82613. * @param vector the vector to normalize
  82614. * @returns the vector
  82615. */
  82616. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82617. /**
  82618. * Updates the given vector "result" from the normalization of the given one.
  82619. * @param vector the vector to normalize
  82620. * @param result the vector to store the result in
  82621. */
  82622. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82623. /**
  82624. * Returns a vector with the minimum values from the left and right vectors
  82625. * @param left left vector to minimize
  82626. * @param right right vector to minimize
  82627. * @returns a new vector with the minimum of the left and right vector values
  82628. */
  82629. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82630. /**
  82631. * Returns a vector with the maximum values from the left and right vectors
  82632. * @param left left vector to maximize
  82633. * @param right right vector to maximize
  82634. * @returns a new vector with the maximum of the left and right vector values
  82635. */
  82636. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82637. /**
  82638. * Returns the distance (float) between the vectors "value1" and "value2".
  82639. * @param value1 value to calulate the distance between
  82640. * @param value2 value to calulate the distance between
  82641. * @return the distance between the two vectors
  82642. */
  82643. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82644. /**
  82645. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82646. * @param value1 value to calulate the distance between
  82647. * @param value2 value to calulate the distance between
  82648. * @return the distance between the two vectors squared
  82649. */
  82650. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82651. /**
  82652. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82653. * @param value1 value to calulate the center between
  82654. * @param value2 value to calulate the center between
  82655. * @return the center between the two vectors
  82656. */
  82657. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82658. /**
  82659. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82660. * This methods computes transformed normalized direction vectors only.
  82661. * @param vector the vector to transform
  82662. * @param transformation the transformation matrix to apply
  82663. * @returns the new vector
  82664. */
  82665. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82666. /**
  82667. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82668. * This methods computes transformed normalized direction vectors only.
  82669. * @param vector the vector to transform
  82670. * @param transformation the transformation matrix to apply
  82671. * @param result the vector to store the result in
  82672. */
  82673. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82674. /**
  82675. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82676. * This methods computes transformed normalized direction vectors only.
  82677. * @param x value to transform
  82678. * @param y value to transform
  82679. * @param z value to transform
  82680. * @param w value to transform
  82681. * @param transformation the transformation matrix to apply
  82682. * @param result the vector to store the results in
  82683. */
  82684. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82685. /**
  82686. * Creates a new Vector4 from a Vector3
  82687. * @param source defines the source data
  82688. * @param w defines the 4th component (default is 0)
  82689. * @returns a new Vector4
  82690. */
  82691. static FromVector3(source: Vector3, w?: number): Vector4;
  82692. }
  82693. /**
  82694. * Class used to store quaternion data
  82695. * @see https://en.wikipedia.org/wiki/Quaternion
  82696. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82697. */
  82698. export class Quaternion {
  82699. /** @hidden */
  82700. _x: number;
  82701. /** @hidden */
  82702. _y: number;
  82703. /** @hidden */
  82704. _z: number;
  82705. /** @hidden */
  82706. _w: number;
  82707. /** @hidden */
  82708. _isDirty: boolean;
  82709. /** Gets or sets the x coordinate */
  82710. get x(): number;
  82711. set x(value: number);
  82712. /** Gets or sets the y coordinate */
  82713. get y(): number;
  82714. set y(value: number);
  82715. /** Gets or sets the z coordinate */
  82716. get z(): number;
  82717. set z(value: number);
  82718. /** Gets or sets the w coordinate */
  82719. get w(): number;
  82720. set w(value: number);
  82721. /**
  82722. * Creates a new Quaternion from the given floats
  82723. * @param x defines the first component (0 by default)
  82724. * @param y defines the second component (0 by default)
  82725. * @param z defines the third component (0 by default)
  82726. * @param w defines the fourth component (1.0 by default)
  82727. */
  82728. constructor(x?: number, y?: number, z?: number, w?: number);
  82729. /**
  82730. * Gets a string representation for the current quaternion
  82731. * @returns a string with the Quaternion coordinates
  82732. */
  82733. toString(): string;
  82734. /**
  82735. * Gets the class name of the quaternion
  82736. * @returns the string "Quaternion"
  82737. */
  82738. getClassName(): string;
  82739. /**
  82740. * Gets a hash code for this quaternion
  82741. * @returns the quaternion hash code
  82742. */
  82743. getHashCode(): number;
  82744. /**
  82745. * Copy the quaternion to an array
  82746. * @returns a new array populated with 4 elements from the quaternion coordinates
  82747. */
  82748. asArray(): number[];
  82749. /**
  82750. * Check if two quaternions are equals
  82751. * @param otherQuaternion defines the second operand
  82752. * @return true if the current quaternion and the given one coordinates are strictly equals
  82753. */
  82754. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82755. /**
  82756. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82757. * @param otherQuaternion defines the other quaternion
  82758. * @param epsilon defines the minimal distance to consider equality
  82759. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82760. */
  82761. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82762. /**
  82763. * Clone the current quaternion
  82764. * @returns a new quaternion copied from the current one
  82765. */
  82766. clone(): Quaternion;
  82767. /**
  82768. * Copy a quaternion to the current one
  82769. * @param other defines the other quaternion
  82770. * @returns the updated current quaternion
  82771. */
  82772. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82773. /**
  82774. * Updates the current quaternion with the given float coordinates
  82775. * @param x defines the x coordinate
  82776. * @param y defines the y coordinate
  82777. * @param z defines the z coordinate
  82778. * @param w defines the w coordinate
  82779. * @returns the updated current quaternion
  82780. */
  82781. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82782. /**
  82783. * Updates the current quaternion from the given float coordinates
  82784. * @param x defines the x coordinate
  82785. * @param y defines the y coordinate
  82786. * @param z defines the z coordinate
  82787. * @param w defines the w coordinate
  82788. * @returns the updated current quaternion
  82789. */
  82790. set(x: number, y: number, z: number, w: number): Quaternion;
  82791. /**
  82792. * Adds two quaternions
  82793. * @param other defines the second operand
  82794. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82795. */
  82796. add(other: DeepImmutable<Quaternion>): Quaternion;
  82797. /**
  82798. * Add a quaternion to the current one
  82799. * @param other defines the quaternion to add
  82800. * @returns the current quaternion
  82801. */
  82802. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82803. /**
  82804. * Subtract two quaternions
  82805. * @param other defines the second operand
  82806. * @returns a new quaternion as the subtraction result of the given one from the current one
  82807. */
  82808. subtract(other: Quaternion): Quaternion;
  82809. /**
  82810. * Multiplies the current quaternion by a scale factor
  82811. * @param value defines the scale factor
  82812. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82813. */
  82814. scale(value: number): Quaternion;
  82815. /**
  82816. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82817. * @param scale defines the scale factor
  82818. * @param result defines the Quaternion object where to store the result
  82819. * @returns the unmodified current quaternion
  82820. */
  82821. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82822. /**
  82823. * Multiplies in place the current quaternion by a scale factor
  82824. * @param value defines the scale factor
  82825. * @returns the current modified quaternion
  82826. */
  82827. scaleInPlace(value: number): Quaternion;
  82828. /**
  82829. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82830. * @param scale defines the scale factor
  82831. * @param result defines the Quaternion object where to store the result
  82832. * @returns the unmodified current quaternion
  82833. */
  82834. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82835. /**
  82836. * Multiplies two quaternions
  82837. * @param q1 defines the second operand
  82838. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82839. */
  82840. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82841. /**
  82842. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82843. * @param q1 defines the second operand
  82844. * @param result defines the target quaternion
  82845. * @returns the current quaternion
  82846. */
  82847. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82848. /**
  82849. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82850. * @param q1 defines the second operand
  82851. * @returns the currentupdated quaternion
  82852. */
  82853. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82854. /**
  82855. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82856. * @param ref defines the target quaternion
  82857. * @returns the current quaternion
  82858. */
  82859. conjugateToRef(ref: Quaternion): Quaternion;
  82860. /**
  82861. * Conjugates in place (1-q) the current quaternion
  82862. * @returns the current updated quaternion
  82863. */
  82864. conjugateInPlace(): Quaternion;
  82865. /**
  82866. * Conjugates in place (1-q) the current quaternion
  82867. * @returns a new quaternion
  82868. */
  82869. conjugate(): Quaternion;
  82870. /**
  82871. * Gets length of current quaternion
  82872. * @returns the quaternion length (float)
  82873. */
  82874. length(): number;
  82875. /**
  82876. * Normalize in place the current quaternion
  82877. * @returns the current updated quaternion
  82878. */
  82879. normalize(): Quaternion;
  82880. /**
  82881. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82882. * @param order is a reserved parameter and is ignore for now
  82883. * @returns a new Vector3 containing the Euler angles
  82884. */
  82885. toEulerAngles(order?: string): Vector3;
  82886. /**
  82887. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82888. * @param result defines the vector which will be filled with the Euler angles
  82889. * @param order is a reserved parameter and is ignore for now
  82890. * @returns the current unchanged quaternion
  82891. */
  82892. toEulerAnglesToRef(result: Vector3): Quaternion;
  82893. /**
  82894. * Updates the given rotation matrix with the current quaternion values
  82895. * @param result defines the target matrix
  82896. * @returns the current unchanged quaternion
  82897. */
  82898. toRotationMatrix(result: Matrix): Quaternion;
  82899. /**
  82900. * Updates the current quaternion from the given rotation matrix values
  82901. * @param matrix defines the source matrix
  82902. * @returns the current updated quaternion
  82903. */
  82904. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82905. /**
  82906. * Creates a new quaternion from a rotation matrix
  82907. * @param matrix defines the source matrix
  82908. * @returns a new quaternion created from the given rotation matrix values
  82909. */
  82910. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82911. /**
  82912. * Updates the given quaternion with the given rotation matrix values
  82913. * @param matrix defines the source matrix
  82914. * @param result defines the target quaternion
  82915. */
  82916. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82917. /**
  82918. * Returns the dot product (float) between the quaternions "left" and "right"
  82919. * @param left defines the left operand
  82920. * @param right defines the right operand
  82921. * @returns the dot product
  82922. */
  82923. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82924. /**
  82925. * Checks if the two quaternions are close to each other
  82926. * @param quat0 defines the first quaternion to check
  82927. * @param quat1 defines the second quaternion to check
  82928. * @returns true if the two quaternions are close to each other
  82929. */
  82930. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82931. /**
  82932. * Creates an empty quaternion
  82933. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82934. */
  82935. static Zero(): Quaternion;
  82936. /**
  82937. * Inverse a given quaternion
  82938. * @param q defines the source quaternion
  82939. * @returns a new quaternion as the inverted current quaternion
  82940. */
  82941. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82942. /**
  82943. * Inverse a given quaternion
  82944. * @param q defines the source quaternion
  82945. * @param result the quaternion the result will be stored in
  82946. * @returns the result quaternion
  82947. */
  82948. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82949. /**
  82950. * Creates an identity quaternion
  82951. * @returns the identity quaternion
  82952. */
  82953. static Identity(): Quaternion;
  82954. /**
  82955. * Gets a boolean indicating if the given quaternion is identity
  82956. * @param quaternion defines the quaternion to check
  82957. * @returns true if the quaternion is identity
  82958. */
  82959. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82960. /**
  82961. * Creates a quaternion from a rotation around an axis
  82962. * @param axis defines the axis to use
  82963. * @param angle defines the angle to use
  82964. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82965. */
  82966. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82967. /**
  82968. * Creates a rotation around an axis and stores it into the given quaternion
  82969. * @param axis defines the axis to use
  82970. * @param angle defines the angle to use
  82971. * @param result defines the target quaternion
  82972. * @returns the target quaternion
  82973. */
  82974. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82975. /**
  82976. * Creates a new quaternion from data stored into an array
  82977. * @param array defines the data source
  82978. * @param offset defines the offset in the source array where the data starts
  82979. * @returns a new quaternion
  82980. */
  82981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82982. /**
  82983. * Updates the given quaternion "result" from the starting index of the given array.
  82984. * @param array the array to pull values from
  82985. * @param offset the offset into the array to start at
  82986. * @param result the quaternion to store the result in
  82987. */
  82988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82989. /**
  82990. * Create a quaternion from Euler rotation angles
  82991. * @param x Pitch
  82992. * @param y Yaw
  82993. * @param z Roll
  82994. * @returns the new Quaternion
  82995. */
  82996. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82997. /**
  82998. * Updates a quaternion from Euler rotation angles
  82999. * @param x Pitch
  83000. * @param y Yaw
  83001. * @param z Roll
  83002. * @param result the quaternion to store the result
  83003. * @returns the updated quaternion
  83004. */
  83005. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83006. /**
  83007. * Create a quaternion from Euler rotation vector
  83008. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83009. * @returns the new Quaternion
  83010. */
  83011. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83012. /**
  83013. * Updates a quaternion from Euler rotation vector
  83014. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83015. * @param result the quaternion to store the result
  83016. * @returns the updated quaternion
  83017. */
  83018. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83019. /**
  83020. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83021. * @param yaw defines the rotation around Y axis
  83022. * @param pitch defines the rotation around X axis
  83023. * @param roll defines the rotation around Z axis
  83024. * @returns the new quaternion
  83025. */
  83026. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83027. /**
  83028. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83029. * @param yaw defines the rotation around Y axis
  83030. * @param pitch defines the rotation around X axis
  83031. * @param roll defines the rotation around Z axis
  83032. * @param result defines the target quaternion
  83033. */
  83034. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83035. /**
  83036. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83037. * @param alpha defines the rotation around first axis
  83038. * @param beta defines the rotation around second axis
  83039. * @param gamma defines the rotation around third axis
  83040. * @returns the new quaternion
  83041. */
  83042. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83043. /**
  83044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83045. * @param alpha defines the rotation around first axis
  83046. * @param beta defines the rotation around second axis
  83047. * @param gamma defines the rotation around third axis
  83048. * @param result defines the target quaternion
  83049. */
  83050. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83051. /**
  83052. * 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)
  83053. * @param axis1 defines the first axis
  83054. * @param axis2 defines the second axis
  83055. * @param axis3 defines the third axis
  83056. * @returns the new quaternion
  83057. */
  83058. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83059. /**
  83060. * 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
  83061. * @param axis1 defines the first axis
  83062. * @param axis2 defines the second axis
  83063. * @param axis3 defines the third axis
  83064. * @param ref defines the target quaternion
  83065. */
  83066. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83067. /**
  83068. * Interpolates between two quaternions
  83069. * @param left defines first quaternion
  83070. * @param right defines second quaternion
  83071. * @param amount defines the gradient to use
  83072. * @returns the new interpolated quaternion
  83073. */
  83074. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83075. /**
  83076. * Interpolates between two quaternions and stores it into a target quaternion
  83077. * @param left defines first quaternion
  83078. * @param right defines second quaternion
  83079. * @param amount defines the gradient to use
  83080. * @param result defines the target quaternion
  83081. */
  83082. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83083. /**
  83084. * Interpolate between two quaternions using Hermite interpolation
  83085. * @param value1 defines first quaternion
  83086. * @param tangent1 defines the incoming tangent
  83087. * @param value2 defines second quaternion
  83088. * @param tangent2 defines the outgoing tangent
  83089. * @param amount defines the target quaternion
  83090. * @returns the new interpolated quaternion
  83091. */
  83092. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83093. }
  83094. /**
  83095. * Class used to store matrix data (4x4)
  83096. */
  83097. export class Matrix {
  83098. /**
  83099. * Gets the precision of matrix computations
  83100. */
  83101. static get Use64Bits(): boolean;
  83102. private static _updateFlagSeed;
  83103. private static _identityReadOnly;
  83104. private _isIdentity;
  83105. private _isIdentityDirty;
  83106. private _isIdentity3x2;
  83107. private _isIdentity3x2Dirty;
  83108. /**
  83109. * Gets the update flag of the matrix which is an unique number for the matrix.
  83110. * It will be incremented every time the matrix data change.
  83111. * You can use it to speed the comparison between two versions of the same matrix.
  83112. */
  83113. updateFlag: number;
  83114. private readonly _m;
  83115. /**
  83116. * Gets the internal data of the matrix
  83117. */
  83118. get m(): DeepImmutable<Float32Array | Array<number>>;
  83119. /** @hidden */
  83120. _markAsUpdated(): void;
  83121. /** @hidden */
  83122. private _updateIdentityStatus;
  83123. /**
  83124. * Creates an empty matrix (filled with zeros)
  83125. */
  83126. constructor();
  83127. /**
  83128. * Check if the current matrix is identity
  83129. * @returns true is the matrix is the identity matrix
  83130. */
  83131. isIdentity(): boolean;
  83132. /**
  83133. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83134. * @returns true is the matrix is the identity matrix
  83135. */
  83136. isIdentityAs3x2(): boolean;
  83137. /**
  83138. * Gets the determinant of the matrix
  83139. * @returns the matrix determinant
  83140. */
  83141. determinant(): number;
  83142. /**
  83143. * Returns the matrix as a Float32Array or Array<number>
  83144. * @returns the matrix underlying array
  83145. */
  83146. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83147. /**
  83148. * Returns the matrix as a Float32Array or Array<number>
  83149. * @returns the matrix underlying array.
  83150. */
  83151. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83152. /**
  83153. * Inverts the current matrix in place
  83154. * @returns the current inverted matrix
  83155. */
  83156. invert(): Matrix;
  83157. /**
  83158. * Sets all the matrix elements to zero
  83159. * @returns the current matrix
  83160. */
  83161. reset(): Matrix;
  83162. /**
  83163. * Adds the current matrix with a second one
  83164. * @param other defines the matrix to add
  83165. * @returns a new matrix as the addition of the current matrix and the given one
  83166. */
  83167. add(other: DeepImmutable<Matrix>): Matrix;
  83168. /**
  83169. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83170. * @param other defines the matrix to add
  83171. * @param result defines the target matrix
  83172. * @returns the current matrix
  83173. */
  83174. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83175. /**
  83176. * Adds in place the given matrix to the current matrix
  83177. * @param other defines the second operand
  83178. * @returns the current updated matrix
  83179. */
  83180. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83181. /**
  83182. * Sets the given matrix to the current inverted Matrix
  83183. * @param other defines the target matrix
  83184. * @returns the unmodified current matrix
  83185. */
  83186. invertToRef(other: Matrix): Matrix;
  83187. /**
  83188. * add a value at the specified position in the current Matrix
  83189. * @param index the index of the value within the matrix. between 0 and 15.
  83190. * @param value the value to be added
  83191. * @returns the current updated matrix
  83192. */
  83193. addAtIndex(index: number, value: number): Matrix;
  83194. /**
  83195. * mutiply the specified position in the current Matrix by a value
  83196. * @param index the index of the value within the matrix. between 0 and 15.
  83197. * @param value the value to be added
  83198. * @returns the current updated matrix
  83199. */
  83200. multiplyAtIndex(index: number, value: number): Matrix;
  83201. /**
  83202. * Inserts the translation vector (using 3 floats) in the current matrix
  83203. * @param x defines the 1st component of the translation
  83204. * @param y defines the 2nd component of the translation
  83205. * @param z defines the 3rd component of the translation
  83206. * @returns the current updated matrix
  83207. */
  83208. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83209. /**
  83210. * Adds the translation vector (using 3 floats) in the current matrix
  83211. * @param x defines the 1st component of the translation
  83212. * @param y defines the 2nd component of the translation
  83213. * @param z defines the 3rd component of the translation
  83214. * @returns the current updated matrix
  83215. */
  83216. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83217. /**
  83218. * Inserts the translation vector in the current matrix
  83219. * @param vector3 defines the translation to insert
  83220. * @returns the current updated matrix
  83221. */
  83222. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83223. /**
  83224. * Gets the translation value of the current matrix
  83225. * @returns a new Vector3 as the extracted translation from the matrix
  83226. */
  83227. getTranslation(): Vector3;
  83228. /**
  83229. * Fill a Vector3 with the extracted translation from the matrix
  83230. * @param result defines the Vector3 where to store the translation
  83231. * @returns the current matrix
  83232. */
  83233. getTranslationToRef(result: Vector3): Matrix;
  83234. /**
  83235. * Remove rotation and scaling part from the matrix
  83236. * @returns the updated matrix
  83237. */
  83238. removeRotationAndScaling(): Matrix;
  83239. /**
  83240. * Multiply two matrices
  83241. * @param other defines the second operand
  83242. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83243. */
  83244. multiply(other: DeepImmutable<Matrix>): Matrix;
  83245. /**
  83246. * Copy the current matrix from the given one
  83247. * @param other defines the source matrix
  83248. * @returns the current updated matrix
  83249. */
  83250. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83251. /**
  83252. * Populates the given array from the starting index with the current matrix values
  83253. * @param array defines the target array
  83254. * @param offset defines the offset in the target array where to start storing values
  83255. * @returns the current matrix
  83256. */
  83257. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83258. /**
  83259. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83260. * @param other defines the second operand
  83261. * @param result defines the matrix where to store the multiplication
  83262. * @returns the current matrix
  83263. */
  83264. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83265. /**
  83266. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83267. * @param other defines the second operand
  83268. * @param result defines the array where to store the multiplication
  83269. * @param offset defines the offset in the target array where to start storing values
  83270. * @returns the current matrix
  83271. */
  83272. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83273. /**
  83274. * Check equality between this matrix and a second one
  83275. * @param value defines the second matrix to compare
  83276. * @returns true is the current matrix and the given one values are strictly equal
  83277. */
  83278. equals(value: DeepImmutable<Matrix>): boolean;
  83279. /**
  83280. * Clone the current matrix
  83281. * @returns a new matrix from the current matrix
  83282. */
  83283. clone(): Matrix;
  83284. /**
  83285. * Returns the name of the current matrix class
  83286. * @returns the string "Matrix"
  83287. */
  83288. getClassName(): string;
  83289. /**
  83290. * Gets the hash code of the current matrix
  83291. * @returns the hash code
  83292. */
  83293. getHashCode(): number;
  83294. /**
  83295. * Decomposes the current Matrix into a translation, rotation and scaling components
  83296. * @param scale defines the scale vector3 given as a reference to update
  83297. * @param rotation defines the rotation quaternion given as a reference to update
  83298. * @param translation defines the translation vector3 given as a reference to update
  83299. * @returns true if operation was successful
  83300. */
  83301. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83302. /**
  83303. * Gets specific row of the matrix
  83304. * @param index defines the number of the row to get
  83305. * @returns the index-th row of the current matrix as a new Vector4
  83306. */
  83307. getRow(index: number): Nullable<Vector4>;
  83308. /**
  83309. * Sets the index-th row of the current matrix to the vector4 values
  83310. * @param index defines the number of the row to set
  83311. * @param row defines the target vector4
  83312. * @returns the updated current matrix
  83313. */
  83314. setRow(index: number, row: Vector4): Matrix;
  83315. /**
  83316. * Compute the transpose of the matrix
  83317. * @returns the new transposed matrix
  83318. */
  83319. transpose(): Matrix;
  83320. /**
  83321. * Compute the transpose of the matrix and store it in a given matrix
  83322. * @param result defines the target matrix
  83323. * @returns the current matrix
  83324. */
  83325. transposeToRef(result: Matrix): Matrix;
  83326. /**
  83327. * Sets the index-th row of the current matrix with the given 4 x float values
  83328. * @param index defines the row index
  83329. * @param x defines the x component to set
  83330. * @param y defines the y component to set
  83331. * @param z defines the z component to set
  83332. * @param w defines the w component to set
  83333. * @returns the updated current matrix
  83334. */
  83335. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83336. /**
  83337. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83338. * @param scale defines the scale factor
  83339. * @returns a new matrix
  83340. */
  83341. scale(scale: number): Matrix;
  83342. /**
  83343. * Scale the current matrix values by a factor to a given result matrix
  83344. * @param scale defines the scale factor
  83345. * @param result defines the matrix to store the result
  83346. * @returns the current matrix
  83347. */
  83348. scaleToRef(scale: number, result: Matrix): Matrix;
  83349. /**
  83350. * Scale the current matrix values by a factor and add the result to a given matrix
  83351. * @param scale defines the scale factor
  83352. * @param result defines the Matrix to store the result
  83353. * @returns the current matrix
  83354. */
  83355. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83356. /**
  83357. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83358. * @param ref matrix to store the result
  83359. */
  83360. toNormalMatrix(ref: Matrix): void;
  83361. /**
  83362. * Gets only rotation part of the current matrix
  83363. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83364. */
  83365. getRotationMatrix(): Matrix;
  83366. /**
  83367. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83368. * @param result defines the target matrix to store data to
  83369. * @returns the current matrix
  83370. */
  83371. getRotationMatrixToRef(result: Matrix): Matrix;
  83372. /**
  83373. * Toggles model matrix from being right handed to left handed in place and vice versa
  83374. */
  83375. toggleModelMatrixHandInPlace(): void;
  83376. /**
  83377. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83378. */
  83379. toggleProjectionMatrixHandInPlace(): void;
  83380. /**
  83381. * Creates a matrix from an array
  83382. * @param array defines the source array
  83383. * @param offset defines an offset in the source array
  83384. * @returns a new Matrix set from the starting index of the given array
  83385. */
  83386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83387. /**
  83388. * Copy the content of an array into a given matrix
  83389. * @param array defines the source array
  83390. * @param offset defines an offset in the source array
  83391. * @param result defines the target matrix
  83392. */
  83393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83394. /**
  83395. * Stores an array into a matrix after having multiplied each component by a given factor
  83396. * @param array defines the source array
  83397. * @param offset defines the offset in the source array
  83398. * @param scale defines the scaling factor
  83399. * @param result defines the target matrix
  83400. */
  83401. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83402. /**
  83403. * Gets an identity matrix that must not be updated
  83404. */
  83405. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83406. /**
  83407. * Stores a list of values (16) inside a given matrix
  83408. * @param initialM11 defines 1st value of 1st row
  83409. * @param initialM12 defines 2nd value of 1st row
  83410. * @param initialM13 defines 3rd value of 1st row
  83411. * @param initialM14 defines 4th value of 1st row
  83412. * @param initialM21 defines 1st value of 2nd row
  83413. * @param initialM22 defines 2nd value of 2nd row
  83414. * @param initialM23 defines 3rd value of 2nd row
  83415. * @param initialM24 defines 4th value of 2nd row
  83416. * @param initialM31 defines 1st value of 3rd row
  83417. * @param initialM32 defines 2nd value of 3rd row
  83418. * @param initialM33 defines 3rd value of 3rd row
  83419. * @param initialM34 defines 4th value of 3rd row
  83420. * @param initialM41 defines 1st value of 4th row
  83421. * @param initialM42 defines 2nd value of 4th row
  83422. * @param initialM43 defines 3rd value of 4th row
  83423. * @param initialM44 defines 4th value of 4th row
  83424. * @param result defines the target matrix
  83425. */
  83426. 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;
  83427. /**
  83428. * Creates new matrix from a list of values (16)
  83429. * @param initialM11 defines 1st value of 1st row
  83430. * @param initialM12 defines 2nd value of 1st row
  83431. * @param initialM13 defines 3rd value of 1st row
  83432. * @param initialM14 defines 4th value of 1st row
  83433. * @param initialM21 defines 1st value of 2nd row
  83434. * @param initialM22 defines 2nd value of 2nd row
  83435. * @param initialM23 defines 3rd value of 2nd row
  83436. * @param initialM24 defines 4th value of 2nd row
  83437. * @param initialM31 defines 1st value of 3rd row
  83438. * @param initialM32 defines 2nd value of 3rd row
  83439. * @param initialM33 defines 3rd value of 3rd row
  83440. * @param initialM34 defines 4th value of 3rd row
  83441. * @param initialM41 defines 1st value of 4th row
  83442. * @param initialM42 defines 2nd value of 4th row
  83443. * @param initialM43 defines 3rd value of 4th row
  83444. * @param initialM44 defines 4th value of 4th row
  83445. * @returns the new matrix
  83446. */
  83447. 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;
  83448. /**
  83449. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83450. * @param scale defines the scale vector3
  83451. * @param rotation defines the rotation quaternion
  83452. * @param translation defines the translation vector3
  83453. * @returns a new matrix
  83454. */
  83455. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83456. /**
  83457. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83458. * @param scale defines the scale vector3
  83459. * @param rotation defines the rotation quaternion
  83460. * @param translation defines the translation vector3
  83461. * @param result defines the target matrix
  83462. */
  83463. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83464. /**
  83465. * Creates a new identity matrix
  83466. * @returns a new identity matrix
  83467. */
  83468. static Identity(): Matrix;
  83469. /**
  83470. * Creates a new identity matrix and stores the result in a given matrix
  83471. * @param result defines the target matrix
  83472. */
  83473. static IdentityToRef(result: Matrix): void;
  83474. /**
  83475. * Creates a new zero matrix
  83476. * @returns a new zero matrix
  83477. */
  83478. static Zero(): Matrix;
  83479. /**
  83480. * Creates a new rotation matrix for "angle" radians around the X axis
  83481. * @param angle defines the angle (in radians) to use
  83482. * @return the new matrix
  83483. */
  83484. static RotationX(angle: number): Matrix;
  83485. /**
  83486. * Creates a new matrix as the invert of a given matrix
  83487. * @param source defines the source matrix
  83488. * @returns the new matrix
  83489. */
  83490. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83491. /**
  83492. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83493. * @param angle defines the angle (in radians) to use
  83494. * @param result defines the target matrix
  83495. */
  83496. static RotationXToRef(angle: number, result: Matrix): void;
  83497. /**
  83498. * Creates a new rotation matrix for "angle" radians around the Y axis
  83499. * @param angle defines the angle (in radians) to use
  83500. * @return the new matrix
  83501. */
  83502. static RotationY(angle: number): Matrix;
  83503. /**
  83504. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83505. * @param angle defines the angle (in radians) to use
  83506. * @param result defines the target matrix
  83507. */
  83508. static RotationYToRef(angle: number, result: Matrix): void;
  83509. /**
  83510. * Creates a new rotation matrix for "angle" radians around the Z axis
  83511. * @param angle defines the angle (in radians) to use
  83512. * @return the new matrix
  83513. */
  83514. static RotationZ(angle: number): Matrix;
  83515. /**
  83516. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83517. * @param angle defines the angle (in radians) to use
  83518. * @param result defines the target matrix
  83519. */
  83520. static RotationZToRef(angle: number, result: Matrix): void;
  83521. /**
  83522. * Creates a new rotation matrix for "angle" radians around the given axis
  83523. * @param axis defines the axis to use
  83524. * @param angle defines the angle (in radians) to use
  83525. * @return the new matrix
  83526. */
  83527. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83528. /**
  83529. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83530. * @param axis defines the axis to use
  83531. * @param angle defines the angle (in radians) to use
  83532. * @param result defines the target matrix
  83533. */
  83534. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83535. /**
  83536. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83537. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83538. * @param from defines the vector to align
  83539. * @param to defines the vector to align to
  83540. * @param result defines the target matrix
  83541. */
  83542. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83543. /**
  83544. * Creates a rotation matrix
  83545. * @param yaw defines the yaw angle in radians (Y axis)
  83546. * @param pitch defines the pitch angle in radians (X axis)
  83547. * @param roll defines the roll angle in radians (Z axis)
  83548. * @returns the new rotation matrix
  83549. */
  83550. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83551. /**
  83552. * Creates a rotation matrix and stores it in a given matrix
  83553. * @param yaw defines the yaw angle in radians (Y axis)
  83554. * @param pitch defines the pitch angle in radians (X axis)
  83555. * @param roll defines the roll angle in radians (Z axis)
  83556. * @param result defines the target matrix
  83557. */
  83558. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83559. /**
  83560. * Creates a scaling matrix
  83561. * @param x defines the scale factor on X axis
  83562. * @param y defines the scale factor on Y axis
  83563. * @param z defines the scale factor on Z axis
  83564. * @returns the new matrix
  83565. */
  83566. static Scaling(x: number, y: number, z: number): Matrix;
  83567. /**
  83568. * Creates a scaling matrix and stores it in a given matrix
  83569. * @param x defines the scale factor on X axis
  83570. * @param y defines the scale factor on Y axis
  83571. * @param z defines the scale factor on Z axis
  83572. * @param result defines the target matrix
  83573. */
  83574. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83575. /**
  83576. * Creates a translation matrix
  83577. * @param x defines the translation on X axis
  83578. * @param y defines the translation on Y axis
  83579. * @param z defines the translationon Z axis
  83580. * @returns the new matrix
  83581. */
  83582. static Translation(x: number, y: number, z: number): Matrix;
  83583. /**
  83584. * Creates a translation matrix and stores it in a given matrix
  83585. * @param x defines the translation on X axis
  83586. * @param y defines the translation on Y axis
  83587. * @param z defines the translationon Z axis
  83588. * @param result defines the target matrix
  83589. */
  83590. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83591. /**
  83592. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83593. * @param startValue defines the start value
  83594. * @param endValue defines the end value
  83595. * @param gradient defines the gradient factor
  83596. * @returns the new matrix
  83597. */
  83598. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83599. /**
  83600. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83601. * @param startValue defines the start value
  83602. * @param endValue defines the end value
  83603. * @param gradient defines the gradient factor
  83604. * @param result defines the Matrix object where to store data
  83605. */
  83606. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83607. /**
  83608. * Builds a new matrix whose values are computed by:
  83609. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83610. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83611. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83612. * @param startValue defines the first matrix
  83613. * @param endValue defines the second matrix
  83614. * @param gradient defines the gradient between the two matrices
  83615. * @returns the new matrix
  83616. */
  83617. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83618. /**
  83619. * Update a matrix to values which are computed by:
  83620. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83621. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83622. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83623. * @param startValue defines the first matrix
  83624. * @param endValue defines the second matrix
  83625. * @param gradient defines the gradient between the two matrices
  83626. * @param result defines the target matrix
  83627. */
  83628. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83629. /**
  83630. * 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"
  83631. * This function works in left handed mode
  83632. * @param eye defines the final position of the entity
  83633. * @param target defines where the entity should look at
  83634. * @param up defines the up vector for the entity
  83635. * @returns the new matrix
  83636. */
  83637. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83638. /**
  83639. * 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".
  83640. * This function works in left handed mode
  83641. * @param eye defines the final position of the entity
  83642. * @param target defines where the entity should look at
  83643. * @param up defines the up vector for the entity
  83644. * @param result defines the target matrix
  83645. */
  83646. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83647. /**
  83648. * 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"
  83649. * This function works in right handed mode
  83650. * @param eye defines the final position of the entity
  83651. * @param target defines where the entity should look at
  83652. * @param up defines the up vector for the entity
  83653. * @returns the new matrix
  83654. */
  83655. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83656. /**
  83657. * 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".
  83658. * This function works in right handed mode
  83659. * @param eye defines the final position of the entity
  83660. * @param target defines where the entity should look at
  83661. * @param up defines the up vector for the entity
  83662. * @param result defines the target matrix
  83663. */
  83664. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83665. /**
  83666. * Create a left-handed orthographic projection matrix
  83667. * @param width defines the viewport width
  83668. * @param height defines the viewport height
  83669. * @param znear defines the near clip plane
  83670. * @param zfar defines the far clip plane
  83671. * @returns a new matrix as a left-handed orthographic projection matrix
  83672. */
  83673. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83674. /**
  83675. * Store a left-handed orthographic projection to a given matrix
  83676. * @param width defines the viewport width
  83677. * @param height defines the viewport height
  83678. * @param znear defines the near clip plane
  83679. * @param zfar defines the far clip plane
  83680. * @param result defines the target matrix
  83681. */
  83682. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83683. /**
  83684. * Create a left-handed orthographic projection matrix
  83685. * @param left defines the viewport left coordinate
  83686. * @param right defines the viewport right coordinate
  83687. * @param bottom defines the viewport bottom coordinate
  83688. * @param top defines the viewport top coordinate
  83689. * @param znear defines the near clip plane
  83690. * @param zfar defines the far clip plane
  83691. * @returns a new matrix as a left-handed orthographic projection matrix
  83692. */
  83693. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83694. /**
  83695. * Stores a left-handed orthographic projection into a given matrix
  83696. * @param left defines the viewport left coordinate
  83697. * @param right defines the viewport right coordinate
  83698. * @param bottom defines the viewport bottom coordinate
  83699. * @param top defines the viewport top coordinate
  83700. * @param znear defines the near clip plane
  83701. * @param zfar defines the far clip plane
  83702. * @param result defines the target matrix
  83703. */
  83704. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83705. /**
  83706. * Creates a right-handed orthographic projection matrix
  83707. * @param left defines the viewport left coordinate
  83708. * @param right defines the viewport right coordinate
  83709. * @param bottom defines the viewport bottom coordinate
  83710. * @param top defines the viewport top coordinate
  83711. * @param znear defines the near clip plane
  83712. * @param zfar defines the far clip plane
  83713. * @returns a new matrix as a right-handed orthographic projection matrix
  83714. */
  83715. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83716. /**
  83717. * Stores a right-handed orthographic projection into a given matrix
  83718. * @param left defines the viewport left coordinate
  83719. * @param right defines the viewport right coordinate
  83720. * @param bottom defines the viewport bottom coordinate
  83721. * @param top defines the viewport top coordinate
  83722. * @param znear defines the near clip plane
  83723. * @param zfar defines the far clip plane
  83724. * @param result defines the target matrix
  83725. */
  83726. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83727. /**
  83728. * Creates a left-handed perspective projection matrix
  83729. * @param width defines the viewport width
  83730. * @param height defines the viewport height
  83731. * @param znear defines the near clip plane
  83732. * @param zfar defines the far clip plane
  83733. * @returns a new matrix as a left-handed perspective projection matrix
  83734. */
  83735. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83736. /**
  83737. * Creates a left-handed perspective projection matrix
  83738. * @param fov defines the horizontal field of view
  83739. * @param aspect defines the aspect ratio
  83740. * @param znear defines the near clip plane
  83741. * @param zfar defines the far clip plane
  83742. * @returns a new matrix as a left-handed perspective projection matrix
  83743. */
  83744. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83745. /**
  83746. * Stores a left-handed perspective projection into a given matrix
  83747. * @param fov defines the horizontal field of view
  83748. * @param aspect defines the aspect ratio
  83749. * @param znear defines the near clip plane
  83750. * @param zfar defines the far clip plane
  83751. * @param result defines the target matrix
  83752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83753. */
  83754. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83755. /**
  83756. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83757. * @param fov defines the horizontal field of view
  83758. * @param aspect defines the aspect ratio
  83759. * @param znear defines the near clip plane
  83760. * @param zfar not used as infinity is used as far clip
  83761. * @param result defines the target matrix
  83762. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83763. */
  83764. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83765. /**
  83766. * Creates a right-handed perspective projection matrix
  83767. * @param fov defines the horizontal field of view
  83768. * @param aspect defines the aspect ratio
  83769. * @param znear defines the near clip plane
  83770. * @param zfar defines the far clip plane
  83771. * @returns a new matrix as a right-handed perspective projection matrix
  83772. */
  83773. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83774. /**
  83775. * Stores a right-handed perspective projection into a given matrix
  83776. * @param fov defines the horizontal field of view
  83777. * @param aspect defines the aspect ratio
  83778. * @param znear defines the near clip plane
  83779. * @param zfar defines the far clip plane
  83780. * @param result defines the target matrix
  83781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83782. */
  83783. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83784. /**
  83785. * Stores a right-handed perspective projection into a given matrix
  83786. * @param fov defines the horizontal field of view
  83787. * @param aspect defines the aspect ratio
  83788. * @param znear defines the near clip plane
  83789. * @param zfar not used as infinity is used as far clip
  83790. * @param result defines the target matrix
  83791. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83792. */
  83793. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83794. /**
  83795. * Stores a perspective projection for WebVR info a given matrix
  83796. * @param fov defines the field of view
  83797. * @param znear defines the near clip plane
  83798. * @param zfar defines the far clip plane
  83799. * @param result defines the target matrix
  83800. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83801. */
  83802. static PerspectiveFovWebVRToRef(fov: {
  83803. upDegrees: number;
  83804. downDegrees: number;
  83805. leftDegrees: number;
  83806. rightDegrees: number;
  83807. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83808. /**
  83809. * Computes a complete transformation matrix
  83810. * @param viewport defines the viewport to use
  83811. * @param world defines the world matrix
  83812. * @param view defines the view matrix
  83813. * @param projection defines the projection matrix
  83814. * @param zmin defines the near clip plane
  83815. * @param zmax defines the far clip plane
  83816. * @returns the transformation matrix
  83817. */
  83818. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83819. /**
  83820. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83821. * @param matrix defines the matrix to use
  83822. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83823. */
  83824. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83825. /**
  83826. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83827. * @param matrix defines the matrix to use
  83828. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83829. */
  83830. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83831. /**
  83832. * Compute the transpose of a given matrix
  83833. * @param matrix defines the matrix to transpose
  83834. * @returns the new matrix
  83835. */
  83836. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83837. /**
  83838. * Compute the transpose of a matrix and store it in a target matrix
  83839. * @param matrix defines the matrix to transpose
  83840. * @param result defines the target matrix
  83841. */
  83842. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83843. /**
  83844. * Computes a reflection matrix from a plane
  83845. * @param plane defines the reflection plane
  83846. * @returns a new matrix
  83847. */
  83848. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83849. /**
  83850. * Computes a reflection matrix from a plane
  83851. * @param plane defines the reflection plane
  83852. * @param result defines the target matrix
  83853. */
  83854. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83855. /**
  83856. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83857. * @param xaxis defines the value of the 1st axis
  83858. * @param yaxis defines the value of the 2nd axis
  83859. * @param zaxis defines the value of the 3rd axis
  83860. * @param result defines the target matrix
  83861. */
  83862. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83863. /**
  83864. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83865. * @param quat defines the quaternion to use
  83866. * @param result defines the target matrix
  83867. */
  83868. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83869. }
  83870. /**
  83871. * @hidden
  83872. */
  83873. export class TmpVectors {
  83874. static Vector2: Vector2[];
  83875. static Vector3: Vector3[];
  83876. static Vector4: Vector4[];
  83877. static Quaternion: Quaternion[];
  83878. static Matrix: Matrix[];
  83879. }
  83880. }
  83881. declare module BABYLON {
  83882. /**
  83883. * Defines potential orientation for back face culling
  83884. */
  83885. export enum Orientation {
  83886. /**
  83887. * Clockwise
  83888. */
  83889. CW = 0,
  83890. /** Counter clockwise */
  83891. CCW = 1
  83892. }
  83893. /** Class used to represent a Bezier curve */
  83894. export class BezierCurve {
  83895. /**
  83896. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83897. * @param t defines the time
  83898. * @param x1 defines the left coordinate on X axis
  83899. * @param y1 defines the left coordinate on Y axis
  83900. * @param x2 defines the right coordinate on X axis
  83901. * @param y2 defines the right coordinate on Y axis
  83902. * @returns the interpolated value
  83903. */
  83904. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83905. }
  83906. /**
  83907. * Defines angle representation
  83908. */
  83909. export class Angle {
  83910. private _radians;
  83911. /**
  83912. * Creates an Angle object of "radians" radians (float).
  83913. * @param radians the angle in radians
  83914. */
  83915. constructor(radians: number);
  83916. /**
  83917. * Get value in degrees
  83918. * @returns the Angle value in degrees (float)
  83919. */
  83920. degrees(): number;
  83921. /**
  83922. * Get value in radians
  83923. * @returns the Angle value in radians (float)
  83924. */
  83925. radians(): number;
  83926. /**
  83927. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83928. * @param a defines first point as the origin
  83929. * @param b defines point
  83930. * @returns a new Angle
  83931. */
  83932. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83933. /**
  83934. * Gets a new Angle object from the given float in radians
  83935. * @param radians defines the angle value in radians
  83936. * @returns a new Angle
  83937. */
  83938. static FromRadians(radians: number): Angle;
  83939. /**
  83940. * Gets a new Angle object from the given float in degrees
  83941. * @param degrees defines the angle value in degrees
  83942. * @returns a new Angle
  83943. */
  83944. static FromDegrees(degrees: number): Angle;
  83945. }
  83946. /**
  83947. * This represents an arc in a 2d space.
  83948. */
  83949. export class Arc2 {
  83950. /** Defines the start point of the arc */
  83951. startPoint: Vector2;
  83952. /** Defines the mid point of the arc */
  83953. midPoint: Vector2;
  83954. /** Defines the end point of the arc */
  83955. endPoint: Vector2;
  83956. /**
  83957. * Defines the center point of the arc.
  83958. */
  83959. centerPoint: Vector2;
  83960. /**
  83961. * Defines the radius of the arc.
  83962. */
  83963. radius: number;
  83964. /**
  83965. * Defines the angle of the arc (from mid point to end point).
  83966. */
  83967. angle: Angle;
  83968. /**
  83969. * Defines the start angle of the arc (from start point to middle point).
  83970. */
  83971. startAngle: Angle;
  83972. /**
  83973. * Defines the orientation of the arc (clock wise/counter clock wise).
  83974. */
  83975. orientation: Orientation;
  83976. /**
  83977. * Creates an Arc object from the three given points : start, middle and end.
  83978. * @param startPoint Defines the start point of the arc
  83979. * @param midPoint Defines the midlle point of the arc
  83980. * @param endPoint Defines the end point of the arc
  83981. */
  83982. constructor(
  83983. /** Defines the start point of the arc */
  83984. startPoint: Vector2,
  83985. /** Defines the mid point of the arc */
  83986. midPoint: Vector2,
  83987. /** Defines the end point of the arc */
  83988. endPoint: Vector2);
  83989. }
  83990. /**
  83991. * Represents a 2D path made up of multiple 2D points
  83992. */
  83993. export class Path2 {
  83994. private _points;
  83995. private _length;
  83996. /**
  83997. * If the path start and end point are the same
  83998. */
  83999. closed: boolean;
  84000. /**
  84001. * Creates a Path2 object from the starting 2D coordinates x and y.
  84002. * @param x the starting points x value
  84003. * @param y the starting points y value
  84004. */
  84005. constructor(x: number, y: number);
  84006. /**
  84007. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84008. * @param x the added points x value
  84009. * @param y the added points y value
  84010. * @returns the updated Path2.
  84011. */
  84012. addLineTo(x: number, y: number): Path2;
  84013. /**
  84014. * 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.
  84015. * @param midX middle point x value
  84016. * @param midY middle point y value
  84017. * @param endX end point x value
  84018. * @param endY end point y value
  84019. * @param numberOfSegments (default: 36)
  84020. * @returns the updated Path2.
  84021. */
  84022. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84023. /**
  84024. * Closes the Path2.
  84025. * @returns the Path2.
  84026. */
  84027. close(): Path2;
  84028. /**
  84029. * Gets the sum of the distance between each sequential point in the path
  84030. * @returns the Path2 total length (float).
  84031. */
  84032. length(): number;
  84033. /**
  84034. * Gets the points which construct the path
  84035. * @returns the Path2 internal array of points.
  84036. */
  84037. getPoints(): Vector2[];
  84038. /**
  84039. * Retreives the point at the distance aways from the starting point
  84040. * @param normalizedLengthPosition the length along the path to retreive the point from
  84041. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84042. */
  84043. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84044. /**
  84045. * Creates a new path starting from an x and y position
  84046. * @param x starting x value
  84047. * @param y starting y value
  84048. * @returns a new Path2 starting at the coordinates (x, y).
  84049. */
  84050. static StartingAt(x: number, y: number): Path2;
  84051. }
  84052. /**
  84053. * Represents a 3D path made up of multiple 3D points
  84054. */
  84055. export class Path3D {
  84056. /**
  84057. * an array of Vector3, the curve axis of the Path3D
  84058. */
  84059. path: Vector3[];
  84060. private _curve;
  84061. private _distances;
  84062. private _tangents;
  84063. private _normals;
  84064. private _binormals;
  84065. private _raw;
  84066. private _alignTangentsWithPath;
  84067. private readonly _pointAtData;
  84068. /**
  84069. * new Path3D(path, normal, raw)
  84070. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84071. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84072. * @param path an array of Vector3, the curve axis of the Path3D
  84073. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84074. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84075. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84076. */
  84077. constructor(
  84078. /**
  84079. * an array of Vector3, the curve axis of the Path3D
  84080. */
  84081. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84082. /**
  84083. * Returns the Path3D array of successive Vector3 designing its curve.
  84084. * @returns the Path3D array of successive Vector3 designing its curve.
  84085. */
  84086. getCurve(): Vector3[];
  84087. /**
  84088. * Returns the Path3D array of successive Vector3 designing its curve.
  84089. * @returns the Path3D array of successive Vector3 designing its curve.
  84090. */
  84091. getPoints(): Vector3[];
  84092. /**
  84093. * @returns the computed length (float) of the path.
  84094. */
  84095. length(): number;
  84096. /**
  84097. * Returns an array populated with tangent vectors on each Path3D curve point.
  84098. * @returns an array populated with tangent vectors on each Path3D curve point.
  84099. */
  84100. getTangents(): Vector3[];
  84101. /**
  84102. * Returns an array populated with normal vectors on each Path3D curve point.
  84103. * @returns an array populated with normal vectors on each Path3D curve point.
  84104. */
  84105. getNormals(): Vector3[];
  84106. /**
  84107. * Returns an array populated with binormal vectors on each Path3D curve point.
  84108. * @returns an array populated with binormal vectors on each Path3D curve point.
  84109. */
  84110. getBinormals(): Vector3[];
  84111. /**
  84112. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84113. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84114. */
  84115. getDistances(): number[];
  84116. /**
  84117. * Returns an interpolated point along this path
  84118. * @param position the position of the point along this path, from 0.0 to 1.0
  84119. * @returns a new Vector3 as the point
  84120. */
  84121. getPointAt(position: number): Vector3;
  84122. /**
  84123. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84124. * @param position the position of the point along this path, from 0.0 to 1.0
  84125. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84126. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84127. */
  84128. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84129. /**
  84130. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84131. * @param position the position of the point along this path, from 0.0 to 1.0
  84132. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84133. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84134. */
  84135. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84136. /**
  84137. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84138. * @param position the position of the point along this path, from 0.0 to 1.0
  84139. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84140. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84141. */
  84142. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84143. /**
  84144. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84145. * @param position the position of the point along this path, from 0.0 to 1.0
  84146. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84147. */
  84148. getDistanceAt(position: number): number;
  84149. /**
  84150. * Returns the array index of the previous point of an interpolated point along this path
  84151. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84152. * @returns the array index
  84153. */
  84154. getPreviousPointIndexAt(position: number): number;
  84155. /**
  84156. * 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)
  84157. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84158. * @returns the sub position
  84159. */
  84160. getSubPositionAt(position: number): number;
  84161. /**
  84162. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84163. * @param target the vector of which to get the closest position to
  84164. * @returns the position of the closest virtual point on this path to the target vector
  84165. */
  84166. getClosestPositionTo(target: Vector3): number;
  84167. /**
  84168. * Returns a sub path (slice) of this path
  84169. * @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
  84170. * @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
  84171. * @returns a sub path (slice) of this path
  84172. */
  84173. slice(start?: number, end?: number): Path3D;
  84174. /**
  84175. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84176. * @param path path which all values are copied into the curves points
  84177. * @param firstNormal which should be projected onto the curve
  84178. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84179. * @returns the same object updated.
  84180. */
  84181. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84182. private _compute;
  84183. private _getFirstNonNullVector;
  84184. private _getLastNonNullVector;
  84185. private _normalVector;
  84186. /**
  84187. * Updates the point at data for an interpolated point along this curve
  84188. * @param position the position of the point along this curve, from 0.0 to 1.0
  84189. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84190. * @returns the (updated) point at data
  84191. */
  84192. private _updatePointAtData;
  84193. /**
  84194. * Updates the point at data from the specified parameters
  84195. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84196. * @param point the interpolated point
  84197. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84198. */
  84199. private _setPointAtData;
  84200. /**
  84201. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84202. */
  84203. private _updateInterpolationMatrix;
  84204. }
  84205. /**
  84206. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84207. * A Curve3 is designed from a series of successive Vector3.
  84208. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84209. */
  84210. export class Curve3 {
  84211. private _points;
  84212. private _length;
  84213. /**
  84214. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84215. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84216. * @param v1 (Vector3) the control point
  84217. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84218. * @param nbPoints (integer) the wanted number of points in the curve
  84219. * @returns the created Curve3
  84220. */
  84221. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84222. /**
  84223. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84224. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84225. * @param v1 (Vector3) the first control point
  84226. * @param v2 (Vector3) the second control point
  84227. * @param v3 (Vector3) the end point of the Cubic Bezier
  84228. * @param nbPoints (integer) the wanted number of points in the curve
  84229. * @returns the created Curve3
  84230. */
  84231. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84232. /**
  84233. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84234. * @param p1 (Vector3) the origin point of the Hermite Spline
  84235. * @param t1 (Vector3) the tangent vector at the origin point
  84236. * @param p2 (Vector3) the end point of the Hermite Spline
  84237. * @param t2 (Vector3) the tangent vector at the end point
  84238. * @param nbPoints (integer) the wanted number of points in the curve
  84239. * @returns the created Curve3
  84240. */
  84241. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84242. /**
  84243. * Returns a Curve3 object along a CatmullRom Spline curve :
  84244. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84245. * @param nbPoints (integer) the wanted number of points between each curve control points
  84246. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84247. * @returns the created Curve3
  84248. */
  84249. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84250. /**
  84251. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84252. * A Curve3 is designed from a series of successive Vector3.
  84253. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84254. * @param points points which make up the curve
  84255. */
  84256. constructor(points: Vector3[]);
  84257. /**
  84258. * @returns the Curve3 stored array of successive Vector3
  84259. */
  84260. getPoints(): Vector3[];
  84261. /**
  84262. * @returns the computed length (float) of the curve.
  84263. */
  84264. length(): number;
  84265. /**
  84266. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84267. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84268. * curveA and curveB keep unchanged.
  84269. * @param curve the curve to continue from this curve
  84270. * @returns the newly constructed curve
  84271. */
  84272. continue(curve: DeepImmutable<Curve3>): Curve3;
  84273. private _computeLength;
  84274. }
  84275. }
  84276. declare module BABYLON {
  84277. /**
  84278. * This represents the main contract an easing function should follow.
  84279. * Easing functions are used throughout the animation system.
  84280. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84281. */
  84282. export interface IEasingFunction {
  84283. /**
  84284. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84285. * of the easing function.
  84286. * The link below provides some of the most common examples of easing functions.
  84287. * @see https://easings.net/
  84288. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84289. * @returns the corresponding value on the curve defined by the easing function
  84290. */
  84291. ease(gradient: number): number;
  84292. }
  84293. /**
  84294. * Base class used for every default easing function.
  84295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84296. */
  84297. export class EasingFunction implements IEasingFunction {
  84298. /**
  84299. * Interpolation follows the mathematical formula associated with the easing function.
  84300. */
  84301. static readonly EASINGMODE_EASEIN: number;
  84302. /**
  84303. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84304. */
  84305. static readonly EASINGMODE_EASEOUT: number;
  84306. /**
  84307. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84308. */
  84309. static readonly EASINGMODE_EASEINOUT: number;
  84310. private _easingMode;
  84311. /**
  84312. * Sets the easing mode of the current function.
  84313. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84314. */
  84315. setEasingMode(easingMode: number): void;
  84316. /**
  84317. * Gets the current easing mode.
  84318. * @returns the easing mode
  84319. */
  84320. getEasingMode(): number;
  84321. /**
  84322. * @hidden
  84323. */
  84324. easeInCore(gradient: number): number;
  84325. /**
  84326. * Given an input gradient between 0 and 1, this returns the corresponding value
  84327. * of the easing function.
  84328. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84329. * @returns the corresponding value on the curve defined by the easing function
  84330. */
  84331. ease(gradient: number): number;
  84332. }
  84333. /**
  84334. * Easing function with a circle shape (see link below).
  84335. * @see https://easings.net/#easeInCirc
  84336. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84337. */
  84338. export class CircleEase extends EasingFunction implements IEasingFunction {
  84339. /** @hidden */
  84340. easeInCore(gradient: number): number;
  84341. }
  84342. /**
  84343. * Easing function with a ease back shape (see link below).
  84344. * @see https://easings.net/#easeInBack
  84345. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84346. */
  84347. export class BackEase extends EasingFunction implements IEasingFunction {
  84348. /** Defines the amplitude of the function */
  84349. amplitude: number;
  84350. /**
  84351. * Instantiates a back ease easing
  84352. * @see https://easings.net/#easeInBack
  84353. * @param amplitude Defines the amplitude of the function
  84354. */
  84355. constructor(
  84356. /** Defines the amplitude of the function */
  84357. amplitude?: number);
  84358. /** @hidden */
  84359. easeInCore(gradient: number): number;
  84360. }
  84361. /**
  84362. * Easing function with a bouncing shape (see link below).
  84363. * @see https://easings.net/#easeInBounce
  84364. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84365. */
  84366. export class BounceEase extends EasingFunction implements IEasingFunction {
  84367. /** Defines the number of bounces */
  84368. bounces: number;
  84369. /** Defines the amplitude of the bounce */
  84370. bounciness: number;
  84371. /**
  84372. * Instantiates a bounce easing
  84373. * @see https://easings.net/#easeInBounce
  84374. * @param bounces Defines the number of bounces
  84375. * @param bounciness Defines the amplitude of the bounce
  84376. */
  84377. constructor(
  84378. /** Defines the number of bounces */
  84379. bounces?: number,
  84380. /** Defines the amplitude of the bounce */
  84381. bounciness?: number);
  84382. /** @hidden */
  84383. easeInCore(gradient: number): number;
  84384. }
  84385. /**
  84386. * Easing function with a power of 3 shape (see link below).
  84387. * @see https://easings.net/#easeInCubic
  84388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84389. */
  84390. export class CubicEase extends EasingFunction implements IEasingFunction {
  84391. /** @hidden */
  84392. easeInCore(gradient: number): number;
  84393. }
  84394. /**
  84395. * Easing function with an elastic shape (see link below).
  84396. * @see https://easings.net/#easeInElastic
  84397. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84398. */
  84399. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84400. /** Defines the number of oscillations*/
  84401. oscillations: number;
  84402. /** Defines the amplitude of the oscillations*/
  84403. springiness: number;
  84404. /**
  84405. * Instantiates an elastic easing function
  84406. * @see https://easings.net/#easeInElastic
  84407. * @param oscillations Defines the number of oscillations
  84408. * @param springiness Defines the amplitude of the oscillations
  84409. */
  84410. constructor(
  84411. /** Defines the number of oscillations*/
  84412. oscillations?: number,
  84413. /** Defines the amplitude of the oscillations*/
  84414. springiness?: number);
  84415. /** @hidden */
  84416. easeInCore(gradient: number): number;
  84417. }
  84418. /**
  84419. * Easing function with an exponential shape (see link below).
  84420. * @see https://easings.net/#easeInExpo
  84421. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84422. */
  84423. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84424. /** Defines the exponent of the function */
  84425. exponent: number;
  84426. /**
  84427. * Instantiates an exponential easing function
  84428. * @see https://easings.net/#easeInExpo
  84429. * @param exponent Defines the exponent of the function
  84430. */
  84431. constructor(
  84432. /** Defines the exponent of the function */
  84433. exponent?: number);
  84434. /** @hidden */
  84435. easeInCore(gradient: number): number;
  84436. }
  84437. /**
  84438. * Easing function with a power shape (see link below).
  84439. * @see https://easings.net/#easeInQuad
  84440. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84441. */
  84442. export class PowerEase extends EasingFunction implements IEasingFunction {
  84443. /** Defines the power of the function */
  84444. power: number;
  84445. /**
  84446. * Instantiates an power base easing function
  84447. * @see https://easings.net/#easeInQuad
  84448. * @param power Defines the power of the function
  84449. */
  84450. constructor(
  84451. /** Defines the power of the function */
  84452. power?: number);
  84453. /** @hidden */
  84454. easeInCore(gradient: number): number;
  84455. }
  84456. /**
  84457. * Easing function with a power of 2 shape (see link below).
  84458. * @see https://easings.net/#easeInQuad
  84459. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84460. */
  84461. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84462. /** @hidden */
  84463. easeInCore(gradient: number): number;
  84464. }
  84465. /**
  84466. * Easing function with a power of 4 shape (see link below).
  84467. * @see https://easings.net/#easeInQuart
  84468. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84469. */
  84470. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84471. /** @hidden */
  84472. easeInCore(gradient: number): number;
  84473. }
  84474. /**
  84475. * Easing function with a power of 5 shape (see link below).
  84476. * @see https://easings.net/#easeInQuint
  84477. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84478. */
  84479. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84480. /** @hidden */
  84481. easeInCore(gradient: number): number;
  84482. }
  84483. /**
  84484. * Easing function with a sin shape (see link below).
  84485. * @see https://easings.net/#easeInSine
  84486. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84487. */
  84488. export class SineEase extends EasingFunction implements IEasingFunction {
  84489. /** @hidden */
  84490. easeInCore(gradient: number): number;
  84491. }
  84492. /**
  84493. * Easing function with a bezier shape (see link below).
  84494. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84495. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84496. */
  84497. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84498. /** Defines the x component of the start tangent in the bezier curve */
  84499. x1: number;
  84500. /** Defines the y component of the start tangent in the bezier curve */
  84501. y1: number;
  84502. /** Defines the x component of the end tangent in the bezier curve */
  84503. x2: number;
  84504. /** Defines the y component of the end tangent in the bezier curve */
  84505. y2: number;
  84506. /**
  84507. * Instantiates a bezier function
  84508. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84509. * @param x1 Defines the x component of the start tangent in the bezier curve
  84510. * @param y1 Defines the y component of the start tangent in the bezier curve
  84511. * @param x2 Defines the x component of the end tangent in the bezier curve
  84512. * @param y2 Defines the y component of the end tangent in the bezier curve
  84513. */
  84514. constructor(
  84515. /** Defines the x component of the start tangent in the bezier curve */
  84516. x1?: number,
  84517. /** Defines the y component of the start tangent in the bezier curve */
  84518. y1?: number,
  84519. /** Defines the x component of the end tangent in the bezier curve */
  84520. x2?: number,
  84521. /** Defines the y component of the end tangent in the bezier curve */
  84522. y2?: number);
  84523. /** @hidden */
  84524. easeInCore(gradient: number): number;
  84525. }
  84526. }
  84527. declare module BABYLON {
  84528. /**
  84529. * Class used to hold a RBG color
  84530. */
  84531. export class Color3 {
  84532. /**
  84533. * Defines the red component (between 0 and 1, default is 0)
  84534. */
  84535. r: number;
  84536. /**
  84537. * Defines the green component (between 0 and 1, default is 0)
  84538. */
  84539. g: number;
  84540. /**
  84541. * Defines the blue component (between 0 and 1, default is 0)
  84542. */
  84543. b: number;
  84544. /**
  84545. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84546. * @param r defines the red component (between 0 and 1, default is 0)
  84547. * @param g defines the green component (between 0 and 1, default is 0)
  84548. * @param b defines the blue component (between 0 and 1, default is 0)
  84549. */
  84550. constructor(
  84551. /**
  84552. * Defines the red component (between 0 and 1, default is 0)
  84553. */
  84554. r?: number,
  84555. /**
  84556. * Defines the green component (between 0 and 1, default is 0)
  84557. */
  84558. g?: number,
  84559. /**
  84560. * Defines the blue component (between 0 and 1, default is 0)
  84561. */
  84562. b?: number);
  84563. /**
  84564. * Creates a string with the Color3 current values
  84565. * @returns the string representation of the Color3 object
  84566. */
  84567. toString(): string;
  84568. /**
  84569. * Returns the string "Color3"
  84570. * @returns "Color3"
  84571. */
  84572. getClassName(): string;
  84573. /**
  84574. * Compute the Color3 hash code
  84575. * @returns an unique number that can be used to hash Color3 objects
  84576. */
  84577. getHashCode(): number;
  84578. /**
  84579. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84580. * @param array defines the array where to store the r,g,b components
  84581. * @param index defines an optional index in the target array to define where to start storing values
  84582. * @returns the current Color3 object
  84583. */
  84584. toArray(array: FloatArray, index?: number): Color3;
  84585. /**
  84586. * Update the current color with values stored in an array from the starting index of the given array
  84587. * @param array defines the source array
  84588. * @param offset defines an offset in the source array
  84589. * @returns the current Color3 object
  84590. */
  84591. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84592. /**
  84593. * Returns a new Color4 object from the current Color3 and the given alpha
  84594. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84595. * @returns a new Color4 object
  84596. */
  84597. toColor4(alpha?: number): Color4;
  84598. /**
  84599. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84600. * @returns the new array
  84601. */
  84602. asArray(): number[];
  84603. /**
  84604. * Returns the luminance value
  84605. * @returns a float value
  84606. */
  84607. toLuminance(): number;
  84608. /**
  84609. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84610. * @param otherColor defines the second operand
  84611. * @returns the new Color3 object
  84612. */
  84613. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84614. /**
  84615. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84616. * @param otherColor defines the second operand
  84617. * @param result defines the Color3 object where to store the result
  84618. * @returns the current Color3
  84619. */
  84620. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84621. /**
  84622. * Determines equality between Color3 objects
  84623. * @param otherColor defines the second operand
  84624. * @returns true if the rgb values are equal to the given ones
  84625. */
  84626. equals(otherColor: DeepImmutable<Color3>): boolean;
  84627. /**
  84628. * Determines equality between the current Color3 object and a set of r,b,g values
  84629. * @param r defines the red component to check
  84630. * @param g defines the green component to check
  84631. * @param b defines the blue component to check
  84632. * @returns true if the rgb values are equal to the given ones
  84633. */
  84634. equalsFloats(r: number, g: number, b: number): boolean;
  84635. /**
  84636. * Multiplies in place each rgb value by scale
  84637. * @param scale defines the scaling factor
  84638. * @returns the updated Color3
  84639. */
  84640. scale(scale: number): Color3;
  84641. /**
  84642. * Multiplies the rgb values by scale and stores the result into "result"
  84643. * @param scale defines the scaling factor
  84644. * @param result defines the Color3 object where to store the result
  84645. * @returns the unmodified current Color3
  84646. */
  84647. scaleToRef(scale: number, result: Color3): Color3;
  84648. /**
  84649. * Scale the current Color3 values by a factor and add the result to a given Color3
  84650. * @param scale defines the scale factor
  84651. * @param result defines color to store the result into
  84652. * @returns the unmodified current Color3
  84653. */
  84654. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84655. /**
  84656. * Clamps the rgb values by the min and max values and stores the result into "result"
  84657. * @param min defines minimum clamping value (default is 0)
  84658. * @param max defines maximum clamping value (default is 1)
  84659. * @param result defines color to store the result into
  84660. * @returns the original Color3
  84661. */
  84662. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84663. /**
  84664. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84665. * @param otherColor defines the second operand
  84666. * @returns the new Color3
  84667. */
  84668. add(otherColor: DeepImmutable<Color3>): Color3;
  84669. /**
  84670. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84671. * @param otherColor defines the second operand
  84672. * @param result defines Color3 object to store the result into
  84673. * @returns the unmodified current Color3
  84674. */
  84675. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84676. /**
  84677. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84678. * @param otherColor defines the second operand
  84679. * @returns the new Color3
  84680. */
  84681. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84682. /**
  84683. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84684. * @param otherColor defines the second operand
  84685. * @param result defines Color3 object to store the result into
  84686. * @returns the unmodified current Color3
  84687. */
  84688. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84689. /**
  84690. * Copy the current object
  84691. * @returns a new Color3 copied the current one
  84692. */
  84693. clone(): Color3;
  84694. /**
  84695. * Copies the rgb values from the source in the current Color3
  84696. * @param source defines the source Color3 object
  84697. * @returns the updated Color3 object
  84698. */
  84699. copyFrom(source: DeepImmutable<Color3>): Color3;
  84700. /**
  84701. * Updates the Color3 rgb values from the given floats
  84702. * @param r defines the red component to read from
  84703. * @param g defines the green component to read from
  84704. * @param b defines the blue component to read from
  84705. * @returns the current Color3 object
  84706. */
  84707. copyFromFloats(r: number, g: number, b: number): Color3;
  84708. /**
  84709. * Updates the Color3 rgb values from the given floats
  84710. * @param r defines the red component to read from
  84711. * @param g defines the green component to read from
  84712. * @param b defines the blue component to read from
  84713. * @returns the current Color3 object
  84714. */
  84715. set(r: number, g: number, b: number): Color3;
  84716. /**
  84717. * Compute the Color3 hexadecimal code as a string
  84718. * @returns a string containing the hexadecimal representation of the Color3 object
  84719. */
  84720. toHexString(): string;
  84721. /**
  84722. * Computes a new Color3 converted from the current one to linear space
  84723. * @returns a new Color3 object
  84724. */
  84725. toLinearSpace(): Color3;
  84726. /**
  84727. * Converts current color in rgb space to HSV values
  84728. * @returns a new color3 representing the HSV values
  84729. */
  84730. toHSV(): Color3;
  84731. /**
  84732. * Converts current color in rgb space to HSV values
  84733. * @param result defines the Color3 where to store the HSV values
  84734. */
  84735. toHSVToRef(result: Color3): void;
  84736. /**
  84737. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84738. * @param convertedColor defines the Color3 object where to store the linear space version
  84739. * @returns the unmodified Color3
  84740. */
  84741. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84742. /**
  84743. * Computes a new Color3 converted from the current one to gamma space
  84744. * @returns a new Color3 object
  84745. */
  84746. toGammaSpace(): Color3;
  84747. /**
  84748. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84749. * @param convertedColor defines the Color3 object where to store the gamma space version
  84750. * @returns the unmodified Color3
  84751. */
  84752. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84753. private static _BlackReadOnly;
  84754. /**
  84755. * Convert Hue, saturation and value to a Color3 (RGB)
  84756. * @param hue defines the hue
  84757. * @param saturation defines the saturation
  84758. * @param value defines the value
  84759. * @param result defines the Color3 where to store the RGB values
  84760. */
  84761. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84762. /**
  84763. * Creates a new Color3 from the string containing valid hexadecimal values
  84764. * @param hex defines a string containing valid hexadecimal values
  84765. * @returns a new Color3 object
  84766. */
  84767. static FromHexString(hex: string): Color3;
  84768. /**
  84769. * Creates a new Color3 from the starting index of the given array
  84770. * @param array defines the source array
  84771. * @param offset defines an offset in the source array
  84772. * @returns a new Color3 object
  84773. */
  84774. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84775. /**
  84776. * Creates a new Color3 from the starting index element of the given array
  84777. * @param array defines the source array to read from
  84778. * @param offset defines the offset in the source array
  84779. * @param result defines the target Color3 object
  84780. */
  84781. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84782. /**
  84783. * Creates a new Color3 from integer values (< 256)
  84784. * @param r defines the red component to read from (value between 0 and 255)
  84785. * @param g defines the green component to read from (value between 0 and 255)
  84786. * @param b defines the blue component to read from (value between 0 and 255)
  84787. * @returns a new Color3 object
  84788. */
  84789. static FromInts(r: number, g: number, b: number): Color3;
  84790. /**
  84791. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84792. * @param start defines the start Color3 value
  84793. * @param end defines the end Color3 value
  84794. * @param amount defines the gradient value between start and end
  84795. * @returns a new Color3 object
  84796. */
  84797. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84798. /**
  84799. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84800. * @param left defines the start value
  84801. * @param right defines the end value
  84802. * @param amount defines the gradient factor
  84803. * @param result defines the Color3 object where to store the result
  84804. */
  84805. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84806. /**
  84807. * Returns a Color3 value containing a red color
  84808. * @returns a new Color3 object
  84809. */
  84810. static Red(): Color3;
  84811. /**
  84812. * Returns a Color3 value containing a green color
  84813. * @returns a new Color3 object
  84814. */
  84815. static Green(): Color3;
  84816. /**
  84817. * Returns a Color3 value containing a blue color
  84818. * @returns a new Color3 object
  84819. */
  84820. static Blue(): Color3;
  84821. /**
  84822. * Returns a Color3 value containing a black color
  84823. * @returns a new Color3 object
  84824. */
  84825. static Black(): Color3;
  84826. /**
  84827. * Gets a Color3 value containing a black color that must not be updated
  84828. */
  84829. static get BlackReadOnly(): DeepImmutable<Color3>;
  84830. /**
  84831. * Returns a Color3 value containing a white color
  84832. * @returns a new Color3 object
  84833. */
  84834. static White(): Color3;
  84835. /**
  84836. * Returns a Color3 value containing a purple color
  84837. * @returns a new Color3 object
  84838. */
  84839. static Purple(): Color3;
  84840. /**
  84841. * Returns a Color3 value containing a magenta color
  84842. * @returns a new Color3 object
  84843. */
  84844. static Magenta(): Color3;
  84845. /**
  84846. * Returns a Color3 value containing a yellow color
  84847. * @returns a new Color3 object
  84848. */
  84849. static Yellow(): Color3;
  84850. /**
  84851. * Returns a Color3 value containing a gray color
  84852. * @returns a new Color3 object
  84853. */
  84854. static Gray(): Color3;
  84855. /**
  84856. * Returns a Color3 value containing a teal color
  84857. * @returns a new Color3 object
  84858. */
  84859. static Teal(): Color3;
  84860. /**
  84861. * Returns a Color3 value containing a random color
  84862. * @returns a new Color3 object
  84863. */
  84864. static Random(): Color3;
  84865. }
  84866. /**
  84867. * Class used to hold a RBGA color
  84868. */
  84869. export class Color4 {
  84870. /**
  84871. * Defines the red component (between 0 and 1, default is 0)
  84872. */
  84873. r: number;
  84874. /**
  84875. * Defines the green component (between 0 and 1, default is 0)
  84876. */
  84877. g: number;
  84878. /**
  84879. * Defines the blue component (between 0 and 1, default is 0)
  84880. */
  84881. b: number;
  84882. /**
  84883. * Defines the alpha component (between 0 and 1, default is 1)
  84884. */
  84885. a: number;
  84886. /**
  84887. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84888. * @param r defines the red component (between 0 and 1, default is 0)
  84889. * @param g defines the green component (between 0 and 1, default is 0)
  84890. * @param b defines the blue component (between 0 and 1, default is 0)
  84891. * @param a defines the alpha component (between 0 and 1, default is 1)
  84892. */
  84893. constructor(
  84894. /**
  84895. * Defines the red component (between 0 and 1, default is 0)
  84896. */
  84897. r?: number,
  84898. /**
  84899. * Defines the green component (between 0 and 1, default is 0)
  84900. */
  84901. g?: number,
  84902. /**
  84903. * Defines the blue component (between 0 and 1, default is 0)
  84904. */
  84905. b?: number,
  84906. /**
  84907. * Defines the alpha component (between 0 and 1, default is 1)
  84908. */
  84909. a?: number);
  84910. /**
  84911. * Adds in place the given Color4 values to the current Color4 object
  84912. * @param right defines the second operand
  84913. * @returns the current updated Color4 object
  84914. */
  84915. addInPlace(right: DeepImmutable<Color4>): Color4;
  84916. /**
  84917. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84918. * @returns the new array
  84919. */
  84920. asArray(): number[];
  84921. /**
  84922. * Stores from the starting index in the given array the Color4 successive values
  84923. * @param array defines the array where to store the r,g,b components
  84924. * @param index defines an optional index in the target array to define where to start storing values
  84925. * @returns the current Color4 object
  84926. */
  84927. toArray(array: number[], index?: number): Color4;
  84928. /**
  84929. * Update the current color with values stored in an array from the starting index of the given array
  84930. * @param array defines the source array
  84931. * @param offset defines an offset in the source array
  84932. * @returns the current Color4 object
  84933. */
  84934. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84935. /**
  84936. * Determines equality between Color4 objects
  84937. * @param otherColor defines the second operand
  84938. * @returns true if the rgba values are equal to the given ones
  84939. */
  84940. equals(otherColor: DeepImmutable<Color4>): boolean;
  84941. /**
  84942. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84943. * @param right defines the second operand
  84944. * @returns a new Color4 object
  84945. */
  84946. add(right: DeepImmutable<Color4>): Color4;
  84947. /**
  84948. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84949. * @param right defines the second operand
  84950. * @returns a new Color4 object
  84951. */
  84952. subtract(right: DeepImmutable<Color4>): Color4;
  84953. /**
  84954. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84955. * @param right defines the second operand
  84956. * @param result defines the Color4 object where to store the result
  84957. * @returns the current Color4 object
  84958. */
  84959. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84960. /**
  84961. * Creates a new Color4 with the current Color4 values multiplied by scale
  84962. * @param scale defines the scaling factor to apply
  84963. * @returns a new Color4 object
  84964. */
  84965. scale(scale: number): Color4;
  84966. /**
  84967. * Multiplies the current Color4 values by scale and stores the result in "result"
  84968. * @param scale defines the scaling factor to apply
  84969. * @param result defines the Color4 object where to store the result
  84970. * @returns the current unmodified Color4
  84971. */
  84972. scaleToRef(scale: number, result: Color4): Color4;
  84973. /**
  84974. * Scale the current Color4 values by a factor and add the result to a given Color4
  84975. * @param scale defines the scale factor
  84976. * @param result defines the Color4 object where to store the result
  84977. * @returns the unmodified current Color4
  84978. */
  84979. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84980. /**
  84981. * Clamps the rgb values by the min and max values and stores the result into "result"
  84982. * @param min defines minimum clamping value (default is 0)
  84983. * @param max defines maximum clamping value (default is 1)
  84984. * @param result defines color to store the result into.
  84985. * @returns the cuurent Color4
  84986. */
  84987. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84988. /**
  84989. * Multipy an Color4 value by another and return a new Color4 object
  84990. * @param color defines the Color4 value to multiply by
  84991. * @returns a new Color4 object
  84992. */
  84993. multiply(color: Color4): Color4;
  84994. /**
  84995. * Multipy a Color4 value by another and push the result in a reference value
  84996. * @param color defines the Color4 value to multiply by
  84997. * @param result defines the Color4 to fill the result in
  84998. * @returns the result Color4
  84999. */
  85000. multiplyToRef(color: Color4, result: Color4): Color4;
  85001. /**
  85002. * Creates a string with the Color4 current values
  85003. * @returns the string representation of the Color4 object
  85004. */
  85005. toString(): string;
  85006. /**
  85007. * Returns the string "Color4"
  85008. * @returns "Color4"
  85009. */
  85010. getClassName(): string;
  85011. /**
  85012. * Compute the Color4 hash code
  85013. * @returns an unique number that can be used to hash Color4 objects
  85014. */
  85015. getHashCode(): number;
  85016. /**
  85017. * Creates a new Color4 copied from the current one
  85018. * @returns a new Color4 object
  85019. */
  85020. clone(): Color4;
  85021. /**
  85022. * Copies the given Color4 values into the current one
  85023. * @param source defines the source Color4 object
  85024. * @returns the current updated Color4 object
  85025. */
  85026. copyFrom(source: Color4): Color4;
  85027. /**
  85028. * Copies the given float values into the current one
  85029. * @param r defines the red component to read from
  85030. * @param g defines the green component to read from
  85031. * @param b defines the blue component to read from
  85032. * @param a defines the alpha component to read from
  85033. * @returns the current updated Color4 object
  85034. */
  85035. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85036. /**
  85037. * Copies the given float values into the current one
  85038. * @param r defines the red component to read from
  85039. * @param g defines the green component to read from
  85040. * @param b defines the blue component to read from
  85041. * @param a defines the alpha component to read from
  85042. * @returns the current updated Color4 object
  85043. */
  85044. set(r: number, g: number, b: number, a: number): Color4;
  85045. /**
  85046. * Compute the Color4 hexadecimal code as a string
  85047. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85048. * @returns a string containing the hexadecimal representation of the Color4 object
  85049. */
  85050. toHexString(returnAsColor3?: boolean): string;
  85051. /**
  85052. * Computes a new Color4 converted from the current one to linear space
  85053. * @returns a new Color4 object
  85054. */
  85055. toLinearSpace(): Color4;
  85056. /**
  85057. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85058. * @param convertedColor defines the Color4 object where to store the linear space version
  85059. * @returns the unmodified Color4
  85060. */
  85061. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85062. /**
  85063. * Computes a new Color4 converted from the current one to gamma space
  85064. * @returns a new Color4 object
  85065. */
  85066. toGammaSpace(): Color4;
  85067. /**
  85068. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85069. * @param convertedColor defines the Color4 object where to store the gamma space version
  85070. * @returns the unmodified Color4
  85071. */
  85072. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85073. /**
  85074. * Creates a new Color4 from the string containing valid hexadecimal values
  85075. * @param hex defines a string containing valid hexadecimal values
  85076. * @returns a new Color4 object
  85077. */
  85078. static FromHexString(hex: string): Color4;
  85079. /**
  85080. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85081. * @param left defines the start value
  85082. * @param right defines the end value
  85083. * @param amount defines the gradient factor
  85084. * @returns a new Color4 object
  85085. */
  85086. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85087. /**
  85088. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85089. * @param left defines the start value
  85090. * @param right defines the end value
  85091. * @param amount defines the gradient factor
  85092. * @param result defines the Color4 object where to store data
  85093. */
  85094. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85095. /**
  85096. * Creates a new Color4 from a Color3 and an alpha value
  85097. * @param color3 defines the source Color3 to read from
  85098. * @param alpha defines the alpha component (1.0 by default)
  85099. * @returns a new Color4 object
  85100. */
  85101. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85102. /**
  85103. * Creates a new Color4 from the starting index element of the given array
  85104. * @param array defines the source array to read from
  85105. * @param offset defines the offset in the source array
  85106. * @returns a new Color4 object
  85107. */
  85108. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85109. /**
  85110. * Creates a new Color4 from the starting index element of the given array
  85111. * @param array defines the source array to read from
  85112. * @param offset defines the offset in the source array
  85113. * @param result defines the target Color4 object
  85114. */
  85115. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85116. /**
  85117. * Creates a new Color3 from integer values (< 256)
  85118. * @param r defines the red component to read from (value between 0 and 255)
  85119. * @param g defines the green component to read from (value between 0 and 255)
  85120. * @param b defines the blue component to read from (value between 0 and 255)
  85121. * @param a defines the alpha component to read from (value between 0 and 255)
  85122. * @returns a new Color3 object
  85123. */
  85124. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85125. /**
  85126. * Check the content of a given array and convert it to an array containing RGBA data
  85127. * If the original array was already containing count * 4 values then it is returned directly
  85128. * @param colors defines the array to check
  85129. * @param count defines the number of RGBA data to expect
  85130. * @returns an array containing count * 4 values (RGBA)
  85131. */
  85132. static CheckColors4(colors: number[], count: number): number[];
  85133. }
  85134. /**
  85135. * @hidden
  85136. */
  85137. export class TmpColors {
  85138. static Color3: Color3[];
  85139. static Color4: Color4[];
  85140. }
  85141. }
  85142. declare module BABYLON {
  85143. /**
  85144. * Defines an interface which represents an animation key frame
  85145. */
  85146. export interface IAnimationKey {
  85147. /**
  85148. * Frame of the key frame
  85149. */
  85150. frame: number;
  85151. /**
  85152. * Value at the specifies key frame
  85153. */
  85154. value: any;
  85155. /**
  85156. * The input tangent for the cubic hermite spline
  85157. */
  85158. inTangent?: any;
  85159. /**
  85160. * The output tangent for the cubic hermite spline
  85161. */
  85162. outTangent?: any;
  85163. /**
  85164. * The animation interpolation type
  85165. */
  85166. interpolation?: AnimationKeyInterpolation;
  85167. }
  85168. /**
  85169. * Enum for the animation key frame interpolation type
  85170. */
  85171. export enum AnimationKeyInterpolation {
  85172. /**
  85173. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85174. */
  85175. STEP = 1
  85176. }
  85177. }
  85178. declare module BABYLON {
  85179. /**
  85180. * Represents the range of an animation
  85181. */
  85182. export class AnimationRange {
  85183. /**The name of the animation range**/
  85184. name: string;
  85185. /**The starting frame of the animation */
  85186. from: number;
  85187. /**The ending frame of the animation*/
  85188. to: number;
  85189. /**
  85190. * Initializes the range of an animation
  85191. * @param name The name of the animation range
  85192. * @param from The starting frame of the animation
  85193. * @param to The ending frame of the animation
  85194. */
  85195. constructor(
  85196. /**The name of the animation range**/
  85197. name: string,
  85198. /**The starting frame of the animation */
  85199. from: number,
  85200. /**The ending frame of the animation*/
  85201. to: number);
  85202. /**
  85203. * Makes a copy of the animation range
  85204. * @returns A copy of the animation range
  85205. */
  85206. clone(): AnimationRange;
  85207. }
  85208. }
  85209. declare module BABYLON {
  85210. /**
  85211. * Composed of a frame, and an action function
  85212. */
  85213. export class AnimationEvent {
  85214. /** The frame for which the event is triggered **/
  85215. frame: number;
  85216. /** The event to perform when triggered **/
  85217. action: (currentFrame: number) => void;
  85218. /** Specifies if the event should be triggered only once**/
  85219. onlyOnce?: boolean | undefined;
  85220. /**
  85221. * Specifies if the animation event is done
  85222. */
  85223. isDone: boolean;
  85224. /**
  85225. * Initializes the animation event
  85226. * @param frame The frame for which the event is triggered
  85227. * @param action The event to perform when triggered
  85228. * @param onlyOnce Specifies if the event should be triggered only once
  85229. */
  85230. constructor(
  85231. /** The frame for which the event is triggered **/
  85232. frame: number,
  85233. /** The event to perform when triggered **/
  85234. action: (currentFrame: number) => void,
  85235. /** Specifies if the event should be triggered only once**/
  85236. onlyOnce?: boolean | undefined);
  85237. /** @hidden */
  85238. _clone(): AnimationEvent;
  85239. }
  85240. }
  85241. declare module BABYLON {
  85242. /**
  85243. * Interface used to define a behavior
  85244. */
  85245. export interface Behavior<T> {
  85246. /** gets or sets behavior's name */
  85247. name: string;
  85248. /**
  85249. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85250. */
  85251. init(): void;
  85252. /**
  85253. * Called when the behavior is attached to a target
  85254. * @param target defines the target where the behavior is attached to
  85255. */
  85256. attach(target: T): void;
  85257. /**
  85258. * Called when the behavior is detached from its target
  85259. */
  85260. detach(): void;
  85261. }
  85262. /**
  85263. * Interface implemented by classes supporting behaviors
  85264. */
  85265. export interface IBehaviorAware<T> {
  85266. /**
  85267. * Attach a behavior
  85268. * @param behavior defines the behavior to attach
  85269. * @returns the current host
  85270. */
  85271. addBehavior(behavior: Behavior<T>): T;
  85272. /**
  85273. * Remove a behavior from the current object
  85274. * @param behavior defines the behavior to detach
  85275. * @returns the current host
  85276. */
  85277. removeBehavior(behavior: Behavior<T>): T;
  85278. /**
  85279. * Gets a behavior using its name to search
  85280. * @param name defines the name to search
  85281. * @returns the behavior or null if not found
  85282. */
  85283. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85284. }
  85285. }
  85286. declare module BABYLON {
  85287. /**
  85288. * Defines an array and its length.
  85289. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85290. */
  85291. export interface ISmartArrayLike<T> {
  85292. /**
  85293. * The data of the array.
  85294. */
  85295. data: Array<T>;
  85296. /**
  85297. * The active length of the array.
  85298. */
  85299. length: number;
  85300. }
  85301. /**
  85302. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85303. */
  85304. export class SmartArray<T> implements ISmartArrayLike<T> {
  85305. /**
  85306. * The full set of data from the array.
  85307. */
  85308. data: Array<T>;
  85309. /**
  85310. * The active length of the array.
  85311. */
  85312. length: number;
  85313. protected _id: number;
  85314. /**
  85315. * Instantiates a Smart Array.
  85316. * @param capacity defines the default capacity of the array.
  85317. */
  85318. constructor(capacity: number);
  85319. /**
  85320. * Pushes a value at the end of the active data.
  85321. * @param value defines the object to push in the array.
  85322. */
  85323. push(value: T): void;
  85324. /**
  85325. * Iterates over the active data and apply the lambda to them.
  85326. * @param func defines the action to apply on each value.
  85327. */
  85328. forEach(func: (content: T) => void): void;
  85329. /**
  85330. * Sorts the full sets of data.
  85331. * @param compareFn defines the comparison function to apply.
  85332. */
  85333. sort(compareFn: (a: T, b: T) => number): void;
  85334. /**
  85335. * Resets the active data to an empty array.
  85336. */
  85337. reset(): void;
  85338. /**
  85339. * Releases all the data from the array as well as the array.
  85340. */
  85341. dispose(): void;
  85342. /**
  85343. * Concats the active data with a given array.
  85344. * @param array defines the data to concatenate with.
  85345. */
  85346. concat(array: any): void;
  85347. /**
  85348. * Returns the position of a value in the active data.
  85349. * @param value defines the value to find the index for
  85350. * @returns the index if found in the active data otherwise -1
  85351. */
  85352. indexOf(value: T): number;
  85353. /**
  85354. * Returns whether an element is part of the active data.
  85355. * @param value defines the value to look for
  85356. * @returns true if found in the active data otherwise false
  85357. */
  85358. contains(value: T): boolean;
  85359. private static _GlobalId;
  85360. }
  85361. /**
  85362. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85363. * The data in this array can only be present once
  85364. */
  85365. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85366. private _duplicateId;
  85367. /**
  85368. * Pushes a value at the end of the active data.
  85369. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85370. * @param value defines the object to push in the array.
  85371. */
  85372. push(value: T): void;
  85373. /**
  85374. * Pushes a value at the end of the active data.
  85375. * If the data is already present, it won t be added again
  85376. * @param value defines the object to push in the array.
  85377. * @returns true if added false if it was already present
  85378. */
  85379. pushNoDuplicate(value: T): boolean;
  85380. /**
  85381. * Resets the active data to an empty array.
  85382. */
  85383. reset(): void;
  85384. /**
  85385. * Concats the active data with a given array.
  85386. * This ensures no dupplicate will be present in the result.
  85387. * @param array defines the data to concatenate with.
  85388. */
  85389. concatWithNoDuplicate(array: any): void;
  85390. }
  85391. }
  85392. declare module BABYLON {
  85393. /**
  85394. * @ignore
  85395. * This is a list of all the different input types that are available in the application.
  85396. * Fo instance: ArcRotateCameraGamepadInput...
  85397. */
  85398. export var CameraInputTypes: {};
  85399. /**
  85400. * This is the contract to implement in order to create a new input class.
  85401. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85402. */
  85403. export interface ICameraInput<TCamera extends Camera> {
  85404. /**
  85405. * Defines the camera the input is attached to.
  85406. */
  85407. camera: Nullable<TCamera>;
  85408. /**
  85409. * Gets the class name of the current intput.
  85410. * @returns the class name
  85411. */
  85412. getClassName(): string;
  85413. /**
  85414. * Get the friendly name associated with the input class.
  85415. * @returns the input friendly name
  85416. */
  85417. getSimpleName(): string;
  85418. /**
  85419. * Attach the input controls to a specific dom element to get the input from.
  85420. * @param element Defines the element the controls should be listened from
  85421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85422. */
  85423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85424. /**
  85425. * Detach the current controls from the specified dom element.
  85426. * @param element Defines the element to stop listening the inputs from
  85427. */
  85428. detachControl(element: Nullable<HTMLElement>): void;
  85429. /**
  85430. * Update the current camera state depending on the inputs that have been used this frame.
  85431. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85432. */
  85433. checkInputs?: () => void;
  85434. }
  85435. /**
  85436. * Represents a map of input types to input instance or input index to input instance.
  85437. */
  85438. export interface CameraInputsMap<TCamera extends Camera> {
  85439. /**
  85440. * Accessor to the input by input type.
  85441. */
  85442. [name: string]: ICameraInput<TCamera>;
  85443. /**
  85444. * Accessor to the input by input index.
  85445. */
  85446. [idx: number]: ICameraInput<TCamera>;
  85447. }
  85448. /**
  85449. * This represents the input manager used within a camera.
  85450. * It helps dealing with all the different kind of input attached to a camera.
  85451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85452. */
  85453. export class CameraInputsManager<TCamera extends Camera> {
  85454. /**
  85455. * Defines the list of inputs attahed to the camera.
  85456. */
  85457. attached: CameraInputsMap<TCamera>;
  85458. /**
  85459. * Defines the dom element the camera is collecting inputs from.
  85460. * This is null if the controls have not been attached.
  85461. */
  85462. attachedElement: Nullable<HTMLElement>;
  85463. /**
  85464. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85465. */
  85466. noPreventDefault: boolean;
  85467. /**
  85468. * Defined the camera the input manager belongs to.
  85469. */
  85470. camera: TCamera;
  85471. /**
  85472. * Update the current camera state depending on the inputs that have been used this frame.
  85473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85474. */
  85475. checkInputs: () => void;
  85476. /**
  85477. * Instantiate a new Camera Input Manager.
  85478. * @param camera Defines the camera the input manager blongs to
  85479. */
  85480. constructor(camera: TCamera);
  85481. /**
  85482. * Add an input method to a camera
  85483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85484. * @param input camera input method
  85485. */
  85486. add(input: ICameraInput<TCamera>): void;
  85487. /**
  85488. * Remove a specific input method from a camera
  85489. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85490. * @param inputToRemove camera input method
  85491. */
  85492. remove(inputToRemove: ICameraInput<TCamera>): void;
  85493. /**
  85494. * Remove a specific input type from a camera
  85495. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85496. * @param inputType the type of the input to remove
  85497. */
  85498. removeByType(inputType: string): void;
  85499. private _addCheckInputs;
  85500. /**
  85501. * Attach the input controls to the currently attached dom element to listen the events from.
  85502. * @param input Defines the input to attach
  85503. */
  85504. attachInput(input: ICameraInput<TCamera>): void;
  85505. /**
  85506. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85507. * @param element Defines the dom element to collect the events from
  85508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85509. */
  85510. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85511. /**
  85512. * Detach the current manager inputs controls from a specific dom element.
  85513. * @param element Defines the dom element to collect the events from
  85514. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85515. */
  85516. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85517. /**
  85518. * Rebuild the dynamic inputCheck function from the current list of
  85519. * defined inputs in the manager.
  85520. */
  85521. rebuildInputCheck(): void;
  85522. /**
  85523. * Remove all attached input methods from a camera
  85524. */
  85525. clear(): void;
  85526. /**
  85527. * Serialize the current input manager attached to a camera.
  85528. * This ensures than once parsed,
  85529. * the input associated to the camera will be identical to the current ones
  85530. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85531. */
  85532. serialize(serializedCamera: any): void;
  85533. /**
  85534. * Parses an input manager serialized JSON to restore the previous list of inputs
  85535. * and states associated to a camera.
  85536. * @param parsedCamera Defines the JSON to parse
  85537. */
  85538. parse(parsedCamera: any): void;
  85539. }
  85540. }
  85541. declare module BABYLON {
  85542. /**
  85543. * Class used to store data that will be store in GPU memory
  85544. */
  85545. export class Buffer {
  85546. private _engine;
  85547. private _buffer;
  85548. /** @hidden */
  85549. _data: Nullable<DataArray>;
  85550. private _updatable;
  85551. private _instanced;
  85552. private _divisor;
  85553. /**
  85554. * Gets the byte stride.
  85555. */
  85556. readonly byteStride: number;
  85557. /**
  85558. * Constructor
  85559. * @param engine the engine
  85560. * @param data the data to use for this buffer
  85561. * @param updatable whether the data is updatable
  85562. * @param stride the stride (optional)
  85563. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85564. * @param instanced whether the buffer is instanced (optional)
  85565. * @param useBytes set to true if the stride in in bytes (optional)
  85566. * @param divisor sets an optional divisor for instances (1 by default)
  85567. */
  85568. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85569. /**
  85570. * Create a new VertexBuffer based on the current buffer
  85571. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85572. * @param offset defines offset in the buffer (0 by default)
  85573. * @param size defines the size in floats of attributes (position is 3 for instance)
  85574. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85575. * @param instanced defines if the vertex buffer contains indexed data
  85576. * @param useBytes defines if the offset and stride are in bytes *
  85577. * @param divisor sets an optional divisor for instances (1 by default)
  85578. * @returns the new vertex buffer
  85579. */
  85580. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85581. /**
  85582. * Gets a boolean indicating if the Buffer is updatable?
  85583. * @returns true if the buffer is updatable
  85584. */
  85585. isUpdatable(): boolean;
  85586. /**
  85587. * Gets current buffer's data
  85588. * @returns a DataArray or null
  85589. */
  85590. getData(): Nullable<DataArray>;
  85591. /**
  85592. * Gets underlying native buffer
  85593. * @returns underlying native buffer
  85594. */
  85595. getBuffer(): Nullable<DataBuffer>;
  85596. /**
  85597. * Gets the stride in float32 units (i.e. byte stride / 4).
  85598. * May not be an integer if the byte stride is not divisible by 4.
  85599. * @returns the stride in float32 units
  85600. * @deprecated Please use byteStride instead.
  85601. */
  85602. getStrideSize(): number;
  85603. /**
  85604. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85605. * @param data defines the data to store
  85606. */
  85607. create(data?: Nullable<DataArray>): void;
  85608. /** @hidden */
  85609. _rebuild(): void;
  85610. /**
  85611. * Update current buffer data
  85612. * @param data defines the data to store
  85613. */
  85614. update(data: DataArray): void;
  85615. /**
  85616. * Updates the data directly.
  85617. * @param data the new data
  85618. * @param offset the new offset
  85619. * @param vertexCount the vertex count (optional)
  85620. * @param useBytes set to true if the offset is in bytes
  85621. */
  85622. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85623. /**
  85624. * Release all resources
  85625. */
  85626. dispose(): void;
  85627. }
  85628. /**
  85629. * Specialized buffer used to store vertex data
  85630. */
  85631. export class VertexBuffer {
  85632. /** @hidden */
  85633. _buffer: Buffer;
  85634. private _kind;
  85635. private _size;
  85636. private _ownsBuffer;
  85637. private _instanced;
  85638. private _instanceDivisor;
  85639. /**
  85640. * The byte type.
  85641. */
  85642. static readonly BYTE: number;
  85643. /**
  85644. * The unsigned byte type.
  85645. */
  85646. static readonly UNSIGNED_BYTE: number;
  85647. /**
  85648. * The short type.
  85649. */
  85650. static readonly SHORT: number;
  85651. /**
  85652. * The unsigned short type.
  85653. */
  85654. static readonly UNSIGNED_SHORT: number;
  85655. /**
  85656. * The integer type.
  85657. */
  85658. static readonly INT: number;
  85659. /**
  85660. * The unsigned integer type.
  85661. */
  85662. static readonly UNSIGNED_INT: number;
  85663. /**
  85664. * The float type.
  85665. */
  85666. static readonly FLOAT: number;
  85667. /**
  85668. * Gets or sets the instance divisor when in instanced mode
  85669. */
  85670. get instanceDivisor(): number;
  85671. set instanceDivisor(value: number);
  85672. /**
  85673. * Gets the byte stride.
  85674. */
  85675. readonly byteStride: number;
  85676. /**
  85677. * Gets the byte offset.
  85678. */
  85679. readonly byteOffset: number;
  85680. /**
  85681. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85682. */
  85683. readonly normalized: boolean;
  85684. /**
  85685. * Gets the data type of each component in the array.
  85686. */
  85687. readonly type: number;
  85688. /**
  85689. * Constructor
  85690. * @param engine the engine
  85691. * @param data the data to use for this vertex buffer
  85692. * @param kind the vertex buffer kind
  85693. * @param updatable whether the data is updatable
  85694. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85695. * @param stride the stride (optional)
  85696. * @param instanced whether the buffer is instanced (optional)
  85697. * @param offset the offset of the data (optional)
  85698. * @param size the number of components (optional)
  85699. * @param type the type of the component (optional)
  85700. * @param normalized whether the data contains normalized data (optional)
  85701. * @param useBytes set to true if stride and offset are in bytes (optional)
  85702. * @param divisor defines the instance divisor to use (1 by default)
  85703. */
  85704. 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);
  85705. /** @hidden */
  85706. _rebuild(): void;
  85707. /**
  85708. * Returns the kind of the VertexBuffer (string)
  85709. * @returns a string
  85710. */
  85711. getKind(): string;
  85712. /**
  85713. * Gets a boolean indicating if the VertexBuffer is updatable?
  85714. * @returns true if the buffer is updatable
  85715. */
  85716. isUpdatable(): boolean;
  85717. /**
  85718. * Gets current buffer's data
  85719. * @returns a DataArray or null
  85720. */
  85721. getData(): Nullable<DataArray>;
  85722. /**
  85723. * Gets underlying native buffer
  85724. * @returns underlying native buffer
  85725. */
  85726. getBuffer(): Nullable<DataBuffer>;
  85727. /**
  85728. * Gets the stride in float32 units (i.e. byte stride / 4).
  85729. * May not be an integer if the byte stride is not divisible by 4.
  85730. * @returns the stride in float32 units
  85731. * @deprecated Please use byteStride instead.
  85732. */
  85733. getStrideSize(): number;
  85734. /**
  85735. * Returns the offset as a multiple of the type byte length.
  85736. * @returns the offset in bytes
  85737. * @deprecated Please use byteOffset instead.
  85738. */
  85739. getOffset(): number;
  85740. /**
  85741. * Returns the number of components per vertex attribute (integer)
  85742. * @returns the size in float
  85743. */
  85744. getSize(): number;
  85745. /**
  85746. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85747. * @returns true if this buffer is instanced
  85748. */
  85749. getIsInstanced(): boolean;
  85750. /**
  85751. * Returns the instancing divisor, zero for non-instanced (integer).
  85752. * @returns a number
  85753. */
  85754. getInstanceDivisor(): number;
  85755. /**
  85756. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85757. * @param data defines the data to store
  85758. */
  85759. create(data?: DataArray): void;
  85760. /**
  85761. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85762. * This function will create a new buffer if the current one is not updatable
  85763. * @param data defines the data to store
  85764. */
  85765. update(data: DataArray): void;
  85766. /**
  85767. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85768. * Returns the directly updated WebGLBuffer.
  85769. * @param data the new data
  85770. * @param offset the new offset
  85771. * @param useBytes set to true if the offset is in bytes
  85772. */
  85773. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85774. /**
  85775. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85776. */
  85777. dispose(): void;
  85778. /**
  85779. * Enumerates each value of this vertex buffer as numbers.
  85780. * @param count the number of values to enumerate
  85781. * @param callback the callback function called for each value
  85782. */
  85783. forEach(count: number, callback: (value: number, index: number) => void): void;
  85784. /**
  85785. * Positions
  85786. */
  85787. static readonly PositionKind: string;
  85788. /**
  85789. * Normals
  85790. */
  85791. static readonly NormalKind: string;
  85792. /**
  85793. * Tangents
  85794. */
  85795. static readonly TangentKind: string;
  85796. /**
  85797. * Texture coordinates
  85798. */
  85799. static readonly UVKind: string;
  85800. /**
  85801. * Texture coordinates 2
  85802. */
  85803. static readonly UV2Kind: string;
  85804. /**
  85805. * Texture coordinates 3
  85806. */
  85807. static readonly UV3Kind: string;
  85808. /**
  85809. * Texture coordinates 4
  85810. */
  85811. static readonly UV4Kind: string;
  85812. /**
  85813. * Texture coordinates 5
  85814. */
  85815. static readonly UV5Kind: string;
  85816. /**
  85817. * Texture coordinates 6
  85818. */
  85819. static readonly UV6Kind: string;
  85820. /**
  85821. * Colors
  85822. */
  85823. static readonly ColorKind: string;
  85824. /**
  85825. * Matrix indices (for bones)
  85826. */
  85827. static readonly MatricesIndicesKind: string;
  85828. /**
  85829. * Matrix weights (for bones)
  85830. */
  85831. static readonly MatricesWeightsKind: string;
  85832. /**
  85833. * Additional matrix indices (for bones)
  85834. */
  85835. static readonly MatricesIndicesExtraKind: string;
  85836. /**
  85837. * Additional matrix weights (for bones)
  85838. */
  85839. static readonly MatricesWeightsExtraKind: string;
  85840. /**
  85841. * Deduces the stride given a kind.
  85842. * @param kind The kind string to deduce
  85843. * @returns The deduced stride
  85844. */
  85845. static DeduceStride(kind: string): number;
  85846. /**
  85847. * Gets the byte length of the given type.
  85848. * @param type the type
  85849. * @returns the number of bytes
  85850. */
  85851. static GetTypeByteLength(type: number): number;
  85852. /**
  85853. * Enumerates each value of the given parameters as numbers.
  85854. * @param data the data to enumerate
  85855. * @param byteOffset the byte offset of the data
  85856. * @param byteStride the byte stride of the data
  85857. * @param componentCount the number of components per element
  85858. * @param componentType the type of the component
  85859. * @param count the number of values to enumerate
  85860. * @param normalized whether the data is normalized
  85861. * @param callback the callback function called for each value
  85862. */
  85863. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85864. private static _GetFloatValue;
  85865. }
  85866. }
  85867. declare module BABYLON {
  85868. /**
  85869. * @hidden
  85870. */
  85871. export class IntersectionInfo {
  85872. bu: Nullable<number>;
  85873. bv: Nullable<number>;
  85874. distance: number;
  85875. faceId: number;
  85876. subMeshId: number;
  85877. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85878. }
  85879. }
  85880. declare module BABYLON {
  85881. /**
  85882. * Class used to store bounding sphere information
  85883. */
  85884. export class BoundingSphere {
  85885. /**
  85886. * Gets the center of the bounding sphere in local space
  85887. */
  85888. readonly center: Vector3;
  85889. /**
  85890. * Radius of the bounding sphere in local space
  85891. */
  85892. radius: number;
  85893. /**
  85894. * Gets the center of the bounding sphere in world space
  85895. */
  85896. readonly centerWorld: Vector3;
  85897. /**
  85898. * Radius of the bounding sphere in world space
  85899. */
  85900. radiusWorld: number;
  85901. /**
  85902. * Gets the minimum vector in local space
  85903. */
  85904. readonly minimum: Vector3;
  85905. /**
  85906. * Gets the maximum vector in local space
  85907. */
  85908. readonly maximum: Vector3;
  85909. private _worldMatrix;
  85910. private static readonly TmpVector3;
  85911. /**
  85912. * Creates a new bounding sphere
  85913. * @param min defines the minimum vector (in local space)
  85914. * @param max defines the maximum vector (in local space)
  85915. * @param worldMatrix defines the new world matrix
  85916. */
  85917. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85918. /**
  85919. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85920. * @param min defines the new minimum vector (in local space)
  85921. * @param max defines the new maximum vector (in local space)
  85922. * @param worldMatrix defines the new world matrix
  85923. */
  85924. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85925. /**
  85926. * Scale the current bounding sphere by applying a scale factor
  85927. * @param factor defines the scale factor to apply
  85928. * @returns the current bounding box
  85929. */
  85930. scale(factor: number): BoundingSphere;
  85931. /**
  85932. * Gets the world matrix of the bounding box
  85933. * @returns a matrix
  85934. */
  85935. getWorldMatrix(): DeepImmutable<Matrix>;
  85936. /** @hidden */
  85937. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85938. /**
  85939. * Tests if the bounding sphere is intersecting the frustum planes
  85940. * @param frustumPlanes defines the frustum planes to test
  85941. * @returns true if there is an intersection
  85942. */
  85943. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85944. /**
  85945. * Tests if the bounding sphere center is in between the frustum planes.
  85946. * Used for optimistic fast inclusion.
  85947. * @param frustumPlanes defines the frustum planes to test
  85948. * @returns true if the sphere center is in between the frustum planes
  85949. */
  85950. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85951. /**
  85952. * Tests if a point is inside the bounding sphere
  85953. * @param point defines the point to test
  85954. * @returns true if the point is inside the bounding sphere
  85955. */
  85956. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85957. /**
  85958. * Checks if two sphere intersct
  85959. * @param sphere0 sphere 0
  85960. * @param sphere1 sphere 1
  85961. * @returns true if the speres intersect
  85962. */
  85963. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85964. }
  85965. }
  85966. declare module BABYLON {
  85967. /**
  85968. * Class used to store bounding box information
  85969. */
  85970. export class BoundingBox implements ICullable {
  85971. /**
  85972. * Gets the 8 vectors representing the bounding box in local space
  85973. */
  85974. readonly vectors: Vector3[];
  85975. /**
  85976. * Gets the center of the bounding box in local space
  85977. */
  85978. readonly center: Vector3;
  85979. /**
  85980. * Gets the center of the bounding box in world space
  85981. */
  85982. readonly centerWorld: Vector3;
  85983. /**
  85984. * Gets the extend size in local space
  85985. */
  85986. readonly extendSize: Vector3;
  85987. /**
  85988. * Gets the extend size in world space
  85989. */
  85990. readonly extendSizeWorld: Vector3;
  85991. /**
  85992. * Gets the OBB (object bounding box) directions
  85993. */
  85994. readonly directions: Vector3[];
  85995. /**
  85996. * Gets the 8 vectors representing the bounding box in world space
  85997. */
  85998. readonly vectorsWorld: Vector3[];
  85999. /**
  86000. * Gets the minimum vector in world space
  86001. */
  86002. readonly minimumWorld: Vector3;
  86003. /**
  86004. * Gets the maximum vector in world space
  86005. */
  86006. readonly maximumWorld: Vector3;
  86007. /**
  86008. * Gets the minimum vector in local space
  86009. */
  86010. readonly minimum: Vector3;
  86011. /**
  86012. * Gets the maximum vector in local space
  86013. */
  86014. readonly maximum: Vector3;
  86015. private _worldMatrix;
  86016. private static readonly TmpVector3;
  86017. /**
  86018. * @hidden
  86019. */
  86020. _tag: number;
  86021. /**
  86022. * Creates a new bounding box
  86023. * @param min defines the minimum vector (in local space)
  86024. * @param max defines the maximum vector (in local space)
  86025. * @param worldMatrix defines the new world matrix
  86026. */
  86027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86028. /**
  86029. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86030. * @param min defines the new minimum vector (in local space)
  86031. * @param max defines the new maximum vector (in local space)
  86032. * @param worldMatrix defines the new world matrix
  86033. */
  86034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86035. /**
  86036. * Scale the current bounding box by applying a scale factor
  86037. * @param factor defines the scale factor to apply
  86038. * @returns the current bounding box
  86039. */
  86040. scale(factor: number): BoundingBox;
  86041. /**
  86042. * Gets the world matrix of the bounding box
  86043. * @returns a matrix
  86044. */
  86045. getWorldMatrix(): DeepImmutable<Matrix>;
  86046. /** @hidden */
  86047. _update(world: DeepImmutable<Matrix>): void;
  86048. /**
  86049. * Tests if the bounding box is intersecting the frustum planes
  86050. * @param frustumPlanes defines the frustum planes to test
  86051. * @returns true if there is an intersection
  86052. */
  86053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86054. /**
  86055. * Tests if the bounding box is entirely inside the frustum planes
  86056. * @param frustumPlanes defines the frustum planes to test
  86057. * @returns true if there is an inclusion
  86058. */
  86059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86060. /**
  86061. * Tests if a point is inside the bounding box
  86062. * @param point defines the point to test
  86063. * @returns true if the point is inside the bounding box
  86064. */
  86065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86066. /**
  86067. * Tests if the bounding box intersects with a bounding sphere
  86068. * @param sphere defines the sphere to test
  86069. * @returns true if there is an intersection
  86070. */
  86071. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86072. /**
  86073. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86074. * @param min defines the min vector to use
  86075. * @param max defines the max vector to use
  86076. * @returns true if there is an intersection
  86077. */
  86078. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86079. /**
  86080. * Tests if two bounding boxes are intersections
  86081. * @param box0 defines the first box to test
  86082. * @param box1 defines the second box to test
  86083. * @returns true if there is an intersection
  86084. */
  86085. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86086. /**
  86087. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86088. * @param minPoint defines the minimum vector of the bounding box
  86089. * @param maxPoint defines the maximum vector of the bounding box
  86090. * @param sphereCenter defines the sphere center
  86091. * @param sphereRadius defines the sphere radius
  86092. * @returns true if there is an intersection
  86093. */
  86094. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86095. /**
  86096. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86098. * @param frustumPlanes defines the frustum planes to test
  86099. * @return true if there is an inclusion
  86100. */
  86101. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86102. /**
  86103. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86105. * @param frustumPlanes defines the frustum planes to test
  86106. * @return true if there is an intersection
  86107. */
  86108. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86109. }
  86110. }
  86111. declare module BABYLON {
  86112. /** @hidden */
  86113. export class Collider {
  86114. /** Define if a collision was found */
  86115. collisionFound: boolean;
  86116. /**
  86117. * Define last intersection point in local space
  86118. */
  86119. intersectionPoint: Vector3;
  86120. /**
  86121. * Define last collided mesh
  86122. */
  86123. collidedMesh: Nullable<AbstractMesh>;
  86124. private _collisionPoint;
  86125. private _planeIntersectionPoint;
  86126. private _tempVector;
  86127. private _tempVector2;
  86128. private _tempVector3;
  86129. private _tempVector4;
  86130. private _edge;
  86131. private _baseToVertex;
  86132. private _destinationPoint;
  86133. private _slidePlaneNormal;
  86134. private _displacementVector;
  86135. /** @hidden */
  86136. _radius: Vector3;
  86137. /** @hidden */
  86138. _retry: number;
  86139. private _velocity;
  86140. private _basePoint;
  86141. private _epsilon;
  86142. /** @hidden */
  86143. _velocityWorldLength: number;
  86144. /** @hidden */
  86145. _basePointWorld: Vector3;
  86146. private _velocityWorld;
  86147. private _normalizedVelocity;
  86148. /** @hidden */
  86149. _initialVelocity: Vector3;
  86150. /** @hidden */
  86151. _initialPosition: Vector3;
  86152. private _nearestDistance;
  86153. private _collisionMask;
  86154. get collisionMask(): number;
  86155. set collisionMask(mask: number);
  86156. /**
  86157. * Gets the plane normal used to compute the sliding response (in local space)
  86158. */
  86159. get slidePlaneNormal(): Vector3;
  86160. /** @hidden */
  86161. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86162. /** @hidden */
  86163. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86164. /** @hidden */
  86165. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86166. /** @hidden */
  86167. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86168. /** @hidden */
  86169. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86170. /** @hidden */
  86171. _getResponse(pos: Vector3, vel: Vector3): void;
  86172. }
  86173. }
  86174. declare module BABYLON {
  86175. /**
  86176. * Interface for cullable objects
  86177. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86178. */
  86179. export interface ICullable {
  86180. /**
  86181. * Checks if the object or part of the object is in the frustum
  86182. * @param frustumPlanes Camera near/planes
  86183. * @returns true if the object is in frustum otherwise false
  86184. */
  86185. isInFrustum(frustumPlanes: Plane[]): boolean;
  86186. /**
  86187. * Checks if a cullable object (mesh...) is in the camera frustum
  86188. * Unlike isInFrustum this cheks the full bounding box
  86189. * @param frustumPlanes Camera near/planes
  86190. * @returns true if the object is in frustum otherwise false
  86191. */
  86192. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86193. }
  86194. /**
  86195. * Info for a bounding data of a mesh
  86196. */
  86197. export class BoundingInfo implements ICullable {
  86198. /**
  86199. * Bounding box for the mesh
  86200. */
  86201. readonly boundingBox: BoundingBox;
  86202. /**
  86203. * Bounding sphere for the mesh
  86204. */
  86205. readonly boundingSphere: BoundingSphere;
  86206. private _isLocked;
  86207. private static readonly TmpVector3;
  86208. /**
  86209. * Constructs bounding info
  86210. * @param minimum min vector of the bounding box/sphere
  86211. * @param maximum max vector of the bounding box/sphere
  86212. * @param worldMatrix defines the new world matrix
  86213. */
  86214. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86215. /**
  86216. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86217. * @param min defines the new minimum vector (in local space)
  86218. * @param max defines the new maximum vector (in local space)
  86219. * @param worldMatrix defines the new world matrix
  86220. */
  86221. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86222. /**
  86223. * min vector of the bounding box/sphere
  86224. */
  86225. get minimum(): Vector3;
  86226. /**
  86227. * max vector of the bounding box/sphere
  86228. */
  86229. get maximum(): Vector3;
  86230. /**
  86231. * If the info is locked and won't be updated to avoid perf overhead
  86232. */
  86233. get isLocked(): boolean;
  86234. set isLocked(value: boolean);
  86235. /**
  86236. * Updates the bounding sphere and box
  86237. * @param world world matrix to be used to update
  86238. */
  86239. update(world: DeepImmutable<Matrix>): void;
  86240. /**
  86241. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86242. * @param center New center of the bounding info
  86243. * @param extend New extend of the bounding info
  86244. * @returns the current bounding info
  86245. */
  86246. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86247. /**
  86248. * Scale the current bounding info by applying a scale factor
  86249. * @param factor defines the scale factor to apply
  86250. * @returns the current bounding info
  86251. */
  86252. scale(factor: number): BoundingInfo;
  86253. /**
  86254. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86255. * @param frustumPlanes defines the frustum to test
  86256. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86257. * @returns true if the bounding info is in the frustum planes
  86258. */
  86259. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86260. /**
  86261. * Gets the world distance between the min and max points of the bounding box
  86262. */
  86263. get diagonalLength(): number;
  86264. /**
  86265. * Checks if a cullable object (mesh...) is in the camera frustum
  86266. * Unlike isInFrustum this cheks the full bounding box
  86267. * @param frustumPlanes Camera near/planes
  86268. * @returns true if the object is in frustum otherwise false
  86269. */
  86270. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86271. /** @hidden */
  86272. _checkCollision(collider: Collider): boolean;
  86273. /**
  86274. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86275. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86276. * @param point the point to check intersection with
  86277. * @returns if the point intersects
  86278. */
  86279. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86280. /**
  86281. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86282. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86283. * @param boundingInfo the bounding info to check intersection with
  86284. * @param precise if the intersection should be done using OBB
  86285. * @returns if the bounding info intersects
  86286. */
  86287. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86288. }
  86289. }
  86290. declare module BABYLON {
  86291. /**
  86292. * Extracts minimum and maximum values from a list of indexed positions
  86293. * @param positions defines the positions to use
  86294. * @param indices defines the indices to the positions
  86295. * @param indexStart defines the start index
  86296. * @param indexCount defines the end index
  86297. * @param bias defines bias value to add to the result
  86298. * @return minimum and maximum values
  86299. */
  86300. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86301. minimum: Vector3;
  86302. maximum: Vector3;
  86303. };
  86304. /**
  86305. * Extracts minimum and maximum values from a list of positions
  86306. * @param positions defines the positions to use
  86307. * @param start defines the start index in the positions array
  86308. * @param count defines the number of positions to handle
  86309. * @param bias defines bias value to add to the result
  86310. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86311. * @return minimum and maximum values
  86312. */
  86313. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86314. minimum: Vector3;
  86315. maximum: Vector3;
  86316. };
  86317. }
  86318. declare module BABYLON {
  86319. /** @hidden */
  86320. export class WebGLDataBuffer extends DataBuffer {
  86321. private _buffer;
  86322. constructor(resource: WebGLBuffer);
  86323. get underlyingResource(): any;
  86324. }
  86325. }
  86326. declare module BABYLON {
  86327. /** @hidden */
  86328. export class WebGLPipelineContext implements IPipelineContext {
  86329. engine: ThinEngine;
  86330. program: Nullable<WebGLProgram>;
  86331. context?: WebGLRenderingContext;
  86332. vertexShader?: WebGLShader;
  86333. fragmentShader?: WebGLShader;
  86334. isParallelCompiled: boolean;
  86335. onCompiled?: () => void;
  86336. transformFeedback?: WebGLTransformFeedback | null;
  86337. vertexCompilationError: Nullable<string>;
  86338. fragmentCompilationError: Nullable<string>;
  86339. programLinkError: Nullable<string>;
  86340. programValidationError: Nullable<string>;
  86341. get isAsync(): boolean;
  86342. get isReady(): boolean;
  86343. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86344. _getVertexShaderCode(): string | null;
  86345. _getFragmentShaderCode(): string | null;
  86346. }
  86347. }
  86348. declare module BABYLON {
  86349. interface ThinEngine {
  86350. /**
  86351. * Create an uniform buffer
  86352. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86353. * @param elements defines the content of the uniform buffer
  86354. * @returns the webGL uniform buffer
  86355. */
  86356. createUniformBuffer(elements: FloatArray): DataBuffer;
  86357. /**
  86358. * Create a dynamic uniform buffer
  86359. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86360. * @param elements defines the content of the uniform buffer
  86361. * @returns the webGL uniform buffer
  86362. */
  86363. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86364. /**
  86365. * Update an existing uniform buffer
  86366. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86367. * @param uniformBuffer defines the target uniform buffer
  86368. * @param elements defines the content to update
  86369. * @param offset defines the offset in the uniform buffer where update should start
  86370. * @param count defines the size of the data to update
  86371. */
  86372. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86373. /**
  86374. * Bind an uniform buffer to the current webGL context
  86375. * @param buffer defines the buffer to bind
  86376. */
  86377. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86378. /**
  86379. * Bind a buffer to the current webGL context at a given location
  86380. * @param buffer defines the buffer to bind
  86381. * @param location defines the index where to bind the buffer
  86382. */
  86383. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86384. /**
  86385. * Bind a specific block at a given index in a specific shader program
  86386. * @param pipelineContext defines the pipeline context to use
  86387. * @param blockName defines the block name
  86388. * @param index defines the index where to bind the block
  86389. */
  86390. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /**
  86395. * Uniform buffer objects.
  86396. *
  86397. * Handles blocks of uniform on the GPU.
  86398. *
  86399. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86400. *
  86401. * For more information, please refer to :
  86402. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86403. */
  86404. export class UniformBuffer {
  86405. private _engine;
  86406. private _buffer;
  86407. private _data;
  86408. private _bufferData;
  86409. private _dynamic?;
  86410. private _uniformLocations;
  86411. private _uniformSizes;
  86412. private _uniformLocationPointer;
  86413. private _needSync;
  86414. private _noUBO;
  86415. private _currentEffect;
  86416. /** @hidden */
  86417. _alreadyBound: boolean;
  86418. private static _MAX_UNIFORM_SIZE;
  86419. private static _tempBuffer;
  86420. /**
  86421. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86422. * This is dynamic to allow compat with webgl 1 and 2.
  86423. * You will need to pass the name of the uniform as well as the value.
  86424. */
  86425. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86426. /**
  86427. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86428. * This is dynamic to allow compat with webgl 1 and 2.
  86429. * You will need to pass the name of the uniform as well as the value.
  86430. */
  86431. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86432. /**
  86433. * Lambda to Update a single float in a uniform buffer.
  86434. * This is dynamic to allow compat with webgl 1 and 2.
  86435. * You will need to pass the name of the uniform as well as the value.
  86436. */
  86437. updateFloat: (name: string, x: number) => void;
  86438. /**
  86439. * Lambda to Update a vec2 of float in a uniform buffer.
  86440. * This is dynamic to allow compat with webgl 1 and 2.
  86441. * You will need to pass the name of the uniform as well as the value.
  86442. */
  86443. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86444. /**
  86445. * Lambda to Update a vec3 of float in a uniform buffer.
  86446. * This is dynamic to allow compat with webgl 1 and 2.
  86447. * You will need to pass the name of the uniform as well as the value.
  86448. */
  86449. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86450. /**
  86451. * Lambda to Update a vec4 of float in a uniform buffer.
  86452. * This is dynamic to allow compat with webgl 1 and 2.
  86453. * You will need to pass the name of the uniform as well as the value.
  86454. */
  86455. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86456. /**
  86457. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86458. * This is dynamic to allow compat with webgl 1 and 2.
  86459. * You will need to pass the name of the uniform as well as the value.
  86460. */
  86461. updateMatrix: (name: string, mat: Matrix) => void;
  86462. /**
  86463. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86464. * This is dynamic to allow compat with webgl 1 and 2.
  86465. * You will need to pass the name of the uniform as well as the value.
  86466. */
  86467. updateVector3: (name: string, vector: Vector3) => void;
  86468. /**
  86469. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86470. * This is dynamic to allow compat with webgl 1 and 2.
  86471. * You will need to pass the name of the uniform as well as the value.
  86472. */
  86473. updateVector4: (name: string, vector: Vector4) => void;
  86474. /**
  86475. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86476. * This is dynamic to allow compat with webgl 1 and 2.
  86477. * You will need to pass the name of the uniform as well as the value.
  86478. */
  86479. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86480. /**
  86481. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86482. * This is dynamic to allow compat with webgl 1 and 2.
  86483. * You will need to pass the name of the uniform as well as the value.
  86484. */
  86485. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86486. /**
  86487. * Instantiates a new Uniform buffer objects.
  86488. *
  86489. * Handles blocks of uniform on the GPU.
  86490. *
  86491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86492. *
  86493. * For more information, please refer to :
  86494. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86495. * @param engine Define the engine the buffer is associated with
  86496. * @param data Define the data contained in the buffer
  86497. * @param dynamic Define if the buffer is updatable
  86498. */
  86499. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86500. /**
  86501. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86502. * or just falling back on setUniformXXX calls.
  86503. */
  86504. get useUbo(): boolean;
  86505. /**
  86506. * Indicates if the WebGL underlying uniform buffer is in sync
  86507. * with the javascript cache data.
  86508. */
  86509. get isSync(): boolean;
  86510. /**
  86511. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86512. * Also, a dynamic UniformBuffer will disable cache verification and always
  86513. * update the underlying WebGL uniform buffer to the GPU.
  86514. * @returns if Dynamic, otherwise false
  86515. */
  86516. isDynamic(): boolean;
  86517. /**
  86518. * The data cache on JS side.
  86519. * @returns the underlying data as a float array
  86520. */
  86521. getData(): Float32Array;
  86522. /**
  86523. * The underlying WebGL Uniform buffer.
  86524. * @returns the webgl buffer
  86525. */
  86526. getBuffer(): Nullable<DataBuffer>;
  86527. /**
  86528. * std140 layout specifies how to align data within an UBO structure.
  86529. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86530. * for specs.
  86531. */
  86532. private _fillAlignment;
  86533. /**
  86534. * Adds an uniform in the buffer.
  86535. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86536. * for the layout to be correct !
  86537. * @param name Name of the uniform, as used in the uniform block in the shader.
  86538. * @param size Data size, or data directly.
  86539. */
  86540. addUniform(name: string, size: number | number[]): void;
  86541. /**
  86542. * Adds a Matrix 4x4 to the uniform buffer.
  86543. * @param name Name of the uniform, as used in the uniform block in the shader.
  86544. * @param mat A 4x4 matrix.
  86545. */
  86546. addMatrix(name: string, mat: Matrix): void;
  86547. /**
  86548. * Adds a vec2 to the uniform buffer.
  86549. * @param name Name of the uniform, as used in the uniform block in the shader.
  86550. * @param x Define the x component value of the vec2
  86551. * @param y Define the y component value of the vec2
  86552. */
  86553. addFloat2(name: string, x: number, y: number): void;
  86554. /**
  86555. * Adds a vec3 to the uniform buffer.
  86556. * @param name Name of the uniform, as used in the uniform block in the shader.
  86557. * @param x Define the x component value of the vec3
  86558. * @param y Define the y component value of the vec3
  86559. * @param z Define the z component value of the vec3
  86560. */
  86561. addFloat3(name: string, x: number, y: number, z: number): void;
  86562. /**
  86563. * Adds a vec3 to the uniform buffer.
  86564. * @param name Name of the uniform, as used in the uniform block in the shader.
  86565. * @param color Define the vec3 from a Color
  86566. */
  86567. addColor3(name: string, color: Color3): void;
  86568. /**
  86569. * Adds a vec4 to the uniform buffer.
  86570. * @param name Name of the uniform, as used in the uniform block in the shader.
  86571. * @param color Define the rgb components from a Color
  86572. * @param alpha Define the a component of the vec4
  86573. */
  86574. addColor4(name: string, color: Color3, alpha: number): void;
  86575. /**
  86576. * Adds a vec3 to the uniform buffer.
  86577. * @param name Name of the uniform, as used in the uniform block in the shader.
  86578. * @param vector Define the vec3 components from a Vector
  86579. */
  86580. addVector3(name: string, vector: Vector3): void;
  86581. /**
  86582. * Adds a Matrix 3x3 to the uniform buffer.
  86583. * @param name Name of the uniform, as used in the uniform block in the shader.
  86584. */
  86585. addMatrix3x3(name: string): void;
  86586. /**
  86587. * Adds a Matrix 2x2 to the uniform buffer.
  86588. * @param name Name of the uniform, as used in the uniform block in the shader.
  86589. */
  86590. addMatrix2x2(name: string): void;
  86591. /**
  86592. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86593. */
  86594. create(): void;
  86595. /** @hidden */
  86596. _rebuild(): void;
  86597. /**
  86598. * Updates the WebGL Uniform Buffer on the GPU.
  86599. * If the `dynamic` flag is set to true, no cache comparison is done.
  86600. * Otherwise, the buffer will be updated only if the cache differs.
  86601. */
  86602. update(): void;
  86603. /**
  86604. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86605. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86606. * @param data Define the flattened data
  86607. * @param size Define the size of the data.
  86608. */
  86609. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86610. private _valueCache;
  86611. private _cacheMatrix;
  86612. private _updateMatrix3x3ForUniform;
  86613. private _updateMatrix3x3ForEffect;
  86614. private _updateMatrix2x2ForEffect;
  86615. private _updateMatrix2x2ForUniform;
  86616. private _updateFloatForEffect;
  86617. private _updateFloatForUniform;
  86618. private _updateFloat2ForEffect;
  86619. private _updateFloat2ForUniform;
  86620. private _updateFloat3ForEffect;
  86621. private _updateFloat3ForUniform;
  86622. private _updateFloat4ForEffect;
  86623. private _updateFloat4ForUniform;
  86624. private _updateMatrixForEffect;
  86625. private _updateMatrixForUniform;
  86626. private _updateVector3ForEffect;
  86627. private _updateVector3ForUniform;
  86628. private _updateVector4ForEffect;
  86629. private _updateVector4ForUniform;
  86630. private _updateColor3ForEffect;
  86631. private _updateColor3ForUniform;
  86632. private _updateColor4ForEffect;
  86633. private _updateColor4ForUniform;
  86634. /**
  86635. * Sets a sampler uniform on the effect.
  86636. * @param name Define the name of the sampler.
  86637. * @param texture Define the texture to set in the sampler
  86638. */
  86639. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86640. /**
  86641. * Directly updates the value of the uniform in the cache AND on the GPU.
  86642. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86643. * @param data Define the flattened data
  86644. */
  86645. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86646. /**
  86647. * Binds this uniform buffer to an effect.
  86648. * @param effect Define the effect to bind the buffer to
  86649. * @param name Name of the uniform block in the shader.
  86650. */
  86651. bindToEffect(effect: Effect, name: string): void;
  86652. /**
  86653. * Disposes the uniform buffer.
  86654. */
  86655. dispose(): void;
  86656. }
  86657. }
  86658. declare module BABYLON {
  86659. /**
  86660. * Enum that determines the text-wrapping mode to use.
  86661. */
  86662. export enum InspectableType {
  86663. /**
  86664. * Checkbox for booleans
  86665. */
  86666. Checkbox = 0,
  86667. /**
  86668. * Sliders for numbers
  86669. */
  86670. Slider = 1,
  86671. /**
  86672. * Vector3
  86673. */
  86674. Vector3 = 2,
  86675. /**
  86676. * Quaternions
  86677. */
  86678. Quaternion = 3,
  86679. /**
  86680. * Color3
  86681. */
  86682. Color3 = 4,
  86683. /**
  86684. * String
  86685. */
  86686. String = 5
  86687. }
  86688. /**
  86689. * Interface used to define custom inspectable properties.
  86690. * This interface is used by the inspector to display custom property grids
  86691. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86692. */
  86693. export interface IInspectable {
  86694. /**
  86695. * Gets the label to display
  86696. */
  86697. label: string;
  86698. /**
  86699. * Gets the name of the property to edit
  86700. */
  86701. propertyName: string;
  86702. /**
  86703. * Gets the type of the editor to use
  86704. */
  86705. type: InspectableType;
  86706. /**
  86707. * Gets the minimum value of the property when using in "slider" mode
  86708. */
  86709. min?: number;
  86710. /**
  86711. * Gets the maximum value of the property when using in "slider" mode
  86712. */
  86713. max?: number;
  86714. /**
  86715. * Gets the setp to use when using in "slider" mode
  86716. */
  86717. step?: number;
  86718. }
  86719. }
  86720. declare module BABYLON {
  86721. /**
  86722. * Class used to provide helper for timing
  86723. */
  86724. export class TimingTools {
  86725. /**
  86726. * Polyfill for setImmediate
  86727. * @param action defines the action to execute after the current execution block
  86728. */
  86729. static SetImmediate(action: () => void): void;
  86730. }
  86731. }
  86732. declare module BABYLON {
  86733. /**
  86734. * Class used to enable instatition of objects by class name
  86735. */
  86736. export class InstantiationTools {
  86737. /**
  86738. * Use this object to register external classes like custom textures or material
  86739. * to allow the laoders to instantiate them
  86740. */
  86741. static RegisteredExternalClasses: {
  86742. [key: string]: Object;
  86743. };
  86744. /**
  86745. * Tries to instantiate a new object from a given class name
  86746. * @param className defines the class name to instantiate
  86747. * @returns the new object or null if the system was not able to do the instantiation
  86748. */
  86749. static Instantiate(className: string): any;
  86750. }
  86751. }
  86752. declare module BABYLON {
  86753. /**
  86754. * Define options used to create a depth texture
  86755. */
  86756. export class DepthTextureCreationOptions {
  86757. /** Specifies whether or not a stencil should be allocated in the texture */
  86758. generateStencil?: boolean;
  86759. /** Specifies whether or not bilinear filtering is enable on the texture */
  86760. bilinearFiltering?: boolean;
  86761. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86762. comparisonFunction?: number;
  86763. /** Specifies if the created texture is a cube texture */
  86764. isCube?: boolean;
  86765. }
  86766. }
  86767. declare module BABYLON {
  86768. interface ThinEngine {
  86769. /**
  86770. * Creates a depth stencil cube texture.
  86771. * This is only available in WebGL 2.
  86772. * @param size The size of face edge in the cube texture.
  86773. * @param options The options defining the cube texture.
  86774. * @returns The cube texture
  86775. */
  86776. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86777. /**
  86778. * Creates a cube texture
  86779. * @param rootUrl defines the url where the files to load is located
  86780. * @param scene defines the current scene
  86781. * @param files defines the list of files to load (1 per face)
  86782. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86783. * @param onLoad defines an optional callback raised when the texture is loaded
  86784. * @param onError defines an optional callback raised if there is an issue to load the texture
  86785. * @param format defines the format of the data
  86786. * @param forcedExtension defines the extension to use to pick the right loader
  86787. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86788. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86789. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86790. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86791. * @returns the cube texture as an InternalTexture
  86792. */
  86793. 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;
  86794. /**
  86795. * Creates a cube texture
  86796. * @param rootUrl defines the url where the files to load is located
  86797. * @param scene defines the current scene
  86798. * @param files defines the list of files to load (1 per face)
  86799. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86800. * @param onLoad defines an optional callback raised when the texture is loaded
  86801. * @param onError defines an optional callback raised if there is an issue to load the texture
  86802. * @param format defines the format of the data
  86803. * @param forcedExtension defines the extension to use to pick the right loader
  86804. * @returns the cube texture as an InternalTexture
  86805. */
  86806. 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;
  86807. /**
  86808. * Creates a cube texture
  86809. * @param rootUrl defines the url where the files to load is located
  86810. * @param scene defines the current scene
  86811. * @param files defines the list of files to load (1 per face)
  86812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86813. * @param onLoad defines an optional callback raised when the texture is loaded
  86814. * @param onError defines an optional callback raised if there is an issue to load the texture
  86815. * @param format defines the format of the data
  86816. * @param forcedExtension defines the extension to use to pick the right loader
  86817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86820. * @returns the cube texture as an InternalTexture
  86821. */
  86822. 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;
  86823. /** @hidden */
  86824. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86825. /** @hidden */
  86826. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86827. /** @hidden */
  86828. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86829. /** @hidden */
  86830. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86831. /**
  86832. * @hidden
  86833. */
  86834. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86835. }
  86836. }
  86837. declare module BABYLON {
  86838. /**
  86839. * Class for creating a cube texture
  86840. */
  86841. export class CubeTexture extends BaseTexture {
  86842. private _delayedOnLoad;
  86843. /**
  86844. * Observable triggered once the texture has been loaded.
  86845. */
  86846. onLoadObservable: Observable<CubeTexture>;
  86847. /**
  86848. * The url of the texture
  86849. */
  86850. url: string;
  86851. /**
  86852. * Gets or sets the center of the bounding box associated with the cube texture.
  86853. * It must define where the camera used to render the texture was set
  86854. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86855. */
  86856. boundingBoxPosition: Vector3;
  86857. private _boundingBoxSize;
  86858. /**
  86859. * Gets or sets the size of the bounding box associated with the cube texture
  86860. * When defined, the cubemap will switch to local mode
  86861. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86862. * @example https://www.babylonjs-playground.com/#RNASML
  86863. */
  86864. set boundingBoxSize(value: Vector3);
  86865. /**
  86866. * Returns the bounding box size
  86867. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86868. */
  86869. get boundingBoxSize(): Vector3;
  86870. protected _rotationY: number;
  86871. /**
  86872. * Sets texture matrix rotation angle around Y axis in radians.
  86873. */
  86874. set rotationY(value: number);
  86875. /**
  86876. * Gets texture matrix rotation angle around Y axis radians.
  86877. */
  86878. get rotationY(): number;
  86879. /**
  86880. * Are mip maps generated for this texture or not.
  86881. */
  86882. get noMipmap(): boolean;
  86883. private _noMipmap;
  86884. private _files;
  86885. protected _forcedExtension: Nullable<string>;
  86886. private _extensions;
  86887. private _textureMatrix;
  86888. private _format;
  86889. private _createPolynomials;
  86890. /**
  86891. * Creates a cube texture from an array of image urls
  86892. * @param files defines an array of image urls
  86893. * @param scene defines the hosting scene
  86894. * @param noMipmap specifies if mip maps are not used
  86895. * @returns a cube texture
  86896. */
  86897. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86898. /**
  86899. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86900. * @param url defines the url of the prefiltered texture
  86901. * @param scene defines the scene the texture is attached to
  86902. * @param forcedExtension defines the extension of the file if different from the url
  86903. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86904. * @return the prefiltered texture
  86905. */
  86906. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86907. /**
  86908. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86909. * as prefiltered data.
  86910. * @param rootUrl defines the url of the texture or the root name of the six images
  86911. * @param null defines the scene or engine the texture is attached to
  86912. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86913. * @param noMipmap defines if mipmaps should be created or not
  86914. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86915. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86916. * @param onError defines a callback triggered in case of error during load
  86917. * @param format defines the internal format to use for the texture once loaded
  86918. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86919. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86920. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86921. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86922. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86923. * @return the cube texture
  86924. */
  86925. 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);
  86926. /**
  86927. * Get the current class name of the texture useful for serialization or dynamic coding.
  86928. * @returns "CubeTexture"
  86929. */
  86930. getClassName(): string;
  86931. /**
  86932. * Update the url (and optional buffer) of this texture if url was null during construction.
  86933. * @param url the url of the texture
  86934. * @param forcedExtension defines the extension to use
  86935. * @param onLoad callback called when the texture is loaded (defaults to null)
  86936. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86937. */
  86938. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86939. /**
  86940. * Delays loading of the cube texture
  86941. * @param forcedExtension defines the extension to use
  86942. */
  86943. delayLoad(forcedExtension?: string): void;
  86944. /**
  86945. * Returns the reflection texture matrix
  86946. * @returns the reflection texture matrix
  86947. */
  86948. getReflectionTextureMatrix(): Matrix;
  86949. /**
  86950. * Sets the reflection texture matrix
  86951. * @param value Reflection texture matrix
  86952. */
  86953. setReflectionTextureMatrix(value: Matrix): void;
  86954. /**
  86955. * Parses text to create a cube texture
  86956. * @param parsedTexture define the serialized text to read from
  86957. * @param scene defines the hosting scene
  86958. * @param rootUrl defines the root url of the cube texture
  86959. * @returns a cube texture
  86960. */
  86961. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86962. /**
  86963. * Makes a clone, or deep copy, of the cube texture
  86964. * @returns a new cube texture
  86965. */
  86966. clone(): CubeTexture;
  86967. }
  86968. }
  86969. declare module BABYLON {
  86970. /**
  86971. * Manages the defines for the Material
  86972. */
  86973. export class MaterialDefines {
  86974. /** @hidden */
  86975. protected _keys: string[];
  86976. private _isDirty;
  86977. /** @hidden */
  86978. _renderId: number;
  86979. /** @hidden */
  86980. _areLightsDirty: boolean;
  86981. /** @hidden */
  86982. _areLightsDisposed: boolean;
  86983. /** @hidden */
  86984. _areAttributesDirty: boolean;
  86985. /** @hidden */
  86986. _areTexturesDirty: boolean;
  86987. /** @hidden */
  86988. _areFresnelDirty: boolean;
  86989. /** @hidden */
  86990. _areMiscDirty: boolean;
  86991. /** @hidden */
  86992. _areImageProcessingDirty: boolean;
  86993. /** @hidden */
  86994. _normals: boolean;
  86995. /** @hidden */
  86996. _uvs: boolean;
  86997. /** @hidden */
  86998. _needNormals: boolean;
  86999. /** @hidden */
  87000. _needUVs: boolean;
  87001. [id: string]: any;
  87002. /**
  87003. * Specifies if the material needs to be re-calculated
  87004. */
  87005. get isDirty(): boolean;
  87006. /**
  87007. * Marks the material to indicate that it has been re-calculated
  87008. */
  87009. markAsProcessed(): void;
  87010. /**
  87011. * Marks the material to indicate that it needs to be re-calculated
  87012. */
  87013. markAsUnprocessed(): void;
  87014. /**
  87015. * Marks the material to indicate all of its defines need to be re-calculated
  87016. */
  87017. markAllAsDirty(): void;
  87018. /**
  87019. * Marks the material to indicate that image processing needs to be re-calculated
  87020. */
  87021. markAsImageProcessingDirty(): void;
  87022. /**
  87023. * Marks the material to indicate the lights need to be re-calculated
  87024. * @param disposed Defines whether the light is dirty due to dispose or not
  87025. */
  87026. markAsLightDirty(disposed?: boolean): void;
  87027. /**
  87028. * Marks the attribute state as changed
  87029. */
  87030. markAsAttributesDirty(): void;
  87031. /**
  87032. * Marks the texture state as changed
  87033. */
  87034. markAsTexturesDirty(): void;
  87035. /**
  87036. * Marks the fresnel state as changed
  87037. */
  87038. markAsFresnelDirty(): void;
  87039. /**
  87040. * Marks the misc state as changed
  87041. */
  87042. markAsMiscDirty(): void;
  87043. /**
  87044. * Rebuilds the material defines
  87045. */
  87046. rebuild(): void;
  87047. /**
  87048. * Specifies if two material defines are equal
  87049. * @param other - A material define instance to compare to
  87050. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87051. */
  87052. isEqual(other: MaterialDefines): boolean;
  87053. /**
  87054. * Clones this instance's defines to another instance
  87055. * @param other - material defines to clone values to
  87056. */
  87057. cloneTo(other: MaterialDefines): void;
  87058. /**
  87059. * Resets the material define values
  87060. */
  87061. reset(): void;
  87062. /**
  87063. * Converts the material define values to a string
  87064. * @returns - String of material define information
  87065. */
  87066. toString(): string;
  87067. }
  87068. }
  87069. declare module BABYLON {
  87070. /**
  87071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87073. * 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;
  87074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87075. */
  87076. export class ColorCurves {
  87077. private _dirty;
  87078. private _tempColor;
  87079. private _globalCurve;
  87080. private _highlightsCurve;
  87081. private _midtonesCurve;
  87082. private _shadowsCurve;
  87083. private _positiveCurve;
  87084. private _negativeCurve;
  87085. private _globalHue;
  87086. private _globalDensity;
  87087. private _globalSaturation;
  87088. private _globalExposure;
  87089. /**
  87090. * Gets the global Hue value.
  87091. * 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).
  87092. */
  87093. get globalHue(): number;
  87094. /**
  87095. * Sets the global Hue value.
  87096. * 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).
  87097. */
  87098. set globalHue(value: number);
  87099. /**
  87100. * Gets the global Density value.
  87101. * 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.
  87102. * Values less than zero provide a filter of opposite hue.
  87103. */
  87104. get globalDensity(): number;
  87105. /**
  87106. * Sets the global Density value.
  87107. * 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.
  87108. * Values less than zero provide a filter of opposite hue.
  87109. */
  87110. set globalDensity(value: number);
  87111. /**
  87112. * Gets the global Saturation value.
  87113. * 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.
  87114. */
  87115. get globalSaturation(): number;
  87116. /**
  87117. * Sets the global Saturation value.
  87118. * 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.
  87119. */
  87120. set globalSaturation(value: number);
  87121. /**
  87122. * Gets the global Exposure value.
  87123. * 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.
  87124. */
  87125. get globalExposure(): number;
  87126. /**
  87127. * Sets the global Exposure value.
  87128. * 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.
  87129. */
  87130. set globalExposure(value: number);
  87131. private _highlightsHue;
  87132. private _highlightsDensity;
  87133. private _highlightsSaturation;
  87134. private _highlightsExposure;
  87135. /**
  87136. * Gets the highlights Hue value.
  87137. * 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).
  87138. */
  87139. get highlightsHue(): number;
  87140. /**
  87141. * Sets the highlights Hue value.
  87142. * 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).
  87143. */
  87144. set highlightsHue(value: number);
  87145. /**
  87146. * Gets the highlights Density value.
  87147. * 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.
  87148. * Values less than zero provide a filter of opposite hue.
  87149. */
  87150. get highlightsDensity(): number;
  87151. /**
  87152. * Sets the highlights Density value.
  87153. * 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.
  87154. * Values less than zero provide a filter of opposite hue.
  87155. */
  87156. set highlightsDensity(value: number);
  87157. /**
  87158. * Gets the highlights Saturation value.
  87159. * 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.
  87160. */
  87161. get highlightsSaturation(): number;
  87162. /**
  87163. * Sets the highlights Saturation value.
  87164. * 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.
  87165. */
  87166. set highlightsSaturation(value: number);
  87167. /**
  87168. * Gets the highlights Exposure value.
  87169. * 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.
  87170. */
  87171. get highlightsExposure(): number;
  87172. /**
  87173. * Sets the highlights Exposure value.
  87174. * 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.
  87175. */
  87176. set highlightsExposure(value: number);
  87177. private _midtonesHue;
  87178. private _midtonesDensity;
  87179. private _midtonesSaturation;
  87180. private _midtonesExposure;
  87181. /**
  87182. * Gets the midtones Hue value.
  87183. * 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).
  87184. */
  87185. get midtonesHue(): number;
  87186. /**
  87187. * Sets the midtones Hue value.
  87188. * 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).
  87189. */
  87190. set midtonesHue(value: number);
  87191. /**
  87192. * Gets the midtones Density value.
  87193. * 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.
  87194. * Values less than zero provide a filter of opposite hue.
  87195. */
  87196. get midtonesDensity(): number;
  87197. /**
  87198. * Sets the midtones Density value.
  87199. * 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.
  87200. * Values less than zero provide a filter of opposite hue.
  87201. */
  87202. set midtonesDensity(value: number);
  87203. /**
  87204. * Gets the midtones Saturation value.
  87205. * 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.
  87206. */
  87207. get midtonesSaturation(): number;
  87208. /**
  87209. * Sets the midtones Saturation value.
  87210. * 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.
  87211. */
  87212. set midtonesSaturation(value: number);
  87213. /**
  87214. * Gets the midtones Exposure value.
  87215. * 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.
  87216. */
  87217. get midtonesExposure(): number;
  87218. /**
  87219. * Sets the midtones Exposure value.
  87220. * 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.
  87221. */
  87222. set midtonesExposure(value: number);
  87223. private _shadowsHue;
  87224. private _shadowsDensity;
  87225. private _shadowsSaturation;
  87226. private _shadowsExposure;
  87227. /**
  87228. * Gets the shadows Hue value.
  87229. * 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).
  87230. */
  87231. get shadowsHue(): number;
  87232. /**
  87233. * Sets the shadows Hue value.
  87234. * 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).
  87235. */
  87236. set shadowsHue(value: number);
  87237. /**
  87238. * Gets the shadows Density value.
  87239. * 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.
  87240. * Values less than zero provide a filter of opposite hue.
  87241. */
  87242. get shadowsDensity(): number;
  87243. /**
  87244. * Sets the shadows Density value.
  87245. * 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.
  87246. * Values less than zero provide a filter of opposite hue.
  87247. */
  87248. set shadowsDensity(value: number);
  87249. /**
  87250. * Gets the shadows Saturation value.
  87251. * 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.
  87252. */
  87253. get shadowsSaturation(): number;
  87254. /**
  87255. * Sets the shadows Saturation value.
  87256. * 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.
  87257. */
  87258. set shadowsSaturation(value: number);
  87259. /**
  87260. * Gets the shadows Exposure value.
  87261. * 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.
  87262. */
  87263. get shadowsExposure(): number;
  87264. /**
  87265. * Sets the shadows Exposure value.
  87266. * 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.
  87267. */
  87268. set shadowsExposure(value: number);
  87269. /**
  87270. * Returns the class name
  87271. * @returns The class name
  87272. */
  87273. getClassName(): string;
  87274. /**
  87275. * Binds the color curves to the shader.
  87276. * @param colorCurves The color curve to bind
  87277. * @param effect The effect to bind to
  87278. * @param positiveUniform The positive uniform shader parameter
  87279. * @param neutralUniform The neutral uniform shader parameter
  87280. * @param negativeUniform The negative uniform shader parameter
  87281. */
  87282. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87283. /**
  87284. * Prepare the list of uniforms associated with the ColorCurves effects.
  87285. * @param uniformsList The list of uniforms used in the effect
  87286. */
  87287. static PrepareUniforms(uniformsList: string[]): void;
  87288. /**
  87289. * Returns color grading data based on a hue, density, saturation and exposure value.
  87290. * @param filterHue The hue of the color filter.
  87291. * @param filterDensity The density of the color filter.
  87292. * @param saturation The saturation.
  87293. * @param exposure The exposure.
  87294. * @param result The result data container.
  87295. */
  87296. private getColorGradingDataToRef;
  87297. /**
  87298. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87299. * @param value The input slider value in range [-100,100].
  87300. * @returns Adjusted value.
  87301. */
  87302. private static applyColorGradingSliderNonlinear;
  87303. /**
  87304. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87305. * @param hue The hue (H) input.
  87306. * @param saturation The saturation (S) input.
  87307. * @param brightness The brightness (B) input.
  87308. * @result An RGBA color represented as Vector4.
  87309. */
  87310. private static fromHSBToRef;
  87311. /**
  87312. * Returns a value clamped between min and max
  87313. * @param value The value to clamp
  87314. * @param min The minimum of value
  87315. * @param max The maximum of value
  87316. * @returns The clamped value.
  87317. */
  87318. private static clamp;
  87319. /**
  87320. * Clones the current color curve instance.
  87321. * @return The cloned curves
  87322. */
  87323. clone(): ColorCurves;
  87324. /**
  87325. * Serializes the current color curve instance to a json representation.
  87326. * @return a JSON representation
  87327. */
  87328. serialize(): any;
  87329. /**
  87330. * Parses the color curve from a json representation.
  87331. * @param source the JSON source to parse
  87332. * @return The parsed curves
  87333. */
  87334. static Parse(source: any): ColorCurves;
  87335. }
  87336. }
  87337. declare module BABYLON {
  87338. /**
  87339. * Interface to follow in your material defines to integrate easily the
  87340. * Image proccessing functions.
  87341. * @hidden
  87342. */
  87343. export interface IImageProcessingConfigurationDefines {
  87344. IMAGEPROCESSING: boolean;
  87345. VIGNETTE: boolean;
  87346. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87347. VIGNETTEBLENDMODEOPAQUE: boolean;
  87348. TONEMAPPING: boolean;
  87349. TONEMAPPING_ACES: boolean;
  87350. CONTRAST: boolean;
  87351. EXPOSURE: boolean;
  87352. COLORCURVES: boolean;
  87353. COLORGRADING: boolean;
  87354. COLORGRADING3D: boolean;
  87355. SAMPLER3DGREENDEPTH: boolean;
  87356. SAMPLER3DBGRMAP: boolean;
  87357. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87358. }
  87359. /**
  87360. * @hidden
  87361. */
  87362. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87363. IMAGEPROCESSING: boolean;
  87364. VIGNETTE: boolean;
  87365. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87366. VIGNETTEBLENDMODEOPAQUE: boolean;
  87367. TONEMAPPING: boolean;
  87368. TONEMAPPING_ACES: boolean;
  87369. CONTRAST: boolean;
  87370. COLORCURVES: boolean;
  87371. COLORGRADING: boolean;
  87372. COLORGRADING3D: boolean;
  87373. SAMPLER3DGREENDEPTH: boolean;
  87374. SAMPLER3DBGRMAP: boolean;
  87375. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87376. EXPOSURE: boolean;
  87377. constructor();
  87378. }
  87379. /**
  87380. * This groups together the common properties used for image processing either in direct forward pass
  87381. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87382. * or not.
  87383. */
  87384. export class ImageProcessingConfiguration {
  87385. /**
  87386. * Default tone mapping applied in BabylonJS.
  87387. */
  87388. static readonly TONEMAPPING_STANDARD: number;
  87389. /**
  87390. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87391. * to other engines rendering to increase portability.
  87392. */
  87393. static readonly TONEMAPPING_ACES: number;
  87394. /**
  87395. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87396. */
  87397. colorCurves: Nullable<ColorCurves>;
  87398. private _colorCurvesEnabled;
  87399. /**
  87400. * Gets wether the color curves effect is enabled.
  87401. */
  87402. get colorCurvesEnabled(): boolean;
  87403. /**
  87404. * Sets wether the color curves effect is enabled.
  87405. */
  87406. set colorCurvesEnabled(value: boolean);
  87407. private _colorGradingTexture;
  87408. /**
  87409. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87410. */
  87411. get colorGradingTexture(): Nullable<BaseTexture>;
  87412. /**
  87413. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87414. */
  87415. set colorGradingTexture(value: Nullable<BaseTexture>);
  87416. private _colorGradingEnabled;
  87417. /**
  87418. * Gets wether the color grading effect is enabled.
  87419. */
  87420. get colorGradingEnabled(): boolean;
  87421. /**
  87422. * Sets wether the color grading effect is enabled.
  87423. */
  87424. set colorGradingEnabled(value: boolean);
  87425. private _colorGradingWithGreenDepth;
  87426. /**
  87427. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87428. */
  87429. get colorGradingWithGreenDepth(): boolean;
  87430. /**
  87431. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87432. */
  87433. set colorGradingWithGreenDepth(value: boolean);
  87434. private _colorGradingBGR;
  87435. /**
  87436. * Gets wether the color grading texture contains BGR values.
  87437. */
  87438. get colorGradingBGR(): boolean;
  87439. /**
  87440. * Sets wether the color grading texture contains BGR values.
  87441. */
  87442. set colorGradingBGR(value: boolean);
  87443. /** @hidden */
  87444. _exposure: number;
  87445. /**
  87446. * Gets the Exposure used in the effect.
  87447. */
  87448. get exposure(): number;
  87449. /**
  87450. * Sets the Exposure used in the effect.
  87451. */
  87452. set exposure(value: number);
  87453. private _toneMappingEnabled;
  87454. /**
  87455. * Gets wether the tone mapping effect is enabled.
  87456. */
  87457. get toneMappingEnabled(): boolean;
  87458. /**
  87459. * Sets wether the tone mapping effect is enabled.
  87460. */
  87461. set toneMappingEnabled(value: boolean);
  87462. private _toneMappingType;
  87463. /**
  87464. * Gets the type of tone mapping effect.
  87465. */
  87466. get toneMappingType(): number;
  87467. /**
  87468. * Sets the type of tone mapping effect used in BabylonJS.
  87469. */
  87470. set toneMappingType(value: number);
  87471. protected _contrast: number;
  87472. /**
  87473. * Gets the contrast used in the effect.
  87474. */
  87475. get contrast(): number;
  87476. /**
  87477. * Sets the contrast used in the effect.
  87478. */
  87479. set contrast(value: number);
  87480. /**
  87481. * Vignette stretch size.
  87482. */
  87483. vignetteStretch: number;
  87484. /**
  87485. * Vignette centre X Offset.
  87486. */
  87487. vignetteCentreX: number;
  87488. /**
  87489. * Vignette centre Y Offset.
  87490. */
  87491. vignetteCentreY: number;
  87492. /**
  87493. * Vignette weight or intensity of the vignette effect.
  87494. */
  87495. vignetteWeight: number;
  87496. /**
  87497. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87498. * if vignetteEnabled is set to true.
  87499. */
  87500. vignetteColor: Color4;
  87501. /**
  87502. * Camera field of view used by the Vignette effect.
  87503. */
  87504. vignetteCameraFov: number;
  87505. private _vignetteBlendMode;
  87506. /**
  87507. * Gets the vignette blend mode allowing different kind of effect.
  87508. */
  87509. get vignetteBlendMode(): number;
  87510. /**
  87511. * Sets the vignette blend mode allowing different kind of effect.
  87512. */
  87513. set vignetteBlendMode(value: number);
  87514. private _vignetteEnabled;
  87515. /**
  87516. * Gets wether the vignette effect is enabled.
  87517. */
  87518. get vignetteEnabled(): boolean;
  87519. /**
  87520. * Sets wether the vignette effect is enabled.
  87521. */
  87522. set vignetteEnabled(value: boolean);
  87523. private _applyByPostProcess;
  87524. /**
  87525. * Gets wether the image processing is applied through a post process or not.
  87526. */
  87527. get applyByPostProcess(): boolean;
  87528. /**
  87529. * Sets wether the image processing is applied through a post process or not.
  87530. */
  87531. set applyByPostProcess(value: boolean);
  87532. private _isEnabled;
  87533. /**
  87534. * Gets wether the image processing is enabled or not.
  87535. */
  87536. get isEnabled(): boolean;
  87537. /**
  87538. * Sets wether the image processing is enabled or not.
  87539. */
  87540. set isEnabled(value: boolean);
  87541. /**
  87542. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87543. */
  87544. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87545. /**
  87546. * Method called each time the image processing information changes requires to recompile the effect.
  87547. */
  87548. protected _updateParameters(): void;
  87549. /**
  87550. * Gets the current class name.
  87551. * @return "ImageProcessingConfiguration"
  87552. */
  87553. getClassName(): string;
  87554. /**
  87555. * Prepare the list of uniforms associated with the Image Processing effects.
  87556. * @param uniforms The list of uniforms used in the effect
  87557. * @param defines the list of defines currently in use
  87558. */
  87559. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87560. /**
  87561. * Prepare the list of samplers associated with the Image Processing effects.
  87562. * @param samplersList The list of uniforms used in the effect
  87563. * @param defines the list of defines currently in use
  87564. */
  87565. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87566. /**
  87567. * Prepare the list of defines associated to the shader.
  87568. * @param defines the list of defines to complete
  87569. * @param forPostProcess Define if we are currently in post process mode or not
  87570. */
  87571. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87572. /**
  87573. * Returns true if all the image processing information are ready.
  87574. * @returns True if ready, otherwise, false
  87575. */
  87576. isReady(): boolean;
  87577. /**
  87578. * Binds the image processing to the shader.
  87579. * @param effect The effect to bind to
  87580. * @param overrideAspectRatio Override the aspect ratio of the effect
  87581. */
  87582. bind(effect: Effect, overrideAspectRatio?: number): void;
  87583. /**
  87584. * Clones the current image processing instance.
  87585. * @return The cloned image processing
  87586. */
  87587. clone(): ImageProcessingConfiguration;
  87588. /**
  87589. * Serializes the current image processing instance to a json representation.
  87590. * @return a JSON representation
  87591. */
  87592. serialize(): any;
  87593. /**
  87594. * Parses the image processing from a json representation.
  87595. * @param source the JSON source to parse
  87596. * @return The parsed image processing
  87597. */
  87598. static Parse(source: any): ImageProcessingConfiguration;
  87599. private static _VIGNETTEMODE_MULTIPLY;
  87600. private static _VIGNETTEMODE_OPAQUE;
  87601. /**
  87602. * Used to apply the vignette as a mix with the pixel color.
  87603. */
  87604. static get VIGNETTEMODE_MULTIPLY(): number;
  87605. /**
  87606. * Used to apply the vignette as a replacement of the pixel color.
  87607. */
  87608. static get VIGNETTEMODE_OPAQUE(): number;
  87609. }
  87610. }
  87611. declare module BABYLON {
  87612. /** @hidden */
  87613. export var postprocessVertexShader: {
  87614. name: string;
  87615. shader: string;
  87616. };
  87617. }
  87618. declare module BABYLON {
  87619. interface ThinEngine {
  87620. /**
  87621. * Creates a new render target texture
  87622. * @param size defines the size of the texture
  87623. * @param options defines the options used to create the texture
  87624. * @returns a new render target texture stored in an InternalTexture
  87625. */
  87626. createRenderTargetTexture(size: number | {
  87627. width: number;
  87628. height: number;
  87629. layers?: number;
  87630. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87631. /**
  87632. * Creates a depth stencil texture.
  87633. * This is only available in WebGL 2 or with the depth texture extension available.
  87634. * @param size The size of face edge in the texture.
  87635. * @param options The options defining the texture.
  87636. * @returns The texture
  87637. */
  87638. createDepthStencilTexture(size: number | {
  87639. width: number;
  87640. height: number;
  87641. layers?: number;
  87642. }, options: DepthTextureCreationOptions): InternalTexture;
  87643. /** @hidden */
  87644. _createDepthStencilTexture(size: number | {
  87645. width: number;
  87646. height: number;
  87647. layers?: number;
  87648. }, options: DepthTextureCreationOptions): InternalTexture;
  87649. }
  87650. }
  87651. declare module BABYLON {
  87652. /**
  87653. * Defines the kind of connection point for node based material
  87654. */
  87655. export enum NodeMaterialBlockConnectionPointTypes {
  87656. /** Float */
  87657. Float = 1,
  87658. /** Int */
  87659. Int = 2,
  87660. /** Vector2 */
  87661. Vector2 = 4,
  87662. /** Vector3 */
  87663. Vector3 = 8,
  87664. /** Vector4 */
  87665. Vector4 = 16,
  87666. /** Color3 */
  87667. Color3 = 32,
  87668. /** Color4 */
  87669. Color4 = 64,
  87670. /** Matrix */
  87671. Matrix = 128,
  87672. /** Custom object */
  87673. Object = 256,
  87674. /** Detect type based on connection */
  87675. AutoDetect = 1024,
  87676. /** Output type that will be defined by input type */
  87677. BasedOnInput = 2048
  87678. }
  87679. }
  87680. declare module BABYLON {
  87681. /**
  87682. * Enum used to define the target of a block
  87683. */
  87684. export enum NodeMaterialBlockTargets {
  87685. /** Vertex shader */
  87686. Vertex = 1,
  87687. /** Fragment shader */
  87688. Fragment = 2,
  87689. /** Neutral */
  87690. Neutral = 4,
  87691. /** Vertex and Fragment */
  87692. VertexAndFragment = 3
  87693. }
  87694. }
  87695. declare module BABYLON {
  87696. /**
  87697. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87698. */
  87699. export enum NodeMaterialBlockConnectionPointMode {
  87700. /** Value is an uniform */
  87701. Uniform = 0,
  87702. /** Value is a mesh attribute */
  87703. Attribute = 1,
  87704. /** Value is a varying between vertex and fragment shaders */
  87705. Varying = 2,
  87706. /** Mode is undefined */
  87707. Undefined = 3
  87708. }
  87709. }
  87710. declare module BABYLON {
  87711. /**
  87712. * Enum used to define system values e.g. values automatically provided by the system
  87713. */
  87714. export enum NodeMaterialSystemValues {
  87715. /** World */
  87716. World = 1,
  87717. /** View */
  87718. View = 2,
  87719. /** Projection */
  87720. Projection = 3,
  87721. /** ViewProjection */
  87722. ViewProjection = 4,
  87723. /** WorldView */
  87724. WorldView = 5,
  87725. /** WorldViewProjection */
  87726. WorldViewProjection = 6,
  87727. /** CameraPosition */
  87728. CameraPosition = 7,
  87729. /** Fog Color */
  87730. FogColor = 8,
  87731. /** Delta time */
  87732. DeltaTime = 9
  87733. }
  87734. }
  87735. declare module BABYLON {
  87736. /** Defines supported spaces */
  87737. export enum Space {
  87738. /** Local (object) space */
  87739. LOCAL = 0,
  87740. /** World space */
  87741. WORLD = 1,
  87742. /** Bone space */
  87743. BONE = 2
  87744. }
  87745. /** Defines the 3 main axes */
  87746. export class Axis {
  87747. /** X axis */
  87748. static X: Vector3;
  87749. /** Y axis */
  87750. static Y: Vector3;
  87751. /** Z axis */
  87752. static Z: Vector3;
  87753. }
  87754. }
  87755. declare module BABYLON {
  87756. /**
  87757. * Represents a camera frustum
  87758. */
  87759. export class Frustum {
  87760. /**
  87761. * Gets the planes representing the frustum
  87762. * @param transform matrix to be applied to the returned planes
  87763. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87764. */
  87765. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87766. /**
  87767. * Gets the near frustum plane transformed by the transform matrix
  87768. * @param transform transformation matrix to be applied to the resulting frustum plane
  87769. * @param frustumPlane the resuling frustum plane
  87770. */
  87771. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87772. /**
  87773. * Gets the far frustum plane transformed by the transform matrix
  87774. * @param transform transformation matrix to be applied to the resulting frustum plane
  87775. * @param frustumPlane the resuling frustum plane
  87776. */
  87777. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87778. /**
  87779. * Gets the left frustum plane transformed by the transform matrix
  87780. * @param transform transformation matrix to be applied to the resulting frustum plane
  87781. * @param frustumPlane the resuling frustum plane
  87782. */
  87783. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87784. /**
  87785. * Gets the right frustum plane transformed by the transform matrix
  87786. * @param transform transformation matrix to be applied to the resulting frustum plane
  87787. * @param frustumPlane the resuling frustum plane
  87788. */
  87789. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87790. /**
  87791. * Gets the top frustum plane transformed by the transform matrix
  87792. * @param transform transformation matrix to be applied to the resulting frustum plane
  87793. * @param frustumPlane the resuling frustum plane
  87794. */
  87795. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87796. /**
  87797. * Gets the bottom frustum plane transformed by the transform matrix
  87798. * @param transform transformation matrix to be applied to the resulting frustum plane
  87799. * @param frustumPlane the resuling frustum plane
  87800. */
  87801. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87802. /**
  87803. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87804. * @param transform transformation matrix to be applied to the resulting frustum planes
  87805. * @param frustumPlanes the resuling frustum planes
  87806. */
  87807. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87808. }
  87809. }
  87810. declare module BABYLON {
  87811. /**
  87812. * Interface for the size containing width and height
  87813. */
  87814. export interface ISize {
  87815. /**
  87816. * Width
  87817. */
  87818. width: number;
  87819. /**
  87820. * Heighht
  87821. */
  87822. height: number;
  87823. }
  87824. /**
  87825. * Size containing widht and height
  87826. */
  87827. export class Size implements ISize {
  87828. /**
  87829. * Width
  87830. */
  87831. width: number;
  87832. /**
  87833. * Height
  87834. */
  87835. height: number;
  87836. /**
  87837. * Creates a Size object from the given width and height (floats).
  87838. * @param width width of the new size
  87839. * @param height height of the new size
  87840. */
  87841. constructor(width: number, height: number);
  87842. /**
  87843. * Returns a string with the Size width and height
  87844. * @returns a string with the Size width and height
  87845. */
  87846. toString(): string;
  87847. /**
  87848. * "Size"
  87849. * @returns the string "Size"
  87850. */
  87851. getClassName(): string;
  87852. /**
  87853. * Returns the Size hash code.
  87854. * @returns a hash code for a unique width and height
  87855. */
  87856. getHashCode(): number;
  87857. /**
  87858. * Updates the current size from the given one.
  87859. * @param src the given size
  87860. */
  87861. copyFrom(src: Size): void;
  87862. /**
  87863. * Updates in place the current Size from the given floats.
  87864. * @param width width of the new size
  87865. * @param height height of the new size
  87866. * @returns the updated Size.
  87867. */
  87868. copyFromFloats(width: number, height: number): Size;
  87869. /**
  87870. * Updates in place the current Size from the given floats.
  87871. * @param width width to set
  87872. * @param height height to set
  87873. * @returns the updated Size.
  87874. */
  87875. set(width: number, height: number): Size;
  87876. /**
  87877. * Multiplies the width and height by numbers
  87878. * @param w factor to multiple the width by
  87879. * @param h factor to multiple the height by
  87880. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87881. */
  87882. multiplyByFloats(w: number, h: number): Size;
  87883. /**
  87884. * Clones the size
  87885. * @returns a new Size copied from the given one.
  87886. */
  87887. clone(): Size;
  87888. /**
  87889. * True if the current Size and the given one width and height are strictly equal.
  87890. * @param other the other size to compare against
  87891. * @returns True if the current Size and the given one width and height are strictly equal.
  87892. */
  87893. equals(other: Size): boolean;
  87894. /**
  87895. * The surface of the Size : width * height (float).
  87896. */
  87897. get surface(): number;
  87898. /**
  87899. * Create a new size of zero
  87900. * @returns a new Size set to (0.0, 0.0)
  87901. */
  87902. static Zero(): Size;
  87903. /**
  87904. * Sums the width and height of two sizes
  87905. * @param otherSize size to add to this size
  87906. * @returns a new Size set as the addition result of the current Size and the given one.
  87907. */
  87908. add(otherSize: Size): Size;
  87909. /**
  87910. * Subtracts the width and height of two
  87911. * @param otherSize size to subtract to this size
  87912. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87913. */
  87914. subtract(otherSize: Size): Size;
  87915. /**
  87916. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87917. * @param start starting size to lerp between
  87918. * @param end end size to lerp between
  87919. * @param amount amount to lerp between the start and end values
  87920. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87921. */
  87922. static Lerp(start: Size, end: Size, amount: number): Size;
  87923. }
  87924. }
  87925. declare module BABYLON {
  87926. /**
  87927. * Contains position and normal vectors for a vertex
  87928. */
  87929. export class PositionNormalVertex {
  87930. /** the position of the vertex (defaut: 0,0,0) */
  87931. position: Vector3;
  87932. /** the normal of the vertex (defaut: 0,1,0) */
  87933. normal: Vector3;
  87934. /**
  87935. * Creates a PositionNormalVertex
  87936. * @param position the position of the vertex (defaut: 0,0,0)
  87937. * @param normal the normal of the vertex (defaut: 0,1,0)
  87938. */
  87939. constructor(
  87940. /** the position of the vertex (defaut: 0,0,0) */
  87941. position?: Vector3,
  87942. /** the normal of the vertex (defaut: 0,1,0) */
  87943. normal?: Vector3);
  87944. /**
  87945. * Clones the PositionNormalVertex
  87946. * @returns the cloned PositionNormalVertex
  87947. */
  87948. clone(): PositionNormalVertex;
  87949. }
  87950. /**
  87951. * Contains position, normal and uv vectors for a vertex
  87952. */
  87953. export class PositionNormalTextureVertex {
  87954. /** the position of the vertex (defaut: 0,0,0) */
  87955. position: Vector3;
  87956. /** the normal of the vertex (defaut: 0,1,0) */
  87957. normal: Vector3;
  87958. /** the uv of the vertex (default: 0,0) */
  87959. uv: Vector2;
  87960. /**
  87961. * Creates a PositionNormalTextureVertex
  87962. * @param position the position of the vertex (defaut: 0,0,0)
  87963. * @param normal the normal of the vertex (defaut: 0,1,0)
  87964. * @param uv the uv of the vertex (default: 0,0)
  87965. */
  87966. constructor(
  87967. /** the position of the vertex (defaut: 0,0,0) */
  87968. position?: Vector3,
  87969. /** the normal of the vertex (defaut: 0,1,0) */
  87970. normal?: Vector3,
  87971. /** the uv of the vertex (default: 0,0) */
  87972. uv?: Vector2);
  87973. /**
  87974. * Clones the PositionNormalTextureVertex
  87975. * @returns the cloned PositionNormalTextureVertex
  87976. */
  87977. clone(): PositionNormalTextureVertex;
  87978. }
  87979. }
  87980. declare module BABYLON {
  87981. /**
  87982. * Enum defining the type of animations supported by InputBlock
  87983. */
  87984. export enum AnimatedInputBlockTypes {
  87985. /** No animation */
  87986. None = 0,
  87987. /** Time based animation. Will only work for floats */
  87988. Time = 1
  87989. }
  87990. }
  87991. declare module BABYLON {
  87992. /**
  87993. * Interface describing all the common properties and methods a shadow light needs to implement.
  87994. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87995. * as well as binding the different shadow properties to the effects.
  87996. */
  87997. export interface IShadowLight extends Light {
  87998. /**
  87999. * The light id in the scene (used in scene.findLighById for instance)
  88000. */
  88001. id: string;
  88002. /**
  88003. * The position the shdow will be casted from.
  88004. */
  88005. position: Vector3;
  88006. /**
  88007. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88008. */
  88009. direction: Vector3;
  88010. /**
  88011. * The transformed position. Position of the light in world space taking parenting in account.
  88012. */
  88013. transformedPosition: Vector3;
  88014. /**
  88015. * The transformed direction. Direction of the light in world space taking parenting in account.
  88016. */
  88017. transformedDirection: Vector3;
  88018. /**
  88019. * The friendly name of the light in the scene.
  88020. */
  88021. name: string;
  88022. /**
  88023. * Defines the shadow projection clipping minimum z value.
  88024. */
  88025. shadowMinZ: number;
  88026. /**
  88027. * Defines the shadow projection clipping maximum z value.
  88028. */
  88029. shadowMaxZ: number;
  88030. /**
  88031. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88032. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88033. */
  88034. computeTransformedInformation(): boolean;
  88035. /**
  88036. * Gets the scene the light belongs to.
  88037. * @returns The scene
  88038. */
  88039. getScene(): Scene;
  88040. /**
  88041. * Callback defining a custom Projection Matrix Builder.
  88042. * This can be used to override the default projection matrix computation.
  88043. */
  88044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88045. /**
  88046. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88047. * @param matrix The materix to updated with the projection information
  88048. * @param viewMatrix The transform matrix of the light
  88049. * @param renderList The list of mesh to render in the map
  88050. * @returns The current light
  88051. */
  88052. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88053. /**
  88054. * Gets the current depth scale used in ESM.
  88055. * @returns The scale
  88056. */
  88057. getDepthScale(): number;
  88058. /**
  88059. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88060. * @returns true if a cube texture needs to be use
  88061. */
  88062. needCube(): boolean;
  88063. /**
  88064. * Detects if the projection matrix requires to be recomputed this frame.
  88065. * @returns true if it requires to be recomputed otherwise, false.
  88066. */
  88067. needProjectionMatrixCompute(): boolean;
  88068. /**
  88069. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88070. */
  88071. forceProjectionMatrixCompute(): void;
  88072. /**
  88073. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88074. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88075. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88076. */
  88077. getShadowDirection(faceIndex?: number): Vector3;
  88078. /**
  88079. * Gets the minZ used for shadow according to both the scene and the light.
  88080. * @param activeCamera The camera we are returning the min for
  88081. * @returns the depth min z
  88082. */
  88083. getDepthMinZ(activeCamera: Camera): number;
  88084. /**
  88085. * Gets the maxZ used for shadow according to both the scene and the light.
  88086. * @param activeCamera The camera we are returning the max for
  88087. * @returns the depth max z
  88088. */
  88089. getDepthMaxZ(activeCamera: Camera): number;
  88090. }
  88091. /**
  88092. * Base implementation IShadowLight
  88093. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88094. */
  88095. export abstract class ShadowLight extends Light implements IShadowLight {
  88096. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88097. protected _position: Vector3;
  88098. protected _setPosition(value: Vector3): void;
  88099. /**
  88100. * Sets the position the shadow will be casted from. Also use as the light position for both
  88101. * point and spot lights.
  88102. */
  88103. get position(): Vector3;
  88104. /**
  88105. * Sets the position the shadow will be casted from. Also use as the light position for both
  88106. * point and spot lights.
  88107. */
  88108. set position(value: Vector3);
  88109. protected _direction: Vector3;
  88110. protected _setDirection(value: Vector3): void;
  88111. /**
  88112. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88113. * Also use as the light direction on spot and directional lights.
  88114. */
  88115. get direction(): Vector3;
  88116. /**
  88117. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88118. * Also use as the light direction on spot and directional lights.
  88119. */
  88120. set direction(value: Vector3);
  88121. protected _shadowMinZ: number;
  88122. /**
  88123. * Gets the shadow projection clipping minimum z value.
  88124. */
  88125. get shadowMinZ(): number;
  88126. /**
  88127. * Sets the shadow projection clipping minimum z value.
  88128. */
  88129. set shadowMinZ(value: number);
  88130. protected _shadowMaxZ: number;
  88131. /**
  88132. * Sets the shadow projection clipping maximum z value.
  88133. */
  88134. get shadowMaxZ(): number;
  88135. /**
  88136. * Gets the shadow projection clipping maximum z value.
  88137. */
  88138. set shadowMaxZ(value: number);
  88139. /**
  88140. * Callback defining a custom Projection Matrix Builder.
  88141. * This can be used to override the default projection matrix computation.
  88142. */
  88143. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88144. /**
  88145. * The transformed position. Position of the light in world space taking parenting in account.
  88146. */
  88147. transformedPosition: Vector3;
  88148. /**
  88149. * The transformed direction. Direction of the light in world space taking parenting in account.
  88150. */
  88151. transformedDirection: Vector3;
  88152. private _needProjectionMatrixCompute;
  88153. /**
  88154. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88155. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88156. */
  88157. computeTransformedInformation(): boolean;
  88158. /**
  88159. * Return the depth scale used for the shadow map.
  88160. * @returns the depth scale.
  88161. */
  88162. getDepthScale(): number;
  88163. /**
  88164. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88165. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88166. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88167. */
  88168. getShadowDirection(faceIndex?: number): Vector3;
  88169. /**
  88170. * Returns the ShadowLight absolute position in the World.
  88171. * @returns the position vector in world space
  88172. */
  88173. getAbsolutePosition(): Vector3;
  88174. /**
  88175. * Sets the ShadowLight direction toward the passed target.
  88176. * @param target The point to target in local space
  88177. * @returns the updated ShadowLight direction
  88178. */
  88179. setDirectionToTarget(target: Vector3): Vector3;
  88180. /**
  88181. * Returns the light rotation in euler definition.
  88182. * @returns the x y z rotation in local space.
  88183. */
  88184. getRotation(): Vector3;
  88185. /**
  88186. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88187. * @returns true if a cube texture needs to be use
  88188. */
  88189. needCube(): boolean;
  88190. /**
  88191. * Detects if the projection matrix requires to be recomputed this frame.
  88192. * @returns true if it requires to be recomputed otherwise, false.
  88193. */
  88194. needProjectionMatrixCompute(): boolean;
  88195. /**
  88196. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88197. */
  88198. forceProjectionMatrixCompute(): void;
  88199. /** @hidden */
  88200. _initCache(): void;
  88201. /** @hidden */
  88202. _isSynchronized(): boolean;
  88203. /**
  88204. * Computes the world matrix of the node
  88205. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88206. * @returns the world matrix
  88207. */
  88208. computeWorldMatrix(force?: boolean): Matrix;
  88209. /**
  88210. * Gets the minZ used for shadow according to both the scene and the light.
  88211. * @param activeCamera The camera we are returning the min for
  88212. * @returns the depth min z
  88213. */
  88214. getDepthMinZ(activeCamera: Camera): number;
  88215. /**
  88216. * Gets the maxZ used for shadow according to both the scene and the light.
  88217. * @param activeCamera The camera we are returning the max for
  88218. * @returns the depth max z
  88219. */
  88220. getDepthMaxZ(activeCamera: Camera): number;
  88221. /**
  88222. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88223. * @param matrix The materix to updated with the projection information
  88224. * @param viewMatrix The transform matrix of the light
  88225. * @param renderList The list of mesh to render in the map
  88226. * @returns The current light
  88227. */
  88228. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88229. }
  88230. }
  88231. declare module BABYLON {
  88232. /** @hidden */
  88233. export var packingFunctions: {
  88234. name: string;
  88235. shader: string;
  88236. };
  88237. }
  88238. declare module BABYLON {
  88239. /** @hidden */
  88240. export var bayerDitherFunctions: {
  88241. name: string;
  88242. shader: string;
  88243. };
  88244. }
  88245. declare module BABYLON {
  88246. /** @hidden */
  88247. export var shadowMapFragmentDeclaration: {
  88248. name: string;
  88249. shader: string;
  88250. };
  88251. }
  88252. declare module BABYLON {
  88253. /** @hidden */
  88254. export var clipPlaneFragmentDeclaration: {
  88255. name: string;
  88256. shader: string;
  88257. };
  88258. }
  88259. declare module BABYLON {
  88260. /** @hidden */
  88261. export var clipPlaneFragment: {
  88262. name: string;
  88263. shader: string;
  88264. };
  88265. }
  88266. declare module BABYLON {
  88267. /** @hidden */
  88268. export var shadowMapFragment: {
  88269. name: string;
  88270. shader: string;
  88271. };
  88272. }
  88273. declare module BABYLON {
  88274. /** @hidden */
  88275. export var shadowMapPixelShader: {
  88276. name: string;
  88277. shader: string;
  88278. };
  88279. }
  88280. declare module BABYLON {
  88281. /** @hidden */
  88282. export var bonesDeclaration: {
  88283. name: string;
  88284. shader: string;
  88285. };
  88286. }
  88287. declare module BABYLON {
  88288. /** @hidden */
  88289. export var morphTargetsVertexGlobalDeclaration: {
  88290. name: string;
  88291. shader: string;
  88292. };
  88293. }
  88294. declare module BABYLON {
  88295. /** @hidden */
  88296. export var morphTargetsVertexDeclaration: {
  88297. name: string;
  88298. shader: string;
  88299. };
  88300. }
  88301. declare module BABYLON {
  88302. /** @hidden */
  88303. export var instancesDeclaration: {
  88304. name: string;
  88305. shader: string;
  88306. };
  88307. }
  88308. declare module BABYLON {
  88309. /** @hidden */
  88310. export var helperFunctions: {
  88311. name: string;
  88312. shader: string;
  88313. };
  88314. }
  88315. declare module BABYLON {
  88316. /** @hidden */
  88317. export var shadowMapVertexDeclaration: {
  88318. name: string;
  88319. shader: string;
  88320. };
  88321. }
  88322. declare module BABYLON {
  88323. /** @hidden */
  88324. export var clipPlaneVertexDeclaration: {
  88325. name: string;
  88326. shader: string;
  88327. };
  88328. }
  88329. declare module BABYLON {
  88330. /** @hidden */
  88331. export var morphTargetsVertex: {
  88332. name: string;
  88333. shader: string;
  88334. };
  88335. }
  88336. declare module BABYLON {
  88337. /** @hidden */
  88338. export var instancesVertex: {
  88339. name: string;
  88340. shader: string;
  88341. };
  88342. }
  88343. declare module BABYLON {
  88344. /** @hidden */
  88345. export var bonesVertex: {
  88346. name: string;
  88347. shader: string;
  88348. };
  88349. }
  88350. declare module BABYLON {
  88351. /** @hidden */
  88352. export var shadowMapVertexNormalBias: {
  88353. name: string;
  88354. shader: string;
  88355. };
  88356. }
  88357. declare module BABYLON {
  88358. /** @hidden */
  88359. export var shadowMapVertexMetric: {
  88360. name: string;
  88361. shader: string;
  88362. };
  88363. }
  88364. declare module BABYLON {
  88365. /** @hidden */
  88366. export var clipPlaneVertex: {
  88367. name: string;
  88368. shader: string;
  88369. };
  88370. }
  88371. declare module BABYLON {
  88372. /** @hidden */
  88373. export var shadowMapVertexShader: {
  88374. name: string;
  88375. shader: string;
  88376. };
  88377. }
  88378. declare module BABYLON {
  88379. /** @hidden */
  88380. export var depthBoxBlurPixelShader: {
  88381. name: string;
  88382. shader: string;
  88383. };
  88384. }
  88385. declare module BABYLON {
  88386. /** @hidden */
  88387. export var shadowMapFragmentSoftTransparentShadow: {
  88388. name: string;
  88389. shader: string;
  88390. };
  88391. }
  88392. declare module BABYLON {
  88393. /**
  88394. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88395. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88396. */
  88397. export class EffectFallbacks implements IEffectFallbacks {
  88398. private _defines;
  88399. private _currentRank;
  88400. private _maxRank;
  88401. private _mesh;
  88402. /**
  88403. * Removes the fallback from the bound mesh.
  88404. */
  88405. unBindMesh(): void;
  88406. /**
  88407. * Adds a fallback on the specified property.
  88408. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88409. * @param define The name of the define in the shader
  88410. */
  88411. addFallback(rank: number, define: string): void;
  88412. /**
  88413. * Sets the mesh to use CPU skinning when needing to fallback.
  88414. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88415. * @param mesh The mesh to use the fallbacks.
  88416. */
  88417. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88418. /**
  88419. * Checks to see if more fallbacks are still availible.
  88420. */
  88421. get hasMoreFallbacks(): boolean;
  88422. /**
  88423. * Removes the defines that should be removed when falling back.
  88424. * @param currentDefines defines the current define statements for the shader.
  88425. * @param effect defines the current effect we try to compile
  88426. * @returns The resulting defines with defines of the current rank removed.
  88427. */
  88428. reduce(currentDefines: string, effect: Effect): string;
  88429. }
  88430. }
  88431. declare module BABYLON {
  88432. /**
  88433. * Interface used to define Action
  88434. */
  88435. export interface IAction {
  88436. /**
  88437. * Trigger for the action
  88438. */
  88439. trigger: number;
  88440. /** Options of the trigger */
  88441. triggerOptions: any;
  88442. /**
  88443. * Gets the trigger parameters
  88444. * @returns the trigger parameters
  88445. */
  88446. getTriggerParameter(): any;
  88447. /**
  88448. * Internal only - executes current action event
  88449. * @hidden
  88450. */
  88451. _executeCurrent(evt?: ActionEvent): void;
  88452. /**
  88453. * Serialize placeholder for child classes
  88454. * @param parent of child
  88455. * @returns the serialized object
  88456. */
  88457. serialize(parent: any): any;
  88458. /**
  88459. * Internal only
  88460. * @hidden
  88461. */
  88462. _prepare(): void;
  88463. /**
  88464. * Internal only - manager for action
  88465. * @hidden
  88466. */
  88467. _actionManager: AbstractActionManager;
  88468. /**
  88469. * Adds action to chain of actions, may be a DoNothingAction
  88470. * @param action defines the next action to execute
  88471. * @returns The action passed in
  88472. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88473. */
  88474. then(action: IAction): IAction;
  88475. }
  88476. /**
  88477. * The action to be carried out following a trigger
  88478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88479. */
  88480. export class Action implements IAction {
  88481. /** the trigger, with or without parameters, for the action */
  88482. triggerOptions: any;
  88483. /**
  88484. * Trigger for the action
  88485. */
  88486. trigger: number;
  88487. /**
  88488. * Internal only - manager for action
  88489. * @hidden
  88490. */
  88491. _actionManager: ActionManager;
  88492. private _nextActiveAction;
  88493. private _child;
  88494. private _condition?;
  88495. private _triggerParameter;
  88496. /**
  88497. * An event triggered prior to action being executed.
  88498. */
  88499. onBeforeExecuteObservable: Observable<Action>;
  88500. /**
  88501. * Creates a new Action
  88502. * @param triggerOptions the trigger, with or without parameters, for the action
  88503. * @param condition an optional determinant of action
  88504. */
  88505. constructor(
  88506. /** the trigger, with or without parameters, for the action */
  88507. triggerOptions: any, condition?: Condition);
  88508. /**
  88509. * Internal only
  88510. * @hidden
  88511. */
  88512. _prepare(): void;
  88513. /**
  88514. * Gets the trigger parameters
  88515. * @returns the trigger parameters
  88516. */
  88517. getTriggerParameter(): any;
  88518. /**
  88519. * Internal only - executes current action event
  88520. * @hidden
  88521. */
  88522. _executeCurrent(evt?: ActionEvent): void;
  88523. /**
  88524. * Execute placeholder for child classes
  88525. * @param evt optional action event
  88526. */
  88527. execute(evt?: ActionEvent): void;
  88528. /**
  88529. * Skips to next active action
  88530. */
  88531. skipToNextActiveAction(): void;
  88532. /**
  88533. * Adds action to chain of actions, may be a DoNothingAction
  88534. * @param action defines the next action to execute
  88535. * @returns The action passed in
  88536. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88537. */
  88538. then(action: Action): Action;
  88539. /**
  88540. * Internal only
  88541. * @hidden
  88542. */
  88543. _getProperty(propertyPath: string): string;
  88544. /**
  88545. * Internal only
  88546. * @hidden
  88547. */
  88548. _getEffectiveTarget(target: any, propertyPath: string): any;
  88549. /**
  88550. * Serialize placeholder for child classes
  88551. * @param parent of child
  88552. * @returns the serialized object
  88553. */
  88554. serialize(parent: any): any;
  88555. /**
  88556. * Internal only called by serialize
  88557. * @hidden
  88558. */
  88559. protected _serialize(serializedAction: any, parent?: any): any;
  88560. /**
  88561. * Internal only
  88562. * @hidden
  88563. */
  88564. static _SerializeValueAsString: (value: any) => string;
  88565. /**
  88566. * Internal only
  88567. * @hidden
  88568. */
  88569. static _GetTargetProperty: (target: Scene | Node) => {
  88570. name: string;
  88571. targetType: string;
  88572. value: string;
  88573. };
  88574. }
  88575. }
  88576. declare module BABYLON {
  88577. /**
  88578. * A Condition applied to an Action
  88579. */
  88580. export class Condition {
  88581. /**
  88582. * Internal only - manager for action
  88583. * @hidden
  88584. */
  88585. _actionManager: ActionManager;
  88586. /**
  88587. * Internal only
  88588. * @hidden
  88589. */
  88590. _evaluationId: number;
  88591. /**
  88592. * Internal only
  88593. * @hidden
  88594. */
  88595. _currentResult: boolean;
  88596. /**
  88597. * Creates a new Condition
  88598. * @param actionManager the manager of the action the condition is applied to
  88599. */
  88600. constructor(actionManager: ActionManager);
  88601. /**
  88602. * Check if the current condition is valid
  88603. * @returns a boolean
  88604. */
  88605. isValid(): boolean;
  88606. /**
  88607. * Internal only
  88608. * @hidden
  88609. */
  88610. _getProperty(propertyPath: string): string;
  88611. /**
  88612. * Internal only
  88613. * @hidden
  88614. */
  88615. _getEffectiveTarget(target: any, propertyPath: string): any;
  88616. /**
  88617. * Serialize placeholder for child classes
  88618. * @returns the serialized object
  88619. */
  88620. serialize(): any;
  88621. /**
  88622. * Internal only
  88623. * @hidden
  88624. */
  88625. protected _serialize(serializedCondition: any): any;
  88626. }
  88627. /**
  88628. * Defines specific conditional operators as extensions of Condition
  88629. */
  88630. export class ValueCondition extends Condition {
  88631. /** path to specify the property of the target the conditional operator uses */
  88632. propertyPath: string;
  88633. /** the value compared by the conditional operator against the current value of the property */
  88634. value: any;
  88635. /** the conditional operator, default ValueCondition.IsEqual */
  88636. operator: number;
  88637. /**
  88638. * Internal only
  88639. * @hidden
  88640. */
  88641. private static _IsEqual;
  88642. /**
  88643. * Internal only
  88644. * @hidden
  88645. */
  88646. private static _IsDifferent;
  88647. /**
  88648. * Internal only
  88649. * @hidden
  88650. */
  88651. private static _IsGreater;
  88652. /**
  88653. * Internal only
  88654. * @hidden
  88655. */
  88656. private static _IsLesser;
  88657. /**
  88658. * returns the number for IsEqual
  88659. */
  88660. static get IsEqual(): number;
  88661. /**
  88662. * Returns the number for IsDifferent
  88663. */
  88664. static get IsDifferent(): number;
  88665. /**
  88666. * Returns the number for IsGreater
  88667. */
  88668. static get IsGreater(): number;
  88669. /**
  88670. * Returns the number for IsLesser
  88671. */
  88672. static get IsLesser(): number;
  88673. /**
  88674. * Internal only The action manager for the condition
  88675. * @hidden
  88676. */
  88677. _actionManager: ActionManager;
  88678. /**
  88679. * Internal only
  88680. * @hidden
  88681. */
  88682. private _target;
  88683. /**
  88684. * Internal only
  88685. * @hidden
  88686. */
  88687. private _effectiveTarget;
  88688. /**
  88689. * Internal only
  88690. * @hidden
  88691. */
  88692. private _property;
  88693. /**
  88694. * Creates a new ValueCondition
  88695. * @param actionManager manager for the action the condition applies to
  88696. * @param target for the action
  88697. * @param propertyPath path to specify the property of the target the conditional operator uses
  88698. * @param value the value compared by the conditional operator against the current value of the property
  88699. * @param operator the conditional operator, default ValueCondition.IsEqual
  88700. */
  88701. constructor(actionManager: ActionManager, target: any,
  88702. /** path to specify the property of the target the conditional operator uses */
  88703. propertyPath: string,
  88704. /** the value compared by the conditional operator against the current value of the property */
  88705. value: any,
  88706. /** the conditional operator, default ValueCondition.IsEqual */
  88707. operator?: number);
  88708. /**
  88709. * Compares the given value with the property value for the specified conditional operator
  88710. * @returns the result of the comparison
  88711. */
  88712. isValid(): boolean;
  88713. /**
  88714. * Serialize the ValueCondition into a JSON compatible object
  88715. * @returns serialization object
  88716. */
  88717. serialize(): any;
  88718. /**
  88719. * Gets the name of the conditional operator for the ValueCondition
  88720. * @param operator the conditional operator
  88721. * @returns the name
  88722. */
  88723. static GetOperatorName(operator: number): string;
  88724. }
  88725. /**
  88726. * Defines a predicate condition as an extension of Condition
  88727. */
  88728. export class PredicateCondition extends Condition {
  88729. /** defines the predicate function used to validate the condition */
  88730. predicate: () => boolean;
  88731. /**
  88732. * Internal only - manager for action
  88733. * @hidden
  88734. */
  88735. _actionManager: ActionManager;
  88736. /**
  88737. * Creates a new PredicateCondition
  88738. * @param actionManager manager for the action the condition applies to
  88739. * @param predicate defines the predicate function used to validate the condition
  88740. */
  88741. constructor(actionManager: ActionManager,
  88742. /** defines the predicate function used to validate the condition */
  88743. predicate: () => boolean);
  88744. /**
  88745. * @returns the validity of the predicate condition
  88746. */
  88747. isValid(): boolean;
  88748. }
  88749. /**
  88750. * Defines a state condition as an extension of Condition
  88751. */
  88752. export class StateCondition extends Condition {
  88753. /** Value to compare with target state */
  88754. value: string;
  88755. /**
  88756. * Internal only - manager for action
  88757. * @hidden
  88758. */
  88759. _actionManager: ActionManager;
  88760. /**
  88761. * Internal only
  88762. * @hidden
  88763. */
  88764. private _target;
  88765. /**
  88766. * Creates a new StateCondition
  88767. * @param actionManager manager for the action the condition applies to
  88768. * @param target of the condition
  88769. * @param value to compare with target state
  88770. */
  88771. constructor(actionManager: ActionManager, target: any,
  88772. /** Value to compare with target state */
  88773. value: string);
  88774. /**
  88775. * Gets a boolean indicating if the current condition is met
  88776. * @returns the validity of the state
  88777. */
  88778. isValid(): boolean;
  88779. /**
  88780. * Serialize the StateCondition into a JSON compatible object
  88781. * @returns serialization object
  88782. */
  88783. serialize(): any;
  88784. }
  88785. }
  88786. declare module BABYLON {
  88787. /**
  88788. * This defines an action responsible to toggle a boolean once triggered.
  88789. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88790. */
  88791. export class SwitchBooleanAction extends Action {
  88792. /**
  88793. * The path to the boolean property in the target object
  88794. */
  88795. propertyPath: string;
  88796. private _target;
  88797. private _effectiveTarget;
  88798. private _property;
  88799. /**
  88800. * Instantiate the action
  88801. * @param triggerOptions defines the trigger options
  88802. * @param target defines the object containing the boolean
  88803. * @param propertyPath defines the path to the boolean property in the target object
  88804. * @param condition defines the trigger related conditions
  88805. */
  88806. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88807. /** @hidden */
  88808. _prepare(): void;
  88809. /**
  88810. * Execute the action toggle the boolean value.
  88811. */
  88812. execute(): void;
  88813. /**
  88814. * Serializes the actions and its related information.
  88815. * @param parent defines the object to serialize in
  88816. * @returns the serialized object
  88817. */
  88818. serialize(parent: any): any;
  88819. }
  88820. /**
  88821. * This defines an action responsible to set a the state field of the target
  88822. * to a desired value once triggered.
  88823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88824. */
  88825. export class SetStateAction extends Action {
  88826. /**
  88827. * The value to store in the state field.
  88828. */
  88829. value: string;
  88830. private _target;
  88831. /**
  88832. * Instantiate the action
  88833. * @param triggerOptions defines the trigger options
  88834. * @param target defines the object containing the state property
  88835. * @param value defines the value to store in the state field
  88836. * @param condition defines the trigger related conditions
  88837. */
  88838. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88839. /**
  88840. * Execute the action and store the value on the target state property.
  88841. */
  88842. execute(): void;
  88843. /**
  88844. * Serializes the actions and its related information.
  88845. * @param parent defines the object to serialize in
  88846. * @returns the serialized object
  88847. */
  88848. serialize(parent: any): any;
  88849. }
  88850. /**
  88851. * This defines an action responsible to set a property of the target
  88852. * to a desired value once triggered.
  88853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88854. */
  88855. export class SetValueAction extends Action {
  88856. /**
  88857. * The path of the property to set in the target.
  88858. */
  88859. propertyPath: string;
  88860. /**
  88861. * The value to set in the property
  88862. */
  88863. value: any;
  88864. private _target;
  88865. private _effectiveTarget;
  88866. private _property;
  88867. /**
  88868. * Instantiate the action
  88869. * @param triggerOptions defines the trigger options
  88870. * @param target defines the object containing the property
  88871. * @param propertyPath defines the path of the property to set in the target
  88872. * @param value defines the value to set in the property
  88873. * @param condition defines the trigger related conditions
  88874. */
  88875. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88876. /** @hidden */
  88877. _prepare(): void;
  88878. /**
  88879. * Execute the action and set the targetted property to the desired value.
  88880. */
  88881. execute(): void;
  88882. /**
  88883. * Serializes the actions and its related information.
  88884. * @param parent defines the object to serialize in
  88885. * @returns the serialized object
  88886. */
  88887. serialize(parent: any): any;
  88888. }
  88889. /**
  88890. * This defines an action responsible to increment the target value
  88891. * to a desired value once triggered.
  88892. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88893. */
  88894. export class IncrementValueAction extends Action {
  88895. /**
  88896. * The path of the property to increment in the target.
  88897. */
  88898. propertyPath: string;
  88899. /**
  88900. * The value we should increment the property by.
  88901. */
  88902. value: any;
  88903. private _target;
  88904. private _effectiveTarget;
  88905. private _property;
  88906. /**
  88907. * Instantiate the action
  88908. * @param triggerOptions defines the trigger options
  88909. * @param target defines the object containing the property
  88910. * @param propertyPath defines the path of the property to increment in the target
  88911. * @param value defines the value value we should increment the property by
  88912. * @param condition defines the trigger related conditions
  88913. */
  88914. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88915. /** @hidden */
  88916. _prepare(): void;
  88917. /**
  88918. * Execute the action and increment the target of the value amount.
  88919. */
  88920. execute(): void;
  88921. /**
  88922. * Serializes the actions and its related information.
  88923. * @param parent defines the object to serialize in
  88924. * @returns the serialized object
  88925. */
  88926. serialize(parent: any): any;
  88927. }
  88928. /**
  88929. * This defines an action responsible to start an animation once triggered.
  88930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88931. */
  88932. export class PlayAnimationAction extends Action {
  88933. /**
  88934. * Where the animation should start (animation frame)
  88935. */
  88936. from: number;
  88937. /**
  88938. * Where the animation should stop (animation frame)
  88939. */
  88940. to: number;
  88941. /**
  88942. * Define if the animation should loop or stop after the first play.
  88943. */
  88944. loop?: boolean;
  88945. private _target;
  88946. /**
  88947. * Instantiate the action
  88948. * @param triggerOptions defines the trigger options
  88949. * @param target defines the target animation or animation name
  88950. * @param from defines from where the animation should start (animation frame)
  88951. * @param end defines where the animation should stop (animation frame)
  88952. * @param loop defines if the animation should loop or stop after the first play
  88953. * @param condition defines the trigger related conditions
  88954. */
  88955. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88956. /** @hidden */
  88957. _prepare(): void;
  88958. /**
  88959. * Execute the action and play the animation.
  88960. */
  88961. execute(): void;
  88962. /**
  88963. * Serializes the actions and its related information.
  88964. * @param parent defines the object to serialize in
  88965. * @returns the serialized object
  88966. */
  88967. serialize(parent: any): any;
  88968. }
  88969. /**
  88970. * This defines an action responsible to stop an animation once triggered.
  88971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88972. */
  88973. export class StopAnimationAction extends Action {
  88974. private _target;
  88975. /**
  88976. * Instantiate the action
  88977. * @param triggerOptions defines the trigger options
  88978. * @param target defines the target animation or animation name
  88979. * @param condition defines the trigger related conditions
  88980. */
  88981. constructor(triggerOptions: any, target: any, condition?: Condition);
  88982. /** @hidden */
  88983. _prepare(): void;
  88984. /**
  88985. * Execute the action and stop the animation.
  88986. */
  88987. execute(): void;
  88988. /**
  88989. * Serializes the actions and its related information.
  88990. * @param parent defines the object to serialize in
  88991. * @returns the serialized object
  88992. */
  88993. serialize(parent: any): any;
  88994. }
  88995. /**
  88996. * This defines an action responsible that does nothing once triggered.
  88997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88998. */
  88999. export class DoNothingAction extends Action {
  89000. /**
  89001. * Instantiate the action
  89002. * @param triggerOptions defines the trigger options
  89003. * @param condition defines the trigger related conditions
  89004. */
  89005. constructor(triggerOptions?: any, condition?: Condition);
  89006. /**
  89007. * Execute the action and do nothing.
  89008. */
  89009. execute(): void;
  89010. /**
  89011. * Serializes the actions and its related information.
  89012. * @param parent defines the object to serialize in
  89013. * @returns the serialized object
  89014. */
  89015. serialize(parent: any): any;
  89016. }
  89017. /**
  89018. * This defines an action responsible to trigger several actions once triggered.
  89019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89020. */
  89021. export class CombineAction extends Action {
  89022. /**
  89023. * The list of aggregated animations to run.
  89024. */
  89025. children: Action[];
  89026. /**
  89027. * Instantiate the action
  89028. * @param triggerOptions defines the trigger options
  89029. * @param children defines the list of aggregated animations to run
  89030. * @param condition defines the trigger related conditions
  89031. */
  89032. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89033. /** @hidden */
  89034. _prepare(): void;
  89035. /**
  89036. * Execute the action and executes all the aggregated actions.
  89037. */
  89038. execute(evt: ActionEvent): void;
  89039. /**
  89040. * Serializes the actions and its related information.
  89041. * @param parent defines the object to serialize in
  89042. * @returns the serialized object
  89043. */
  89044. serialize(parent: any): any;
  89045. }
  89046. /**
  89047. * This defines an action responsible to run code (external event) once triggered.
  89048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89049. */
  89050. export class ExecuteCodeAction extends Action {
  89051. /**
  89052. * The callback function to run.
  89053. */
  89054. func: (evt: ActionEvent) => void;
  89055. /**
  89056. * Instantiate the action
  89057. * @param triggerOptions defines the trigger options
  89058. * @param func defines the callback function to run
  89059. * @param condition defines the trigger related conditions
  89060. */
  89061. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89062. /**
  89063. * Execute the action and run the attached code.
  89064. */
  89065. execute(evt: ActionEvent): void;
  89066. }
  89067. /**
  89068. * This defines an action responsible to set the parent property of the target once triggered.
  89069. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89070. */
  89071. export class SetParentAction extends Action {
  89072. private _parent;
  89073. private _target;
  89074. /**
  89075. * Instantiate the action
  89076. * @param triggerOptions defines the trigger options
  89077. * @param target defines the target containing the parent property
  89078. * @param parent defines from where the animation should start (animation frame)
  89079. * @param condition defines the trigger related conditions
  89080. */
  89081. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89082. /** @hidden */
  89083. _prepare(): void;
  89084. /**
  89085. * Execute the action and set the parent property.
  89086. */
  89087. execute(): void;
  89088. /**
  89089. * Serializes the actions and its related information.
  89090. * @param parent defines the object to serialize in
  89091. * @returns the serialized object
  89092. */
  89093. serialize(parent: any): any;
  89094. }
  89095. }
  89096. declare module BABYLON {
  89097. /**
  89098. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89099. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89100. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89101. */
  89102. export class ActionManager extends AbstractActionManager {
  89103. /**
  89104. * Nothing
  89105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89106. */
  89107. static readonly NothingTrigger: number;
  89108. /**
  89109. * On pick
  89110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89111. */
  89112. static readonly OnPickTrigger: number;
  89113. /**
  89114. * On left pick
  89115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89116. */
  89117. static readonly OnLeftPickTrigger: number;
  89118. /**
  89119. * On right pick
  89120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89121. */
  89122. static readonly OnRightPickTrigger: number;
  89123. /**
  89124. * On center pick
  89125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89126. */
  89127. static readonly OnCenterPickTrigger: number;
  89128. /**
  89129. * On pick down
  89130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89131. */
  89132. static readonly OnPickDownTrigger: number;
  89133. /**
  89134. * On double pick
  89135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89136. */
  89137. static readonly OnDoublePickTrigger: number;
  89138. /**
  89139. * On pick up
  89140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89141. */
  89142. static readonly OnPickUpTrigger: number;
  89143. /**
  89144. * On pick out.
  89145. * This trigger will only be raised if you also declared a OnPickDown
  89146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89147. */
  89148. static readonly OnPickOutTrigger: number;
  89149. /**
  89150. * On long press
  89151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89152. */
  89153. static readonly OnLongPressTrigger: number;
  89154. /**
  89155. * On pointer over
  89156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89157. */
  89158. static readonly OnPointerOverTrigger: number;
  89159. /**
  89160. * On pointer out
  89161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89162. */
  89163. static readonly OnPointerOutTrigger: number;
  89164. /**
  89165. * On every frame
  89166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89167. */
  89168. static readonly OnEveryFrameTrigger: number;
  89169. /**
  89170. * On intersection enter
  89171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89172. */
  89173. static readonly OnIntersectionEnterTrigger: number;
  89174. /**
  89175. * On intersection exit
  89176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89177. */
  89178. static readonly OnIntersectionExitTrigger: number;
  89179. /**
  89180. * On key down
  89181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89182. */
  89183. static readonly OnKeyDownTrigger: number;
  89184. /**
  89185. * On key up
  89186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89187. */
  89188. static readonly OnKeyUpTrigger: number;
  89189. private _scene;
  89190. /**
  89191. * Creates a new action manager
  89192. * @param scene defines the hosting scene
  89193. */
  89194. constructor(scene: Scene);
  89195. /**
  89196. * Releases all associated resources
  89197. */
  89198. dispose(): void;
  89199. /**
  89200. * Gets hosting scene
  89201. * @returns the hosting scene
  89202. */
  89203. getScene(): Scene;
  89204. /**
  89205. * Does this action manager handles actions of any of the given triggers
  89206. * @param triggers defines the triggers to be tested
  89207. * @return a boolean indicating whether one (or more) of the triggers is handled
  89208. */
  89209. hasSpecificTriggers(triggers: number[]): boolean;
  89210. /**
  89211. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89212. * speed.
  89213. * @param triggerA defines the trigger to be tested
  89214. * @param triggerB defines the trigger to be tested
  89215. * @return a boolean indicating whether one (or more) of the triggers is handled
  89216. */
  89217. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89218. /**
  89219. * Does this action manager handles actions of a given trigger
  89220. * @param trigger defines the trigger to be tested
  89221. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89222. * @return whether the trigger is handled
  89223. */
  89224. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89225. /**
  89226. * Does this action manager has pointer triggers
  89227. */
  89228. get hasPointerTriggers(): boolean;
  89229. /**
  89230. * Does this action manager has pick triggers
  89231. */
  89232. get hasPickTriggers(): boolean;
  89233. /**
  89234. * Registers an action to this action manager
  89235. * @param action defines the action to be registered
  89236. * @return the action amended (prepared) after registration
  89237. */
  89238. registerAction(action: IAction): Nullable<IAction>;
  89239. /**
  89240. * Unregisters an action to this action manager
  89241. * @param action defines the action to be unregistered
  89242. * @return a boolean indicating whether the action has been unregistered
  89243. */
  89244. unregisterAction(action: IAction): Boolean;
  89245. /**
  89246. * Process a specific trigger
  89247. * @param trigger defines the trigger to process
  89248. * @param evt defines the event details to be processed
  89249. */
  89250. processTrigger(trigger: number, evt?: IActionEvent): void;
  89251. /** @hidden */
  89252. _getEffectiveTarget(target: any, propertyPath: string): any;
  89253. /** @hidden */
  89254. _getProperty(propertyPath: string): string;
  89255. /**
  89256. * Serialize this manager to a JSON object
  89257. * @param name defines the property name to store this manager
  89258. * @returns a JSON representation of this manager
  89259. */
  89260. serialize(name: string): any;
  89261. /**
  89262. * Creates a new ActionManager from a JSON data
  89263. * @param parsedActions defines the JSON data to read from
  89264. * @param object defines the hosting mesh
  89265. * @param scene defines the hosting scene
  89266. */
  89267. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89268. /**
  89269. * Get a trigger name by index
  89270. * @param trigger defines the trigger index
  89271. * @returns a trigger name
  89272. */
  89273. static GetTriggerName(trigger: number): string;
  89274. }
  89275. }
  89276. declare module BABYLON {
  89277. /**
  89278. * Class used to represent a sprite
  89279. * @see https://doc.babylonjs.com/babylon101/sprites
  89280. */
  89281. export class Sprite implements IAnimatable {
  89282. /** defines the name */
  89283. name: string;
  89284. /** Gets or sets the current world position */
  89285. position: Vector3;
  89286. /** Gets or sets the main color */
  89287. color: Color4;
  89288. /** Gets or sets the width */
  89289. width: number;
  89290. /** Gets or sets the height */
  89291. height: number;
  89292. /** Gets or sets rotation angle */
  89293. angle: number;
  89294. /** Gets or sets the cell index in the sprite sheet */
  89295. cellIndex: number;
  89296. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89297. cellRef: string;
  89298. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89299. invertU: boolean;
  89300. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89301. invertV: boolean;
  89302. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89303. disposeWhenFinishedAnimating: boolean;
  89304. /** Gets the list of attached animations */
  89305. animations: Nullable<Array<Animation>>;
  89306. /** Gets or sets a boolean indicating if the sprite can be picked */
  89307. isPickable: boolean;
  89308. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89309. useAlphaForPicking: boolean;
  89310. /** @hidden */
  89311. _xOffset: number;
  89312. /** @hidden */
  89313. _yOffset: number;
  89314. /** @hidden */
  89315. _xSize: number;
  89316. /** @hidden */
  89317. _ySize: number;
  89318. /**
  89319. * Gets or sets the associated action manager
  89320. */
  89321. actionManager: Nullable<ActionManager>;
  89322. /**
  89323. * An event triggered when the control has been disposed
  89324. */
  89325. onDisposeObservable: Observable<Sprite>;
  89326. private _animationStarted;
  89327. private _loopAnimation;
  89328. private _fromIndex;
  89329. private _toIndex;
  89330. private _delay;
  89331. private _direction;
  89332. private _manager;
  89333. private _time;
  89334. private _onAnimationEnd;
  89335. /**
  89336. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89337. */
  89338. isVisible: boolean;
  89339. /**
  89340. * Gets or sets the sprite size
  89341. */
  89342. get size(): number;
  89343. set size(value: number);
  89344. /**
  89345. * Returns a boolean indicating if the animation is started
  89346. */
  89347. get animationStarted(): boolean;
  89348. /**
  89349. * Gets or sets the unique id of the sprite
  89350. */
  89351. uniqueId: number;
  89352. /**
  89353. * Gets the manager of this sprite
  89354. */
  89355. get manager(): ISpriteManager;
  89356. /**
  89357. * Creates a new Sprite
  89358. * @param name defines the name
  89359. * @param manager defines the manager
  89360. */
  89361. constructor(
  89362. /** defines the name */
  89363. name: string, manager: ISpriteManager);
  89364. /**
  89365. * Returns the string "Sprite"
  89366. * @returns "Sprite"
  89367. */
  89368. getClassName(): string;
  89369. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89370. get fromIndex(): number;
  89371. set fromIndex(value: number);
  89372. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89373. get toIndex(): number;
  89374. set toIndex(value: number);
  89375. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89376. get loopAnimation(): boolean;
  89377. set loopAnimation(value: boolean);
  89378. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89379. get delay(): number;
  89380. set delay(value: number);
  89381. /**
  89382. * Starts an animation
  89383. * @param from defines the initial key
  89384. * @param to defines the end key
  89385. * @param loop defines if the animation must loop
  89386. * @param delay defines the start delay (in ms)
  89387. * @param onAnimationEnd defines a callback to call when animation ends
  89388. */
  89389. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89390. /** Stops current animation (if any) */
  89391. stopAnimation(): void;
  89392. /** @hidden */
  89393. _animate(deltaTime: number): void;
  89394. /** Release associated resources */
  89395. dispose(): void;
  89396. /**
  89397. * Serializes the sprite to a JSON object
  89398. * @returns the JSON object
  89399. */
  89400. serialize(): any;
  89401. /**
  89402. * Parses a JSON object to create a new sprite
  89403. * @param parsedSprite The JSON object to parse
  89404. * @param manager defines the hosting manager
  89405. * @returns the new sprite
  89406. */
  89407. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89408. }
  89409. }
  89410. declare module BABYLON {
  89411. /**
  89412. * Information about the result of picking within a scene
  89413. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89414. */
  89415. export class PickingInfo {
  89416. /** @hidden */
  89417. _pickingUnavailable: boolean;
  89418. /**
  89419. * If the pick collided with an object
  89420. */
  89421. hit: boolean;
  89422. /**
  89423. * Distance away where the pick collided
  89424. */
  89425. distance: number;
  89426. /**
  89427. * The location of pick collision
  89428. */
  89429. pickedPoint: Nullable<Vector3>;
  89430. /**
  89431. * The mesh corresponding the the pick collision
  89432. */
  89433. pickedMesh: Nullable<AbstractMesh>;
  89434. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89435. bu: number;
  89436. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89437. bv: number;
  89438. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89439. faceId: number;
  89440. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89441. subMeshFaceId: number;
  89442. /** Id of the the submesh that was picked */
  89443. subMeshId: number;
  89444. /** If a sprite was picked, this will be the sprite the pick collided with */
  89445. pickedSprite: Nullable<Sprite>;
  89446. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89447. thinInstanceIndex: number;
  89448. /**
  89449. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89450. */
  89451. originMesh: Nullable<AbstractMesh>;
  89452. /**
  89453. * The ray that was used to perform the picking.
  89454. */
  89455. ray: Nullable<Ray>;
  89456. /**
  89457. * Gets the normal correspodning to the face the pick collided with
  89458. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89459. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89460. * @returns The normal correspodning to the face the pick collided with
  89461. */
  89462. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89463. /**
  89464. * Gets the texture coordinates of where the pick occured
  89465. * @returns the vector containing the coordnates of the texture
  89466. */
  89467. getTextureCoordinates(): Nullable<Vector2>;
  89468. }
  89469. }
  89470. declare module BABYLON {
  89471. /**
  89472. * Class representing a ray with position and direction
  89473. */
  89474. export class Ray {
  89475. /** origin point */
  89476. origin: Vector3;
  89477. /** direction */
  89478. direction: Vector3;
  89479. /** length of the ray */
  89480. length: number;
  89481. private static readonly _TmpVector3;
  89482. private _tmpRay;
  89483. /**
  89484. * Creates a new ray
  89485. * @param origin origin point
  89486. * @param direction direction
  89487. * @param length length of the ray
  89488. */
  89489. constructor(
  89490. /** origin point */
  89491. origin: Vector3,
  89492. /** direction */
  89493. direction: Vector3,
  89494. /** length of the ray */
  89495. length?: number);
  89496. /**
  89497. * Checks if the ray intersects a box
  89498. * This does not account for the ray lenght by design to improve perfs.
  89499. * @param minimum bound of the box
  89500. * @param maximum bound of the box
  89501. * @param intersectionTreshold extra extend to be added to the box in all direction
  89502. * @returns if the box was hit
  89503. */
  89504. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89505. /**
  89506. * Checks if the ray intersects a box
  89507. * This does not account for the ray lenght by design to improve perfs.
  89508. * @param box the bounding box to check
  89509. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89510. * @returns if the box was hit
  89511. */
  89512. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89513. /**
  89514. * If the ray hits a sphere
  89515. * @param sphere the bounding sphere to check
  89516. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89517. * @returns true if it hits the sphere
  89518. */
  89519. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89520. /**
  89521. * If the ray hits a triange
  89522. * @param vertex0 triangle vertex
  89523. * @param vertex1 triangle vertex
  89524. * @param vertex2 triangle vertex
  89525. * @returns intersection information if hit
  89526. */
  89527. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89528. /**
  89529. * Checks if ray intersects a plane
  89530. * @param plane the plane to check
  89531. * @returns the distance away it was hit
  89532. */
  89533. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89534. /**
  89535. * Calculate the intercept of a ray on a given axis
  89536. * @param axis to check 'x' | 'y' | 'z'
  89537. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89538. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89539. */
  89540. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89541. /**
  89542. * Checks if ray intersects a mesh
  89543. * @param mesh the mesh to check
  89544. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89545. * @returns picking info of the intersecton
  89546. */
  89547. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89548. /**
  89549. * Checks if ray intersects a mesh
  89550. * @param meshes the meshes to check
  89551. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89552. * @param results array to store result in
  89553. * @returns Array of picking infos
  89554. */
  89555. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89556. private _comparePickingInfo;
  89557. private static smallnum;
  89558. private static rayl;
  89559. /**
  89560. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89561. * @param sega the first point of the segment to test the intersection against
  89562. * @param segb the second point of the segment to test the intersection against
  89563. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89564. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89565. */
  89566. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89567. /**
  89568. * Update the ray from viewport position
  89569. * @param x position
  89570. * @param y y position
  89571. * @param viewportWidth viewport width
  89572. * @param viewportHeight viewport height
  89573. * @param world world matrix
  89574. * @param view view matrix
  89575. * @param projection projection matrix
  89576. * @returns this ray updated
  89577. */
  89578. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89579. /**
  89580. * Creates a ray with origin and direction of 0,0,0
  89581. * @returns the new ray
  89582. */
  89583. static Zero(): Ray;
  89584. /**
  89585. * Creates a new ray from screen space and viewport
  89586. * @param x position
  89587. * @param y y position
  89588. * @param viewportWidth viewport width
  89589. * @param viewportHeight viewport height
  89590. * @param world world matrix
  89591. * @param view view matrix
  89592. * @param projection projection matrix
  89593. * @returns new ray
  89594. */
  89595. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89596. /**
  89597. * 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
  89598. * transformed to the given world matrix.
  89599. * @param origin The origin point
  89600. * @param end The end point
  89601. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89602. * @returns the new ray
  89603. */
  89604. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89605. /**
  89606. * Transforms a ray by a matrix
  89607. * @param ray ray to transform
  89608. * @param matrix matrix to apply
  89609. * @returns the resulting new ray
  89610. */
  89611. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89612. /**
  89613. * Transforms a ray by a matrix
  89614. * @param ray ray to transform
  89615. * @param matrix matrix to apply
  89616. * @param result ray to store result in
  89617. */
  89618. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89619. /**
  89620. * Unproject a ray from screen space to object space
  89621. * @param sourceX defines the screen space x coordinate to use
  89622. * @param sourceY defines the screen space y coordinate to use
  89623. * @param viewportWidth defines the current width of the viewport
  89624. * @param viewportHeight defines the current height of the viewport
  89625. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89626. * @param view defines the view matrix to use
  89627. * @param projection defines the projection matrix to use
  89628. */
  89629. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89630. }
  89631. /**
  89632. * Type used to define predicate used to select faces when a mesh intersection is detected
  89633. */
  89634. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89635. interface Scene {
  89636. /** @hidden */
  89637. _tempPickingRay: Nullable<Ray>;
  89638. /** @hidden */
  89639. _cachedRayForTransform: Ray;
  89640. /** @hidden */
  89641. _pickWithRayInverseMatrix: Matrix;
  89642. /** @hidden */
  89643. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89644. /** @hidden */
  89645. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89646. /** @hidden */
  89647. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89648. }
  89649. }
  89650. declare module BABYLON {
  89651. /**
  89652. * Groups all the scene component constants in one place to ease maintenance.
  89653. * @hidden
  89654. */
  89655. export class SceneComponentConstants {
  89656. static readonly NAME_EFFECTLAYER: string;
  89657. static readonly NAME_LAYER: string;
  89658. static readonly NAME_LENSFLARESYSTEM: string;
  89659. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89660. static readonly NAME_PARTICLESYSTEM: string;
  89661. static readonly NAME_GAMEPAD: string;
  89662. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89663. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89664. static readonly NAME_PREPASSRENDERER: string;
  89665. static readonly NAME_DEPTHRENDERER: string;
  89666. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89667. static readonly NAME_SPRITE: string;
  89668. static readonly NAME_OUTLINERENDERER: string;
  89669. static readonly NAME_PROCEDURALTEXTURE: string;
  89670. static readonly NAME_SHADOWGENERATOR: string;
  89671. static readonly NAME_OCTREE: string;
  89672. static readonly NAME_PHYSICSENGINE: string;
  89673. static readonly NAME_AUDIO: string;
  89674. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89675. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89676. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89677. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89678. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89679. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89680. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89681. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89682. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89683. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89684. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89685. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89686. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89687. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89688. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89689. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89690. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89691. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89692. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89693. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89694. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89695. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89696. static readonly STEP_AFTERRENDER_AUDIO: number;
  89697. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89698. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89699. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89700. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89701. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89702. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89703. static readonly STEP_POINTERMOVE_SPRITE: number;
  89704. static readonly STEP_POINTERDOWN_SPRITE: number;
  89705. static readonly STEP_POINTERUP_SPRITE: number;
  89706. }
  89707. /**
  89708. * This represents a scene component.
  89709. *
  89710. * This is used to decouple the dependency the scene is having on the different workloads like
  89711. * layers, post processes...
  89712. */
  89713. export interface ISceneComponent {
  89714. /**
  89715. * The name of the component. Each component must have a unique name.
  89716. */
  89717. name: string;
  89718. /**
  89719. * The scene the component belongs to.
  89720. */
  89721. scene: Scene;
  89722. /**
  89723. * Register the component to one instance of a scene.
  89724. */
  89725. register(): void;
  89726. /**
  89727. * Rebuilds the elements related to this component in case of
  89728. * context lost for instance.
  89729. */
  89730. rebuild(): void;
  89731. /**
  89732. * Disposes the component and the associated ressources.
  89733. */
  89734. dispose(): void;
  89735. }
  89736. /**
  89737. * This represents a SERIALIZABLE scene component.
  89738. *
  89739. * This extends Scene Component to add Serialization methods on top.
  89740. */
  89741. export interface ISceneSerializableComponent extends ISceneComponent {
  89742. /**
  89743. * Adds all the elements from the container to the scene
  89744. * @param container the container holding the elements
  89745. */
  89746. addFromContainer(container: AbstractScene): void;
  89747. /**
  89748. * Removes all the elements in the container from the scene
  89749. * @param container contains the elements to remove
  89750. * @param dispose if the removed element should be disposed (default: false)
  89751. */
  89752. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89753. /**
  89754. * Serializes the component data to the specified json object
  89755. * @param serializationObject The object to serialize to
  89756. */
  89757. serialize(serializationObject: any): void;
  89758. }
  89759. /**
  89760. * Strong typing of a Mesh related stage step action
  89761. */
  89762. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89763. /**
  89764. * Strong typing of a Evaluate Sub Mesh related stage step action
  89765. */
  89766. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89767. /**
  89768. * Strong typing of a Active Mesh related stage step action
  89769. */
  89770. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89771. /**
  89772. * Strong typing of a Camera related stage step action
  89773. */
  89774. export type CameraStageAction = (camera: Camera) => void;
  89775. /**
  89776. * Strong typing of a Camera Frame buffer related stage step action
  89777. */
  89778. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89779. /**
  89780. * Strong typing of a Render Target related stage step action
  89781. */
  89782. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89783. /**
  89784. * Strong typing of a RenderingGroup related stage step action
  89785. */
  89786. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89787. /**
  89788. * Strong typing of a Mesh Render related stage step action
  89789. */
  89790. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89791. /**
  89792. * Strong typing of a simple stage step action
  89793. */
  89794. export type SimpleStageAction = () => void;
  89795. /**
  89796. * Strong typing of a render target action.
  89797. */
  89798. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89799. /**
  89800. * Strong typing of a pointer move action.
  89801. */
  89802. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89803. /**
  89804. * Strong typing of a pointer up/down action.
  89805. */
  89806. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89807. /**
  89808. * Representation of a stage in the scene (Basically a list of ordered steps)
  89809. * @hidden
  89810. */
  89811. export class Stage<T extends Function> extends Array<{
  89812. index: number;
  89813. component: ISceneComponent;
  89814. action: T;
  89815. }> {
  89816. /**
  89817. * Hide ctor from the rest of the world.
  89818. * @param items The items to add.
  89819. */
  89820. private constructor();
  89821. /**
  89822. * Creates a new Stage.
  89823. * @returns A new instance of a Stage
  89824. */
  89825. static Create<T extends Function>(): Stage<T>;
  89826. /**
  89827. * Registers a step in an ordered way in the targeted stage.
  89828. * @param index Defines the position to register the step in
  89829. * @param component Defines the component attached to the step
  89830. * @param action Defines the action to launch during the step
  89831. */
  89832. registerStep(index: number, component: ISceneComponent, action: T): void;
  89833. /**
  89834. * Clears all the steps from the stage.
  89835. */
  89836. clear(): void;
  89837. }
  89838. }
  89839. declare module BABYLON {
  89840. interface Scene {
  89841. /** @hidden */
  89842. _pointerOverSprite: Nullable<Sprite>;
  89843. /** @hidden */
  89844. _pickedDownSprite: Nullable<Sprite>;
  89845. /** @hidden */
  89846. _tempSpritePickingRay: Nullable<Ray>;
  89847. /**
  89848. * All of the sprite managers added to this scene
  89849. * @see https://doc.babylonjs.com/babylon101/sprites
  89850. */
  89851. spriteManagers: Array<ISpriteManager>;
  89852. /**
  89853. * An event triggered when sprites rendering is about to start
  89854. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89855. */
  89856. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89857. /**
  89858. * An event triggered when sprites rendering is done
  89859. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89860. */
  89861. onAfterSpritesRenderingObservable: Observable<Scene>;
  89862. /** @hidden */
  89863. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89864. /** Launch a ray to try to pick a sprite in the scene
  89865. * @param x position on screen
  89866. * @param y position on screen
  89867. * @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
  89868. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89869. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89870. * @returns a PickingInfo
  89871. */
  89872. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89873. /** Use the given ray to pick a sprite in the scene
  89874. * @param ray The ray (in world space) to use to pick meshes
  89875. * @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
  89876. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89877. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89878. * @returns a PickingInfo
  89879. */
  89880. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89881. /** @hidden */
  89882. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89883. /** Launch a ray to try to pick sprites in the scene
  89884. * @param x position on screen
  89885. * @param y position on screen
  89886. * @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
  89887. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89888. * @returns a PickingInfo array
  89889. */
  89890. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89891. /** Use the given ray to pick sprites in the scene
  89892. * @param ray The ray (in world space) to use to pick meshes
  89893. * @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
  89894. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89895. * @returns a PickingInfo array
  89896. */
  89897. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89898. /**
  89899. * Force the sprite under the pointer
  89900. * @param sprite defines the sprite to use
  89901. */
  89902. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89903. /**
  89904. * Gets the sprite under the pointer
  89905. * @returns a Sprite or null if no sprite is under the pointer
  89906. */
  89907. getPointerOverSprite(): Nullable<Sprite>;
  89908. }
  89909. /**
  89910. * Defines the sprite scene component responsible to manage sprites
  89911. * in a given scene.
  89912. */
  89913. export class SpriteSceneComponent implements ISceneComponent {
  89914. /**
  89915. * The component name helpfull to identify the component in the list of scene components.
  89916. */
  89917. readonly name: string;
  89918. /**
  89919. * The scene the component belongs to.
  89920. */
  89921. scene: Scene;
  89922. /** @hidden */
  89923. private _spritePredicate;
  89924. /**
  89925. * Creates a new instance of the component for the given scene
  89926. * @param scene Defines the scene to register the component in
  89927. */
  89928. constructor(scene: Scene);
  89929. /**
  89930. * Registers the component in a given scene
  89931. */
  89932. register(): void;
  89933. /**
  89934. * Rebuilds the elements related to this component in case of
  89935. * context lost for instance.
  89936. */
  89937. rebuild(): void;
  89938. /**
  89939. * Disposes the component and the associated ressources.
  89940. */
  89941. dispose(): void;
  89942. private _pickSpriteButKeepRay;
  89943. private _pointerMove;
  89944. private _pointerDown;
  89945. private _pointerUp;
  89946. }
  89947. }
  89948. declare module BABYLON {
  89949. /** @hidden */
  89950. export var fogFragmentDeclaration: {
  89951. name: string;
  89952. shader: string;
  89953. };
  89954. }
  89955. declare module BABYLON {
  89956. /** @hidden */
  89957. export var fogFragment: {
  89958. name: string;
  89959. shader: string;
  89960. };
  89961. }
  89962. declare module BABYLON {
  89963. /** @hidden */
  89964. export var spritesPixelShader: {
  89965. name: string;
  89966. shader: string;
  89967. };
  89968. }
  89969. declare module BABYLON {
  89970. /** @hidden */
  89971. export var fogVertexDeclaration: {
  89972. name: string;
  89973. shader: string;
  89974. };
  89975. }
  89976. declare module BABYLON {
  89977. /** @hidden */
  89978. export var spritesVertexShader: {
  89979. name: string;
  89980. shader: string;
  89981. };
  89982. }
  89983. declare module BABYLON {
  89984. /**
  89985. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89986. */
  89987. export interface ISpriteManager extends IDisposable {
  89988. /**
  89989. * Gets manager's name
  89990. */
  89991. name: string;
  89992. /**
  89993. * Restricts the camera to viewing objects with the same layerMask.
  89994. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89995. */
  89996. layerMask: number;
  89997. /**
  89998. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89999. */
  90000. isPickable: boolean;
  90001. /**
  90002. * Gets the hosting scene
  90003. */
  90004. scene: Scene;
  90005. /**
  90006. * Specifies the rendering group id for this mesh (0 by default)
  90007. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90008. */
  90009. renderingGroupId: number;
  90010. /**
  90011. * Defines the list of sprites managed by the manager.
  90012. */
  90013. sprites: Array<Sprite>;
  90014. /**
  90015. * Gets or sets the spritesheet texture
  90016. */
  90017. texture: Texture;
  90018. /** Defines the default width of a cell in the spritesheet */
  90019. cellWidth: number;
  90020. /** Defines the default height of a cell in the spritesheet */
  90021. cellHeight: number;
  90022. /**
  90023. * Tests the intersection of a sprite with a specific ray.
  90024. * @param ray The ray we are sending to test the collision
  90025. * @param camera The camera space we are sending rays in
  90026. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90027. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90028. * @returns picking info or null.
  90029. */
  90030. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90031. /**
  90032. * Intersects the sprites with a ray
  90033. * @param ray defines the ray to intersect with
  90034. * @param camera defines the current active camera
  90035. * @param predicate defines a predicate used to select candidate sprites
  90036. * @returns null if no hit or a PickingInfo array
  90037. */
  90038. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90039. /**
  90040. * Renders the list of sprites on screen.
  90041. */
  90042. render(): void;
  90043. }
  90044. /**
  90045. * Class used to manage multiple sprites on the same spritesheet
  90046. * @see https://doc.babylonjs.com/babylon101/sprites
  90047. */
  90048. export class SpriteManager implements ISpriteManager {
  90049. /** defines the manager's name */
  90050. name: string;
  90051. /** Define the Url to load snippets */
  90052. static SnippetUrl: string;
  90053. /** Snippet ID if the manager was created from the snippet server */
  90054. snippetId: string;
  90055. /** Gets the list of sprites */
  90056. sprites: Sprite[];
  90057. /** Gets or sets the rendering group id (0 by default) */
  90058. renderingGroupId: number;
  90059. /** Gets or sets camera layer mask */
  90060. layerMask: number;
  90061. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90062. fogEnabled: boolean;
  90063. /** Gets or sets a boolean indicating if the sprites are pickable */
  90064. isPickable: boolean;
  90065. /** Defines the default width of a cell in the spritesheet */
  90066. cellWidth: number;
  90067. /** Defines the default height of a cell in the spritesheet */
  90068. cellHeight: number;
  90069. /** Associative array from JSON sprite data file */
  90070. private _cellData;
  90071. /** Array of sprite names from JSON sprite data file */
  90072. private _spriteMap;
  90073. /** True when packed cell data from JSON file is ready*/
  90074. private _packedAndReady;
  90075. private _textureContent;
  90076. private _useInstancing;
  90077. /**
  90078. * An event triggered when the manager is disposed.
  90079. */
  90080. onDisposeObservable: Observable<SpriteManager>;
  90081. private _onDisposeObserver;
  90082. /**
  90083. * Callback called when the manager is disposed
  90084. */
  90085. set onDispose(callback: () => void);
  90086. private _capacity;
  90087. private _fromPacked;
  90088. private _spriteTexture;
  90089. private _epsilon;
  90090. private _scene;
  90091. private _vertexData;
  90092. private _buffer;
  90093. private _vertexBuffers;
  90094. private _spriteBuffer;
  90095. private _indexBuffer;
  90096. private _effectBase;
  90097. private _effectFog;
  90098. private _vertexBufferSize;
  90099. /**
  90100. * Gets or sets the unique id of the sprite
  90101. */
  90102. uniqueId: number;
  90103. /**
  90104. * Gets the array of sprites
  90105. */
  90106. get children(): Sprite[];
  90107. /**
  90108. * Gets the hosting scene
  90109. */
  90110. get scene(): Scene;
  90111. /**
  90112. * Gets the capacity of the manager
  90113. */
  90114. get capacity(): number;
  90115. /**
  90116. * Gets or sets the spritesheet texture
  90117. */
  90118. get texture(): Texture;
  90119. set texture(value: Texture);
  90120. private _blendMode;
  90121. /**
  90122. * Blend mode use to render the particle, it can be any of
  90123. * the static Constants.ALPHA_x properties provided in this class.
  90124. * Default value is Constants.ALPHA_COMBINE
  90125. */
  90126. get blendMode(): number;
  90127. set blendMode(blendMode: number);
  90128. /** Disables writing to the depth buffer when rendering the sprites.
  90129. * It can be handy to disable depth writing when using textures without alpha channel
  90130. * and setting some specific blend modes.
  90131. */
  90132. disableDepthWrite: boolean;
  90133. /**
  90134. * Creates a new sprite manager
  90135. * @param name defines the manager's name
  90136. * @param imgUrl defines the sprite sheet url
  90137. * @param capacity defines the maximum allowed number of sprites
  90138. * @param cellSize defines the size of a sprite cell
  90139. * @param scene defines the hosting scene
  90140. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90141. * @param samplingMode defines the smapling mode to use with spritesheet
  90142. * @param fromPacked set to false; do not alter
  90143. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90144. */
  90145. constructor(
  90146. /** defines the manager's name */
  90147. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90148. /**
  90149. * Returns the string "SpriteManager"
  90150. * @returns "SpriteManager"
  90151. */
  90152. getClassName(): string;
  90153. private _makePacked;
  90154. private _appendSpriteVertex;
  90155. private _checkTextureAlpha;
  90156. /**
  90157. * Intersects the sprites with a ray
  90158. * @param ray defines the ray to intersect with
  90159. * @param camera defines the current active camera
  90160. * @param predicate defines a predicate used to select candidate sprites
  90161. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90162. * @returns null if no hit or a PickingInfo
  90163. */
  90164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90165. /**
  90166. * Intersects the sprites with a ray
  90167. * @param ray defines the ray to intersect with
  90168. * @param camera defines the current active camera
  90169. * @param predicate defines a predicate used to select candidate sprites
  90170. * @returns null if no hit or a PickingInfo array
  90171. */
  90172. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90173. /**
  90174. * Render all child sprites
  90175. */
  90176. render(): void;
  90177. /**
  90178. * Release associated resources
  90179. */
  90180. dispose(): void;
  90181. /**
  90182. * Serializes the sprite manager to a JSON object
  90183. * @param serializeTexture defines if the texture must be serialized as well
  90184. * @returns the JSON object
  90185. */
  90186. serialize(serializeTexture?: boolean): any;
  90187. /**
  90188. * Parses a JSON object to create a new sprite manager.
  90189. * @param parsedManager The JSON object to parse
  90190. * @param scene The scene to create the sprite managerin
  90191. * @param rootUrl The root url to use to load external dependencies like texture
  90192. * @returns the new sprite manager
  90193. */
  90194. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90195. /**
  90196. * Creates a sprite manager from a snippet saved in a remote file
  90197. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90198. * @param url defines the url to load from
  90199. * @param scene defines the hosting scene
  90200. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90201. * @returns a promise that will resolve to the new sprite manager
  90202. */
  90203. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90204. /**
  90205. * Creates a sprite manager from a snippet saved by the sprite editor
  90206. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90207. * @param scene defines the hosting scene
  90208. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90209. * @returns a promise that will resolve to the new sprite manager
  90210. */
  90211. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90212. }
  90213. }
  90214. declare module BABYLON {
  90215. /** Interface used by value gradients (color, factor, ...) */
  90216. export interface IValueGradient {
  90217. /**
  90218. * Gets or sets the gradient value (between 0 and 1)
  90219. */
  90220. gradient: number;
  90221. }
  90222. /** Class used to store color4 gradient */
  90223. export class ColorGradient implements IValueGradient {
  90224. /**
  90225. * Gets or sets the gradient value (between 0 and 1)
  90226. */
  90227. gradient: number;
  90228. /**
  90229. * Gets or sets first associated color
  90230. */
  90231. color1: Color4;
  90232. /**
  90233. * Gets or sets second associated color
  90234. */
  90235. color2?: Color4 | undefined;
  90236. /**
  90237. * Creates a new color4 gradient
  90238. * @param gradient gets or sets the gradient value (between 0 and 1)
  90239. * @param color1 gets or sets first associated color
  90240. * @param color2 gets or sets first second color
  90241. */
  90242. constructor(
  90243. /**
  90244. * Gets or sets the gradient value (between 0 and 1)
  90245. */
  90246. gradient: number,
  90247. /**
  90248. * Gets or sets first associated color
  90249. */
  90250. color1: Color4,
  90251. /**
  90252. * Gets or sets second associated color
  90253. */
  90254. color2?: Color4 | undefined);
  90255. /**
  90256. * Will get a color picked randomly between color1 and color2.
  90257. * If color2 is undefined then color1 will be used
  90258. * @param result defines the target Color4 to store the result in
  90259. */
  90260. getColorToRef(result: Color4): void;
  90261. }
  90262. /** Class used to store color 3 gradient */
  90263. export class Color3Gradient implements IValueGradient {
  90264. /**
  90265. * Gets or sets the gradient value (between 0 and 1)
  90266. */
  90267. gradient: number;
  90268. /**
  90269. * Gets or sets the associated color
  90270. */
  90271. color: Color3;
  90272. /**
  90273. * Creates a new color3 gradient
  90274. * @param gradient gets or sets the gradient value (between 0 and 1)
  90275. * @param color gets or sets associated color
  90276. */
  90277. constructor(
  90278. /**
  90279. * Gets or sets the gradient value (between 0 and 1)
  90280. */
  90281. gradient: number,
  90282. /**
  90283. * Gets or sets the associated color
  90284. */
  90285. color: Color3);
  90286. }
  90287. /** Class used to store factor gradient */
  90288. export class FactorGradient implements IValueGradient {
  90289. /**
  90290. * Gets or sets the gradient value (between 0 and 1)
  90291. */
  90292. gradient: number;
  90293. /**
  90294. * Gets or sets first associated factor
  90295. */
  90296. factor1: number;
  90297. /**
  90298. * Gets or sets second associated factor
  90299. */
  90300. factor2?: number | undefined;
  90301. /**
  90302. * Creates a new factor gradient
  90303. * @param gradient gets or sets the gradient value (between 0 and 1)
  90304. * @param factor1 gets or sets first associated factor
  90305. * @param factor2 gets or sets second associated factor
  90306. */
  90307. constructor(
  90308. /**
  90309. * Gets or sets the gradient value (between 0 and 1)
  90310. */
  90311. gradient: number,
  90312. /**
  90313. * Gets or sets first associated factor
  90314. */
  90315. factor1: number,
  90316. /**
  90317. * Gets or sets second associated factor
  90318. */
  90319. factor2?: number | undefined);
  90320. /**
  90321. * Will get a number picked randomly between factor1 and factor2.
  90322. * If factor2 is undefined then factor1 will be used
  90323. * @returns the picked number
  90324. */
  90325. getFactor(): number;
  90326. }
  90327. /**
  90328. * Helper used to simplify some generic gradient tasks
  90329. */
  90330. export class GradientHelper {
  90331. /**
  90332. * Gets the current gradient from an array of IValueGradient
  90333. * @param ratio defines the current ratio to get
  90334. * @param gradients defines the array of IValueGradient
  90335. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90336. */
  90337. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90338. }
  90339. }
  90340. declare module BABYLON {
  90341. interface ThinEngine {
  90342. /**
  90343. * Creates a raw texture
  90344. * @param data defines the data to store in the texture
  90345. * @param width defines the width of the texture
  90346. * @param height defines the height of the texture
  90347. * @param format defines the format of the data
  90348. * @param generateMipMaps defines if the engine should generate the mip levels
  90349. * @param invertY defines if data must be stored with Y axis inverted
  90350. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90351. * @param compression defines the compression used (null by default)
  90352. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90353. * @returns the raw texture inside an InternalTexture
  90354. */
  90355. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90356. /**
  90357. * Update a raw texture
  90358. * @param texture defines the texture to update
  90359. * @param data defines the data to store in the texture
  90360. * @param format defines the format of the data
  90361. * @param invertY defines if data must be stored with Y axis inverted
  90362. */
  90363. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90364. /**
  90365. * Update a raw texture
  90366. * @param texture defines the texture to update
  90367. * @param data defines the data to store in the texture
  90368. * @param format defines the format of the data
  90369. * @param invertY defines if data must be stored with Y axis inverted
  90370. * @param compression defines the compression used (null by default)
  90371. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90372. */
  90373. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90374. /**
  90375. * Creates a new raw cube texture
  90376. * @param data defines the array of data to use to create each face
  90377. * @param size defines the size of the textures
  90378. * @param format defines the format of the data
  90379. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90380. * @param generateMipMaps defines if the engine should generate the mip levels
  90381. * @param invertY defines if data must be stored with Y axis inverted
  90382. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90383. * @param compression defines the compression used (null by default)
  90384. * @returns the cube texture as an InternalTexture
  90385. */
  90386. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90387. /**
  90388. * Update a raw cube texture
  90389. * @param texture defines the texture to udpdate
  90390. * @param data defines the data to store
  90391. * @param format defines the data format
  90392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90393. * @param invertY defines if data must be stored with Y axis inverted
  90394. */
  90395. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90396. /**
  90397. * Update a raw cube texture
  90398. * @param texture defines the texture to udpdate
  90399. * @param data defines the data to store
  90400. * @param format defines the data format
  90401. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90402. * @param invertY defines if data must be stored with Y axis inverted
  90403. * @param compression defines the compression used (null by default)
  90404. */
  90405. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90406. /**
  90407. * Update a raw cube texture
  90408. * @param texture defines the texture to udpdate
  90409. * @param data defines the data to store
  90410. * @param format defines the data format
  90411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90412. * @param invertY defines if data must be stored with Y axis inverted
  90413. * @param compression defines the compression used (null by default)
  90414. * @param level defines which level of the texture to update
  90415. */
  90416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90417. /**
  90418. * Creates a new raw cube texture from a specified url
  90419. * @param url defines the url where the data is located
  90420. * @param scene defines the current scene
  90421. * @param size defines the size of the textures
  90422. * @param format defines the format of the data
  90423. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90424. * @param noMipmap defines if the engine should avoid generating the mip levels
  90425. * @param callback defines a callback used to extract texture data from loaded data
  90426. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90427. * @param onLoad defines a callback called when texture is loaded
  90428. * @param onError defines a callback called if there is an error
  90429. * @returns the cube texture as an InternalTexture
  90430. */
  90431. 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;
  90432. /**
  90433. * Creates a new raw cube texture from a specified url
  90434. * @param url defines the url where the data is located
  90435. * @param scene defines the current scene
  90436. * @param size defines the size of the textures
  90437. * @param format defines the format of the data
  90438. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90439. * @param noMipmap defines if the engine should avoid generating the mip levels
  90440. * @param callback defines a callback used to extract texture data from loaded data
  90441. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90442. * @param onLoad defines a callback called when texture is loaded
  90443. * @param onError defines a callback called if there is an error
  90444. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90445. * @param invertY defines if data must be stored with Y axis inverted
  90446. * @returns the cube texture as an InternalTexture
  90447. */
  90448. 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;
  90449. /**
  90450. * Creates a new raw 3D texture
  90451. * @param data defines the data used to create the texture
  90452. * @param width defines the width of the texture
  90453. * @param height defines the height of the texture
  90454. * @param depth defines the depth of the texture
  90455. * @param format defines the format of the texture
  90456. * @param generateMipMaps defines if the engine must generate mip levels
  90457. * @param invertY defines if data must be stored with Y axis inverted
  90458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90459. * @param compression defines the compressed used (can be null)
  90460. * @param textureType defines the compressed used (can be null)
  90461. * @returns a new raw 3D texture (stored in an InternalTexture)
  90462. */
  90463. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90464. /**
  90465. * Update a raw 3D texture
  90466. * @param texture defines the texture to update
  90467. * @param data defines the data to store
  90468. * @param format defines the data format
  90469. * @param invertY defines if data must be stored with Y axis inverted
  90470. */
  90471. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90472. /**
  90473. * Update a raw 3D texture
  90474. * @param texture defines the texture to update
  90475. * @param data defines the data to store
  90476. * @param format defines the data format
  90477. * @param invertY defines if data must be stored with Y axis inverted
  90478. * @param compression defines the used compression (can be null)
  90479. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90480. */
  90481. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90482. /**
  90483. * Creates a new raw 2D array texture
  90484. * @param data defines the data used to create the texture
  90485. * @param width defines the width of the texture
  90486. * @param height defines the height of the texture
  90487. * @param depth defines the number of layers of the texture
  90488. * @param format defines the format of the texture
  90489. * @param generateMipMaps defines if the engine must generate mip levels
  90490. * @param invertY defines if data must be stored with Y axis inverted
  90491. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90492. * @param compression defines the compressed used (can be null)
  90493. * @param textureType defines the compressed used (can be null)
  90494. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90495. */
  90496. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90497. /**
  90498. * Update a raw 2D array texture
  90499. * @param texture defines the texture to update
  90500. * @param data defines the data to store
  90501. * @param format defines the data format
  90502. * @param invertY defines if data must be stored with Y axis inverted
  90503. */
  90504. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90505. /**
  90506. * Update a raw 2D array texture
  90507. * @param texture defines the texture to update
  90508. * @param data defines the data to store
  90509. * @param format defines the data format
  90510. * @param invertY defines if data must be stored with Y axis inverted
  90511. * @param compression defines the used compression (can be null)
  90512. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90513. */
  90514. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90515. }
  90516. }
  90517. declare module BABYLON {
  90518. /**
  90519. * Raw texture can help creating a texture directly from an array of data.
  90520. * This can be super useful if you either get the data from an uncompressed source or
  90521. * if you wish to create your texture pixel by pixel.
  90522. */
  90523. export class RawTexture extends Texture {
  90524. /**
  90525. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90526. */
  90527. format: number;
  90528. /**
  90529. * Instantiates a new RawTexture.
  90530. * Raw texture can help creating a texture directly from an array of data.
  90531. * This can be super useful if you either get the data from an uncompressed source or
  90532. * if you wish to create your texture pixel by pixel.
  90533. * @param data define the array of data to use to create the texture
  90534. * @param width define the width of the texture
  90535. * @param height define the height of the texture
  90536. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90537. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90538. * @param generateMipMaps define whether mip maps should be generated or not
  90539. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90540. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90541. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90542. */
  90543. constructor(data: ArrayBufferView, width: number, height: number,
  90544. /**
  90545. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90546. */
  90547. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90548. /**
  90549. * Updates the texture underlying data.
  90550. * @param data Define the new data of the texture
  90551. */
  90552. update(data: ArrayBufferView): void;
  90553. /**
  90554. * Creates a luminance texture from some data.
  90555. * @param data Define the texture data
  90556. * @param width Define the width of the texture
  90557. * @param height Define the height of the texture
  90558. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90559. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90560. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90561. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90562. * @returns the luminance texture
  90563. */
  90564. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90565. /**
  90566. * Creates a luminance alpha texture from some data.
  90567. * @param data Define the texture data
  90568. * @param width Define the width of the texture
  90569. * @param height Define the height of the texture
  90570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90574. * @returns the luminance alpha texture
  90575. */
  90576. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90577. /**
  90578. * Creates an alpha texture from some data.
  90579. * @param data Define the texture data
  90580. * @param width Define the width of the texture
  90581. * @param height Define the height of the texture
  90582. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90583. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90586. * @returns the alpha texture
  90587. */
  90588. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90589. /**
  90590. * Creates a RGB texture from some data.
  90591. * @param data Define the texture data
  90592. * @param width Define the width of the texture
  90593. * @param height Define the height of the texture
  90594. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90595. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90596. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90597. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90598. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90599. * @returns the RGB alpha texture
  90600. */
  90601. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90602. /**
  90603. * Creates a RGBA texture from some data.
  90604. * @param data Define the texture data
  90605. * @param width Define the width of the texture
  90606. * @param height Define the height of the texture
  90607. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90611. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90612. * @returns the RGBA texture
  90613. */
  90614. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90615. /**
  90616. * Creates a R texture from some data.
  90617. * @param data Define the texture data
  90618. * @param width Define the width of the texture
  90619. * @param height Define the height of the texture
  90620. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90621. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90624. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90625. * @returns the R texture
  90626. */
  90627. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90628. }
  90629. }
  90630. declare module BABYLON {
  90631. interface AbstractScene {
  90632. /**
  90633. * The list of procedural textures added to the scene
  90634. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90635. */
  90636. proceduralTextures: Array<ProceduralTexture>;
  90637. }
  90638. /**
  90639. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90640. * in a given scene.
  90641. */
  90642. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90643. /**
  90644. * The component name helpfull to identify the component in the list of scene components.
  90645. */
  90646. readonly name: string;
  90647. /**
  90648. * The scene the component belongs to.
  90649. */
  90650. scene: Scene;
  90651. /**
  90652. * Creates a new instance of the component for the given scene
  90653. * @param scene Defines the scene to register the component in
  90654. */
  90655. constructor(scene: Scene);
  90656. /**
  90657. * Registers the component in a given scene
  90658. */
  90659. register(): void;
  90660. /**
  90661. * Rebuilds the elements related to this component in case of
  90662. * context lost for instance.
  90663. */
  90664. rebuild(): void;
  90665. /**
  90666. * Disposes the component and the associated ressources.
  90667. */
  90668. dispose(): void;
  90669. private _beforeClear;
  90670. }
  90671. }
  90672. declare module BABYLON {
  90673. interface ThinEngine {
  90674. /**
  90675. * Creates a new render target cube texture
  90676. * @param size defines the size of the texture
  90677. * @param options defines the options used to create the texture
  90678. * @returns a new render target cube texture stored in an InternalTexture
  90679. */
  90680. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90681. }
  90682. }
  90683. declare module BABYLON {
  90684. /** @hidden */
  90685. export var proceduralVertexShader: {
  90686. name: string;
  90687. shader: string;
  90688. };
  90689. }
  90690. declare module BABYLON {
  90691. /**
  90692. * 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.
  90693. * This is the base class of any Procedural texture and contains most of the shareable code.
  90694. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90695. */
  90696. export class ProceduralTexture extends Texture {
  90697. isCube: boolean;
  90698. /**
  90699. * Define if the texture is enabled or not (disabled texture will not render)
  90700. */
  90701. isEnabled: boolean;
  90702. /**
  90703. * Define if the texture must be cleared before rendering (default is true)
  90704. */
  90705. autoClear: boolean;
  90706. /**
  90707. * Callback called when the texture is generated
  90708. */
  90709. onGenerated: () => void;
  90710. /**
  90711. * Event raised when the texture is generated
  90712. */
  90713. onGeneratedObservable: Observable<ProceduralTexture>;
  90714. /** @hidden */
  90715. _generateMipMaps: boolean;
  90716. /** @hidden **/
  90717. _effect: Effect;
  90718. /** @hidden */
  90719. _textures: {
  90720. [key: string]: Texture;
  90721. };
  90722. /** @hidden */
  90723. protected _fallbackTexture: Nullable<Texture>;
  90724. private _size;
  90725. private _currentRefreshId;
  90726. private _frameId;
  90727. private _refreshRate;
  90728. private _vertexBuffers;
  90729. private _indexBuffer;
  90730. private _uniforms;
  90731. private _samplers;
  90732. private _fragment;
  90733. private _floats;
  90734. private _ints;
  90735. private _floatsArrays;
  90736. private _colors3;
  90737. private _colors4;
  90738. private _vectors2;
  90739. private _vectors3;
  90740. private _matrices;
  90741. private _fallbackTextureUsed;
  90742. private _fullEngine;
  90743. private _cachedDefines;
  90744. private _contentUpdateId;
  90745. private _contentData;
  90746. /**
  90747. * Instantiates a new procedural texture.
  90748. * 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.
  90749. * This is the base class of any Procedural texture and contains most of the shareable code.
  90750. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90751. * @param name Define the name of the texture
  90752. * @param size Define the size of the texture to create
  90753. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90754. * @param scene Define the scene the texture belongs to
  90755. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90756. * @param generateMipMaps Define if the texture should creates mip maps or not
  90757. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90758. */
  90759. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90760. /**
  90761. * The effect that is created when initializing the post process.
  90762. * @returns The created effect corresponding the the postprocess.
  90763. */
  90764. getEffect(): Effect;
  90765. /**
  90766. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90767. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90768. */
  90769. getContent(): Nullable<ArrayBufferView>;
  90770. private _createIndexBuffer;
  90771. /** @hidden */
  90772. _rebuild(): void;
  90773. /**
  90774. * Resets the texture in order to recreate its associated resources.
  90775. * This can be called in case of context loss
  90776. */
  90777. reset(): void;
  90778. protected _getDefines(): string;
  90779. /**
  90780. * Is the texture ready to be used ? (rendered at least once)
  90781. * @returns true if ready, otherwise, false.
  90782. */
  90783. isReady(): boolean;
  90784. /**
  90785. * Resets the refresh counter of the texture and start bak from scratch.
  90786. * Could be useful to regenerate the texture if it is setup to render only once.
  90787. */
  90788. resetRefreshCounter(): void;
  90789. /**
  90790. * Set the fragment shader to use in order to render the texture.
  90791. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90792. */
  90793. setFragment(fragment: any): void;
  90794. /**
  90795. * Define the refresh rate of the texture or the rendering frequency.
  90796. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90797. */
  90798. get refreshRate(): number;
  90799. set refreshRate(value: number);
  90800. /** @hidden */
  90801. _shouldRender(): boolean;
  90802. /**
  90803. * Get the size the texture is rendering at.
  90804. * @returns the size (texture is always squared)
  90805. */
  90806. getRenderSize(): number;
  90807. /**
  90808. * Resize the texture to new value.
  90809. * @param size Define the new size the texture should have
  90810. * @param generateMipMaps Define whether the new texture should create mip maps
  90811. */
  90812. resize(size: number, generateMipMaps: boolean): void;
  90813. private _checkUniform;
  90814. /**
  90815. * Set a texture in the shader program used to render.
  90816. * @param name Define the name of the uniform samplers as defined in the shader
  90817. * @param texture Define the texture to bind to this sampler
  90818. * @return the texture itself allowing "fluent" like uniform updates
  90819. */
  90820. setTexture(name: string, texture: Texture): ProceduralTexture;
  90821. /**
  90822. * Set a float in the shader.
  90823. * @param name Define the name of the uniform as defined in the shader
  90824. * @param value Define the value to give to the uniform
  90825. * @return the texture itself allowing "fluent" like uniform updates
  90826. */
  90827. setFloat(name: string, value: number): ProceduralTexture;
  90828. /**
  90829. * Set a int in the shader.
  90830. * @param name Define the name of the uniform as defined in the shader
  90831. * @param value Define the value to give to the uniform
  90832. * @return the texture itself allowing "fluent" like uniform updates
  90833. */
  90834. setInt(name: string, value: number): ProceduralTexture;
  90835. /**
  90836. * Set an array of floats in the shader.
  90837. * @param name Define the name of the uniform as defined in the shader
  90838. * @param value Define the value to give to the uniform
  90839. * @return the texture itself allowing "fluent" like uniform updates
  90840. */
  90841. setFloats(name: string, value: number[]): ProceduralTexture;
  90842. /**
  90843. * Set a vec3 in the shader from a Color3.
  90844. * @param name Define the name of the uniform as defined in the shader
  90845. * @param value Define the value to give to the uniform
  90846. * @return the texture itself allowing "fluent" like uniform updates
  90847. */
  90848. setColor3(name: string, value: Color3): ProceduralTexture;
  90849. /**
  90850. * Set a vec4 in the shader from a Color4.
  90851. * @param name Define the name of the uniform as defined in the shader
  90852. * @param value Define the value to give to the uniform
  90853. * @return the texture itself allowing "fluent" like uniform updates
  90854. */
  90855. setColor4(name: string, value: Color4): ProceduralTexture;
  90856. /**
  90857. * Set a vec2 in the shader from a Vector2.
  90858. * @param name Define the name of the uniform as defined in the shader
  90859. * @param value Define the value to give to the uniform
  90860. * @return the texture itself allowing "fluent" like uniform updates
  90861. */
  90862. setVector2(name: string, value: Vector2): ProceduralTexture;
  90863. /**
  90864. * Set a vec3 in the shader from a Vector3.
  90865. * @param name Define the name of the uniform as defined in the shader
  90866. * @param value Define the value to give to the uniform
  90867. * @return the texture itself allowing "fluent" like uniform updates
  90868. */
  90869. setVector3(name: string, value: Vector3): ProceduralTexture;
  90870. /**
  90871. * Set a mat4 in the shader from a MAtrix.
  90872. * @param name Define the name of the uniform as defined in the shader
  90873. * @param value Define the value to give to the uniform
  90874. * @return the texture itself allowing "fluent" like uniform updates
  90875. */
  90876. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90877. /**
  90878. * Render the texture to its associated render target.
  90879. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90880. */
  90881. render(useCameraPostProcess?: boolean): void;
  90882. /**
  90883. * Clone the texture.
  90884. * @returns the cloned texture
  90885. */
  90886. clone(): ProceduralTexture;
  90887. /**
  90888. * Dispose the texture and release its asoociated resources.
  90889. */
  90890. dispose(): void;
  90891. }
  90892. }
  90893. declare module BABYLON {
  90894. /**
  90895. * This represents the base class for particle system in Babylon.
  90896. * 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.
  90897. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90898. * @example https://doc.babylonjs.com/babylon101/particles
  90899. */
  90900. export class BaseParticleSystem {
  90901. /**
  90902. * Source color is added to the destination color without alpha affecting the result
  90903. */
  90904. static BLENDMODE_ONEONE: number;
  90905. /**
  90906. * Blend current color and particle color using particle’s alpha
  90907. */
  90908. static BLENDMODE_STANDARD: number;
  90909. /**
  90910. * Add current color and particle color multiplied by particle’s alpha
  90911. */
  90912. static BLENDMODE_ADD: number;
  90913. /**
  90914. * Multiply current color with particle color
  90915. */
  90916. static BLENDMODE_MULTIPLY: number;
  90917. /**
  90918. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90919. */
  90920. static BLENDMODE_MULTIPLYADD: number;
  90921. /**
  90922. * List of animations used by the particle system.
  90923. */
  90924. animations: Animation[];
  90925. /**
  90926. * Gets or sets the unique id of the particle system
  90927. */
  90928. uniqueId: number;
  90929. /**
  90930. * The id of the Particle system.
  90931. */
  90932. id: string;
  90933. /**
  90934. * The friendly name of the Particle system.
  90935. */
  90936. name: string;
  90937. /**
  90938. * Snippet ID if the particle system was created from the snippet server
  90939. */
  90940. snippetId: string;
  90941. /**
  90942. * The rendering group used by the Particle system to chose when to render.
  90943. */
  90944. renderingGroupId: number;
  90945. /**
  90946. * The emitter represents the Mesh or position we are attaching the particle system to.
  90947. */
  90948. emitter: Nullable<AbstractMesh | Vector3>;
  90949. /**
  90950. * The maximum number of particles to emit per frame
  90951. */
  90952. emitRate: number;
  90953. /**
  90954. * If you want to launch only a few particles at once, that can be done, as well.
  90955. */
  90956. manualEmitCount: number;
  90957. /**
  90958. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90959. */
  90960. updateSpeed: number;
  90961. /**
  90962. * The amount of time the particle system is running (depends of the overall update speed).
  90963. */
  90964. targetStopDuration: number;
  90965. /**
  90966. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90967. */
  90968. disposeOnStop: boolean;
  90969. /**
  90970. * Minimum power of emitting particles.
  90971. */
  90972. minEmitPower: number;
  90973. /**
  90974. * Maximum power of emitting particles.
  90975. */
  90976. maxEmitPower: number;
  90977. /**
  90978. * Minimum life time of emitting particles.
  90979. */
  90980. minLifeTime: number;
  90981. /**
  90982. * Maximum life time of emitting particles.
  90983. */
  90984. maxLifeTime: number;
  90985. /**
  90986. * Minimum Size of emitting particles.
  90987. */
  90988. minSize: number;
  90989. /**
  90990. * Maximum Size of emitting particles.
  90991. */
  90992. maxSize: number;
  90993. /**
  90994. * Minimum scale of emitting particles on X axis.
  90995. */
  90996. minScaleX: number;
  90997. /**
  90998. * Maximum scale of emitting particles on X axis.
  90999. */
  91000. maxScaleX: number;
  91001. /**
  91002. * Minimum scale of emitting particles on Y axis.
  91003. */
  91004. minScaleY: number;
  91005. /**
  91006. * Maximum scale of emitting particles on Y axis.
  91007. */
  91008. maxScaleY: number;
  91009. /**
  91010. * Gets or sets the minimal initial rotation in radians.
  91011. */
  91012. minInitialRotation: number;
  91013. /**
  91014. * Gets or sets the maximal initial rotation in radians.
  91015. */
  91016. maxInitialRotation: number;
  91017. /**
  91018. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91019. */
  91020. minAngularSpeed: number;
  91021. /**
  91022. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91023. */
  91024. maxAngularSpeed: number;
  91025. /**
  91026. * The texture used to render each particle. (this can be a spritesheet)
  91027. */
  91028. particleTexture: Nullable<Texture>;
  91029. /**
  91030. * The layer mask we are rendering the particles through.
  91031. */
  91032. layerMask: number;
  91033. /**
  91034. * This can help using your own shader to render the particle system.
  91035. * The according effect will be created
  91036. */
  91037. customShader: any;
  91038. /**
  91039. * By default particle system starts as soon as they are created. This prevents the
  91040. * automatic start to happen and let you decide when to start emitting particles.
  91041. */
  91042. preventAutoStart: boolean;
  91043. private _noiseTexture;
  91044. /**
  91045. * Gets or sets a texture used to add random noise to particle positions
  91046. */
  91047. get noiseTexture(): Nullable<ProceduralTexture>;
  91048. set noiseTexture(value: Nullable<ProceduralTexture>);
  91049. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91050. noiseStrength: Vector3;
  91051. /**
  91052. * Callback triggered when the particle animation is ending.
  91053. */
  91054. onAnimationEnd: Nullable<() => void>;
  91055. /**
  91056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91057. */
  91058. blendMode: number;
  91059. /**
  91060. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91061. * to override the particles.
  91062. */
  91063. forceDepthWrite: boolean;
  91064. /** 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 */
  91065. preWarmCycles: number;
  91066. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91067. preWarmStepOffset: number;
  91068. /**
  91069. * 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)
  91070. */
  91071. spriteCellChangeSpeed: number;
  91072. /**
  91073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91074. */
  91075. startSpriteCellID: number;
  91076. /**
  91077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91078. */
  91079. endSpriteCellID: number;
  91080. /**
  91081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91082. */
  91083. spriteCellWidth: number;
  91084. /**
  91085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91086. */
  91087. spriteCellHeight: number;
  91088. /**
  91089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91090. */
  91091. spriteRandomStartCell: boolean;
  91092. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91093. translationPivot: Vector2;
  91094. /** @hidden */
  91095. protected _isAnimationSheetEnabled: boolean;
  91096. /**
  91097. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91098. */
  91099. beginAnimationOnStart: boolean;
  91100. /**
  91101. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91102. */
  91103. beginAnimationFrom: number;
  91104. /**
  91105. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91106. */
  91107. beginAnimationTo: number;
  91108. /**
  91109. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91110. */
  91111. beginAnimationLoop: boolean;
  91112. /**
  91113. * Gets or sets a world offset applied to all particles
  91114. */
  91115. worldOffset: Vector3;
  91116. /**
  91117. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91118. */
  91119. get isAnimationSheetEnabled(): boolean;
  91120. set isAnimationSheetEnabled(value: boolean);
  91121. /**
  91122. * Get hosting scene
  91123. * @returns the scene
  91124. */
  91125. getScene(): Nullable<Scene>;
  91126. /**
  91127. * You can use gravity if you want to give an orientation to your particles.
  91128. */
  91129. gravity: Vector3;
  91130. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91131. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91132. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91133. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91134. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91135. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91136. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91137. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91138. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91139. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91140. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91141. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91142. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91143. /**
  91144. * Defines the delay in milliseconds before starting the system (0 by default)
  91145. */
  91146. startDelay: number;
  91147. /**
  91148. * Gets the current list of drag gradients.
  91149. * You must use addDragGradient and removeDragGradient to udpate this list
  91150. * @returns the list of drag gradients
  91151. */
  91152. getDragGradients(): Nullable<Array<FactorGradient>>;
  91153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91154. limitVelocityDamping: number;
  91155. /**
  91156. * Gets the current list of limit velocity gradients.
  91157. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91158. * @returns the list of limit velocity gradients
  91159. */
  91160. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91161. /**
  91162. * Gets the current list of color gradients.
  91163. * You must use addColorGradient and removeColorGradient to udpate this list
  91164. * @returns the list of color gradients
  91165. */
  91166. getColorGradients(): Nullable<Array<ColorGradient>>;
  91167. /**
  91168. * Gets the current list of size gradients.
  91169. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91170. * @returns the list of size gradients
  91171. */
  91172. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91173. /**
  91174. * Gets the current list of color remap gradients.
  91175. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91176. * @returns the list of color remap gradients
  91177. */
  91178. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91179. /**
  91180. * Gets the current list of alpha remap gradients.
  91181. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91182. * @returns the list of alpha remap gradients
  91183. */
  91184. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91185. /**
  91186. * Gets the current list of life time gradients.
  91187. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91188. * @returns the list of life time gradients
  91189. */
  91190. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91191. /**
  91192. * Gets the current list of angular speed gradients.
  91193. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91194. * @returns the list of angular speed gradients
  91195. */
  91196. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91197. /**
  91198. * Gets the current list of velocity gradients.
  91199. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91200. * @returns the list of velocity gradients
  91201. */
  91202. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91203. /**
  91204. * Gets the current list of start size gradients.
  91205. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91206. * @returns the list of start size gradients
  91207. */
  91208. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91209. /**
  91210. * Gets the current list of emit rate gradients.
  91211. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91212. * @returns the list of emit rate gradients
  91213. */
  91214. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91215. /**
  91216. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91218. */
  91219. get direction1(): Vector3;
  91220. set direction1(value: Vector3);
  91221. /**
  91222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91223. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91224. */
  91225. get direction2(): Vector3;
  91226. set direction2(value: Vector3);
  91227. /**
  91228. * 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.
  91229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91230. */
  91231. get minEmitBox(): Vector3;
  91232. set minEmitBox(value: Vector3);
  91233. /**
  91234. * 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.
  91235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91236. */
  91237. get maxEmitBox(): Vector3;
  91238. set maxEmitBox(value: Vector3);
  91239. /**
  91240. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91241. */
  91242. color1: Color4;
  91243. /**
  91244. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91245. */
  91246. color2: Color4;
  91247. /**
  91248. * Color the particle will have at the end of its lifetime
  91249. */
  91250. colorDead: Color4;
  91251. /**
  91252. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91253. */
  91254. textureMask: Color4;
  91255. /**
  91256. * The particle emitter type defines the emitter used by the particle system.
  91257. * It can be for example box, sphere, or cone...
  91258. */
  91259. particleEmitterType: IParticleEmitterType;
  91260. /** @hidden */
  91261. _isSubEmitter: boolean;
  91262. /**
  91263. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91264. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91265. */
  91266. billboardMode: number;
  91267. protected _isBillboardBased: boolean;
  91268. /**
  91269. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91270. */
  91271. get isBillboardBased(): boolean;
  91272. set isBillboardBased(value: boolean);
  91273. /**
  91274. * The scene the particle system belongs to.
  91275. */
  91276. protected _scene: Nullable<Scene>;
  91277. /**
  91278. * The engine the particle system belongs to.
  91279. */
  91280. protected _engine: ThinEngine;
  91281. /**
  91282. * Local cache of defines for image processing.
  91283. */
  91284. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91285. /**
  91286. * Default configuration related to image processing available in the standard Material.
  91287. */
  91288. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91289. /**
  91290. * Gets the image processing configuration used either in this material.
  91291. */
  91292. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91293. /**
  91294. * Sets the Default image processing configuration used either in the this material.
  91295. *
  91296. * If sets to null, the scene one is in use.
  91297. */
  91298. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91299. /**
  91300. * Attaches a new image processing configuration to the Standard Material.
  91301. * @param configuration
  91302. */
  91303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91304. /** @hidden */
  91305. protected _reset(): void;
  91306. /** @hidden */
  91307. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91308. /**
  91309. * Instantiates a particle system.
  91310. * 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.
  91311. * @param name The name of the particle system
  91312. */
  91313. constructor(name: string);
  91314. /**
  91315. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91318. * @returns the emitter
  91319. */
  91320. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91321. /**
  91322. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91323. * @param radius The radius of the hemisphere to emit from
  91324. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91325. * @returns the emitter
  91326. */
  91327. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91328. /**
  91329. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91330. * @param radius The radius of the sphere to emit from
  91331. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91332. * @returns the emitter
  91333. */
  91334. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91335. /**
  91336. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91337. * @param radius The radius of the sphere to emit from
  91338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91340. * @returns the emitter
  91341. */
  91342. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91343. /**
  91344. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91345. * @param radius The radius of the emission cylinder
  91346. * @param height The height of the emission cylinder
  91347. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91348. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91349. * @returns the emitter
  91350. */
  91351. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91352. /**
  91353. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91354. * @param radius The radius of the cylinder to emit from
  91355. * @param height The height of the emission cylinder
  91356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91357. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91358. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91359. * @returns the emitter
  91360. */
  91361. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91362. /**
  91363. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91364. * @param radius The radius of the cone to emit from
  91365. * @param angle The base angle of the cone
  91366. * @returns the emitter
  91367. */
  91368. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91369. /**
  91370. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91373. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91374. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91375. * @returns the emitter
  91376. */
  91377. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91378. }
  91379. }
  91380. declare module BABYLON {
  91381. /**
  91382. * Type of sub emitter
  91383. */
  91384. export enum SubEmitterType {
  91385. /**
  91386. * Attached to the particle over it's lifetime
  91387. */
  91388. ATTACHED = 0,
  91389. /**
  91390. * Created when the particle dies
  91391. */
  91392. END = 1
  91393. }
  91394. /**
  91395. * Sub emitter class used to emit particles from an existing particle
  91396. */
  91397. export class SubEmitter {
  91398. /**
  91399. * the particle system to be used by the sub emitter
  91400. */
  91401. particleSystem: ParticleSystem;
  91402. /**
  91403. * Type of the submitter (Default: END)
  91404. */
  91405. type: SubEmitterType;
  91406. /**
  91407. * 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)
  91408. * Note: This only is supported when using an emitter of type Mesh
  91409. */
  91410. inheritDirection: boolean;
  91411. /**
  91412. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91413. */
  91414. inheritedVelocityAmount: number;
  91415. /**
  91416. * Creates a sub emitter
  91417. * @param particleSystem the particle system to be used by the sub emitter
  91418. */
  91419. constructor(
  91420. /**
  91421. * the particle system to be used by the sub emitter
  91422. */
  91423. particleSystem: ParticleSystem);
  91424. /**
  91425. * Clones the sub emitter
  91426. * @returns the cloned sub emitter
  91427. */
  91428. clone(): SubEmitter;
  91429. /**
  91430. * Serialize current object to a JSON object
  91431. * @returns the serialized object
  91432. */
  91433. serialize(): any;
  91434. /** @hidden */
  91435. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  91436. /**
  91437. * Creates a new SubEmitter from a serialized JSON version
  91438. * @param serializationObject defines the JSON object to read from
  91439. * @param sceneOrEngine defines the hosting scene or the hosting engine
  91440. * @param rootUrl defines the rootUrl for data loading
  91441. * @returns a new SubEmitter
  91442. */
  91443. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  91444. /** Release associated resources */
  91445. dispose(): void;
  91446. }
  91447. }
  91448. declare module BABYLON {
  91449. /** @hidden */
  91450. export var imageProcessingDeclaration: {
  91451. name: string;
  91452. shader: string;
  91453. };
  91454. }
  91455. declare module BABYLON {
  91456. /** @hidden */
  91457. export var imageProcessingFunctions: {
  91458. name: string;
  91459. shader: string;
  91460. };
  91461. }
  91462. declare module BABYLON {
  91463. /** @hidden */
  91464. export var particlesPixelShader: {
  91465. name: string;
  91466. shader: string;
  91467. };
  91468. }
  91469. declare module BABYLON {
  91470. /** @hidden */
  91471. export var particlesVertexShader: {
  91472. name: string;
  91473. shader: string;
  91474. };
  91475. }
  91476. declare module BABYLON {
  91477. /**
  91478. * Interface used to define entities containing multiple clip planes
  91479. */
  91480. export interface IClipPlanesHolder {
  91481. /**
  91482. * Gets or sets the active clipplane 1
  91483. */
  91484. clipPlane: Nullable<Plane>;
  91485. /**
  91486. * Gets or sets the active clipplane 2
  91487. */
  91488. clipPlane2: Nullable<Plane>;
  91489. /**
  91490. * Gets or sets the active clipplane 3
  91491. */
  91492. clipPlane3: Nullable<Plane>;
  91493. /**
  91494. * Gets or sets the active clipplane 4
  91495. */
  91496. clipPlane4: Nullable<Plane>;
  91497. /**
  91498. * Gets or sets the active clipplane 5
  91499. */
  91500. clipPlane5: Nullable<Plane>;
  91501. /**
  91502. * Gets or sets the active clipplane 6
  91503. */
  91504. clipPlane6: Nullable<Plane>;
  91505. }
  91506. }
  91507. declare module BABYLON {
  91508. /**
  91509. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  91510. *
  91511. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  91512. *
  91513. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  91514. */
  91515. export class ThinMaterialHelper {
  91516. /**
  91517. * Binds the clip plane information from the holder to the effect.
  91518. * @param effect The effect we are binding the data to
  91519. * @param holder The entity containing the clip plane information
  91520. */
  91521. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  91522. }
  91523. }
  91524. declare module BABYLON {
  91525. /**
  91526. * This represents a particle system in Babylon.
  91527. * 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.
  91528. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91529. * @example https://doc.babylonjs.com/babylon101/particles
  91530. */
  91531. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91532. /**
  91533. * Billboard mode will only apply to Y axis
  91534. */
  91535. static readonly BILLBOARDMODE_Y: number;
  91536. /**
  91537. * Billboard mode will apply to all axes
  91538. */
  91539. static readonly BILLBOARDMODE_ALL: number;
  91540. /**
  91541. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91542. */
  91543. static readonly BILLBOARDMODE_STRETCHED: number;
  91544. /**
  91545. * This function can be defined to provide custom update for active particles.
  91546. * This function will be called instead of regular update (age, position, color, etc.).
  91547. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91548. */
  91549. updateFunction: (particles: Particle[]) => void;
  91550. private _emitterWorldMatrix;
  91551. /**
  91552. * This function can be defined to specify initial direction for every new particle.
  91553. * It by default use the emitterType defined function
  91554. */
  91555. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91556. /**
  91557. * This function can be defined to specify initial position for every new particle.
  91558. * It by default use the emitterType defined function
  91559. */
  91560. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91561. /**
  91562. * @hidden
  91563. */
  91564. _inheritedVelocityOffset: Vector3;
  91565. /**
  91566. * An event triggered when the system is disposed
  91567. */
  91568. onDisposeObservable: Observable<IParticleSystem>;
  91569. private _onDisposeObserver;
  91570. /**
  91571. * Sets a callback that will be triggered when the system is disposed
  91572. */
  91573. set onDispose(callback: () => void);
  91574. private _particles;
  91575. private _epsilon;
  91576. private _capacity;
  91577. private _stockParticles;
  91578. private _newPartsExcess;
  91579. private _vertexData;
  91580. private _vertexBuffer;
  91581. private _vertexBuffers;
  91582. private _spriteBuffer;
  91583. private _indexBuffer;
  91584. private _effect;
  91585. private _customEffect;
  91586. private _cachedDefines;
  91587. private _scaledColorStep;
  91588. private _colorDiff;
  91589. private _scaledDirection;
  91590. private _scaledGravity;
  91591. private _currentRenderId;
  91592. private _alive;
  91593. private _useInstancing;
  91594. private _started;
  91595. private _stopped;
  91596. private _actualFrame;
  91597. private _scaledUpdateSpeed;
  91598. private _vertexBufferSize;
  91599. /** @hidden */
  91600. _currentEmitRateGradient: Nullable<FactorGradient>;
  91601. /** @hidden */
  91602. _currentEmitRate1: number;
  91603. /** @hidden */
  91604. _currentEmitRate2: number;
  91605. /** @hidden */
  91606. _currentStartSizeGradient: Nullable<FactorGradient>;
  91607. /** @hidden */
  91608. _currentStartSize1: number;
  91609. /** @hidden */
  91610. _currentStartSize2: number;
  91611. private readonly _rawTextureWidth;
  91612. private _rampGradientsTexture;
  91613. private _useRampGradients;
  91614. /** Gets or sets a matrix to use to compute projection */
  91615. defaultProjectionMatrix: Matrix;
  91616. /** Gets or sets a boolean indicating that ramp gradients must be used
  91617. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91618. */
  91619. get useRampGradients(): boolean;
  91620. set useRampGradients(value: boolean);
  91621. /**
  91622. * 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.
  91623. * 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: [])
  91624. */
  91625. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91626. private _subEmitters;
  91627. /**
  91628. * @hidden
  91629. * If the particle systems emitter should be disposed when the particle system is disposed
  91630. */
  91631. _disposeEmitterOnDispose: boolean;
  91632. /**
  91633. * The current active Sub-systems, this property is used by the root particle system only.
  91634. */
  91635. activeSubSystems: Array<ParticleSystem>;
  91636. /**
  91637. * Specifies if the particles are updated in emitter local space or world space
  91638. */
  91639. isLocal: boolean;
  91640. private _rootParticleSystem;
  91641. /**
  91642. * Gets the current list of active particles
  91643. */
  91644. get particles(): Particle[];
  91645. /**
  91646. * Gets the number of particles active at the same time.
  91647. * @returns The number of active particles.
  91648. */
  91649. getActiveCount(): number;
  91650. /**
  91651. * Returns the string "ParticleSystem"
  91652. * @returns a string containing the class name
  91653. */
  91654. getClassName(): string;
  91655. /**
  91656. * Gets a boolean indicating that the system is stopping
  91657. * @returns true if the system is currently stopping
  91658. */
  91659. isStopping(): boolean;
  91660. /**
  91661. * Gets the custom effect used to render the particles
  91662. * @param blendMode Blend mode for which the effect should be retrieved
  91663. * @returns The effect
  91664. */
  91665. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91666. /**
  91667. * Sets the custom effect used to render the particles
  91668. * @param effect The effect to set
  91669. * @param blendMode Blend mode for which the effect should be set
  91670. */
  91671. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91672. /** @hidden */
  91673. private _onBeforeDrawParticlesObservable;
  91674. /**
  91675. * Observable that will be called just before the particles are drawn
  91676. */
  91677. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91678. /**
  91679. * Gets the name of the particle vertex shader
  91680. */
  91681. get vertexShaderName(): string;
  91682. /**
  91683. * Instantiates a particle system.
  91684. * 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.
  91685. * @param name The name of the particle system
  91686. * @param capacity The max number of particles alive at the same time
  91687. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  91688. * @param customEffect a custom effect used to change the way particles are rendered by default
  91689. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91690. * @param epsilon Offset used to render the particles
  91691. */
  91692. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91693. private _addFactorGradient;
  91694. private _removeFactorGradient;
  91695. /**
  91696. * Adds a new life time gradient
  91697. * @param gradient defines the gradient to use (between 0 and 1)
  91698. * @param factor defines the life time factor to affect to the specified gradient
  91699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91700. * @returns the current particle system
  91701. */
  91702. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91703. /**
  91704. * Remove a specific life time gradient
  91705. * @param gradient defines the gradient to remove
  91706. * @returns the current particle system
  91707. */
  91708. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91709. /**
  91710. * Adds a new size gradient
  91711. * @param gradient defines the gradient to use (between 0 and 1)
  91712. * @param factor defines the size factor to affect to the specified gradient
  91713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91714. * @returns the current particle system
  91715. */
  91716. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91717. /**
  91718. * Remove a specific size gradient
  91719. * @param gradient defines the gradient to remove
  91720. * @returns the current particle system
  91721. */
  91722. removeSizeGradient(gradient: number): IParticleSystem;
  91723. /**
  91724. * Adds a new color remap gradient
  91725. * @param gradient defines the gradient to use (between 0 and 1)
  91726. * @param min defines the color remap minimal range
  91727. * @param max defines the color remap maximal range
  91728. * @returns the current particle system
  91729. */
  91730. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91731. /**
  91732. * Remove a specific color remap gradient
  91733. * @param gradient defines the gradient to remove
  91734. * @returns the current particle system
  91735. */
  91736. removeColorRemapGradient(gradient: number): IParticleSystem;
  91737. /**
  91738. * Adds a new alpha remap gradient
  91739. * @param gradient defines the gradient to use (between 0 and 1)
  91740. * @param min defines the alpha remap minimal range
  91741. * @param max defines the alpha remap maximal range
  91742. * @returns the current particle system
  91743. */
  91744. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91745. /**
  91746. * Remove a specific alpha remap gradient
  91747. * @param gradient defines the gradient to remove
  91748. * @returns the current particle system
  91749. */
  91750. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91751. /**
  91752. * Adds a new angular speed gradient
  91753. * @param gradient defines the gradient to use (between 0 and 1)
  91754. * @param factor defines the angular speed to affect to the specified gradient
  91755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91756. * @returns the current particle system
  91757. */
  91758. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91759. /**
  91760. * Remove a specific angular speed gradient
  91761. * @param gradient defines the gradient to remove
  91762. * @returns the current particle system
  91763. */
  91764. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91765. /**
  91766. * Adds a new velocity gradient
  91767. * @param gradient defines the gradient to use (between 0 and 1)
  91768. * @param factor defines the velocity to affect to the specified gradient
  91769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91770. * @returns the current particle system
  91771. */
  91772. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91773. /**
  91774. * Remove a specific velocity gradient
  91775. * @param gradient defines the gradient to remove
  91776. * @returns the current particle system
  91777. */
  91778. removeVelocityGradient(gradient: number): IParticleSystem;
  91779. /**
  91780. * Adds a new limit velocity gradient
  91781. * @param gradient defines the gradient to use (between 0 and 1)
  91782. * @param factor defines the limit velocity value to affect to the specified gradient
  91783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91784. * @returns the current particle system
  91785. */
  91786. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91787. /**
  91788. * Remove a specific limit velocity gradient
  91789. * @param gradient defines the gradient to remove
  91790. * @returns the current particle system
  91791. */
  91792. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91793. /**
  91794. * Adds a new drag gradient
  91795. * @param gradient defines the gradient to use (between 0 and 1)
  91796. * @param factor defines the drag value to affect to the specified gradient
  91797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91798. * @returns the current particle system
  91799. */
  91800. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91801. /**
  91802. * Remove a specific drag gradient
  91803. * @param gradient defines the gradient to remove
  91804. * @returns the current particle system
  91805. */
  91806. removeDragGradient(gradient: number): IParticleSystem;
  91807. /**
  91808. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91809. * @param gradient defines the gradient to use (between 0 and 1)
  91810. * @param factor defines the emit rate value to affect to the specified gradient
  91811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91812. * @returns the current particle system
  91813. */
  91814. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91815. /**
  91816. * Remove a specific emit rate gradient
  91817. * @param gradient defines the gradient to remove
  91818. * @returns the current particle system
  91819. */
  91820. removeEmitRateGradient(gradient: number): IParticleSystem;
  91821. /**
  91822. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91823. * @param gradient defines the gradient to use (between 0 and 1)
  91824. * @param factor defines the start size value to affect to the specified gradient
  91825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91826. * @returns the current particle system
  91827. */
  91828. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91829. /**
  91830. * Remove a specific start size gradient
  91831. * @param gradient defines the gradient to remove
  91832. * @returns the current particle system
  91833. */
  91834. removeStartSizeGradient(gradient: number): IParticleSystem;
  91835. private _createRampGradientTexture;
  91836. /**
  91837. * Gets the current list of ramp gradients.
  91838. * You must use addRampGradient and removeRampGradient to udpate this list
  91839. * @returns the list of ramp gradients
  91840. */
  91841. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91842. /** Force the system to rebuild all gradients that need to be resync */
  91843. forceRefreshGradients(): void;
  91844. private _syncRampGradientTexture;
  91845. /**
  91846. * Adds a new ramp gradient used to remap particle colors
  91847. * @param gradient defines the gradient to use (between 0 and 1)
  91848. * @param color defines the color to affect to the specified gradient
  91849. * @returns the current particle system
  91850. */
  91851. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91852. /**
  91853. * Remove a specific ramp gradient
  91854. * @param gradient defines the gradient to remove
  91855. * @returns the current particle system
  91856. */
  91857. removeRampGradient(gradient: number): ParticleSystem;
  91858. /**
  91859. * Adds a new color gradient
  91860. * @param gradient defines the gradient to use (between 0 and 1)
  91861. * @param color1 defines the color to affect to the specified gradient
  91862. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91863. * @returns this particle system
  91864. */
  91865. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91866. /**
  91867. * Remove a specific color gradient
  91868. * @param gradient defines the gradient to remove
  91869. * @returns this particle system
  91870. */
  91871. removeColorGradient(gradient: number): IParticleSystem;
  91872. private _fetchR;
  91873. protected _reset(): void;
  91874. private _resetEffect;
  91875. private _createVertexBuffers;
  91876. private _createIndexBuffer;
  91877. /**
  91878. * Gets the maximum number of particles active at the same time.
  91879. * @returns The max number of active particles.
  91880. */
  91881. getCapacity(): number;
  91882. /**
  91883. * Gets whether there are still active particles in the system.
  91884. * @returns True if it is alive, otherwise false.
  91885. */
  91886. isAlive(): boolean;
  91887. /**
  91888. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91889. * @returns True if it has been started, otherwise false.
  91890. */
  91891. isStarted(): boolean;
  91892. private _prepareSubEmitterInternalArray;
  91893. /**
  91894. * Starts the particle system and begins to emit
  91895. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91896. */
  91897. start(delay?: number): void;
  91898. /**
  91899. * Stops the particle system.
  91900. * @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.
  91901. */
  91902. stop(stopSubEmitters?: boolean): void;
  91903. /**
  91904. * Remove all active particles
  91905. */
  91906. reset(): void;
  91907. /**
  91908. * @hidden (for internal use only)
  91909. */
  91910. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91911. /**
  91912. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91913. * Its lifetime will start back at 0.
  91914. */
  91915. recycleParticle: (particle: Particle) => void;
  91916. private _stopSubEmitters;
  91917. private _createParticle;
  91918. private _removeFromRoot;
  91919. private _emitFromParticle;
  91920. private _update;
  91921. /** @hidden */
  91922. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91923. /** @hidden */
  91924. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91925. /**
  91926. * Fill the defines array according to the current settings of the particle system
  91927. * @param defines Array to be updated
  91928. * @param blendMode blend mode to take into account when updating the array
  91929. */
  91930. fillDefines(defines: Array<string>, blendMode: number): void;
  91931. /**
  91932. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91933. * @param uniforms Uniforms array to fill
  91934. * @param attributes Attributes array to fill
  91935. * @param samplers Samplers array to fill
  91936. */
  91937. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91938. /** @hidden */
  91939. private _getEffect;
  91940. /**
  91941. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91942. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91943. */
  91944. animate(preWarmOnly?: boolean): void;
  91945. private _appendParticleVertices;
  91946. /**
  91947. * Rebuilds the particle system.
  91948. */
  91949. rebuild(): void;
  91950. /**
  91951. * Is this system ready to be used/rendered
  91952. * @return true if the system is ready
  91953. */
  91954. isReady(): boolean;
  91955. private _render;
  91956. /**
  91957. * Renders the particle system in its current state.
  91958. * @returns the current number of particles
  91959. */
  91960. render(): number;
  91961. /**
  91962. * Disposes the particle system and free the associated resources
  91963. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91964. */
  91965. dispose(disposeTexture?: boolean): void;
  91966. /**
  91967. * Clones the particle system.
  91968. * @param name The name of the cloned object
  91969. * @param newEmitter The new emitter to use
  91970. * @returns the cloned particle system
  91971. */
  91972. clone(name: string, newEmitter: any): ParticleSystem;
  91973. /**
  91974. * Serializes the particle system to a JSON object
  91975. * @param serializeTexture defines if the texture must be serialized as well
  91976. * @returns the JSON object
  91977. */
  91978. serialize(serializeTexture?: boolean): any;
  91979. /** @hidden */
  91980. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91981. /** @hidden */
  91982. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  91983. /**
  91984. * Parses a JSON object to create a particle system.
  91985. * @param parsedParticleSystem The JSON object to parse
  91986. * @param sceneOrEngine The scene or the engine to create the particle system in
  91987. * @param rootUrl The root url to use to load external dependencies like texture
  91988. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91989. * @returns the Parsed particle system
  91990. */
  91991. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91992. }
  91993. }
  91994. declare module BABYLON {
  91995. /**
  91996. * A particle represents one of the element emitted by a particle system.
  91997. * This is mainly define by its coordinates, direction, velocity and age.
  91998. */
  91999. export class Particle {
  92000. /**
  92001. * The particle system the particle belongs to.
  92002. */
  92003. particleSystem: ParticleSystem;
  92004. private static _Count;
  92005. /**
  92006. * Unique ID of the particle
  92007. */
  92008. id: number;
  92009. /**
  92010. * The world position of the particle in the scene.
  92011. */
  92012. position: Vector3;
  92013. /**
  92014. * The world direction of the particle in the scene.
  92015. */
  92016. direction: Vector3;
  92017. /**
  92018. * The color of the particle.
  92019. */
  92020. color: Color4;
  92021. /**
  92022. * The color change of the particle per step.
  92023. */
  92024. colorStep: Color4;
  92025. /**
  92026. * Defines how long will the life of the particle be.
  92027. */
  92028. lifeTime: number;
  92029. /**
  92030. * The current age of the particle.
  92031. */
  92032. age: number;
  92033. /**
  92034. * The current size of the particle.
  92035. */
  92036. size: number;
  92037. /**
  92038. * The current scale of the particle.
  92039. */
  92040. scale: Vector2;
  92041. /**
  92042. * The current angle of the particle.
  92043. */
  92044. angle: number;
  92045. /**
  92046. * Defines how fast is the angle changing.
  92047. */
  92048. angularSpeed: number;
  92049. /**
  92050. * Defines the cell index used by the particle to be rendered from a sprite.
  92051. */
  92052. cellIndex: number;
  92053. /**
  92054. * The information required to support color remapping
  92055. */
  92056. remapData: Vector4;
  92057. /** @hidden */
  92058. _randomCellOffset?: number;
  92059. /** @hidden */
  92060. _initialDirection: Nullable<Vector3>;
  92061. /** @hidden */
  92062. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92063. /** @hidden */
  92064. _initialStartSpriteCellID: number;
  92065. /** @hidden */
  92066. _initialEndSpriteCellID: number;
  92067. /** @hidden */
  92068. _currentColorGradient: Nullable<ColorGradient>;
  92069. /** @hidden */
  92070. _currentColor1: Color4;
  92071. /** @hidden */
  92072. _currentColor2: Color4;
  92073. /** @hidden */
  92074. _currentSizeGradient: Nullable<FactorGradient>;
  92075. /** @hidden */
  92076. _currentSize1: number;
  92077. /** @hidden */
  92078. _currentSize2: number;
  92079. /** @hidden */
  92080. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92081. /** @hidden */
  92082. _currentAngularSpeed1: number;
  92083. /** @hidden */
  92084. _currentAngularSpeed2: number;
  92085. /** @hidden */
  92086. _currentVelocityGradient: Nullable<FactorGradient>;
  92087. /** @hidden */
  92088. _currentVelocity1: number;
  92089. /** @hidden */
  92090. _currentVelocity2: number;
  92091. /** @hidden */
  92092. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92093. /** @hidden */
  92094. _currentLimitVelocity1: number;
  92095. /** @hidden */
  92096. _currentLimitVelocity2: number;
  92097. /** @hidden */
  92098. _currentDragGradient: Nullable<FactorGradient>;
  92099. /** @hidden */
  92100. _currentDrag1: number;
  92101. /** @hidden */
  92102. _currentDrag2: number;
  92103. /** @hidden */
  92104. _randomNoiseCoordinates1: Vector3;
  92105. /** @hidden */
  92106. _randomNoiseCoordinates2: Vector3;
  92107. /** @hidden */
  92108. _localPosition?: Vector3;
  92109. /**
  92110. * Creates a new instance Particle
  92111. * @param particleSystem the particle system the particle belongs to
  92112. */
  92113. constructor(
  92114. /**
  92115. * The particle system the particle belongs to.
  92116. */
  92117. particleSystem: ParticleSystem);
  92118. private updateCellInfoFromSystem;
  92119. /**
  92120. * Defines how the sprite cell index is updated for the particle
  92121. */
  92122. updateCellIndex(): void;
  92123. /** @hidden */
  92124. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92125. /** @hidden */
  92126. _inheritParticleInfoToSubEmitters(): void;
  92127. /** @hidden */
  92128. _reset(): void;
  92129. /**
  92130. * Copy the properties of particle to another one.
  92131. * @param other the particle to copy the information to.
  92132. */
  92133. copyTo(other: Particle): void;
  92134. }
  92135. }
  92136. declare module BABYLON {
  92137. /**
  92138. * Particle emitter represents a volume emitting particles.
  92139. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92140. */
  92141. export interface IParticleEmitterType {
  92142. /**
  92143. * Called by the particle System when the direction is computed for the created particle.
  92144. * @param worldMatrix is the world matrix of the particle system
  92145. * @param directionToUpdate is the direction vector to update with the result
  92146. * @param particle is the particle we are computed the direction for
  92147. * @param isLocal defines if the direction should be set in local space
  92148. */
  92149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92150. /**
  92151. * Called by the particle System when the position is computed for the created particle.
  92152. * @param worldMatrix is the world matrix of the particle system
  92153. * @param positionToUpdate is the position vector to update with the result
  92154. * @param particle is the particle we are computed the position for
  92155. * @param isLocal defines if the position should be set in local space
  92156. */
  92157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92158. /**
  92159. * Clones the current emitter and returns a copy of it
  92160. * @returns the new emitter
  92161. */
  92162. clone(): IParticleEmitterType;
  92163. /**
  92164. * Called by the GPUParticleSystem to setup the update shader
  92165. * @param effect defines the update shader
  92166. */
  92167. applyToShader(effect: Effect): void;
  92168. /**
  92169. * Returns a string to use to update the GPU particles update shader
  92170. * @returns the effect defines string
  92171. */
  92172. getEffectDefines(): string;
  92173. /**
  92174. * Returns a string representing the class name
  92175. * @returns a string containing the class name
  92176. */
  92177. getClassName(): string;
  92178. /**
  92179. * Serializes the particle system to a JSON object.
  92180. * @returns the JSON object
  92181. */
  92182. serialize(): any;
  92183. /**
  92184. * Parse properties from a JSON object
  92185. * @param serializationObject defines the JSON object
  92186. * @param scene defines the hosting scene
  92187. */
  92188. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92189. }
  92190. }
  92191. declare module BABYLON {
  92192. /**
  92193. * Particle emitter emitting particles from the inside of a box.
  92194. * It emits the particles randomly between 2 given directions.
  92195. */
  92196. export class BoxParticleEmitter implements IParticleEmitterType {
  92197. /**
  92198. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92199. */
  92200. direction1: Vector3;
  92201. /**
  92202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92203. */
  92204. direction2: Vector3;
  92205. /**
  92206. * 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.
  92207. */
  92208. minEmitBox: Vector3;
  92209. /**
  92210. * 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.
  92211. */
  92212. maxEmitBox: Vector3;
  92213. /**
  92214. * Creates a new instance BoxParticleEmitter
  92215. */
  92216. constructor();
  92217. /**
  92218. * Called by the particle System when the direction is computed for the created particle.
  92219. * @param worldMatrix is the world matrix of the particle system
  92220. * @param directionToUpdate is the direction vector to update with the result
  92221. * @param particle is the particle we are computed the direction for
  92222. * @param isLocal defines if the direction should be set in local space
  92223. */
  92224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92225. /**
  92226. * Called by the particle System when the position is computed for the created particle.
  92227. * @param worldMatrix is the world matrix of the particle system
  92228. * @param positionToUpdate is the position vector to update with the result
  92229. * @param particle is the particle we are computed the position for
  92230. * @param isLocal defines if the position should be set in local space
  92231. */
  92232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92233. /**
  92234. * Clones the current emitter and returns a copy of it
  92235. * @returns the new emitter
  92236. */
  92237. clone(): BoxParticleEmitter;
  92238. /**
  92239. * Called by the GPUParticleSystem to setup the update shader
  92240. * @param effect defines the update shader
  92241. */
  92242. applyToShader(effect: Effect): void;
  92243. /**
  92244. * Returns a string to use to update the GPU particles update shader
  92245. * @returns a string containng the defines string
  92246. */
  92247. getEffectDefines(): string;
  92248. /**
  92249. * Returns the string "BoxParticleEmitter"
  92250. * @returns a string containing the class name
  92251. */
  92252. getClassName(): string;
  92253. /**
  92254. * Serializes the particle system to a JSON object.
  92255. * @returns the JSON object
  92256. */
  92257. serialize(): any;
  92258. /**
  92259. * Parse properties from a JSON object
  92260. * @param serializationObject defines the JSON object
  92261. */
  92262. parse(serializationObject: any): void;
  92263. }
  92264. }
  92265. declare module BABYLON {
  92266. /**
  92267. * Particle emitter emitting particles from the inside of a cone.
  92268. * It emits the particles alongside the cone volume from the base to the particle.
  92269. * The emission direction might be randomized.
  92270. */
  92271. export class ConeParticleEmitter implements IParticleEmitterType {
  92272. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92273. directionRandomizer: number;
  92274. private _radius;
  92275. private _angle;
  92276. private _height;
  92277. /**
  92278. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92279. */
  92280. radiusRange: number;
  92281. /**
  92282. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92283. */
  92284. heightRange: number;
  92285. /**
  92286. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92287. */
  92288. emitFromSpawnPointOnly: boolean;
  92289. /**
  92290. * Gets or sets the radius of the emission cone
  92291. */
  92292. get radius(): number;
  92293. set radius(value: number);
  92294. /**
  92295. * Gets or sets the angle of the emission cone
  92296. */
  92297. get angle(): number;
  92298. set angle(value: number);
  92299. private _buildHeight;
  92300. /**
  92301. * Creates a new instance ConeParticleEmitter
  92302. * @param radius the radius of the emission cone (1 by default)
  92303. * @param angle the cone base angle (PI by default)
  92304. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92305. */
  92306. constructor(radius?: number, angle?: number,
  92307. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92308. directionRandomizer?: number);
  92309. /**
  92310. * Called by the particle System when the direction is computed for the created particle.
  92311. * @param worldMatrix is the world matrix of the particle system
  92312. * @param directionToUpdate is the direction vector to update with the result
  92313. * @param particle is the particle we are computed the direction for
  92314. * @param isLocal defines if the direction should be set in local space
  92315. */
  92316. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92317. /**
  92318. * Called by the particle System when the position is computed for the created particle.
  92319. * @param worldMatrix is the world matrix of the particle system
  92320. * @param positionToUpdate is the position vector to update with the result
  92321. * @param particle is the particle we are computed the position for
  92322. * @param isLocal defines if the position should be set in local space
  92323. */
  92324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92325. /**
  92326. * Clones the current emitter and returns a copy of it
  92327. * @returns the new emitter
  92328. */
  92329. clone(): ConeParticleEmitter;
  92330. /**
  92331. * Called by the GPUParticleSystem to setup the update shader
  92332. * @param effect defines the update shader
  92333. */
  92334. applyToShader(effect: Effect): void;
  92335. /**
  92336. * Returns a string to use to update the GPU particles update shader
  92337. * @returns a string containng the defines string
  92338. */
  92339. getEffectDefines(): string;
  92340. /**
  92341. * Returns the string "ConeParticleEmitter"
  92342. * @returns a string containing the class name
  92343. */
  92344. getClassName(): string;
  92345. /**
  92346. * Serializes the particle system to a JSON object.
  92347. * @returns the JSON object
  92348. */
  92349. serialize(): any;
  92350. /**
  92351. * Parse properties from a JSON object
  92352. * @param serializationObject defines the JSON object
  92353. */
  92354. parse(serializationObject: any): void;
  92355. }
  92356. }
  92357. declare module BABYLON {
  92358. /**
  92359. * Particle emitter emitting particles from the inside of a cylinder.
  92360. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92361. */
  92362. export class CylinderParticleEmitter implements IParticleEmitterType {
  92363. /**
  92364. * The radius of the emission cylinder.
  92365. */
  92366. radius: number;
  92367. /**
  92368. * The height of the emission cylinder.
  92369. */
  92370. height: number;
  92371. /**
  92372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92373. */
  92374. radiusRange: number;
  92375. /**
  92376. * How much to randomize the particle direction [0-1].
  92377. */
  92378. directionRandomizer: number;
  92379. /**
  92380. * Creates a new instance CylinderParticleEmitter
  92381. * @param radius the radius of the emission cylinder (1 by default)
  92382. * @param height the height of the emission cylinder (1 by default)
  92383. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92384. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92385. */
  92386. constructor(
  92387. /**
  92388. * The radius of the emission cylinder.
  92389. */
  92390. radius?: number,
  92391. /**
  92392. * The height of the emission cylinder.
  92393. */
  92394. height?: number,
  92395. /**
  92396. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92397. */
  92398. radiusRange?: number,
  92399. /**
  92400. * How much to randomize the particle direction [0-1].
  92401. */
  92402. directionRandomizer?: number);
  92403. /**
  92404. * Called by the particle System when the direction is computed for the created particle.
  92405. * @param worldMatrix is the world matrix of the particle system
  92406. * @param directionToUpdate is the direction vector to update with the result
  92407. * @param particle is the particle we are computed the direction for
  92408. * @param isLocal defines if the direction should be set in local space
  92409. */
  92410. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92411. /**
  92412. * Called by the particle System when the position is computed for the created particle.
  92413. * @param worldMatrix is the world matrix of the particle system
  92414. * @param positionToUpdate is the position vector to update with the result
  92415. * @param particle is the particle we are computed the position for
  92416. * @param isLocal defines if the position should be set in local space
  92417. */
  92418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92419. /**
  92420. * Clones the current emitter and returns a copy of it
  92421. * @returns the new emitter
  92422. */
  92423. clone(): CylinderParticleEmitter;
  92424. /**
  92425. * Called by the GPUParticleSystem to setup the update shader
  92426. * @param effect defines the update shader
  92427. */
  92428. applyToShader(effect: Effect): void;
  92429. /**
  92430. * Returns a string to use to update the GPU particles update shader
  92431. * @returns a string containng the defines string
  92432. */
  92433. getEffectDefines(): string;
  92434. /**
  92435. * Returns the string "CylinderParticleEmitter"
  92436. * @returns a string containing the class name
  92437. */
  92438. getClassName(): string;
  92439. /**
  92440. * Serializes the particle system to a JSON object.
  92441. * @returns the JSON object
  92442. */
  92443. serialize(): any;
  92444. /**
  92445. * Parse properties from a JSON object
  92446. * @param serializationObject defines the JSON object
  92447. */
  92448. parse(serializationObject: any): void;
  92449. }
  92450. /**
  92451. * Particle emitter emitting particles from the inside of a cylinder.
  92452. * It emits the particles randomly between two vectors.
  92453. */
  92454. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92455. /**
  92456. * The min limit of the emission direction.
  92457. */
  92458. direction1: Vector3;
  92459. /**
  92460. * The max limit of the emission direction.
  92461. */
  92462. direction2: Vector3;
  92463. /**
  92464. * Creates a new instance CylinderDirectedParticleEmitter
  92465. * @param radius the radius of the emission cylinder (1 by default)
  92466. * @param height the height of the emission cylinder (1 by default)
  92467. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92468. * @param direction1 the min limit of the emission direction (up vector by default)
  92469. * @param direction2 the max limit of the emission direction (up vector by default)
  92470. */
  92471. constructor(radius?: number, height?: number, radiusRange?: number,
  92472. /**
  92473. * The min limit of the emission direction.
  92474. */
  92475. direction1?: Vector3,
  92476. /**
  92477. * The max limit of the emission direction.
  92478. */
  92479. direction2?: Vector3);
  92480. /**
  92481. * Called by the particle System when the direction is computed for the created particle.
  92482. * @param worldMatrix is the world matrix of the particle system
  92483. * @param directionToUpdate is the direction vector to update with the result
  92484. * @param particle is the particle we are computed the direction for
  92485. */
  92486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92487. /**
  92488. * Clones the current emitter and returns a copy of it
  92489. * @returns the new emitter
  92490. */
  92491. clone(): CylinderDirectedParticleEmitter;
  92492. /**
  92493. * Called by the GPUParticleSystem to setup the update shader
  92494. * @param effect defines the update shader
  92495. */
  92496. applyToShader(effect: Effect): void;
  92497. /**
  92498. * Returns a string to use to update the GPU particles update shader
  92499. * @returns a string containng the defines string
  92500. */
  92501. getEffectDefines(): string;
  92502. /**
  92503. * Returns the string "CylinderDirectedParticleEmitter"
  92504. * @returns a string containing the class name
  92505. */
  92506. getClassName(): string;
  92507. /**
  92508. * Serializes the particle system to a JSON object.
  92509. * @returns the JSON object
  92510. */
  92511. serialize(): any;
  92512. /**
  92513. * Parse properties from a JSON object
  92514. * @param serializationObject defines the JSON object
  92515. */
  92516. parse(serializationObject: any): void;
  92517. }
  92518. }
  92519. declare module BABYLON {
  92520. /**
  92521. * Particle emitter emitting particles from the inside of a hemisphere.
  92522. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92523. */
  92524. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92525. /**
  92526. * The radius of the emission hemisphere.
  92527. */
  92528. radius: number;
  92529. /**
  92530. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92531. */
  92532. radiusRange: number;
  92533. /**
  92534. * How much to randomize the particle direction [0-1].
  92535. */
  92536. directionRandomizer: number;
  92537. /**
  92538. * Creates a new instance HemisphericParticleEmitter
  92539. * @param radius the radius of the emission hemisphere (1 by default)
  92540. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92541. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92542. */
  92543. constructor(
  92544. /**
  92545. * The radius of the emission hemisphere.
  92546. */
  92547. radius?: number,
  92548. /**
  92549. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92550. */
  92551. radiusRange?: number,
  92552. /**
  92553. * How much to randomize the particle direction [0-1].
  92554. */
  92555. directionRandomizer?: number);
  92556. /**
  92557. * Called by the particle System when the direction is computed for the created particle.
  92558. * @param worldMatrix is the world matrix of the particle system
  92559. * @param directionToUpdate is the direction vector to update with the result
  92560. * @param particle is the particle we are computed the direction for
  92561. * @param isLocal defines if the direction should be set in local space
  92562. */
  92563. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92564. /**
  92565. * Called by the particle System when the position is computed for the created particle.
  92566. * @param worldMatrix is the world matrix of the particle system
  92567. * @param positionToUpdate is the position vector to update with the result
  92568. * @param particle is the particle we are computed the position for
  92569. * @param isLocal defines if the position should be set in local space
  92570. */
  92571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92572. /**
  92573. * Clones the current emitter and returns a copy of it
  92574. * @returns the new emitter
  92575. */
  92576. clone(): HemisphericParticleEmitter;
  92577. /**
  92578. * Called by the GPUParticleSystem to setup the update shader
  92579. * @param effect defines the update shader
  92580. */
  92581. applyToShader(effect: Effect): void;
  92582. /**
  92583. * Returns a string to use to update the GPU particles update shader
  92584. * @returns a string containng the defines string
  92585. */
  92586. getEffectDefines(): string;
  92587. /**
  92588. * Returns the string "HemisphericParticleEmitter"
  92589. * @returns a string containing the class name
  92590. */
  92591. getClassName(): string;
  92592. /**
  92593. * Serializes the particle system to a JSON object.
  92594. * @returns the JSON object
  92595. */
  92596. serialize(): any;
  92597. /**
  92598. * Parse properties from a JSON object
  92599. * @param serializationObject defines the JSON object
  92600. */
  92601. parse(serializationObject: any): void;
  92602. }
  92603. }
  92604. declare module BABYLON {
  92605. /**
  92606. * Particle emitter emitting particles from a point.
  92607. * It emits the particles randomly between 2 given directions.
  92608. */
  92609. export class PointParticleEmitter implements IParticleEmitterType {
  92610. /**
  92611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92612. */
  92613. direction1: Vector3;
  92614. /**
  92615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92616. */
  92617. direction2: Vector3;
  92618. /**
  92619. * Creates a new instance PointParticleEmitter
  92620. */
  92621. constructor();
  92622. /**
  92623. * Called by the particle System when the direction is computed for the created particle.
  92624. * @param worldMatrix is the world matrix of the particle system
  92625. * @param directionToUpdate is the direction vector to update with the result
  92626. * @param particle is the particle we are computed the direction for
  92627. * @param isLocal defines if the direction should be set in local space
  92628. */
  92629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92630. /**
  92631. * Called by the particle System when the position is computed for the created particle.
  92632. * @param worldMatrix is the world matrix of the particle system
  92633. * @param positionToUpdate is the position vector to update with the result
  92634. * @param particle is the particle we are computed the position for
  92635. * @param isLocal defines if the position should be set in local space
  92636. */
  92637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92638. /**
  92639. * Clones the current emitter and returns a copy of it
  92640. * @returns the new emitter
  92641. */
  92642. clone(): PointParticleEmitter;
  92643. /**
  92644. * Called by the GPUParticleSystem to setup the update shader
  92645. * @param effect defines the update shader
  92646. */
  92647. applyToShader(effect: Effect): void;
  92648. /**
  92649. * Returns a string to use to update the GPU particles update shader
  92650. * @returns a string containng the defines string
  92651. */
  92652. getEffectDefines(): string;
  92653. /**
  92654. * Returns the string "PointParticleEmitter"
  92655. * @returns a string containing the class name
  92656. */
  92657. getClassName(): string;
  92658. /**
  92659. * Serializes the particle system to a JSON object.
  92660. * @returns the JSON object
  92661. */
  92662. serialize(): any;
  92663. /**
  92664. * Parse properties from a JSON object
  92665. * @param serializationObject defines the JSON object
  92666. */
  92667. parse(serializationObject: any): void;
  92668. }
  92669. }
  92670. declare module BABYLON {
  92671. /**
  92672. * Particle emitter emitting particles from the inside of a sphere.
  92673. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92674. */
  92675. export class SphereParticleEmitter implements IParticleEmitterType {
  92676. /**
  92677. * The radius of the emission sphere.
  92678. */
  92679. radius: number;
  92680. /**
  92681. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92682. */
  92683. radiusRange: number;
  92684. /**
  92685. * How much to randomize the particle direction [0-1].
  92686. */
  92687. directionRandomizer: number;
  92688. /**
  92689. * Creates a new instance SphereParticleEmitter
  92690. * @param radius the radius of the emission sphere (1 by default)
  92691. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92692. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92693. */
  92694. constructor(
  92695. /**
  92696. * The radius of the emission sphere.
  92697. */
  92698. radius?: number,
  92699. /**
  92700. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92701. */
  92702. radiusRange?: number,
  92703. /**
  92704. * How much to randomize the particle direction [0-1].
  92705. */
  92706. directionRandomizer?: number);
  92707. /**
  92708. * Called by the particle System when the direction is computed for the created particle.
  92709. * @param worldMatrix is the world matrix of the particle system
  92710. * @param directionToUpdate is the direction vector to update with the result
  92711. * @param particle is the particle we are computed the direction for
  92712. * @param isLocal defines if the direction should be set in local space
  92713. */
  92714. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92715. /**
  92716. * Called by the particle System when the position is computed for the created particle.
  92717. * @param worldMatrix is the world matrix of the particle system
  92718. * @param positionToUpdate is the position vector to update with the result
  92719. * @param particle is the particle we are computed the position for
  92720. * @param isLocal defines if the position should be set in local space
  92721. */
  92722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92723. /**
  92724. * Clones the current emitter and returns a copy of it
  92725. * @returns the new emitter
  92726. */
  92727. clone(): SphereParticleEmitter;
  92728. /**
  92729. * Called by the GPUParticleSystem to setup the update shader
  92730. * @param effect defines the update shader
  92731. */
  92732. applyToShader(effect: Effect): void;
  92733. /**
  92734. * Returns a string to use to update the GPU particles update shader
  92735. * @returns a string containng the defines string
  92736. */
  92737. getEffectDefines(): string;
  92738. /**
  92739. * Returns the string "SphereParticleEmitter"
  92740. * @returns a string containing the class name
  92741. */
  92742. getClassName(): string;
  92743. /**
  92744. * Serializes the particle system to a JSON object.
  92745. * @returns the JSON object
  92746. */
  92747. serialize(): any;
  92748. /**
  92749. * Parse properties from a JSON object
  92750. * @param serializationObject defines the JSON object
  92751. */
  92752. parse(serializationObject: any): void;
  92753. }
  92754. /**
  92755. * Particle emitter emitting particles from the inside of a sphere.
  92756. * It emits the particles randomly between two vectors.
  92757. */
  92758. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92759. /**
  92760. * The min limit of the emission direction.
  92761. */
  92762. direction1: Vector3;
  92763. /**
  92764. * The max limit of the emission direction.
  92765. */
  92766. direction2: Vector3;
  92767. /**
  92768. * Creates a new instance SphereDirectedParticleEmitter
  92769. * @param radius the radius of the emission sphere (1 by default)
  92770. * @param direction1 the min limit of the emission direction (up vector by default)
  92771. * @param direction2 the max limit of the emission direction (up vector by default)
  92772. */
  92773. constructor(radius?: number,
  92774. /**
  92775. * The min limit of the emission direction.
  92776. */
  92777. direction1?: Vector3,
  92778. /**
  92779. * The max limit of the emission direction.
  92780. */
  92781. direction2?: Vector3);
  92782. /**
  92783. * Called by the particle System when the direction is computed for the created particle.
  92784. * @param worldMatrix is the world matrix of the particle system
  92785. * @param directionToUpdate is the direction vector to update with the result
  92786. * @param particle is the particle we are computed the direction for
  92787. */
  92788. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92789. /**
  92790. * Clones the current emitter and returns a copy of it
  92791. * @returns the new emitter
  92792. */
  92793. clone(): SphereDirectedParticleEmitter;
  92794. /**
  92795. * Called by the GPUParticleSystem to setup the update shader
  92796. * @param effect defines the update shader
  92797. */
  92798. applyToShader(effect: Effect): void;
  92799. /**
  92800. * Returns a string to use to update the GPU particles update shader
  92801. * @returns a string containng the defines string
  92802. */
  92803. getEffectDefines(): string;
  92804. /**
  92805. * Returns the string "SphereDirectedParticleEmitter"
  92806. * @returns a string containing the class name
  92807. */
  92808. getClassName(): string;
  92809. /**
  92810. * Serializes the particle system to a JSON object.
  92811. * @returns the JSON object
  92812. */
  92813. serialize(): any;
  92814. /**
  92815. * Parse properties from a JSON object
  92816. * @param serializationObject defines the JSON object
  92817. */
  92818. parse(serializationObject: any): void;
  92819. }
  92820. }
  92821. declare module BABYLON {
  92822. /**
  92823. * Particle emitter emitting particles from a custom list of positions.
  92824. */
  92825. export class CustomParticleEmitter implements IParticleEmitterType {
  92826. /**
  92827. * Gets or sets the position generator that will create the inital position of each particle.
  92828. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92829. */
  92830. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92831. /**
  92832. * Gets or sets the destination generator that will create the final destination of each particle.
  92833. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92834. */
  92835. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92836. /**
  92837. * Creates a new instance CustomParticleEmitter
  92838. */
  92839. constructor();
  92840. /**
  92841. * Called by the particle System when the direction is computed for the created particle.
  92842. * @param worldMatrix is the world matrix of the particle system
  92843. * @param directionToUpdate is the direction vector to update with the result
  92844. * @param particle is the particle we are computed the direction for
  92845. * @param isLocal defines if the direction should be set in local space
  92846. */
  92847. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92848. /**
  92849. * Called by the particle System when the position is computed for the created particle.
  92850. * @param worldMatrix is the world matrix of the particle system
  92851. * @param positionToUpdate is the position vector to update with the result
  92852. * @param particle is the particle we are computed the position for
  92853. * @param isLocal defines if the position should be set in local space
  92854. */
  92855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92856. /**
  92857. * Clones the current emitter and returns a copy of it
  92858. * @returns the new emitter
  92859. */
  92860. clone(): CustomParticleEmitter;
  92861. /**
  92862. * Called by the GPUParticleSystem to setup the update shader
  92863. * @param effect defines the update shader
  92864. */
  92865. applyToShader(effect: Effect): void;
  92866. /**
  92867. * Returns a string to use to update the GPU particles update shader
  92868. * @returns a string containng the defines string
  92869. */
  92870. getEffectDefines(): string;
  92871. /**
  92872. * Returns the string "PointParticleEmitter"
  92873. * @returns a string containing the class name
  92874. */
  92875. getClassName(): string;
  92876. /**
  92877. * Serializes the particle system to a JSON object.
  92878. * @returns the JSON object
  92879. */
  92880. serialize(): any;
  92881. /**
  92882. * Parse properties from a JSON object
  92883. * @param serializationObject defines the JSON object
  92884. */
  92885. parse(serializationObject: any): void;
  92886. }
  92887. }
  92888. declare module BABYLON {
  92889. /**
  92890. * Particle emitter emitting particles from the inside of a box.
  92891. * It emits the particles randomly between 2 given directions.
  92892. */
  92893. export class MeshParticleEmitter implements IParticleEmitterType {
  92894. private _indices;
  92895. private _positions;
  92896. private _normals;
  92897. private _storedNormal;
  92898. private _mesh;
  92899. /**
  92900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92901. */
  92902. direction1: Vector3;
  92903. /**
  92904. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92905. */
  92906. direction2: Vector3;
  92907. /**
  92908. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92909. */
  92910. useMeshNormalsForDirection: boolean;
  92911. /** Defines the mesh to use as source */
  92912. get mesh(): Nullable<AbstractMesh>;
  92913. set mesh(value: Nullable<AbstractMesh>);
  92914. /**
  92915. * Creates a new instance MeshParticleEmitter
  92916. * @param mesh defines the mesh to use as source
  92917. */
  92918. constructor(mesh?: Nullable<AbstractMesh>);
  92919. /**
  92920. * Called by the particle System when the direction is computed for the created particle.
  92921. * @param worldMatrix is the world matrix of the particle system
  92922. * @param directionToUpdate is the direction vector to update with the result
  92923. * @param particle is the particle we are computed the direction for
  92924. * @param isLocal defines if the direction should be set in local space
  92925. */
  92926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92927. /**
  92928. * Called by the particle System when the position is computed for the created particle.
  92929. * @param worldMatrix is the world matrix of the particle system
  92930. * @param positionToUpdate is the position vector to update with the result
  92931. * @param particle is the particle we are computed the position for
  92932. * @param isLocal defines if the position should be set in local space
  92933. */
  92934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92935. /**
  92936. * Clones the current emitter and returns a copy of it
  92937. * @returns the new emitter
  92938. */
  92939. clone(): MeshParticleEmitter;
  92940. /**
  92941. * Called by the GPUParticleSystem to setup the update shader
  92942. * @param effect defines the update shader
  92943. */
  92944. applyToShader(effect: Effect): void;
  92945. /**
  92946. * Returns a string to use to update the GPU particles update shader
  92947. * @returns a string containng the defines string
  92948. */
  92949. getEffectDefines(): string;
  92950. /**
  92951. * Returns the string "BoxParticleEmitter"
  92952. * @returns a string containing the class name
  92953. */
  92954. getClassName(): string;
  92955. /**
  92956. * Serializes the particle system to a JSON object.
  92957. * @returns the JSON object
  92958. */
  92959. serialize(): any;
  92960. /**
  92961. * Parse properties from a JSON object
  92962. * @param serializationObject defines the JSON object
  92963. * @param scene defines the hosting scene
  92964. */
  92965. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92966. }
  92967. }
  92968. declare module BABYLON {
  92969. /**
  92970. * Interface representing a particle system in Babylon.js.
  92971. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92972. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92973. */
  92974. export interface IParticleSystem {
  92975. /**
  92976. * List of animations used by the particle system.
  92977. */
  92978. animations: Animation[];
  92979. /**
  92980. * The id of the Particle system.
  92981. */
  92982. id: string;
  92983. /**
  92984. * The name of the Particle system.
  92985. */
  92986. name: string;
  92987. /**
  92988. * The emitter represents the Mesh or position we are attaching the particle system to.
  92989. */
  92990. emitter: Nullable<AbstractMesh | Vector3>;
  92991. /**
  92992. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92993. */
  92994. isBillboardBased: boolean;
  92995. /**
  92996. * The rendering group used by the Particle system to chose when to render.
  92997. */
  92998. renderingGroupId: number;
  92999. /**
  93000. * The layer mask we are rendering the particles through.
  93001. */
  93002. layerMask: number;
  93003. /**
  93004. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93005. */
  93006. updateSpeed: number;
  93007. /**
  93008. * The amount of time the particle system is running (depends of the overall update speed).
  93009. */
  93010. targetStopDuration: number;
  93011. /**
  93012. * The texture used to render each particle. (this can be a spritesheet)
  93013. */
  93014. particleTexture: Nullable<BaseTexture>;
  93015. /**
  93016. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93017. */
  93018. blendMode: number;
  93019. /**
  93020. * Minimum life time of emitting particles.
  93021. */
  93022. minLifeTime: number;
  93023. /**
  93024. * Maximum life time of emitting particles.
  93025. */
  93026. maxLifeTime: number;
  93027. /**
  93028. * Minimum Size of emitting particles.
  93029. */
  93030. minSize: number;
  93031. /**
  93032. * Maximum Size of emitting particles.
  93033. */
  93034. maxSize: number;
  93035. /**
  93036. * Minimum scale of emitting particles on X axis.
  93037. */
  93038. minScaleX: number;
  93039. /**
  93040. * Maximum scale of emitting particles on X axis.
  93041. */
  93042. maxScaleX: number;
  93043. /**
  93044. * Minimum scale of emitting particles on Y axis.
  93045. */
  93046. minScaleY: number;
  93047. /**
  93048. * Maximum scale of emitting particles on Y axis.
  93049. */
  93050. maxScaleY: number;
  93051. /**
  93052. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93053. */
  93054. color1: Color4;
  93055. /**
  93056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93057. */
  93058. color2: Color4;
  93059. /**
  93060. * Color the particle will have at the end of its lifetime.
  93061. */
  93062. colorDead: Color4;
  93063. /**
  93064. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93065. */
  93066. emitRate: number;
  93067. /**
  93068. * You can use gravity if you want to give an orientation to your particles.
  93069. */
  93070. gravity: Vector3;
  93071. /**
  93072. * Minimum power of emitting particles.
  93073. */
  93074. minEmitPower: number;
  93075. /**
  93076. * Maximum power of emitting particles.
  93077. */
  93078. maxEmitPower: number;
  93079. /**
  93080. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93081. */
  93082. minAngularSpeed: number;
  93083. /**
  93084. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93085. */
  93086. maxAngularSpeed: number;
  93087. /**
  93088. * Gets or sets the minimal initial rotation in radians.
  93089. */
  93090. minInitialRotation: number;
  93091. /**
  93092. * Gets or sets the maximal initial rotation in radians.
  93093. */
  93094. maxInitialRotation: number;
  93095. /**
  93096. * The particle emitter type defines the emitter used by the particle system.
  93097. * It can be for example box, sphere, or cone...
  93098. */
  93099. particleEmitterType: Nullable<IParticleEmitterType>;
  93100. /**
  93101. * Defines the delay in milliseconds before starting the system (0 by default)
  93102. */
  93103. startDelay: number;
  93104. /**
  93105. * 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
  93106. */
  93107. preWarmCycles: number;
  93108. /**
  93109. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93110. */
  93111. preWarmStepOffset: number;
  93112. /**
  93113. * 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)
  93114. */
  93115. spriteCellChangeSpeed: number;
  93116. /**
  93117. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93118. */
  93119. startSpriteCellID: number;
  93120. /**
  93121. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93122. */
  93123. endSpriteCellID: number;
  93124. /**
  93125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93126. */
  93127. spriteCellWidth: number;
  93128. /**
  93129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93130. */
  93131. spriteCellHeight: number;
  93132. /**
  93133. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93134. */
  93135. spriteRandomStartCell: boolean;
  93136. /**
  93137. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93138. */
  93139. isAnimationSheetEnabled: boolean;
  93140. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93141. translationPivot: Vector2;
  93142. /**
  93143. * Gets or sets a texture used to add random noise to particle positions
  93144. */
  93145. noiseTexture: Nullable<BaseTexture>;
  93146. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93147. noiseStrength: Vector3;
  93148. /**
  93149. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93150. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93151. */
  93152. billboardMode: number;
  93153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93154. limitVelocityDamping: number;
  93155. /**
  93156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93157. */
  93158. beginAnimationOnStart: boolean;
  93159. /**
  93160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93161. */
  93162. beginAnimationFrom: number;
  93163. /**
  93164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93165. */
  93166. beginAnimationTo: number;
  93167. /**
  93168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93169. */
  93170. beginAnimationLoop: boolean;
  93171. /**
  93172. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93173. */
  93174. disposeOnStop: boolean;
  93175. /**
  93176. * Specifies if the particles are updated in emitter local space or world space
  93177. */
  93178. isLocal: boolean;
  93179. /** Snippet ID if the particle system was created from the snippet server */
  93180. snippetId: string;
  93181. /** Gets or sets a matrix to use to compute projection */
  93182. defaultProjectionMatrix: Matrix;
  93183. /**
  93184. * Gets the maximum number of particles active at the same time.
  93185. * @returns The max number of active particles.
  93186. */
  93187. getCapacity(): number;
  93188. /**
  93189. * Gets the number of particles active at the same time.
  93190. * @returns The number of active particles.
  93191. */
  93192. getActiveCount(): number;
  93193. /**
  93194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93195. * @returns True if it has been started, otherwise false.
  93196. */
  93197. isStarted(): boolean;
  93198. /**
  93199. * Animates the particle system for this frame.
  93200. */
  93201. animate(): void;
  93202. /**
  93203. * Renders the particle system in its current state.
  93204. * @returns the current number of particles
  93205. */
  93206. render(): number;
  93207. /**
  93208. * Dispose the particle system and frees its associated resources.
  93209. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93210. */
  93211. dispose(disposeTexture?: boolean): void;
  93212. /**
  93213. * An event triggered when the system is disposed
  93214. */
  93215. onDisposeObservable: Observable<IParticleSystem>;
  93216. /**
  93217. * Clones the particle system.
  93218. * @param name The name of the cloned object
  93219. * @param newEmitter The new emitter to use
  93220. * @returns the cloned particle system
  93221. */
  93222. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93223. /**
  93224. * Serializes the particle system to a JSON object
  93225. * @param serializeTexture defines if the texture must be serialized as well
  93226. * @returns the JSON object
  93227. */
  93228. serialize(serializeTexture: boolean): any;
  93229. /**
  93230. * Rebuild the particle system
  93231. */
  93232. rebuild(): void;
  93233. /** Force the system to rebuild all gradients that need to be resync */
  93234. forceRefreshGradients(): void;
  93235. /**
  93236. * Starts the particle system and begins to emit
  93237. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93238. */
  93239. start(delay?: number): void;
  93240. /**
  93241. * Stops the particle system.
  93242. */
  93243. stop(): void;
  93244. /**
  93245. * Remove all active particles
  93246. */
  93247. reset(): void;
  93248. /**
  93249. * Gets a boolean indicating that the system is stopping
  93250. * @returns true if the system is currently stopping
  93251. */
  93252. isStopping(): boolean;
  93253. /**
  93254. * Is this system ready to be used/rendered
  93255. * @return true if the system is ready
  93256. */
  93257. isReady(): boolean;
  93258. /**
  93259. * Returns the string "ParticleSystem"
  93260. * @returns a string containing the class name
  93261. */
  93262. getClassName(): string;
  93263. /**
  93264. * Gets the custom effect used to render the particles
  93265. * @param blendMode Blend mode for which the effect should be retrieved
  93266. * @returns The effect
  93267. */
  93268. getCustomEffect(blendMode: number): Nullable<Effect>;
  93269. /**
  93270. * Sets the custom effect used to render the particles
  93271. * @param effect The effect to set
  93272. * @param blendMode Blend mode for which the effect should be set
  93273. */
  93274. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93275. /**
  93276. * Fill the defines array according to the current settings of the particle system
  93277. * @param defines Array to be updated
  93278. * @param blendMode blend mode to take into account when updating the array
  93279. */
  93280. fillDefines(defines: Array<string>, blendMode: number): void;
  93281. /**
  93282. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93283. * @param uniforms Uniforms array to fill
  93284. * @param attributes Attributes array to fill
  93285. * @param samplers Samplers array to fill
  93286. */
  93287. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93288. /**
  93289. * Observable that will be called just before the particles are drawn
  93290. */
  93291. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93292. /**
  93293. * Gets the name of the particle vertex shader
  93294. */
  93295. vertexShaderName: string;
  93296. /**
  93297. * Adds a new color gradient
  93298. * @param gradient defines the gradient to use (between 0 and 1)
  93299. * @param color1 defines the color to affect to the specified gradient
  93300. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93301. * @returns the current particle system
  93302. */
  93303. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93304. /**
  93305. * Remove a specific color gradient
  93306. * @param gradient defines the gradient to remove
  93307. * @returns the current particle system
  93308. */
  93309. removeColorGradient(gradient: number): IParticleSystem;
  93310. /**
  93311. * Adds a new size gradient
  93312. * @param gradient defines the gradient to use (between 0 and 1)
  93313. * @param factor defines the size factor to affect to the specified gradient
  93314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93315. * @returns the current particle system
  93316. */
  93317. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93318. /**
  93319. * Remove a specific size gradient
  93320. * @param gradient defines the gradient to remove
  93321. * @returns the current particle system
  93322. */
  93323. removeSizeGradient(gradient: number): IParticleSystem;
  93324. /**
  93325. * Gets the current list of color gradients.
  93326. * You must use addColorGradient and removeColorGradient to udpate this list
  93327. * @returns the list of color gradients
  93328. */
  93329. getColorGradients(): Nullable<Array<ColorGradient>>;
  93330. /**
  93331. * Gets the current list of size gradients.
  93332. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93333. * @returns the list of size gradients
  93334. */
  93335. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93336. /**
  93337. * Gets the current list of angular speed gradients.
  93338. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93339. * @returns the list of angular speed gradients
  93340. */
  93341. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93342. /**
  93343. * Adds a new angular speed gradient
  93344. * @param gradient defines the gradient to use (between 0 and 1)
  93345. * @param factor defines the angular speed to affect to the specified gradient
  93346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93347. * @returns the current particle system
  93348. */
  93349. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93350. /**
  93351. * Remove a specific angular speed gradient
  93352. * @param gradient defines the gradient to remove
  93353. * @returns the current particle system
  93354. */
  93355. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93356. /**
  93357. * Gets the current list of velocity gradients.
  93358. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93359. * @returns the list of velocity gradients
  93360. */
  93361. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93362. /**
  93363. * Adds a new velocity gradient
  93364. * @param gradient defines the gradient to use (between 0 and 1)
  93365. * @param factor defines the velocity to affect to the specified gradient
  93366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93367. * @returns the current particle system
  93368. */
  93369. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93370. /**
  93371. * Remove a specific velocity gradient
  93372. * @param gradient defines the gradient to remove
  93373. * @returns the current particle system
  93374. */
  93375. removeVelocityGradient(gradient: number): IParticleSystem;
  93376. /**
  93377. * Gets the current list of limit velocity gradients.
  93378. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93379. * @returns the list of limit velocity gradients
  93380. */
  93381. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93382. /**
  93383. * Adds a new limit velocity gradient
  93384. * @param gradient defines the gradient to use (between 0 and 1)
  93385. * @param factor defines the limit velocity to affect to the specified gradient
  93386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93387. * @returns the current particle system
  93388. */
  93389. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93390. /**
  93391. * Remove a specific limit velocity gradient
  93392. * @param gradient defines the gradient to remove
  93393. * @returns the current particle system
  93394. */
  93395. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93396. /**
  93397. * Adds a new drag gradient
  93398. * @param gradient defines the gradient to use (between 0 and 1)
  93399. * @param factor defines the drag to affect to the specified gradient
  93400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93401. * @returns the current particle system
  93402. */
  93403. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93404. /**
  93405. * Remove a specific drag gradient
  93406. * @param gradient defines the gradient to remove
  93407. * @returns the current particle system
  93408. */
  93409. removeDragGradient(gradient: number): IParticleSystem;
  93410. /**
  93411. * Gets the current list of drag gradients.
  93412. * You must use addDragGradient and removeDragGradient to udpate this list
  93413. * @returns the list of drag gradients
  93414. */
  93415. getDragGradients(): Nullable<Array<FactorGradient>>;
  93416. /**
  93417. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93418. * @param gradient defines the gradient to use (between 0 and 1)
  93419. * @param factor defines the emit rate to affect to the specified gradient
  93420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93421. * @returns the current particle system
  93422. */
  93423. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93424. /**
  93425. * Remove a specific emit rate gradient
  93426. * @param gradient defines the gradient to remove
  93427. * @returns the current particle system
  93428. */
  93429. removeEmitRateGradient(gradient: number): IParticleSystem;
  93430. /**
  93431. * Gets the current list of emit rate gradients.
  93432. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93433. * @returns the list of emit rate gradients
  93434. */
  93435. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93436. /**
  93437. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93438. * @param gradient defines the gradient to use (between 0 and 1)
  93439. * @param factor defines the start size to affect to the specified gradient
  93440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93441. * @returns the current particle system
  93442. */
  93443. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93444. /**
  93445. * Remove a specific start size gradient
  93446. * @param gradient defines the gradient to remove
  93447. * @returns the current particle system
  93448. */
  93449. removeStartSizeGradient(gradient: number): IParticleSystem;
  93450. /**
  93451. * Gets the current list of start size gradients.
  93452. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93453. * @returns the list of start size gradients
  93454. */
  93455. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93456. /**
  93457. * Adds a new life time gradient
  93458. * @param gradient defines the gradient to use (between 0 and 1)
  93459. * @param factor defines the life time factor to affect to the specified gradient
  93460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93461. * @returns the current particle system
  93462. */
  93463. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93464. /**
  93465. * Remove a specific life time gradient
  93466. * @param gradient defines the gradient to remove
  93467. * @returns the current particle system
  93468. */
  93469. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93470. /**
  93471. * Gets the current list of life time gradients.
  93472. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93473. * @returns the list of life time gradients
  93474. */
  93475. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93476. /**
  93477. * Gets the current list of color gradients.
  93478. * You must use addColorGradient and removeColorGradient to udpate this list
  93479. * @returns the list of color gradients
  93480. */
  93481. getColorGradients(): Nullable<Array<ColorGradient>>;
  93482. /**
  93483. * Adds a new ramp gradient used to remap particle colors
  93484. * @param gradient defines the gradient to use (between 0 and 1)
  93485. * @param color defines the color to affect to the specified gradient
  93486. * @returns the current particle system
  93487. */
  93488. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93489. /**
  93490. * Gets the current list of ramp gradients.
  93491. * You must use addRampGradient and removeRampGradient to udpate this list
  93492. * @returns the list of ramp gradients
  93493. */
  93494. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93495. /** Gets or sets a boolean indicating that ramp gradients must be used
  93496. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93497. */
  93498. useRampGradients: boolean;
  93499. /**
  93500. * Adds a new color remap gradient
  93501. * @param gradient defines the gradient to use (between 0 and 1)
  93502. * @param min defines the color remap minimal range
  93503. * @param max defines the color remap maximal range
  93504. * @returns the current particle system
  93505. */
  93506. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93507. /**
  93508. * Gets the current list of color remap gradients.
  93509. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93510. * @returns the list of color remap gradients
  93511. */
  93512. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93513. /**
  93514. * Adds a new alpha remap gradient
  93515. * @param gradient defines the gradient to use (between 0 and 1)
  93516. * @param min defines the alpha remap minimal range
  93517. * @param max defines the alpha remap maximal range
  93518. * @returns the current particle system
  93519. */
  93520. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93521. /**
  93522. * Gets the current list of alpha remap gradients.
  93523. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93524. * @returns the list of alpha remap gradients
  93525. */
  93526. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93527. /**
  93528. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93531. * @returns the emitter
  93532. */
  93533. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93534. /**
  93535. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93536. * @param radius The radius of the hemisphere to emit from
  93537. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93538. * @returns the emitter
  93539. */
  93540. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93541. /**
  93542. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93543. * @param radius The radius of the sphere to emit from
  93544. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93545. * @returns the emitter
  93546. */
  93547. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93548. /**
  93549. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93550. * @param radius The radius of the sphere to emit from
  93551. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93552. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93553. * @returns the emitter
  93554. */
  93555. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93556. /**
  93557. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93558. * @param radius The radius of the emission cylinder
  93559. * @param height The height of the emission cylinder
  93560. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93561. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93562. * @returns the emitter
  93563. */
  93564. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93565. /**
  93566. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93567. * @param radius The radius of the cylinder to emit from
  93568. * @param height The height of the emission cylinder
  93569. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93572. * @returns the emitter
  93573. */
  93574. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93575. /**
  93576. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93577. * @param radius The radius of the cone to emit from
  93578. * @param angle The base angle of the cone
  93579. * @returns the emitter
  93580. */
  93581. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93582. /**
  93583. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93586. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93587. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93588. * @returns the emitter
  93589. */
  93590. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93591. /**
  93592. * Get hosting scene
  93593. * @returns the scene
  93594. */
  93595. getScene(): Nullable<Scene>;
  93596. }
  93597. }
  93598. declare module BABYLON {
  93599. /**
  93600. * 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.
  93601. * @see https://doc.babylonjs.com/how_to/transformnode
  93602. */
  93603. export class TransformNode extends Node {
  93604. /**
  93605. * Object will not rotate to face the camera
  93606. */
  93607. static BILLBOARDMODE_NONE: number;
  93608. /**
  93609. * Object will rotate to face the camera but only on the x axis
  93610. */
  93611. static BILLBOARDMODE_X: number;
  93612. /**
  93613. * Object will rotate to face the camera but only on the y axis
  93614. */
  93615. static BILLBOARDMODE_Y: number;
  93616. /**
  93617. * Object will rotate to face the camera but only on the z axis
  93618. */
  93619. static BILLBOARDMODE_Z: number;
  93620. /**
  93621. * Object will rotate to face the camera
  93622. */
  93623. static BILLBOARDMODE_ALL: number;
  93624. /**
  93625. * Object will rotate to face the camera's position instead of orientation
  93626. */
  93627. static BILLBOARDMODE_USE_POSITION: number;
  93628. private static _TmpRotation;
  93629. private static _TmpScaling;
  93630. private static _TmpTranslation;
  93631. private _forward;
  93632. private _forwardInverted;
  93633. private _up;
  93634. private _right;
  93635. private _rightInverted;
  93636. private _position;
  93637. private _rotation;
  93638. private _rotationQuaternion;
  93639. protected _scaling: Vector3;
  93640. protected _isDirty: boolean;
  93641. private _transformToBoneReferal;
  93642. private _isAbsoluteSynced;
  93643. private _billboardMode;
  93644. /**
  93645. * Gets or sets the billboard mode. Default is 0.
  93646. *
  93647. * | Value | Type | Description |
  93648. * | --- | --- | --- |
  93649. * | 0 | BILLBOARDMODE_NONE | |
  93650. * | 1 | BILLBOARDMODE_X | |
  93651. * | 2 | BILLBOARDMODE_Y | |
  93652. * | 4 | BILLBOARDMODE_Z | |
  93653. * | 7 | BILLBOARDMODE_ALL | |
  93654. *
  93655. */
  93656. get billboardMode(): number;
  93657. set billboardMode(value: number);
  93658. private _preserveParentRotationForBillboard;
  93659. /**
  93660. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93661. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93662. */
  93663. get preserveParentRotationForBillboard(): boolean;
  93664. set preserveParentRotationForBillboard(value: boolean);
  93665. /**
  93666. * 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
  93667. */
  93668. scalingDeterminant: number;
  93669. private _infiniteDistance;
  93670. /**
  93671. * Gets or sets the distance of the object to max, often used by skybox
  93672. */
  93673. get infiniteDistance(): boolean;
  93674. set infiniteDistance(value: boolean);
  93675. /**
  93676. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93677. * By default the system will update normals to compensate
  93678. */
  93679. ignoreNonUniformScaling: boolean;
  93680. /**
  93681. * 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
  93682. */
  93683. reIntegrateRotationIntoRotationQuaternion: boolean;
  93684. /** @hidden */
  93685. _poseMatrix: Nullable<Matrix>;
  93686. /** @hidden */
  93687. _localMatrix: Matrix;
  93688. private _usePivotMatrix;
  93689. private _absolutePosition;
  93690. private _absoluteScaling;
  93691. private _absoluteRotationQuaternion;
  93692. private _pivotMatrix;
  93693. private _pivotMatrixInverse;
  93694. protected _postMultiplyPivotMatrix: boolean;
  93695. protected _isWorldMatrixFrozen: boolean;
  93696. /** @hidden */
  93697. _indexInSceneTransformNodesArray: number;
  93698. /**
  93699. * An event triggered after the world matrix is updated
  93700. */
  93701. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93702. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93703. /**
  93704. * Gets a string identifying the name of the class
  93705. * @returns "TransformNode" string
  93706. */
  93707. getClassName(): string;
  93708. /**
  93709. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93710. */
  93711. get position(): Vector3;
  93712. set position(newPosition: Vector3);
  93713. /**
  93714. * 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)).
  93715. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93716. */
  93717. get rotation(): Vector3;
  93718. set rotation(newRotation: Vector3);
  93719. /**
  93720. * 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)).
  93721. */
  93722. get scaling(): Vector3;
  93723. set scaling(newScaling: Vector3);
  93724. /**
  93725. * 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).
  93726. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93727. */
  93728. get rotationQuaternion(): Nullable<Quaternion>;
  93729. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93730. /**
  93731. * The forward direction of that transform in world space.
  93732. */
  93733. get forward(): Vector3;
  93734. /**
  93735. * The up direction of that transform in world space.
  93736. */
  93737. get up(): Vector3;
  93738. /**
  93739. * The right direction of that transform in world space.
  93740. */
  93741. get right(): Vector3;
  93742. /**
  93743. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93744. * @param matrix the matrix to copy the pose from
  93745. * @returns this TransformNode.
  93746. */
  93747. updatePoseMatrix(matrix: Matrix): TransformNode;
  93748. /**
  93749. * Returns the mesh Pose matrix.
  93750. * @returns the pose matrix
  93751. */
  93752. getPoseMatrix(): Matrix;
  93753. /** @hidden */
  93754. _isSynchronized(): boolean;
  93755. /** @hidden */
  93756. _initCache(): void;
  93757. /**
  93758. * Flag the transform node as dirty (Forcing it to update everything)
  93759. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93760. * @returns this transform node
  93761. */
  93762. markAsDirty(property: string): TransformNode;
  93763. /**
  93764. * Returns the current mesh absolute position.
  93765. * Returns a Vector3.
  93766. */
  93767. get absolutePosition(): Vector3;
  93768. /**
  93769. * Returns the current mesh absolute scaling.
  93770. * Returns a Vector3.
  93771. */
  93772. get absoluteScaling(): Vector3;
  93773. /**
  93774. * Returns the current mesh absolute rotation.
  93775. * Returns a Quaternion.
  93776. */
  93777. get absoluteRotationQuaternion(): Quaternion;
  93778. /**
  93779. * Sets a new matrix to apply before all other transformation
  93780. * @param matrix defines the transform matrix
  93781. * @returns the current TransformNode
  93782. */
  93783. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93784. /**
  93785. * Sets a new pivot matrix to the current node
  93786. * @param matrix defines the new pivot matrix to use
  93787. * @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
  93788. * @returns the current TransformNode
  93789. */
  93790. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93791. /**
  93792. * Returns the mesh pivot matrix.
  93793. * Default : Identity.
  93794. * @returns the matrix
  93795. */
  93796. getPivotMatrix(): Matrix;
  93797. /**
  93798. * Instantiate (when possible) or clone that node with its hierarchy
  93799. * @param newParent defines the new parent to use for the instance (or clone)
  93800. * @param options defines options to configure how copy is done
  93801. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93802. * @returns an instance (or a clone) of the current node with its hiearchy
  93803. */
  93804. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93805. doNotInstantiate: boolean;
  93806. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93807. /**
  93808. * Prevents the World matrix to be computed any longer
  93809. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93810. * @returns the TransformNode.
  93811. */
  93812. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93813. /**
  93814. * Allows back the World matrix computation.
  93815. * @returns the TransformNode.
  93816. */
  93817. unfreezeWorldMatrix(): this;
  93818. /**
  93819. * True if the World matrix has been frozen.
  93820. */
  93821. get isWorldMatrixFrozen(): boolean;
  93822. /**
  93823. * Retuns the mesh absolute position in the World.
  93824. * @returns a Vector3.
  93825. */
  93826. getAbsolutePosition(): Vector3;
  93827. /**
  93828. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93829. * @param absolutePosition the absolute position to set
  93830. * @returns the TransformNode.
  93831. */
  93832. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93833. /**
  93834. * Sets the mesh position in its local space.
  93835. * @param vector3 the position to set in localspace
  93836. * @returns the TransformNode.
  93837. */
  93838. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93839. /**
  93840. * Returns the mesh position in the local space from the current World matrix values.
  93841. * @returns a new Vector3.
  93842. */
  93843. getPositionExpressedInLocalSpace(): Vector3;
  93844. /**
  93845. * Translates the mesh along the passed Vector3 in its local space.
  93846. * @param vector3 the distance to translate in localspace
  93847. * @returns the TransformNode.
  93848. */
  93849. locallyTranslate(vector3: Vector3): TransformNode;
  93850. private static _lookAtVectorCache;
  93851. /**
  93852. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93853. * @param targetPoint the position (must be in same space as current mesh) to look at
  93854. * @param yawCor optional yaw (y-axis) correction in radians
  93855. * @param pitchCor optional pitch (x-axis) correction in radians
  93856. * @param rollCor optional roll (z-axis) correction in radians
  93857. * @param space the choosen space of the target
  93858. * @returns the TransformNode.
  93859. */
  93860. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93861. /**
  93862. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93863. * This Vector3 is expressed in the World space.
  93864. * @param localAxis axis to rotate
  93865. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93866. */
  93867. getDirection(localAxis: Vector3): Vector3;
  93868. /**
  93869. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93870. * localAxis is expressed in the mesh local space.
  93871. * result is computed in the Wordl space from the mesh World matrix.
  93872. * @param localAxis axis to rotate
  93873. * @param result the resulting transformnode
  93874. * @returns this TransformNode.
  93875. */
  93876. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93877. /**
  93878. * Sets this transform node rotation to the given local axis.
  93879. * @param localAxis the axis in local space
  93880. * @param yawCor optional yaw (y-axis) correction in radians
  93881. * @param pitchCor optional pitch (x-axis) correction in radians
  93882. * @param rollCor optional roll (z-axis) correction in radians
  93883. * @returns this TransformNode
  93884. */
  93885. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93886. /**
  93887. * Sets a new pivot point to the current node
  93888. * @param point defines the new pivot point to use
  93889. * @param space defines if the point is in world or local space (local by default)
  93890. * @returns the current TransformNode
  93891. */
  93892. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93893. /**
  93894. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93895. * @returns the pivot point
  93896. */
  93897. getPivotPoint(): Vector3;
  93898. /**
  93899. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93900. * @param result the vector3 to store the result
  93901. * @returns this TransformNode.
  93902. */
  93903. getPivotPointToRef(result: Vector3): TransformNode;
  93904. /**
  93905. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93906. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93907. */
  93908. getAbsolutePivotPoint(): Vector3;
  93909. /**
  93910. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93911. * @param result vector3 to store the result
  93912. * @returns this TransformNode.
  93913. */
  93914. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93915. /**
  93916. * Defines the passed node as the parent of the current node.
  93917. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93918. * @see https://doc.babylonjs.com/how_to/parenting
  93919. * @param node the node ot set as the parent
  93920. * @returns this TransformNode.
  93921. */
  93922. setParent(node: Nullable<Node>): TransformNode;
  93923. private _nonUniformScaling;
  93924. /**
  93925. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93926. */
  93927. get nonUniformScaling(): boolean;
  93928. /** @hidden */
  93929. _updateNonUniformScalingState(value: boolean): boolean;
  93930. /**
  93931. * Attach the current TransformNode to another TransformNode associated with a bone
  93932. * @param bone Bone affecting the TransformNode
  93933. * @param affectedTransformNode TransformNode associated with the bone
  93934. * @returns this object
  93935. */
  93936. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93937. /**
  93938. * Detach the transform node if its associated with a bone
  93939. * @returns this object
  93940. */
  93941. detachFromBone(): TransformNode;
  93942. private static _rotationAxisCache;
  93943. /**
  93944. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93945. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93946. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93947. * The passed axis is also normalized.
  93948. * @param axis the axis to rotate around
  93949. * @param amount the amount to rotate in radians
  93950. * @param space Space to rotate in (Default: local)
  93951. * @returns the TransformNode.
  93952. */
  93953. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93954. /**
  93955. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93956. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93957. * The passed axis is also normalized. .
  93958. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93959. * @param point the point to rotate around
  93960. * @param axis the axis to rotate around
  93961. * @param amount the amount to rotate in radians
  93962. * @returns the TransformNode
  93963. */
  93964. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93965. /**
  93966. * Translates the mesh along the axis vector for the passed distance in the given space.
  93967. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93968. * @param axis the axis to translate in
  93969. * @param distance the distance to translate
  93970. * @param space Space to rotate in (Default: local)
  93971. * @returns the TransformNode.
  93972. */
  93973. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93974. /**
  93975. * Adds a rotation step to the mesh current rotation.
  93976. * x, y, z are Euler angles expressed in radians.
  93977. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93978. * This means this rotation is made in the mesh local space only.
  93979. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93980. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93981. * ```javascript
  93982. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93983. * ```
  93984. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93985. * 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.
  93986. * @param x Rotation to add
  93987. * @param y Rotation to add
  93988. * @param z Rotation to add
  93989. * @returns the TransformNode.
  93990. */
  93991. addRotation(x: number, y: number, z: number): TransformNode;
  93992. /**
  93993. * @hidden
  93994. */
  93995. protected _getEffectiveParent(): Nullable<Node>;
  93996. /**
  93997. * Computes the world matrix of the node
  93998. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93999. * @returns the world matrix
  94000. */
  94001. computeWorldMatrix(force?: boolean): Matrix;
  94002. /**
  94003. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94004. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94005. */
  94006. resetLocalMatrix(independentOfChildren?: boolean): void;
  94007. protected _afterComputeWorldMatrix(): void;
  94008. /**
  94009. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94010. * @param func callback function to add
  94011. *
  94012. * @returns the TransformNode.
  94013. */
  94014. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94015. /**
  94016. * Removes a registered callback function.
  94017. * @param func callback function to remove
  94018. * @returns the TransformNode.
  94019. */
  94020. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94021. /**
  94022. * Gets the position of the current mesh in camera space
  94023. * @param camera defines the camera to use
  94024. * @returns a position
  94025. */
  94026. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94027. /**
  94028. * Returns the distance from the mesh to the active camera
  94029. * @param camera defines the camera to use
  94030. * @returns the distance
  94031. */
  94032. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94033. /**
  94034. * Clone the current transform node
  94035. * @param name Name of the new clone
  94036. * @param newParent New parent for the clone
  94037. * @param doNotCloneChildren Do not clone children hierarchy
  94038. * @returns the new transform node
  94039. */
  94040. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94041. /**
  94042. * Serializes the objects information.
  94043. * @param currentSerializationObject defines the object to serialize in
  94044. * @returns the serialized object
  94045. */
  94046. serialize(currentSerializationObject?: any): any;
  94047. /**
  94048. * Returns a new TransformNode object parsed from the source provided.
  94049. * @param parsedTransformNode is the source.
  94050. * @param scene the scne the object belongs to
  94051. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94052. * @returns a new TransformNode object parsed from the source provided.
  94053. */
  94054. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94055. /**
  94056. * Get all child-transformNodes of this node
  94057. * @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
  94058. * @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
  94059. * @returns an array of TransformNode
  94060. */
  94061. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94062. /**
  94063. * Releases resources associated with this transform node.
  94064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94066. */
  94067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94068. /**
  94069. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94070. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94071. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94072. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94073. * @returns the current mesh
  94074. */
  94075. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94076. private _syncAbsoluteScalingAndRotation;
  94077. }
  94078. }
  94079. declare module BABYLON {
  94080. /**
  94081. * Class used to override all child animations of a given target
  94082. */
  94083. export class AnimationPropertiesOverride {
  94084. /**
  94085. * Gets or sets a value indicating if animation blending must be used
  94086. */
  94087. enableBlending: boolean;
  94088. /**
  94089. * Gets or sets the blending speed to use when enableBlending is true
  94090. */
  94091. blendingSpeed: number;
  94092. /**
  94093. * Gets or sets the default loop mode to use
  94094. */
  94095. loopMode: number;
  94096. }
  94097. }
  94098. declare module BABYLON {
  94099. /**
  94100. * Class used to store bone information
  94101. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94102. */
  94103. export class Bone extends Node {
  94104. /**
  94105. * defines the bone name
  94106. */
  94107. name: string;
  94108. private static _tmpVecs;
  94109. private static _tmpQuat;
  94110. private static _tmpMats;
  94111. /**
  94112. * Gets the list of child bones
  94113. */
  94114. children: Bone[];
  94115. /** Gets the animations associated with this bone */
  94116. animations: Animation[];
  94117. /**
  94118. * Gets or sets bone length
  94119. */
  94120. length: number;
  94121. /**
  94122. * @hidden Internal only
  94123. * Set this value to map this bone to a different index in the transform matrices
  94124. * Set this value to -1 to exclude the bone from the transform matrices
  94125. */
  94126. _index: Nullable<number>;
  94127. private _skeleton;
  94128. private _localMatrix;
  94129. private _restPose;
  94130. private _bindPose;
  94131. private _baseMatrix;
  94132. private _absoluteTransform;
  94133. private _invertedAbsoluteTransform;
  94134. private _parent;
  94135. private _scalingDeterminant;
  94136. private _worldTransform;
  94137. private _localScaling;
  94138. private _localRotation;
  94139. private _localPosition;
  94140. private _needToDecompose;
  94141. private _needToCompose;
  94142. /** @hidden */
  94143. _linkedTransformNode: Nullable<TransformNode>;
  94144. /** @hidden */
  94145. _waitingTransformNodeId: Nullable<string>;
  94146. /** @hidden */
  94147. get _matrix(): Matrix;
  94148. /** @hidden */
  94149. set _matrix(value: Matrix);
  94150. /**
  94151. * Create a new bone
  94152. * @param name defines the bone name
  94153. * @param skeleton defines the parent skeleton
  94154. * @param parentBone defines the parent (can be null if the bone is the root)
  94155. * @param localMatrix defines the local matrix
  94156. * @param restPose defines the rest pose matrix
  94157. * @param baseMatrix defines the base matrix
  94158. * @param index defines index of the bone in the hiearchy
  94159. */
  94160. constructor(
  94161. /**
  94162. * defines the bone name
  94163. */
  94164. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94165. /**
  94166. * Gets the current object class name.
  94167. * @return the class name
  94168. */
  94169. getClassName(): string;
  94170. /**
  94171. * Gets the parent skeleton
  94172. * @returns a skeleton
  94173. */
  94174. getSkeleton(): Skeleton;
  94175. /**
  94176. * Gets parent bone
  94177. * @returns a bone or null if the bone is the root of the bone hierarchy
  94178. */
  94179. getParent(): Nullable<Bone>;
  94180. /**
  94181. * Returns an array containing the root bones
  94182. * @returns an array containing the root bones
  94183. */
  94184. getChildren(): Array<Bone>;
  94185. /**
  94186. * Gets the node index in matrix array generated for rendering
  94187. * @returns the node index
  94188. */
  94189. getIndex(): number;
  94190. /**
  94191. * Sets the parent bone
  94192. * @param parent defines the parent (can be null if the bone is the root)
  94193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94194. */
  94195. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94196. /**
  94197. * Gets the local matrix
  94198. * @returns a matrix
  94199. */
  94200. getLocalMatrix(): Matrix;
  94201. /**
  94202. * Gets the base matrix (initial matrix which remains unchanged)
  94203. * @returns a matrix
  94204. */
  94205. getBaseMatrix(): Matrix;
  94206. /**
  94207. * Gets the rest pose matrix
  94208. * @returns a matrix
  94209. */
  94210. getRestPose(): Matrix;
  94211. /**
  94212. * Sets the rest pose matrix
  94213. * @param matrix the local-space rest pose to set for this bone
  94214. */
  94215. setRestPose(matrix: Matrix): void;
  94216. /**
  94217. * Gets the bind pose matrix
  94218. * @returns the bind pose matrix
  94219. */
  94220. getBindPose(): Matrix;
  94221. /**
  94222. * Sets the bind pose matrix
  94223. * @param matrix the local-space bind pose to set for this bone
  94224. */
  94225. setBindPose(matrix: Matrix): void;
  94226. /**
  94227. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94228. */
  94229. getWorldMatrix(): Matrix;
  94230. /**
  94231. * Sets the local matrix to rest pose matrix
  94232. */
  94233. returnToRest(): void;
  94234. /**
  94235. * Gets the inverse of the absolute transform matrix.
  94236. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94237. * @returns a matrix
  94238. */
  94239. getInvertedAbsoluteTransform(): Matrix;
  94240. /**
  94241. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94242. * @returns a matrix
  94243. */
  94244. getAbsoluteTransform(): Matrix;
  94245. /**
  94246. * Links with the given transform node.
  94247. * The local matrix of this bone is copied from the transform node every frame.
  94248. * @param transformNode defines the transform node to link to
  94249. */
  94250. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94251. /**
  94252. * Gets the node used to drive the bone's transformation
  94253. * @returns a transform node or null
  94254. */
  94255. getTransformNode(): Nullable<TransformNode>;
  94256. /** Gets or sets current position (in local space) */
  94257. get position(): Vector3;
  94258. set position(newPosition: Vector3);
  94259. /** Gets or sets current rotation (in local space) */
  94260. get rotation(): Vector3;
  94261. set rotation(newRotation: Vector3);
  94262. /** Gets or sets current rotation quaternion (in local space) */
  94263. get rotationQuaternion(): Quaternion;
  94264. set rotationQuaternion(newRotation: Quaternion);
  94265. /** Gets or sets current scaling (in local space) */
  94266. get scaling(): Vector3;
  94267. set scaling(newScaling: Vector3);
  94268. /**
  94269. * Gets the animation properties override
  94270. */
  94271. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94272. private _decompose;
  94273. private _compose;
  94274. /**
  94275. * Update the base and local matrices
  94276. * @param matrix defines the new base or local matrix
  94277. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94278. * @param updateLocalMatrix defines if the local matrix should be updated
  94279. */
  94280. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94281. /** @hidden */
  94282. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94283. /**
  94284. * Flag the bone as dirty (Forcing it to update everything)
  94285. */
  94286. markAsDirty(): void;
  94287. /** @hidden */
  94288. _markAsDirtyAndCompose(): void;
  94289. private _markAsDirtyAndDecompose;
  94290. /**
  94291. * Translate the bone in local or world space
  94292. * @param vec The amount to translate the bone
  94293. * @param space The space that the translation is in
  94294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94295. */
  94296. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94297. /**
  94298. * Set the postion of the bone in local or world space
  94299. * @param position The position to set the bone
  94300. * @param space The space that the position is in
  94301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94302. */
  94303. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94304. /**
  94305. * Set the absolute position of the bone (world space)
  94306. * @param position The position to set the bone
  94307. * @param mesh The mesh that this bone is attached to
  94308. */
  94309. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94310. /**
  94311. * Scale the bone on the x, y and z axes (in local space)
  94312. * @param x The amount to scale the bone on the x axis
  94313. * @param y The amount to scale the bone on the y axis
  94314. * @param z The amount to scale the bone on the z axis
  94315. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94316. */
  94317. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94318. /**
  94319. * Set the bone scaling in local space
  94320. * @param scale defines the scaling vector
  94321. */
  94322. setScale(scale: Vector3): void;
  94323. /**
  94324. * Gets the current scaling in local space
  94325. * @returns the current scaling vector
  94326. */
  94327. getScale(): Vector3;
  94328. /**
  94329. * Gets the current scaling in local space and stores it in a target vector
  94330. * @param result defines the target vector
  94331. */
  94332. getScaleToRef(result: Vector3): void;
  94333. /**
  94334. * Set the yaw, pitch, and roll of the bone in local or world space
  94335. * @param yaw The rotation of the bone on the y axis
  94336. * @param pitch The rotation of the bone on the x axis
  94337. * @param roll The rotation of the bone on the z axis
  94338. * @param space The space that the axes of rotation are in
  94339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94340. */
  94341. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94342. /**
  94343. * Add a rotation to the bone on an axis in local or world space
  94344. * @param axis The axis to rotate the bone on
  94345. * @param amount The amount to rotate the bone
  94346. * @param space The space that the axis is in
  94347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94348. */
  94349. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94350. /**
  94351. * Set the rotation of the bone to a particular axis angle in local or world space
  94352. * @param axis The axis to rotate the bone on
  94353. * @param angle The angle that the bone should be rotated to
  94354. * @param space The space that the axis is in
  94355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94356. */
  94357. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94358. /**
  94359. * Set the euler rotation of the bone in local of world space
  94360. * @param rotation The euler rotation that the bone should be set to
  94361. * @param space The space that the rotation is in
  94362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94363. */
  94364. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94365. /**
  94366. * Set the quaternion rotation of the bone in local of world space
  94367. * @param quat The quaternion rotation that the bone should be set to
  94368. * @param space The space that the rotation is in
  94369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94370. */
  94371. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94372. /**
  94373. * Set the rotation matrix of the bone in local of world space
  94374. * @param rotMat The rotation matrix that the bone should be set to
  94375. * @param space The space that the rotation is in
  94376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94377. */
  94378. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94379. private _rotateWithMatrix;
  94380. private _getNegativeRotationToRef;
  94381. /**
  94382. * Get the position of the bone in local or world space
  94383. * @param space The space that the returned position is in
  94384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94385. * @returns The position of the bone
  94386. */
  94387. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94388. /**
  94389. * Copy the position of the bone to a vector3 in local or world space
  94390. * @param space The space that the returned position is in
  94391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94392. * @param result The vector3 to copy the position to
  94393. */
  94394. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94395. /**
  94396. * Get the absolute position of the bone (world space)
  94397. * @param mesh The mesh that this bone is attached to
  94398. * @returns The absolute position of the bone
  94399. */
  94400. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94401. /**
  94402. * Copy the absolute position of the bone (world space) to the result param
  94403. * @param mesh The mesh that this bone is attached to
  94404. * @param result The vector3 to copy the absolute position to
  94405. */
  94406. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94407. /**
  94408. * Compute the absolute transforms of this bone and its children
  94409. */
  94410. computeAbsoluteTransforms(): void;
  94411. /**
  94412. * Get the world direction from an axis that is in the local space of the bone
  94413. * @param localAxis The local direction that is used to compute the world direction
  94414. * @param mesh The mesh that this bone is attached to
  94415. * @returns The world direction
  94416. */
  94417. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94418. /**
  94419. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94420. * @param localAxis The local direction that is used to compute the world direction
  94421. * @param mesh The mesh that this bone is attached to
  94422. * @param result The vector3 that the world direction will be copied to
  94423. */
  94424. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94425. /**
  94426. * Get the euler rotation of the bone in local or world space
  94427. * @param space The space that the rotation should be in
  94428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94429. * @returns The euler rotation
  94430. */
  94431. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94432. /**
  94433. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94434. * @param space The space that the rotation should be in
  94435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94436. * @param result The vector3 that the rotation should be copied to
  94437. */
  94438. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94439. /**
  94440. * Get the quaternion rotation of the bone in either local or world space
  94441. * @param space The space that the rotation should be in
  94442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94443. * @returns The quaternion rotation
  94444. */
  94445. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94446. /**
  94447. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94448. * @param space The space that the rotation should be in
  94449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94450. * @param result The quaternion that the rotation should be copied to
  94451. */
  94452. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94453. /**
  94454. * Get the rotation matrix of the bone in local or world space
  94455. * @param space The space that the rotation should be in
  94456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94457. * @returns The rotation matrix
  94458. */
  94459. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94460. /**
  94461. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94462. * @param space The space that the rotation should be in
  94463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94464. * @param result The quaternion that the rotation should be copied to
  94465. */
  94466. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94467. /**
  94468. * Get the world position of a point that is in the local space of the bone
  94469. * @param position The local position
  94470. * @param mesh The mesh that this bone is attached to
  94471. * @returns The world position
  94472. */
  94473. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94474. /**
  94475. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94476. * @param position The local position
  94477. * @param mesh The mesh that this bone is attached to
  94478. * @param result The vector3 that the world position should be copied to
  94479. */
  94480. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94481. /**
  94482. * Get the local position of a point that is in world space
  94483. * @param position The world position
  94484. * @param mesh The mesh that this bone is attached to
  94485. * @returns The local position
  94486. */
  94487. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94488. /**
  94489. * Get the local position of a point that is in world space and copy it to the result param
  94490. * @param position The world position
  94491. * @param mesh The mesh that this bone is attached to
  94492. * @param result The vector3 that the local position should be copied to
  94493. */
  94494. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94495. }
  94496. }
  94497. declare module BABYLON {
  94498. /**
  94499. * Defines a runtime animation
  94500. */
  94501. export class RuntimeAnimation {
  94502. private _events;
  94503. /**
  94504. * The current frame of the runtime animation
  94505. */
  94506. private _currentFrame;
  94507. /**
  94508. * The animation used by the runtime animation
  94509. */
  94510. private _animation;
  94511. /**
  94512. * The target of the runtime animation
  94513. */
  94514. private _target;
  94515. /**
  94516. * The initiating animatable
  94517. */
  94518. private _host;
  94519. /**
  94520. * The original value of the runtime animation
  94521. */
  94522. private _originalValue;
  94523. /**
  94524. * The original blend value of the runtime animation
  94525. */
  94526. private _originalBlendValue;
  94527. /**
  94528. * The offsets cache of the runtime animation
  94529. */
  94530. private _offsetsCache;
  94531. /**
  94532. * The high limits cache of the runtime animation
  94533. */
  94534. private _highLimitsCache;
  94535. /**
  94536. * Specifies if the runtime animation has been stopped
  94537. */
  94538. private _stopped;
  94539. /**
  94540. * The blending factor of the runtime animation
  94541. */
  94542. private _blendingFactor;
  94543. /**
  94544. * The BabylonJS scene
  94545. */
  94546. private _scene;
  94547. /**
  94548. * The current value of the runtime animation
  94549. */
  94550. private _currentValue;
  94551. /** @hidden */
  94552. _animationState: _IAnimationState;
  94553. /**
  94554. * The active target of the runtime animation
  94555. */
  94556. private _activeTargets;
  94557. private _currentActiveTarget;
  94558. private _directTarget;
  94559. /**
  94560. * The target path of the runtime animation
  94561. */
  94562. private _targetPath;
  94563. /**
  94564. * The weight of the runtime animation
  94565. */
  94566. private _weight;
  94567. /**
  94568. * The ratio offset of the runtime animation
  94569. */
  94570. private _ratioOffset;
  94571. /**
  94572. * The previous delay of the runtime animation
  94573. */
  94574. private _previousDelay;
  94575. /**
  94576. * The previous ratio of the runtime animation
  94577. */
  94578. private _previousRatio;
  94579. private _enableBlending;
  94580. private _keys;
  94581. private _minFrame;
  94582. private _maxFrame;
  94583. private _minValue;
  94584. private _maxValue;
  94585. private _targetIsArray;
  94586. /**
  94587. * Gets the current frame of the runtime animation
  94588. */
  94589. get currentFrame(): number;
  94590. /**
  94591. * Gets the weight of the runtime animation
  94592. */
  94593. get weight(): number;
  94594. /**
  94595. * Gets the current value of the runtime animation
  94596. */
  94597. get currentValue(): any;
  94598. /**
  94599. * Gets the target path of the runtime animation
  94600. */
  94601. get targetPath(): string;
  94602. /**
  94603. * Gets the actual target of the runtime animation
  94604. */
  94605. get target(): any;
  94606. /**
  94607. * Gets the additive state of the runtime animation
  94608. */
  94609. get isAdditive(): boolean;
  94610. /** @hidden */
  94611. _onLoop: () => void;
  94612. /**
  94613. * Create a new RuntimeAnimation object
  94614. * @param target defines the target of the animation
  94615. * @param animation defines the source animation object
  94616. * @param scene defines the hosting scene
  94617. * @param host defines the initiating Animatable
  94618. */
  94619. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94620. private _preparePath;
  94621. /**
  94622. * Gets the animation from the runtime animation
  94623. */
  94624. get animation(): Animation;
  94625. /**
  94626. * Resets the runtime animation to the beginning
  94627. * @param restoreOriginal defines whether to restore the target property to the original value
  94628. */
  94629. reset(restoreOriginal?: boolean): void;
  94630. /**
  94631. * Specifies if the runtime animation is stopped
  94632. * @returns Boolean specifying if the runtime animation is stopped
  94633. */
  94634. isStopped(): boolean;
  94635. /**
  94636. * Disposes of the runtime animation
  94637. */
  94638. dispose(): void;
  94639. /**
  94640. * Apply the interpolated value to the target
  94641. * @param currentValue defines the value computed by the animation
  94642. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94643. */
  94644. setValue(currentValue: any, weight: number): void;
  94645. private _getOriginalValues;
  94646. private _setValue;
  94647. /**
  94648. * Gets the loop pmode of the runtime animation
  94649. * @returns Loop Mode
  94650. */
  94651. private _getCorrectLoopMode;
  94652. /**
  94653. * Move the current animation to a given frame
  94654. * @param frame defines the frame to move to
  94655. */
  94656. goToFrame(frame: number): void;
  94657. /**
  94658. * @hidden Internal use only
  94659. */
  94660. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94661. /**
  94662. * Execute the current animation
  94663. * @param delay defines the delay to add to the current frame
  94664. * @param from defines the lower bound of the animation range
  94665. * @param to defines the upper bound of the animation range
  94666. * @param loop defines if the current animation must loop
  94667. * @param speedRatio defines the current speed ratio
  94668. * @param weight defines the weight of the animation (default is -1 so no weight)
  94669. * @param onLoop optional callback called when animation loops
  94670. * @returns a boolean indicating if the animation is running
  94671. */
  94672. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94673. }
  94674. }
  94675. declare module BABYLON {
  94676. /**
  94677. * Class used to store an actual running animation
  94678. */
  94679. export class Animatable {
  94680. /** defines the target object */
  94681. target: any;
  94682. /** defines the starting frame number (default is 0) */
  94683. fromFrame: number;
  94684. /** defines the ending frame number (default is 100) */
  94685. toFrame: number;
  94686. /** defines if the animation must loop (default is false) */
  94687. loopAnimation: boolean;
  94688. /** defines a callback to call when animation ends if it is not looping */
  94689. onAnimationEnd?: (() => void) | null | undefined;
  94690. /** defines a callback to call when animation loops */
  94691. onAnimationLoop?: (() => void) | null | undefined;
  94692. /** defines whether the animation should be evaluated additively */
  94693. isAdditive: boolean;
  94694. private _localDelayOffset;
  94695. private _pausedDelay;
  94696. private _runtimeAnimations;
  94697. private _paused;
  94698. private _scene;
  94699. private _speedRatio;
  94700. private _weight;
  94701. private _syncRoot;
  94702. /**
  94703. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94704. * This will only apply for non looping animation (default is true)
  94705. */
  94706. disposeOnEnd: boolean;
  94707. /**
  94708. * Gets a boolean indicating if the animation has started
  94709. */
  94710. animationStarted: boolean;
  94711. /**
  94712. * Observer raised when the animation ends
  94713. */
  94714. onAnimationEndObservable: Observable<Animatable>;
  94715. /**
  94716. * Observer raised when the animation loops
  94717. */
  94718. onAnimationLoopObservable: Observable<Animatable>;
  94719. /**
  94720. * Gets the root Animatable used to synchronize and normalize animations
  94721. */
  94722. get syncRoot(): Nullable<Animatable>;
  94723. /**
  94724. * Gets the current frame of the first RuntimeAnimation
  94725. * Used to synchronize Animatables
  94726. */
  94727. get masterFrame(): number;
  94728. /**
  94729. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94730. */
  94731. get weight(): number;
  94732. set weight(value: number);
  94733. /**
  94734. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94735. */
  94736. get speedRatio(): number;
  94737. set speedRatio(value: number);
  94738. /**
  94739. * Creates a new Animatable
  94740. * @param scene defines the hosting scene
  94741. * @param target defines the target object
  94742. * @param fromFrame defines the starting frame number (default is 0)
  94743. * @param toFrame defines the ending frame number (default is 100)
  94744. * @param loopAnimation defines if the animation must loop (default is false)
  94745. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94746. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94747. * @param animations defines a group of animation to add to the new Animatable
  94748. * @param onAnimationLoop defines a callback to call when animation loops
  94749. * @param isAdditive defines whether the animation should be evaluated additively
  94750. */
  94751. constructor(scene: Scene,
  94752. /** defines the target object */
  94753. target: any,
  94754. /** defines the starting frame number (default is 0) */
  94755. fromFrame?: number,
  94756. /** defines the ending frame number (default is 100) */
  94757. toFrame?: number,
  94758. /** defines if the animation must loop (default is false) */
  94759. loopAnimation?: boolean, speedRatio?: number,
  94760. /** defines a callback to call when animation ends if it is not looping */
  94761. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94762. /** defines a callback to call when animation loops */
  94763. onAnimationLoop?: (() => void) | null | undefined,
  94764. /** defines whether the animation should be evaluated additively */
  94765. isAdditive?: boolean);
  94766. /**
  94767. * Synchronize and normalize current Animatable with a source Animatable
  94768. * This is useful when using animation weights and when animations are not of the same length
  94769. * @param root defines the root Animatable to synchronize with
  94770. * @returns the current Animatable
  94771. */
  94772. syncWith(root: Animatable): Animatable;
  94773. /**
  94774. * Gets the list of runtime animations
  94775. * @returns an array of RuntimeAnimation
  94776. */
  94777. getAnimations(): RuntimeAnimation[];
  94778. /**
  94779. * Adds more animations to the current animatable
  94780. * @param target defines the target of the animations
  94781. * @param animations defines the new animations to add
  94782. */
  94783. appendAnimations(target: any, animations: Animation[]): void;
  94784. /**
  94785. * Gets the source animation for a specific property
  94786. * @param property defines the propertyu to look for
  94787. * @returns null or the source animation for the given property
  94788. */
  94789. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94790. /**
  94791. * Gets the runtime animation for a specific property
  94792. * @param property defines the propertyu to look for
  94793. * @returns null or the runtime animation for the given property
  94794. */
  94795. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94796. /**
  94797. * Resets the animatable to its original state
  94798. */
  94799. reset(): void;
  94800. /**
  94801. * Allows the animatable to blend with current running animations
  94802. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94803. * @param blendingSpeed defines the blending speed to use
  94804. */
  94805. enableBlending(blendingSpeed: number): void;
  94806. /**
  94807. * Disable animation blending
  94808. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94809. */
  94810. disableBlending(): void;
  94811. /**
  94812. * Jump directly to a given frame
  94813. * @param frame defines the frame to jump to
  94814. */
  94815. goToFrame(frame: number): void;
  94816. /**
  94817. * Pause the animation
  94818. */
  94819. pause(): void;
  94820. /**
  94821. * Restart the animation
  94822. */
  94823. restart(): void;
  94824. private _raiseOnAnimationEnd;
  94825. /**
  94826. * Stop and delete the current animation
  94827. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94828. * @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)
  94829. */
  94830. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94831. /**
  94832. * Wait asynchronously for the animation to end
  94833. * @returns a promise which will be fullfilled when the animation ends
  94834. */
  94835. waitAsync(): Promise<Animatable>;
  94836. /** @hidden */
  94837. _animate(delay: number): boolean;
  94838. }
  94839. interface Scene {
  94840. /** @hidden */
  94841. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94842. /** @hidden */
  94843. _processLateAnimationBindingsForMatrices(holder: {
  94844. totalWeight: number;
  94845. totalAdditiveWeight: number;
  94846. animations: RuntimeAnimation[];
  94847. additiveAnimations: RuntimeAnimation[];
  94848. originalValue: Matrix;
  94849. }): any;
  94850. /** @hidden */
  94851. _processLateAnimationBindingsForQuaternions(holder: {
  94852. totalWeight: number;
  94853. totalAdditiveWeight: number;
  94854. animations: RuntimeAnimation[];
  94855. additiveAnimations: RuntimeAnimation[];
  94856. originalValue: Quaternion;
  94857. }, refQuaternion: Quaternion): Quaternion;
  94858. /** @hidden */
  94859. _processLateAnimationBindings(): void;
  94860. /**
  94861. * Will start the animation sequence of a given target
  94862. * @param target defines the target
  94863. * @param from defines from which frame should animation start
  94864. * @param to defines until which frame should animation run.
  94865. * @param weight defines the weight to apply to the animation (1.0 by default)
  94866. * @param loop defines if the animation loops
  94867. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94868. * @param onAnimationEnd defines the function to be executed when the animation ends
  94869. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94870. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94871. * @param onAnimationLoop defines the callback to call when an animation loops
  94872. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94873. * @returns the animatable object created for this animation
  94874. */
  94875. 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;
  94876. /**
  94877. * Will start the animation sequence of a given target
  94878. * @param target defines the target
  94879. * @param from defines from which frame should animation start
  94880. * @param to defines until which frame should animation run.
  94881. * @param loop defines if the animation loops
  94882. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94883. * @param onAnimationEnd defines the function to be executed when the animation ends
  94884. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94885. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94886. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94887. * @param onAnimationLoop defines the callback to call when an animation loops
  94888. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94889. * @returns the animatable object created for this animation
  94890. */
  94891. 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;
  94892. /**
  94893. * Will start the animation sequence of a given target and its hierarchy
  94894. * @param target defines the target
  94895. * @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.
  94896. * @param from defines from which frame should animation start
  94897. * @param to defines until which frame should animation run.
  94898. * @param loop defines if the animation loops
  94899. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94900. * @param onAnimationEnd defines the function to be executed when the animation ends
  94901. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94902. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94903. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94904. * @param onAnimationLoop defines the callback to call when an animation loops
  94905. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94906. * @returns the list of created animatables
  94907. */
  94908. 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[];
  94909. /**
  94910. * Begin a new animation on a given node
  94911. * @param target defines the target where the animation will take place
  94912. * @param animations defines the list of animations to start
  94913. * @param from defines the initial value
  94914. * @param to defines the final value
  94915. * @param loop defines if you want animation to loop (off by default)
  94916. * @param speedRatio defines the speed ratio to apply to all animations
  94917. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94918. * @param onAnimationLoop defines the callback to call when an animation loops
  94919. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94920. * @returns the list of created animatables
  94921. */
  94922. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94923. /**
  94924. * Begin a new animation on a given node and its hierarchy
  94925. * @param target defines the root node where the animation will take place
  94926. * @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.
  94927. * @param animations defines the list of animations to start
  94928. * @param from defines the initial value
  94929. * @param to defines the final value
  94930. * @param loop defines if you want animation to loop (off by default)
  94931. * @param speedRatio defines the speed ratio to apply to all animations
  94932. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94933. * @param onAnimationLoop defines the callback to call when an animation loops
  94934. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94935. * @returns the list of animatables created for all nodes
  94936. */
  94937. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94938. /**
  94939. * Gets the animatable associated with a specific target
  94940. * @param target defines the target of the animatable
  94941. * @returns the required animatable if found
  94942. */
  94943. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94944. /**
  94945. * Gets all animatables associated with a given target
  94946. * @param target defines the target to look animatables for
  94947. * @returns an array of Animatables
  94948. */
  94949. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94950. /**
  94951. * Stops and removes all animations that have been applied to the scene
  94952. */
  94953. stopAllAnimations(): void;
  94954. /**
  94955. * Gets the current delta time used by animation engine
  94956. */
  94957. deltaTime: number;
  94958. }
  94959. interface Bone {
  94960. /**
  94961. * Copy an animation range from another bone
  94962. * @param source defines the source bone
  94963. * @param rangeName defines the range name to copy
  94964. * @param frameOffset defines the frame offset
  94965. * @param rescaleAsRequired defines if rescaling must be applied if required
  94966. * @param skelDimensionsRatio defines the scaling ratio
  94967. * @returns true if operation was successful
  94968. */
  94969. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94970. }
  94971. }
  94972. declare module BABYLON {
  94973. /**
  94974. * Class used to handle skinning animations
  94975. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94976. */
  94977. export class Skeleton implements IAnimatable {
  94978. /** defines the skeleton name */
  94979. name: string;
  94980. /** defines the skeleton Id */
  94981. id: string;
  94982. /**
  94983. * Defines the list of child bones
  94984. */
  94985. bones: Bone[];
  94986. /**
  94987. * Defines an estimate of the dimension of the skeleton at rest
  94988. */
  94989. dimensionsAtRest: Vector3;
  94990. /**
  94991. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94992. */
  94993. needInitialSkinMatrix: boolean;
  94994. /**
  94995. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94996. */
  94997. overrideMesh: Nullable<AbstractMesh>;
  94998. /**
  94999. * Gets the list of animations attached to this skeleton
  95000. */
  95001. animations: Array<Animation>;
  95002. private _scene;
  95003. private _isDirty;
  95004. private _transformMatrices;
  95005. private _transformMatrixTexture;
  95006. private _meshesWithPoseMatrix;
  95007. private _animatables;
  95008. private _identity;
  95009. private _synchronizedWithMesh;
  95010. private _ranges;
  95011. private _lastAbsoluteTransformsUpdateId;
  95012. private _canUseTextureForBones;
  95013. private _uniqueId;
  95014. /** @hidden */
  95015. _numBonesWithLinkedTransformNode: number;
  95016. /** @hidden */
  95017. _hasWaitingData: Nullable<boolean>;
  95018. /**
  95019. * Specifies if the skeleton should be serialized
  95020. */
  95021. doNotSerialize: boolean;
  95022. private _useTextureToStoreBoneMatrices;
  95023. /**
  95024. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95025. * Please note that this option is not available if the hardware does not support it
  95026. */
  95027. get useTextureToStoreBoneMatrices(): boolean;
  95028. set useTextureToStoreBoneMatrices(value: boolean);
  95029. private _animationPropertiesOverride;
  95030. /**
  95031. * Gets or sets the animation properties override
  95032. */
  95033. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95034. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95035. /**
  95036. * List of inspectable custom properties (used by the Inspector)
  95037. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95038. */
  95039. inspectableCustomProperties: IInspectable[];
  95040. /**
  95041. * An observable triggered before computing the skeleton's matrices
  95042. */
  95043. onBeforeComputeObservable: Observable<Skeleton>;
  95044. /**
  95045. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95046. */
  95047. get isUsingTextureForMatrices(): boolean;
  95048. /**
  95049. * Gets the unique ID of this skeleton
  95050. */
  95051. get uniqueId(): number;
  95052. /**
  95053. * Creates a new skeleton
  95054. * @param name defines the skeleton name
  95055. * @param id defines the skeleton Id
  95056. * @param scene defines the hosting scene
  95057. */
  95058. constructor(
  95059. /** defines the skeleton name */
  95060. name: string,
  95061. /** defines the skeleton Id */
  95062. id: string, scene: Scene);
  95063. /**
  95064. * Gets the current object class name.
  95065. * @return the class name
  95066. */
  95067. getClassName(): string;
  95068. /**
  95069. * Returns an array containing the root bones
  95070. * @returns an array containing the root bones
  95071. */
  95072. getChildren(): Array<Bone>;
  95073. /**
  95074. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95075. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95076. * @returns a Float32Array containing matrices data
  95077. */
  95078. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95079. /**
  95080. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95081. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95082. * @returns a raw texture containing the data
  95083. */
  95084. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95085. /**
  95086. * Gets the current hosting scene
  95087. * @returns a scene object
  95088. */
  95089. getScene(): Scene;
  95090. /**
  95091. * Gets a string representing the current skeleton data
  95092. * @param fullDetails defines a boolean indicating if we want a verbose version
  95093. * @returns a string representing the current skeleton data
  95094. */
  95095. toString(fullDetails?: boolean): string;
  95096. /**
  95097. * Get bone's index searching by name
  95098. * @param name defines bone's name to search for
  95099. * @return the indice of the bone. Returns -1 if not found
  95100. */
  95101. getBoneIndexByName(name: string): number;
  95102. /**
  95103. * Creater a new animation range
  95104. * @param name defines the name of the range
  95105. * @param from defines the start key
  95106. * @param to defines the end key
  95107. */
  95108. createAnimationRange(name: string, from: number, to: number): void;
  95109. /**
  95110. * Delete a specific animation range
  95111. * @param name defines the name of the range
  95112. * @param deleteFrames defines if frames must be removed as well
  95113. */
  95114. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95115. /**
  95116. * Gets a specific animation range
  95117. * @param name defines the name of the range to look for
  95118. * @returns the requested animation range or null if not found
  95119. */
  95120. getAnimationRange(name: string): Nullable<AnimationRange>;
  95121. /**
  95122. * Gets the list of all animation ranges defined on this skeleton
  95123. * @returns an array
  95124. */
  95125. getAnimationRanges(): Nullable<AnimationRange>[];
  95126. /**
  95127. * Copy animation range from a source skeleton.
  95128. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95129. * @param source defines the source skeleton
  95130. * @param name defines the name of the range to copy
  95131. * @param rescaleAsRequired defines if rescaling must be applied if required
  95132. * @returns true if operation was successful
  95133. */
  95134. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95135. /**
  95136. * Forces the skeleton to go to rest pose
  95137. */
  95138. returnToRest(): void;
  95139. private _getHighestAnimationFrame;
  95140. /**
  95141. * Begin a specific animation range
  95142. * @param name defines the name of the range to start
  95143. * @param loop defines if looping must be turned on (false by default)
  95144. * @param speedRatio defines the speed ratio to apply (1 by default)
  95145. * @param onAnimationEnd defines a callback which will be called when animation will end
  95146. * @returns a new animatable
  95147. */
  95148. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95149. /**
  95150. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95151. * @param skeleton defines the Skeleton containing the animation range to convert
  95152. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95153. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95154. * @returns the original skeleton
  95155. */
  95156. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95157. /** @hidden */
  95158. _markAsDirty(): void;
  95159. /** @hidden */
  95160. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95161. /** @hidden */
  95162. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95163. private _computeTransformMatrices;
  95164. /**
  95165. * Build all resources required to render a skeleton
  95166. */
  95167. prepare(): void;
  95168. /**
  95169. * Gets the list of animatables currently running for this skeleton
  95170. * @returns an array of animatables
  95171. */
  95172. getAnimatables(): IAnimatable[];
  95173. /**
  95174. * Clone the current skeleton
  95175. * @param name defines the name of the new skeleton
  95176. * @param id defines the id of the new skeleton
  95177. * @returns the new skeleton
  95178. */
  95179. clone(name: string, id?: string): Skeleton;
  95180. /**
  95181. * Enable animation blending for this skeleton
  95182. * @param blendingSpeed defines the blending speed to apply
  95183. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95184. */
  95185. enableBlending(blendingSpeed?: number): void;
  95186. /**
  95187. * Releases all resources associated with the current skeleton
  95188. */
  95189. dispose(): void;
  95190. /**
  95191. * Serialize the skeleton in a JSON object
  95192. * @returns a JSON object
  95193. */
  95194. serialize(): any;
  95195. /**
  95196. * Creates a new skeleton from serialized data
  95197. * @param parsedSkeleton defines the serialized data
  95198. * @param scene defines the hosting scene
  95199. * @returns a new skeleton
  95200. */
  95201. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95202. /**
  95203. * Compute all node absolute transforms
  95204. * @param forceUpdate defines if computation must be done even if cache is up to date
  95205. */
  95206. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95207. /**
  95208. * Gets the root pose matrix
  95209. * @returns a matrix
  95210. */
  95211. getPoseMatrix(): Nullable<Matrix>;
  95212. /**
  95213. * Sorts bones per internal index
  95214. */
  95215. sortBones(): void;
  95216. private _sortBones;
  95217. }
  95218. }
  95219. declare module BABYLON {
  95220. /**
  95221. * Creates an instance based on a source mesh.
  95222. */
  95223. export class InstancedMesh extends AbstractMesh {
  95224. private _sourceMesh;
  95225. private _currentLOD;
  95226. /** @hidden */
  95227. _indexInSourceMeshInstanceArray: number;
  95228. constructor(name: string, source: Mesh);
  95229. /**
  95230. * Returns the string "InstancedMesh".
  95231. */
  95232. getClassName(): string;
  95233. /** Gets the list of lights affecting that mesh */
  95234. get lightSources(): Light[];
  95235. _resyncLightSources(): void;
  95236. _resyncLightSource(light: Light): void;
  95237. _removeLightSource(light: Light, dispose: boolean): void;
  95238. /**
  95239. * If the source mesh receives shadows
  95240. */
  95241. get receiveShadows(): boolean;
  95242. /**
  95243. * The material of the source mesh
  95244. */
  95245. get material(): Nullable<Material>;
  95246. /**
  95247. * Visibility of the source mesh
  95248. */
  95249. get visibility(): number;
  95250. /**
  95251. * Skeleton of the source mesh
  95252. */
  95253. get skeleton(): Nullable<Skeleton>;
  95254. /**
  95255. * Rendering ground id of the source mesh
  95256. */
  95257. get renderingGroupId(): number;
  95258. set renderingGroupId(value: number);
  95259. /**
  95260. * Returns the total number of vertices (integer).
  95261. */
  95262. getTotalVertices(): number;
  95263. /**
  95264. * Returns a positive integer : the total number of indices in this mesh geometry.
  95265. * @returns the numner of indices or zero if the mesh has no geometry.
  95266. */
  95267. getTotalIndices(): number;
  95268. /**
  95269. * The source mesh of the instance
  95270. */
  95271. get sourceMesh(): Mesh;
  95272. /**
  95273. * Creates a new InstancedMesh object from the mesh model.
  95274. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95275. * @param name defines the name of the new instance
  95276. * @returns a new InstancedMesh
  95277. */
  95278. createInstance(name: string): InstancedMesh;
  95279. /**
  95280. * Is this node ready to be used/rendered
  95281. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95282. * @return {boolean} is it ready
  95283. */
  95284. isReady(completeCheck?: boolean): boolean;
  95285. /**
  95286. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95287. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95288. * @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.
  95289. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95290. */
  95291. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95292. /**
  95293. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95294. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95295. * The `data` are either a numeric array either a Float32Array.
  95296. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95297. * 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).
  95298. * Note that a new underlying VertexBuffer object is created each call.
  95299. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95300. *
  95301. * Possible `kind` values :
  95302. * - VertexBuffer.PositionKind
  95303. * - VertexBuffer.UVKind
  95304. * - VertexBuffer.UV2Kind
  95305. * - VertexBuffer.UV3Kind
  95306. * - VertexBuffer.UV4Kind
  95307. * - VertexBuffer.UV5Kind
  95308. * - VertexBuffer.UV6Kind
  95309. * - VertexBuffer.ColorKind
  95310. * - VertexBuffer.MatricesIndicesKind
  95311. * - VertexBuffer.MatricesIndicesExtraKind
  95312. * - VertexBuffer.MatricesWeightsKind
  95313. * - VertexBuffer.MatricesWeightsExtraKind
  95314. *
  95315. * Returns the Mesh.
  95316. */
  95317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95318. /**
  95319. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95320. * If the mesh has no geometry, it is simply returned as it is.
  95321. * The `data` are either a numeric array either a Float32Array.
  95322. * No new underlying VertexBuffer object is created.
  95323. * 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.
  95324. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95325. *
  95326. * Possible `kind` values :
  95327. * - VertexBuffer.PositionKind
  95328. * - VertexBuffer.UVKind
  95329. * - VertexBuffer.UV2Kind
  95330. * - VertexBuffer.UV3Kind
  95331. * - VertexBuffer.UV4Kind
  95332. * - VertexBuffer.UV5Kind
  95333. * - VertexBuffer.UV6Kind
  95334. * - VertexBuffer.ColorKind
  95335. * - VertexBuffer.MatricesIndicesKind
  95336. * - VertexBuffer.MatricesIndicesExtraKind
  95337. * - VertexBuffer.MatricesWeightsKind
  95338. * - VertexBuffer.MatricesWeightsExtraKind
  95339. *
  95340. * Returns the Mesh.
  95341. */
  95342. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95343. /**
  95344. * Sets the mesh indices.
  95345. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95346. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95347. * This method creates a new index buffer each call.
  95348. * Returns the Mesh.
  95349. */
  95350. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95351. /**
  95352. * Boolean : True if the mesh owns the requested kind of data.
  95353. */
  95354. isVerticesDataPresent(kind: string): boolean;
  95355. /**
  95356. * Returns an array of indices (IndicesArray).
  95357. */
  95358. getIndices(): Nullable<IndicesArray>;
  95359. get _positions(): Nullable<Vector3[]>;
  95360. /**
  95361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95362. * This means the mesh underlying bounding box and sphere are recomputed.
  95363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95364. * @returns the current mesh
  95365. */
  95366. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95367. /** @hidden */
  95368. _preActivate(): InstancedMesh;
  95369. /** @hidden */
  95370. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95371. /** @hidden */
  95372. _postActivate(): void;
  95373. getWorldMatrix(): Matrix;
  95374. get isAnInstance(): boolean;
  95375. /**
  95376. * Returns the current associated LOD AbstractMesh.
  95377. */
  95378. getLOD(camera: Camera): AbstractMesh;
  95379. /** @hidden */
  95380. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95381. /** @hidden */
  95382. _syncSubMeshes(): InstancedMesh;
  95383. /** @hidden */
  95384. _generatePointsArray(): boolean;
  95385. /** @hidden */
  95386. _updateBoundingInfo(): AbstractMesh;
  95387. /**
  95388. * Creates a new InstancedMesh from the current mesh.
  95389. * - name (string) : the cloned mesh name
  95390. * - newParent (optional Node) : the optional Node to parent the clone to.
  95391. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95392. *
  95393. * Returns the clone.
  95394. */
  95395. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95396. /**
  95397. * Disposes the InstancedMesh.
  95398. * Returns nothing.
  95399. */
  95400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95401. }
  95402. interface Mesh {
  95403. /**
  95404. * Register a custom buffer that will be instanced
  95405. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95406. * @param kind defines the buffer kind
  95407. * @param stride defines the stride in floats
  95408. */
  95409. registerInstancedBuffer(kind: string, stride: number): void;
  95410. /**
  95411. * true to use the edge renderer for all instances of this mesh
  95412. */
  95413. edgesShareWithInstances: boolean;
  95414. /** @hidden */
  95415. _userInstancedBuffersStorage: {
  95416. data: {
  95417. [key: string]: Float32Array;
  95418. };
  95419. sizes: {
  95420. [key: string]: number;
  95421. };
  95422. vertexBuffers: {
  95423. [key: string]: Nullable<VertexBuffer>;
  95424. };
  95425. strides: {
  95426. [key: string]: number;
  95427. };
  95428. };
  95429. }
  95430. interface AbstractMesh {
  95431. /**
  95432. * Object used to store instanced buffers defined by user
  95433. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95434. */
  95435. instancedBuffers: {
  95436. [key: string]: any;
  95437. };
  95438. }
  95439. }
  95440. declare module BABYLON {
  95441. /**
  95442. * Defines the options associated with the creation of a shader material.
  95443. */
  95444. export interface IShaderMaterialOptions {
  95445. /**
  95446. * Does the material work in alpha blend mode
  95447. */
  95448. needAlphaBlending: boolean;
  95449. /**
  95450. * Does the material work in alpha test mode
  95451. */
  95452. needAlphaTesting: boolean;
  95453. /**
  95454. * The list of attribute names used in the shader
  95455. */
  95456. attributes: string[];
  95457. /**
  95458. * The list of unifrom names used in the shader
  95459. */
  95460. uniforms: string[];
  95461. /**
  95462. * The list of UBO names used in the shader
  95463. */
  95464. uniformBuffers: string[];
  95465. /**
  95466. * The list of sampler names used in the shader
  95467. */
  95468. samplers: string[];
  95469. /**
  95470. * The list of defines used in the shader
  95471. */
  95472. defines: string[];
  95473. }
  95474. /**
  95475. * 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.
  95476. *
  95477. * This returned material effects how the mesh will look based on the code in the shaders.
  95478. *
  95479. * @see https://doc.babylonjs.com/how_to/shader_material
  95480. */
  95481. export class ShaderMaterial extends Material {
  95482. private _shaderPath;
  95483. private _options;
  95484. private _textures;
  95485. private _textureArrays;
  95486. private _floats;
  95487. private _ints;
  95488. private _floatsArrays;
  95489. private _colors3;
  95490. private _colors3Arrays;
  95491. private _colors4;
  95492. private _colors4Arrays;
  95493. private _vectors2;
  95494. private _vectors3;
  95495. private _vectors4;
  95496. private _matrices;
  95497. private _matrixArrays;
  95498. private _matrices3x3;
  95499. private _matrices2x2;
  95500. private _vectors2Arrays;
  95501. private _vectors3Arrays;
  95502. private _vectors4Arrays;
  95503. private _cachedWorldViewMatrix;
  95504. private _cachedWorldViewProjectionMatrix;
  95505. private _renderId;
  95506. private _multiview;
  95507. private _cachedDefines;
  95508. /** Define the Url to load snippets */
  95509. static SnippetUrl: string;
  95510. /** Snippet ID if the material was created from the snippet server */
  95511. snippetId: string;
  95512. /**
  95513. * Instantiate a new shader material.
  95514. * 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.
  95515. * This returned material effects how the mesh will look based on the code in the shaders.
  95516. * @see https://doc.babylonjs.com/how_to/shader_material
  95517. * @param name Define the name of the material in the scene
  95518. * @param scene Define the scene the material belongs to
  95519. * @param shaderPath Defines the route to the shader code in one of three ways:
  95520. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95521. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95522. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95523. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95524. * @param options Define the options used to create the shader
  95525. */
  95526. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95527. /**
  95528. * Gets the shader path used to define the shader code
  95529. * It can be modified to trigger a new compilation
  95530. */
  95531. get shaderPath(): any;
  95532. /**
  95533. * Sets the shader path used to define the shader code
  95534. * It can be modified to trigger a new compilation
  95535. */
  95536. set shaderPath(shaderPath: any);
  95537. /**
  95538. * Gets the options used to compile the shader.
  95539. * They can be modified to trigger a new compilation
  95540. */
  95541. get options(): IShaderMaterialOptions;
  95542. /**
  95543. * Gets the current class name of the material e.g. "ShaderMaterial"
  95544. * Mainly use in serialization.
  95545. * @returns the class name
  95546. */
  95547. getClassName(): string;
  95548. /**
  95549. * Specifies if the material will require alpha blending
  95550. * @returns a boolean specifying if alpha blending is needed
  95551. */
  95552. needAlphaBlending(): boolean;
  95553. /**
  95554. * Specifies if this material should be rendered in alpha test mode
  95555. * @returns a boolean specifying if an alpha test is needed.
  95556. */
  95557. needAlphaTesting(): boolean;
  95558. private _checkUniform;
  95559. /**
  95560. * Set a texture in the shader.
  95561. * @param name Define the name of the uniform samplers as defined in the shader
  95562. * @param texture Define the texture to bind to this sampler
  95563. * @return the material itself allowing "fluent" like uniform updates
  95564. */
  95565. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95566. /**
  95567. * Set a texture array in the shader.
  95568. * @param name Define the name of the uniform sampler array as defined in the shader
  95569. * @param textures Define the list of textures to bind to this sampler
  95570. * @return the material itself allowing "fluent" like uniform updates
  95571. */
  95572. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95573. /**
  95574. * Set a float in the shader.
  95575. * @param name Define the name of the uniform as defined in the shader
  95576. * @param value Define the value to give to the uniform
  95577. * @return the material itself allowing "fluent" like uniform updates
  95578. */
  95579. setFloat(name: string, value: number): ShaderMaterial;
  95580. /**
  95581. * Set a int in the shader.
  95582. * @param name Define the name of the uniform as defined in the shader
  95583. * @param value Define the value to give to the uniform
  95584. * @return the material itself allowing "fluent" like uniform updates
  95585. */
  95586. setInt(name: string, value: number): ShaderMaterial;
  95587. /**
  95588. * Set an array of floats in the shader.
  95589. * @param name Define the name of the uniform as defined in the shader
  95590. * @param value Define the value to give to the uniform
  95591. * @return the material itself allowing "fluent" like uniform updates
  95592. */
  95593. setFloats(name: string, value: number[]): ShaderMaterial;
  95594. /**
  95595. * Set a vec3 in the shader from a Color3.
  95596. * @param name Define the name of the uniform as defined in the shader
  95597. * @param value Define the value to give to the uniform
  95598. * @return the material itself allowing "fluent" like uniform updates
  95599. */
  95600. setColor3(name: string, value: Color3): ShaderMaterial;
  95601. /**
  95602. * Set a vec3 array in the shader from a Color3 array.
  95603. * @param name Define the name of the uniform as defined in the shader
  95604. * @param value Define the value to give to the uniform
  95605. * @return the material itself allowing "fluent" like uniform updates
  95606. */
  95607. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95608. /**
  95609. * Set a vec4 in the shader from a Color4.
  95610. * @param name Define the name of the uniform as defined in the shader
  95611. * @param value Define the value to give to the uniform
  95612. * @return the material itself allowing "fluent" like uniform updates
  95613. */
  95614. setColor4(name: string, value: Color4): ShaderMaterial;
  95615. /**
  95616. * Set a vec4 array in the shader from a Color4 array.
  95617. * @param name Define the name of the uniform as defined in the shader
  95618. * @param value Define the value to give to the uniform
  95619. * @return the material itself allowing "fluent" like uniform updates
  95620. */
  95621. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95622. /**
  95623. * Set a vec2 in the shader from a Vector2.
  95624. * @param name Define the name of the uniform as defined in the shader
  95625. * @param value Define the value to give to the uniform
  95626. * @return the material itself allowing "fluent" like uniform updates
  95627. */
  95628. setVector2(name: string, value: Vector2): ShaderMaterial;
  95629. /**
  95630. * Set a vec3 in the shader from a Vector3.
  95631. * @param name Define the name of the uniform as defined in the shader
  95632. * @param value Define the value to give to the uniform
  95633. * @return the material itself allowing "fluent" like uniform updates
  95634. */
  95635. setVector3(name: string, value: Vector3): ShaderMaterial;
  95636. /**
  95637. * Set a vec4 in the shader from a Vector4.
  95638. * @param name Define the name of the uniform as defined in the shader
  95639. * @param value Define the value to give to the uniform
  95640. * @return the material itself allowing "fluent" like uniform updates
  95641. */
  95642. setVector4(name: string, value: Vector4): ShaderMaterial;
  95643. /**
  95644. * Set a mat4 in the shader from a Matrix.
  95645. * @param name Define the name of the uniform as defined in the shader
  95646. * @param value Define the value to give to the uniform
  95647. * @return the material itself allowing "fluent" like uniform updates
  95648. */
  95649. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95650. /**
  95651. * Set a float32Array in the shader from a matrix array.
  95652. * @param name Define the name of the uniform as defined in the shader
  95653. * @param value Define the value to give to the uniform
  95654. * @return the material itself allowing "fluent" like uniform updates
  95655. */
  95656. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95657. /**
  95658. * Set a mat3 in the shader from a Float32Array.
  95659. * @param name Define the name of the uniform as defined in the shader
  95660. * @param value Define the value to give to the uniform
  95661. * @return the material itself allowing "fluent" like uniform updates
  95662. */
  95663. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95664. /**
  95665. * Set a mat2 in the shader from a Float32Array.
  95666. * @param name Define the name of the uniform as defined in the shader
  95667. * @param value Define the value to give to the uniform
  95668. * @return the material itself allowing "fluent" like uniform updates
  95669. */
  95670. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95671. /**
  95672. * Set a vec2 array in the shader from a number array.
  95673. * @param name Define the name of the uniform as defined in the shader
  95674. * @param value Define the value to give to the uniform
  95675. * @return the material itself allowing "fluent" like uniform updates
  95676. */
  95677. setArray2(name: string, value: number[]): ShaderMaterial;
  95678. /**
  95679. * Set a vec3 array in the shader from a number array.
  95680. * @param name Define the name of the uniform as defined in the shader
  95681. * @param value Define the value to give to the uniform
  95682. * @return the material itself allowing "fluent" like uniform updates
  95683. */
  95684. setArray3(name: string, value: number[]): ShaderMaterial;
  95685. /**
  95686. * Set a vec4 array in the shader from a number array.
  95687. * @param name Define the name of the uniform as defined in the shader
  95688. * @param value Define the value to give to the uniform
  95689. * @return the material itself allowing "fluent" like uniform updates
  95690. */
  95691. setArray4(name: string, value: number[]): ShaderMaterial;
  95692. private _checkCache;
  95693. /**
  95694. * Specifies that the submesh is ready to be used
  95695. * @param mesh defines the mesh to check
  95696. * @param subMesh defines which submesh to check
  95697. * @param useInstances specifies that instances should be used
  95698. * @returns a boolean indicating that the submesh is ready or not
  95699. */
  95700. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95701. /**
  95702. * Checks if the material is ready to render the requested mesh
  95703. * @param mesh Define the mesh to render
  95704. * @param useInstances Define whether or not the material is used with instances
  95705. * @returns true if ready, otherwise false
  95706. */
  95707. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95708. /**
  95709. * Binds the world matrix to the material
  95710. * @param world defines the world transformation matrix
  95711. * @param effectOverride - If provided, use this effect instead of internal effect
  95712. */
  95713. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95714. /**
  95715. * Binds the submesh to this material by preparing the effect and shader to draw
  95716. * @param world defines the world transformation matrix
  95717. * @param mesh defines the mesh containing the submesh
  95718. * @param subMesh defines the submesh to bind the material to
  95719. */
  95720. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95721. /**
  95722. * Binds the material to the mesh
  95723. * @param world defines the world transformation matrix
  95724. * @param mesh defines the mesh to bind the material to
  95725. * @param effectOverride - If provided, use this effect instead of internal effect
  95726. */
  95727. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95728. protected _afterBind(mesh?: Mesh): void;
  95729. /**
  95730. * Gets the active textures from the material
  95731. * @returns an array of textures
  95732. */
  95733. getActiveTextures(): BaseTexture[];
  95734. /**
  95735. * Specifies if the material uses a texture
  95736. * @param texture defines the texture to check against the material
  95737. * @returns a boolean specifying if the material uses the texture
  95738. */
  95739. hasTexture(texture: BaseTexture): boolean;
  95740. /**
  95741. * Makes a duplicate of the material, and gives it a new name
  95742. * @param name defines the new name for the duplicated material
  95743. * @returns the cloned material
  95744. */
  95745. clone(name: string): ShaderMaterial;
  95746. /**
  95747. * Disposes the material
  95748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95750. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95751. */
  95752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95753. /**
  95754. * Serializes this material in a JSON representation
  95755. * @returns the serialized material object
  95756. */
  95757. serialize(): any;
  95758. /**
  95759. * Creates a shader material from parsed shader material data
  95760. * @param source defines the JSON represnetation of the material
  95761. * @param scene defines the hosting scene
  95762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95763. * @returns a new material
  95764. */
  95765. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95766. /**
  95767. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95768. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95769. * @param url defines the url to load from
  95770. * @param scene defines the hosting scene
  95771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95772. * @returns a promise that will resolve to the new ShaderMaterial
  95773. */
  95774. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95775. /**
  95776. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95777. * @param snippetId defines the snippet to load
  95778. * @param scene defines the hosting scene
  95779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95780. * @returns a promise that will resolve to the new ShaderMaterial
  95781. */
  95782. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95783. }
  95784. }
  95785. declare module BABYLON {
  95786. /** @hidden */
  95787. export var colorPixelShader: {
  95788. name: string;
  95789. shader: string;
  95790. };
  95791. }
  95792. declare module BABYLON {
  95793. /** @hidden */
  95794. export var colorVertexShader: {
  95795. name: string;
  95796. shader: string;
  95797. };
  95798. }
  95799. declare module BABYLON {
  95800. /**
  95801. * Line mesh
  95802. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95803. */
  95804. export class LinesMesh extends Mesh {
  95805. /**
  95806. * If vertex color should be applied to the mesh
  95807. */
  95808. readonly useVertexColor?: boolean | undefined;
  95809. /**
  95810. * If vertex alpha should be applied to the mesh
  95811. */
  95812. readonly useVertexAlpha?: boolean | undefined;
  95813. /**
  95814. * Color of the line (Default: White)
  95815. */
  95816. color: Color3;
  95817. /**
  95818. * Alpha of the line (Default: 1)
  95819. */
  95820. alpha: number;
  95821. /**
  95822. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95823. * This margin is expressed in world space coordinates, so its value may vary.
  95824. * Default value is 0.1
  95825. */
  95826. intersectionThreshold: number;
  95827. private _colorShader;
  95828. private color4;
  95829. /**
  95830. * Creates a new LinesMesh
  95831. * @param name defines the name
  95832. * @param scene defines the hosting scene
  95833. * @param parent defines the parent mesh if any
  95834. * @param source defines the optional source LinesMesh used to clone data from
  95835. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95836. * When false, achieved by calling a clone(), also passing False.
  95837. * This will make creation of children, recursive.
  95838. * @param useVertexColor defines if this LinesMesh supports vertex color
  95839. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95840. */
  95841. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95842. /**
  95843. * If vertex color should be applied to the mesh
  95844. */
  95845. useVertexColor?: boolean | undefined,
  95846. /**
  95847. * If vertex alpha should be applied to the mesh
  95848. */
  95849. useVertexAlpha?: boolean | undefined);
  95850. private _addClipPlaneDefine;
  95851. private _removeClipPlaneDefine;
  95852. isReady(): boolean;
  95853. /**
  95854. * Returns the string "LineMesh"
  95855. */
  95856. getClassName(): string;
  95857. /**
  95858. * @hidden
  95859. */
  95860. get material(): Material;
  95861. /**
  95862. * @hidden
  95863. */
  95864. set material(value: Material);
  95865. /**
  95866. * @hidden
  95867. */
  95868. get checkCollisions(): boolean;
  95869. /** @hidden */
  95870. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95871. /** @hidden */
  95872. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95873. /**
  95874. * Disposes of the line mesh
  95875. * @param doNotRecurse If children should be disposed
  95876. */
  95877. dispose(doNotRecurse?: boolean): void;
  95878. /**
  95879. * Returns a new LineMesh object cloned from the current one.
  95880. */
  95881. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95882. /**
  95883. * Creates a new InstancedLinesMesh object from the mesh model.
  95884. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95885. * @param name defines the name of the new instance
  95886. * @returns a new InstancedLinesMesh
  95887. */
  95888. createInstance(name: string): InstancedLinesMesh;
  95889. }
  95890. /**
  95891. * Creates an instance based on a source LinesMesh
  95892. */
  95893. export class InstancedLinesMesh extends InstancedMesh {
  95894. /**
  95895. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95896. * This margin is expressed in world space coordinates, so its value may vary.
  95897. * Initilized with the intersectionThreshold value of the source LinesMesh
  95898. */
  95899. intersectionThreshold: number;
  95900. constructor(name: string, source: LinesMesh);
  95901. /**
  95902. * Returns the string "InstancedLinesMesh".
  95903. */
  95904. getClassName(): string;
  95905. }
  95906. }
  95907. declare module BABYLON {
  95908. /** @hidden */
  95909. export var linePixelShader: {
  95910. name: string;
  95911. shader: string;
  95912. };
  95913. }
  95914. declare module BABYLON {
  95915. /** @hidden */
  95916. export var lineVertexShader: {
  95917. name: string;
  95918. shader: string;
  95919. };
  95920. }
  95921. declare module BABYLON {
  95922. interface Scene {
  95923. /** @hidden */
  95924. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95925. }
  95926. interface AbstractMesh {
  95927. /**
  95928. * Gets the edgesRenderer associated with the mesh
  95929. */
  95930. edgesRenderer: Nullable<EdgesRenderer>;
  95931. }
  95932. interface LinesMesh {
  95933. /**
  95934. * Enables the edge rendering mode on the mesh.
  95935. * This mode makes the mesh edges visible
  95936. * @param epsilon defines the maximal distance between two angles to detect a face
  95937. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95938. * @returns the currentAbstractMesh
  95939. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95940. */
  95941. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95942. }
  95943. interface InstancedLinesMesh {
  95944. /**
  95945. * Enables the edge rendering mode on the mesh.
  95946. * This mode makes the mesh edges visible
  95947. * @param epsilon defines the maximal distance between two angles to detect a face
  95948. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95949. * @returns the current InstancedLinesMesh
  95950. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95951. */
  95952. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95953. }
  95954. /**
  95955. * Defines the minimum contract an Edges renderer should follow.
  95956. */
  95957. export interface IEdgesRenderer extends IDisposable {
  95958. /**
  95959. * Gets or sets a boolean indicating if the edgesRenderer is active
  95960. */
  95961. isEnabled: boolean;
  95962. /**
  95963. * Renders the edges of the attached mesh,
  95964. */
  95965. render(): void;
  95966. /**
  95967. * Checks wether or not the edges renderer is ready to render.
  95968. * @return true if ready, otherwise false.
  95969. */
  95970. isReady(): boolean;
  95971. /**
  95972. * List of instances to render in case the source mesh has instances
  95973. */
  95974. customInstances: SmartArray<Matrix>;
  95975. }
  95976. /**
  95977. * Defines the additional options of the edges renderer
  95978. */
  95979. export interface IEdgesRendererOptions {
  95980. /**
  95981. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95982. * If not defined, the default value is true
  95983. */
  95984. useAlternateEdgeFinder?: boolean;
  95985. /**
  95986. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95987. * If not defined, the default value is true.
  95988. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  95989. * This option is used only if useAlternateEdgeFinder = true
  95990. */
  95991. useFastVertexMerger?: boolean;
  95992. /**
  95993. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95994. * The default value is 1e-6
  95995. * This option is used only if useAlternateEdgeFinder = true
  95996. */
  95997. epsilonVertexMerge?: number;
  95998. /**
  95999. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  96000. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  96001. * This option is used only if useAlternateEdgeFinder = true
  96002. */
  96003. applyTessellation?: boolean;
  96004. /**
  96005. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  96006. * The default value is 1e-6
  96007. * This option is used only if useAlternateEdgeFinder = true
  96008. */
  96009. epsilonVertexAligned?: number;
  96010. }
  96011. /**
  96012. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96013. */
  96014. export class EdgesRenderer implements IEdgesRenderer {
  96015. /**
  96016. * Define the size of the edges with an orthographic camera
  96017. */
  96018. edgesWidthScalerForOrthographic: number;
  96019. /**
  96020. * Define the size of the edges with a perspective camera
  96021. */
  96022. edgesWidthScalerForPerspective: number;
  96023. protected _source: AbstractMesh;
  96024. protected _linesPositions: number[];
  96025. protected _linesNormals: number[];
  96026. protected _linesIndices: number[];
  96027. protected _epsilon: number;
  96028. protected _indicesCount: number;
  96029. protected _lineShader: ShaderMaterial;
  96030. protected _ib: DataBuffer;
  96031. protected _buffers: {
  96032. [key: string]: Nullable<VertexBuffer>;
  96033. };
  96034. protected _buffersForInstances: {
  96035. [key: string]: Nullable<VertexBuffer>;
  96036. };
  96037. protected _checkVerticesInsteadOfIndices: boolean;
  96038. protected _options: Nullable<IEdgesRendererOptions>;
  96039. private _meshRebuildObserver;
  96040. private _meshDisposeObserver;
  96041. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96042. isEnabled: boolean;
  96043. /**
  96044. * List of instances to render in case the source mesh has instances
  96045. */
  96046. customInstances: SmartArray<Matrix>;
  96047. private static GetShader;
  96048. /**
  96049. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96050. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96051. * @param source Mesh used to create edges
  96052. * @param epsilon sum of angles in adjacency to check for edge
  96053. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96054. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96055. * @param options The options to apply when generating the edges
  96056. */
  96057. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96058. protected _prepareRessources(): void;
  96059. /** @hidden */
  96060. _rebuild(): void;
  96061. /**
  96062. * Releases the required resources for the edges renderer
  96063. */
  96064. dispose(): void;
  96065. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96066. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96067. /**
  96068. * Checks if the pair of p0 and p1 is en edge
  96069. * @param faceIndex
  96070. * @param edge
  96071. * @param faceNormals
  96072. * @param p0
  96073. * @param p1
  96074. * @private
  96075. */
  96076. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96077. /**
  96078. * push line into the position, normal and index buffer
  96079. * @protected
  96080. */
  96081. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96082. /**
  96083. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96084. */
  96085. private _tessellateTriangle;
  96086. private _generateEdgesLinesAlternate;
  96087. /**
  96088. * Generates lines edges from adjacencjes
  96089. * @private
  96090. */
  96091. _generateEdgesLines(): void;
  96092. /**
  96093. * Checks wether or not the edges renderer is ready to render.
  96094. * @return true if ready, otherwise false.
  96095. */
  96096. isReady(): boolean;
  96097. /**
  96098. * Renders the edges of the attached mesh,
  96099. */
  96100. render(): void;
  96101. }
  96102. /**
  96103. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96104. */
  96105. export class LineEdgesRenderer extends EdgesRenderer {
  96106. /**
  96107. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96108. * @param source LineMesh used to generate edges
  96109. * @param epsilon not important (specified angle for edge detection)
  96110. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96111. */
  96112. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96113. /**
  96114. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96115. */
  96116. _generateEdgesLines(): void;
  96117. }
  96118. }
  96119. declare module BABYLON {
  96120. /**
  96121. * This represents the object necessary to create a rendering group.
  96122. * This is exclusively used and created by the rendering manager.
  96123. * To modify the behavior, you use the available helpers in your scene or meshes.
  96124. * @hidden
  96125. */
  96126. export class RenderingGroup {
  96127. index: number;
  96128. private static _zeroVector;
  96129. private _scene;
  96130. private _opaqueSubMeshes;
  96131. private _transparentSubMeshes;
  96132. private _alphaTestSubMeshes;
  96133. private _depthOnlySubMeshes;
  96134. private _particleSystems;
  96135. private _spriteManagers;
  96136. private _opaqueSortCompareFn;
  96137. private _alphaTestSortCompareFn;
  96138. private _transparentSortCompareFn;
  96139. private _renderOpaque;
  96140. private _renderAlphaTest;
  96141. private _renderTransparent;
  96142. /** @hidden */
  96143. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96144. onBeforeTransparentRendering: () => void;
  96145. /**
  96146. * Set the opaque sort comparison function.
  96147. * If null the sub meshes will be render in the order they were created
  96148. */
  96149. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96150. /**
  96151. * Set the alpha test sort comparison function.
  96152. * If null the sub meshes will be render in the order they were created
  96153. */
  96154. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96155. /**
  96156. * Set the transparent sort comparison function.
  96157. * If null the sub meshes will be render in the order they were created
  96158. */
  96159. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96160. /**
  96161. * Creates a new rendering group.
  96162. * @param index The rendering group index
  96163. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96164. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96165. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96166. */
  96167. 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>);
  96168. /**
  96169. * Render all the sub meshes contained in the group.
  96170. * @param customRenderFunction Used to override the default render behaviour of the group.
  96171. * @returns true if rendered some submeshes.
  96172. */
  96173. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96174. /**
  96175. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96176. * @param subMeshes The submeshes to render
  96177. */
  96178. private renderOpaqueSorted;
  96179. /**
  96180. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96181. * @param subMeshes The submeshes to render
  96182. */
  96183. private renderAlphaTestSorted;
  96184. /**
  96185. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96186. * @param subMeshes The submeshes to render
  96187. */
  96188. private renderTransparentSorted;
  96189. /**
  96190. * Renders the submeshes in a specified order.
  96191. * @param subMeshes The submeshes to sort before render
  96192. * @param sortCompareFn The comparison function use to sort
  96193. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96194. * @param transparent Specifies to activate blending if true
  96195. */
  96196. private static renderSorted;
  96197. /**
  96198. * Renders the submeshes in the order they were dispatched (no sort applied).
  96199. * @param subMeshes The submeshes to render
  96200. */
  96201. private static renderUnsorted;
  96202. /**
  96203. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96204. * are rendered back to front if in the same alpha index.
  96205. *
  96206. * @param a The first submesh
  96207. * @param b The second submesh
  96208. * @returns The result of the comparison
  96209. */
  96210. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96211. /**
  96212. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96213. * are rendered back to front.
  96214. *
  96215. * @param a The first submesh
  96216. * @param b The second submesh
  96217. * @returns The result of the comparison
  96218. */
  96219. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96220. /**
  96221. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96222. * are rendered front to back (prevent overdraw).
  96223. *
  96224. * @param a The first submesh
  96225. * @param b The second submesh
  96226. * @returns The result of the comparison
  96227. */
  96228. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96229. /**
  96230. * Resets the different lists of submeshes to prepare a new frame.
  96231. */
  96232. prepare(): void;
  96233. dispose(): void;
  96234. /**
  96235. * Inserts the submesh in its correct queue depending on its material.
  96236. * @param subMesh The submesh to dispatch
  96237. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96238. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96239. */
  96240. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96241. dispatchSprites(spriteManager: ISpriteManager): void;
  96242. dispatchParticles(particleSystem: IParticleSystem): void;
  96243. private _renderParticles;
  96244. private _renderSprites;
  96245. }
  96246. }
  96247. declare module BABYLON {
  96248. /**
  96249. * Interface describing the different options available in the rendering manager
  96250. * regarding Auto Clear between groups.
  96251. */
  96252. export interface IRenderingManagerAutoClearSetup {
  96253. /**
  96254. * Defines whether or not autoclear is enable.
  96255. */
  96256. autoClear: boolean;
  96257. /**
  96258. * Defines whether or not to autoclear the depth buffer.
  96259. */
  96260. depth: boolean;
  96261. /**
  96262. * Defines whether or not to autoclear the stencil buffer.
  96263. */
  96264. stencil: boolean;
  96265. }
  96266. /**
  96267. * This class is used by the onRenderingGroupObservable
  96268. */
  96269. export class RenderingGroupInfo {
  96270. /**
  96271. * The Scene that being rendered
  96272. */
  96273. scene: Scene;
  96274. /**
  96275. * The camera currently used for the rendering pass
  96276. */
  96277. camera: Nullable<Camera>;
  96278. /**
  96279. * The ID of the renderingGroup being processed
  96280. */
  96281. renderingGroupId: number;
  96282. }
  96283. /**
  96284. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96285. * It is enable to manage the different groups as well as the different necessary sort functions.
  96286. * This should not be used directly aside of the few static configurations
  96287. */
  96288. export class RenderingManager {
  96289. /**
  96290. * The max id used for rendering groups (not included)
  96291. */
  96292. static MAX_RENDERINGGROUPS: number;
  96293. /**
  96294. * The min id used for rendering groups (included)
  96295. */
  96296. static MIN_RENDERINGGROUPS: number;
  96297. /**
  96298. * Used to globally prevent autoclearing scenes.
  96299. */
  96300. static AUTOCLEAR: boolean;
  96301. /**
  96302. * @hidden
  96303. */
  96304. _useSceneAutoClearSetup: boolean;
  96305. private _scene;
  96306. private _renderingGroups;
  96307. private _depthStencilBufferAlreadyCleaned;
  96308. private _autoClearDepthStencil;
  96309. private _customOpaqueSortCompareFn;
  96310. private _customAlphaTestSortCompareFn;
  96311. private _customTransparentSortCompareFn;
  96312. private _renderingGroupInfo;
  96313. /**
  96314. * Instantiates a new rendering group for a particular scene
  96315. * @param scene Defines the scene the groups belongs to
  96316. */
  96317. constructor(scene: Scene);
  96318. private _clearDepthStencilBuffer;
  96319. /**
  96320. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96321. * @hidden
  96322. */
  96323. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96324. /**
  96325. * Resets the different information of the group to prepare a new frame
  96326. * @hidden
  96327. */
  96328. reset(): void;
  96329. /**
  96330. * Dispose and release the group and its associated resources.
  96331. * @hidden
  96332. */
  96333. dispose(): void;
  96334. /**
  96335. * Clear the info related to rendering groups preventing retention points during dispose.
  96336. */
  96337. freeRenderingGroups(): void;
  96338. private _prepareRenderingGroup;
  96339. /**
  96340. * Add a sprite manager to the rendering manager in order to render it this frame.
  96341. * @param spriteManager Define the sprite manager to render
  96342. */
  96343. dispatchSprites(spriteManager: ISpriteManager): void;
  96344. /**
  96345. * Add a particle system to the rendering manager in order to render it this frame.
  96346. * @param particleSystem Define the particle system to render
  96347. */
  96348. dispatchParticles(particleSystem: IParticleSystem): void;
  96349. /**
  96350. * Add a submesh to the manager in order to render it this frame
  96351. * @param subMesh The submesh to dispatch
  96352. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96353. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96354. */
  96355. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96356. /**
  96357. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96358. * This allowed control for front to back rendering or reversly depending of the special needs.
  96359. *
  96360. * @param renderingGroupId The rendering group id corresponding to its index
  96361. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96362. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96363. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96364. */
  96365. 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;
  96366. /**
  96367. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96368. *
  96369. * @param renderingGroupId The rendering group id corresponding to its index
  96370. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96371. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96372. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96373. */
  96374. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96375. /**
  96376. * Gets the current auto clear configuration for one rendering group of the rendering
  96377. * manager.
  96378. * @param index the rendering group index to get the information for
  96379. * @returns The auto clear setup for the requested rendering group
  96380. */
  96381. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96382. }
  96383. }
  96384. declare module BABYLON {
  96385. /**
  96386. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96387. */
  96388. export interface ICustomShaderOptions {
  96389. /**
  96390. * Gets or sets the custom shader name to use
  96391. */
  96392. shaderName: string;
  96393. /**
  96394. * The list of attribute names used in the shader
  96395. */
  96396. attributes?: string[];
  96397. /**
  96398. * The list of unifrom names used in the shader
  96399. */
  96400. uniforms?: string[];
  96401. /**
  96402. * The list of sampler names used in the shader
  96403. */
  96404. samplers?: string[];
  96405. /**
  96406. * The list of defines used in the shader
  96407. */
  96408. defines?: string[];
  96409. }
  96410. /**
  96411. * Interface to implement to create a shadow generator compatible with BJS.
  96412. */
  96413. export interface IShadowGenerator {
  96414. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96415. id: string;
  96416. /**
  96417. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96418. * @returns The render target texture if present otherwise, null
  96419. */
  96420. getShadowMap(): Nullable<RenderTargetTexture>;
  96421. /**
  96422. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96423. * @param subMesh The submesh we want to render in the shadow map
  96424. * @param useInstances Defines wether will draw in the map using instances
  96425. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96426. * @returns true if ready otherwise, false
  96427. */
  96428. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96429. /**
  96430. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96431. * @param defines Defines of the material we want to update
  96432. * @param lightIndex Index of the light in the enabled light list of the material
  96433. */
  96434. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96435. /**
  96436. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96437. * defined in the generator but impacting the effect).
  96438. * It implies the unifroms available on the materials are the standard BJS ones.
  96439. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96440. * @param effect The effect we are binfing the information for
  96441. */
  96442. bindShadowLight(lightIndex: string, effect: Effect): void;
  96443. /**
  96444. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96445. * (eq to shadow prjection matrix * light transform matrix)
  96446. * @returns The transform matrix used to create the shadow map
  96447. */
  96448. getTransformMatrix(): Matrix;
  96449. /**
  96450. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96451. * Cube and 2D textures for instance.
  96452. */
  96453. recreateShadowMap(): void;
  96454. /**
  96455. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96456. * @param onCompiled Callback triggered at the and of the effects compilation
  96457. * @param options Sets of optional options forcing the compilation with different modes
  96458. */
  96459. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96460. useInstances: boolean;
  96461. }>): void;
  96462. /**
  96463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96464. * @param options Sets of optional options forcing the compilation with different modes
  96465. * @returns A promise that resolves when the compilation completes
  96466. */
  96467. forceCompilationAsync(options?: Partial<{
  96468. useInstances: boolean;
  96469. }>): Promise<void>;
  96470. /**
  96471. * Serializes the shadow generator setup to a json object.
  96472. * @returns The serialized JSON object
  96473. */
  96474. serialize(): any;
  96475. /**
  96476. * Disposes the Shadow map and related Textures and effects.
  96477. */
  96478. dispose(): void;
  96479. }
  96480. /**
  96481. * Default implementation IShadowGenerator.
  96482. * This is the main object responsible of generating shadows in the framework.
  96483. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96484. */
  96485. export class ShadowGenerator implements IShadowGenerator {
  96486. /**
  96487. * Name of the shadow generator class
  96488. */
  96489. static CLASSNAME: string;
  96490. /**
  96491. * Shadow generator mode None: no filtering applied.
  96492. */
  96493. static readonly FILTER_NONE: number;
  96494. /**
  96495. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96497. */
  96498. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96499. /**
  96500. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96501. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96502. */
  96503. static readonly FILTER_POISSONSAMPLING: number;
  96504. /**
  96505. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96506. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96507. */
  96508. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96509. /**
  96510. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96511. * edge artifacts on steep falloff.
  96512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96513. */
  96514. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96515. /**
  96516. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96517. * edge artifacts on steep falloff.
  96518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96519. */
  96520. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96521. /**
  96522. * Shadow generator mode PCF: Percentage Closer Filtering
  96523. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96524. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96525. */
  96526. static readonly FILTER_PCF: number;
  96527. /**
  96528. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96530. * Contact Hardening
  96531. */
  96532. static readonly FILTER_PCSS: number;
  96533. /**
  96534. * Reserved for PCF and PCSS
  96535. * Highest Quality.
  96536. *
  96537. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96538. *
  96539. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96540. */
  96541. static readonly QUALITY_HIGH: number;
  96542. /**
  96543. * Reserved for PCF and PCSS
  96544. * Good tradeoff for quality/perf cross devices
  96545. *
  96546. * Execute PCF on a 3*3 kernel.
  96547. *
  96548. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96549. */
  96550. static readonly QUALITY_MEDIUM: number;
  96551. /**
  96552. * Reserved for PCF and PCSS
  96553. * The lowest quality but the fastest.
  96554. *
  96555. * Execute PCF on a 1*1 kernel.
  96556. *
  96557. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96558. */
  96559. static readonly QUALITY_LOW: number;
  96560. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96561. id: string;
  96562. /** Gets or sets the custom shader name to use */
  96563. customShaderOptions: ICustomShaderOptions;
  96564. /**
  96565. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96566. */
  96567. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96568. /**
  96569. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96570. */
  96571. onAfterShadowMapRenderObservable: Observable<Effect>;
  96572. /**
  96573. * Observable triggered before a mesh is rendered in the shadow map.
  96574. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96575. */
  96576. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96577. /**
  96578. * Observable triggered after a mesh is rendered in the shadow map.
  96579. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96580. */
  96581. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96582. protected _bias: number;
  96583. /**
  96584. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96585. */
  96586. get bias(): number;
  96587. /**
  96588. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96589. */
  96590. set bias(bias: number);
  96591. protected _normalBias: number;
  96592. /**
  96593. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96594. */
  96595. get normalBias(): number;
  96596. /**
  96597. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96598. */
  96599. set normalBias(normalBias: number);
  96600. protected _blurBoxOffset: number;
  96601. /**
  96602. * Gets the blur box offset: offset applied during the blur pass.
  96603. * Only useful if useKernelBlur = false
  96604. */
  96605. get blurBoxOffset(): number;
  96606. /**
  96607. * Sets the blur box offset: offset applied during the blur pass.
  96608. * Only useful if useKernelBlur = false
  96609. */
  96610. set blurBoxOffset(value: number);
  96611. protected _blurScale: number;
  96612. /**
  96613. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96614. * 2 means half of the size.
  96615. */
  96616. get blurScale(): number;
  96617. /**
  96618. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96619. * 2 means half of the size.
  96620. */
  96621. set blurScale(value: number);
  96622. protected _blurKernel: number;
  96623. /**
  96624. * Gets the blur kernel: kernel size of the blur pass.
  96625. * Only useful if useKernelBlur = true
  96626. */
  96627. get blurKernel(): number;
  96628. /**
  96629. * Sets the blur kernel: kernel size of the blur pass.
  96630. * Only useful if useKernelBlur = true
  96631. */
  96632. set blurKernel(value: number);
  96633. protected _useKernelBlur: boolean;
  96634. /**
  96635. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96636. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96637. */
  96638. get useKernelBlur(): boolean;
  96639. /**
  96640. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96641. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96642. */
  96643. set useKernelBlur(value: boolean);
  96644. protected _depthScale: number;
  96645. /**
  96646. * Gets the depth scale used in ESM mode.
  96647. */
  96648. get depthScale(): number;
  96649. /**
  96650. * Sets the depth scale used in ESM mode.
  96651. * This can override the scale stored on the light.
  96652. */
  96653. set depthScale(value: number);
  96654. protected _validateFilter(filter: number): number;
  96655. protected _filter: number;
  96656. /**
  96657. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96659. */
  96660. get filter(): number;
  96661. /**
  96662. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96663. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96664. */
  96665. set filter(value: number);
  96666. /**
  96667. * Gets if the current filter is set to Poisson Sampling.
  96668. */
  96669. get usePoissonSampling(): boolean;
  96670. /**
  96671. * Sets the current filter to Poisson Sampling.
  96672. */
  96673. set usePoissonSampling(value: boolean);
  96674. /**
  96675. * Gets if the current filter is set to ESM.
  96676. */
  96677. get useExponentialShadowMap(): boolean;
  96678. /**
  96679. * Sets the current filter is to ESM.
  96680. */
  96681. set useExponentialShadowMap(value: boolean);
  96682. /**
  96683. * Gets if the current filter is set to filtered ESM.
  96684. */
  96685. get useBlurExponentialShadowMap(): boolean;
  96686. /**
  96687. * Gets if the current filter is set to filtered ESM.
  96688. */
  96689. set useBlurExponentialShadowMap(value: boolean);
  96690. /**
  96691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96692. * exponential to prevent steep falloff artifacts).
  96693. */
  96694. get useCloseExponentialShadowMap(): boolean;
  96695. /**
  96696. * Sets the current filter to "close ESM" (using the inverse of the
  96697. * exponential to prevent steep falloff artifacts).
  96698. */
  96699. set useCloseExponentialShadowMap(value: boolean);
  96700. /**
  96701. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96702. * exponential to prevent steep falloff artifacts).
  96703. */
  96704. get useBlurCloseExponentialShadowMap(): boolean;
  96705. /**
  96706. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96707. * exponential to prevent steep falloff artifacts).
  96708. */
  96709. set useBlurCloseExponentialShadowMap(value: boolean);
  96710. /**
  96711. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96712. */
  96713. get usePercentageCloserFiltering(): boolean;
  96714. /**
  96715. * Sets the current filter to "PCF" (percentage closer filtering).
  96716. */
  96717. set usePercentageCloserFiltering(value: boolean);
  96718. protected _filteringQuality: number;
  96719. /**
  96720. * Gets the PCF or PCSS Quality.
  96721. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96722. */
  96723. get filteringQuality(): number;
  96724. /**
  96725. * Sets the PCF or PCSS Quality.
  96726. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96727. */
  96728. set filteringQuality(filteringQuality: number);
  96729. /**
  96730. * Gets if the current filter is set to "PCSS" (contact hardening).
  96731. */
  96732. get useContactHardeningShadow(): boolean;
  96733. /**
  96734. * Sets the current filter to "PCSS" (contact hardening).
  96735. */
  96736. set useContactHardeningShadow(value: boolean);
  96737. protected _contactHardeningLightSizeUVRatio: number;
  96738. /**
  96739. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96740. * Using a ratio helps keeping shape stability independently of the map size.
  96741. *
  96742. * It does not account for the light projection as it was having too much
  96743. * instability during the light setup or during light position changes.
  96744. *
  96745. * Only valid if useContactHardeningShadow is true.
  96746. */
  96747. get contactHardeningLightSizeUVRatio(): number;
  96748. /**
  96749. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96750. * Using a ratio helps keeping shape stability independently of the map size.
  96751. *
  96752. * It does not account for the light projection as it was having too much
  96753. * instability during the light setup or during light position changes.
  96754. *
  96755. * Only valid if useContactHardeningShadow is true.
  96756. */
  96757. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96758. protected _darkness: number;
  96759. /** Gets or sets the actual darkness of a shadow */
  96760. get darkness(): number;
  96761. set darkness(value: number);
  96762. /**
  96763. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96764. * 0 means strongest and 1 would means no shadow.
  96765. * @returns the darkness.
  96766. */
  96767. getDarkness(): number;
  96768. /**
  96769. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96770. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96771. * @returns the shadow generator allowing fluent coding.
  96772. */
  96773. setDarkness(darkness: number): ShadowGenerator;
  96774. protected _transparencyShadow: boolean;
  96775. /** Gets or sets the ability to have transparent shadow */
  96776. get transparencyShadow(): boolean;
  96777. set transparencyShadow(value: boolean);
  96778. /**
  96779. * Sets the ability to have transparent shadow (boolean).
  96780. * @param transparent True if transparent else False
  96781. * @returns the shadow generator allowing fluent coding
  96782. */
  96783. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96784. /**
  96785. * Enables or disables shadows with varying strength based on the transparency
  96786. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96787. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96788. * mesh.visibility * alphaTexture.a
  96789. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96790. */
  96791. enableSoftTransparentShadow: boolean;
  96792. protected _shadowMap: Nullable<RenderTargetTexture>;
  96793. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96794. /**
  96795. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96796. * @returns The render target texture if present otherwise, null
  96797. */
  96798. getShadowMap(): Nullable<RenderTargetTexture>;
  96799. /**
  96800. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96801. * @returns The render target texture if the shadow map is present otherwise, null
  96802. */
  96803. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96804. /**
  96805. * Gets the class name of that object
  96806. * @returns "ShadowGenerator"
  96807. */
  96808. getClassName(): string;
  96809. /**
  96810. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96811. * @param mesh Mesh to add
  96812. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96813. * @returns the Shadow Generator itself
  96814. */
  96815. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96816. /**
  96817. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96818. * @param mesh Mesh to remove
  96819. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96820. * @returns the Shadow Generator itself
  96821. */
  96822. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96823. /**
  96824. * Controls the extent to which the shadows fade out at the edge of the frustum
  96825. */
  96826. frustumEdgeFalloff: number;
  96827. protected _light: IShadowLight;
  96828. /**
  96829. * Returns the associated light object.
  96830. * @returns the light generating the shadow
  96831. */
  96832. getLight(): IShadowLight;
  96833. /**
  96834. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96835. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96836. * It might on the other hand introduce peter panning.
  96837. */
  96838. forceBackFacesOnly: boolean;
  96839. protected _scene: Scene;
  96840. protected _lightDirection: Vector3;
  96841. protected _effect: Effect;
  96842. protected _viewMatrix: Matrix;
  96843. protected _projectionMatrix: Matrix;
  96844. protected _transformMatrix: Matrix;
  96845. protected _cachedPosition: Vector3;
  96846. protected _cachedDirection: Vector3;
  96847. protected _cachedDefines: string;
  96848. protected _currentRenderID: number;
  96849. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96850. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96851. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96852. protected _blurPostProcesses: PostProcess[];
  96853. protected _mapSize: number;
  96854. protected _currentFaceIndex: number;
  96855. protected _currentFaceIndexCache: number;
  96856. protected _textureType: number;
  96857. protected _defaultTextureMatrix: Matrix;
  96858. protected _storedUniqueId: Nullable<number>;
  96859. /** @hidden */
  96860. static _SceneComponentInitialization: (scene: Scene) => void;
  96861. /**
  96862. * Creates a ShadowGenerator object.
  96863. * A ShadowGenerator is the required tool to use the shadows.
  96864. * Each light casting shadows needs to use its own ShadowGenerator.
  96865. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96866. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96867. * @param light The light object generating the shadows.
  96868. * @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.
  96869. */
  96870. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96871. protected _initializeGenerator(): void;
  96872. protected _createTargetRenderTexture(): void;
  96873. protected _initializeShadowMap(): void;
  96874. protected _initializeBlurRTTAndPostProcesses(): void;
  96875. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96876. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96877. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96878. protected _applyFilterValues(): void;
  96879. /**
  96880. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96881. * @param onCompiled Callback triggered at the and of the effects compilation
  96882. * @param options Sets of optional options forcing the compilation with different modes
  96883. */
  96884. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96885. useInstances: boolean;
  96886. }>): void;
  96887. /**
  96888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96889. * @param options Sets of optional options forcing the compilation with different modes
  96890. * @returns A promise that resolves when the compilation completes
  96891. */
  96892. forceCompilationAsync(options?: Partial<{
  96893. useInstances: boolean;
  96894. }>): Promise<void>;
  96895. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96896. private _prepareShadowDefines;
  96897. /**
  96898. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96899. * @param subMesh The submesh we want to render in the shadow map
  96900. * @param useInstances Defines wether will draw in the map using instances
  96901. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96902. * @returns true if ready otherwise, false
  96903. */
  96904. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96905. /**
  96906. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96907. * @param defines Defines of the material we want to update
  96908. * @param lightIndex Index of the light in the enabled light list of the material
  96909. */
  96910. prepareDefines(defines: any, lightIndex: number): void;
  96911. /**
  96912. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96913. * defined in the generator but impacting the effect).
  96914. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96915. * @param effect The effect we are binfing the information for
  96916. */
  96917. bindShadowLight(lightIndex: string, effect: Effect): void;
  96918. /**
  96919. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96920. * (eq to shadow prjection matrix * light transform matrix)
  96921. * @returns The transform matrix used to create the shadow map
  96922. */
  96923. getTransformMatrix(): Matrix;
  96924. /**
  96925. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96926. * Cube and 2D textures for instance.
  96927. */
  96928. recreateShadowMap(): void;
  96929. protected _disposeBlurPostProcesses(): void;
  96930. protected _disposeRTTandPostProcesses(): void;
  96931. /**
  96932. * Disposes the ShadowGenerator.
  96933. * Returns nothing.
  96934. */
  96935. dispose(): void;
  96936. /**
  96937. * Serializes the shadow generator setup to a json object.
  96938. * @returns The serialized JSON object
  96939. */
  96940. serialize(): any;
  96941. /**
  96942. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96943. * @param parsedShadowGenerator The JSON object to parse
  96944. * @param scene The scene to create the shadow map for
  96945. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96946. * @returns The parsed shadow generator
  96947. */
  96948. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96949. }
  96950. }
  96951. declare module BABYLON {
  96952. /**
  96953. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96954. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96955. * 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.
  96956. */
  96957. export abstract class Light extends Node {
  96958. /**
  96959. * Falloff Default: light is falling off following the material specification:
  96960. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96961. */
  96962. static readonly FALLOFF_DEFAULT: number;
  96963. /**
  96964. * Falloff Physical: light is falling off following the inverse squared distance law.
  96965. */
  96966. static readonly FALLOFF_PHYSICAL: number;
  96967. /**
  96968. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96969. * to enhance interoperability with other engines.
  96970. */
  96971. static readonly FALLOFF_GLTF: number;
  96972. /**
  96973. * Falloff Standard: light is falling off like in the standard material
  96974. * to enhance interoperability with other materials.
  96975. */
  96976. static readonly FALLOFF_STANDARD: number;
  96977. /**
  96978. * If every light affecting the material is in this lightmapMode,
  96979. * material.lightmapTexture adds or multiplies
  96980. * (depends on material.useLightmapAsShadowmap)
  96981. * after every other light calculations.
  96982. */
  96983. static readonly LIGHTMAP_DEFAULT: number;
  96984. /**
  96985. * material.lightmapTexture as only diffuse lighting from this light
  96986. * adds only specular lighting from this light
  96987. * adds dynamic shadows
  96988. */
  96989. static readonly LIGHTMAP_SPECULAR: number;
  96990. /**
  96991. * material.lightmapTexture as only lighting
  96992. * no light calculation from this light
  96993. * only adds dynamic shadows from this light
  96994. */
  96995. static readonly LIGHTMAP_SHADOWSONLY: number;
  96996. /**
  96997. * Each light type uses the default quantity according to its type:
  96998. * point/spot lights use luminous intensity
  96999. * directional lights use illuminance
  97000. */
  97001. static readonly INTENSITYMODE_AUTOMATIC: number;
  97002. /**
  97003. * lumen (lm)
  97004. */
  97005. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97006. /**
  97007. * candela (lm/sr)
  97008. */
  97009. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97010. /**
  97011. * lux (lm/m^2)
  97012. */
  97013. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97014. /**
  97015. * nit (cd/m^2)
  97016. */
  97017. static readonly INTENSITYMODE_LUMINANCE: number;
  97018. /**
  97019. * Light type const id of the point light.
  97020. */
  97021. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97022. /**
  97023. * Light type const id of the directional light.
  97024. */
  97025. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97026. /**
  97027. * Light type const id of the spot light.
  97028. */
  97029. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97030. /**
  97031. * Light type const id of the hemispheric light.
  97032. */
  97033. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97034. /**
  97035. * Diffuse gives the basic color to an object.
  97036. */
  97037. diffuse: Color3;
  97038. /**
  97039. * Specular produces a highlight color on an object.
  97040. * Note: This is note affecting PBR materials.
  97041. */
  97042. specular: Color3;
  97043. /**
  97044. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97045. * falling off base on range or angle.
  97046. * This can be set to any values in Light.FALLOFF_x.
  97047. *
  97048. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97049. * other types of materials.
  97050. */
  97051. falloffType: number;
  97052. /**
  97053. * Strength of the light.
  97054. * Note: By default it is define in the framework own unit.
  97055. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97056. */
  97057. intensity: number;
  97058. private _range;
  97059. protected _inverseSquaredRange: number;
  97060. /**
  97061. * Defines how far from the source the light is impacting in scene units.
  97062. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97063. */
  97064. get range(): number;
  97065. /**
  97066. * Defines how far from the source the light is impacting in scene units.
  97067. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97068. */
  97069. set range(value: number);
  97070. /**
  97071. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97072. * of light.
  97073. */
  97074. private _photometricScale;
  97075. private _intensityMode;
  97076. /**
  97077. * Gets the photometric scale used to interpret the intensity.
  97078. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97079. */
  97080. get intensityMode(): number;
  97081. /**
  97082. * Sets the photometric scale used to interpret the intensity.
  97083. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97084. */
  97085. set intensityMode(value: number);
  97086. private _radius;
  97087. /**
  97088. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97089. */
  97090. get radius(): number;
  97091. /**
  97092. * sets the light radius used by PBR Materials to simulate soft area lights.
  97093. */
  97094. set radius(value: number);
  97095. private _renderPriority;
  97096. /**
  97097. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97098. * exceeding the number allowed of the materials.
  97099. */
  97100. renderPriority: number;
  97101. private _shadowEnabled;
  97102. /**
  97103. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97104. * the current shadow generator.
  97105. */
  97106. get shadowEnabled(): boolean;
  97107. /**
  97108. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97109. * the current shadow generator.
  97110. */
  97111. set shadowEnabled(value: boolean);
  97112. private _includedOnlyMeshes;
  97113. /**
  97114. * Gets the only meshes impacted by this light.
  97115. */
  97116. get includedOnlyMeshes(): AbstractMesh[];
  97117. /**
  97118. * Sets the only meshes impacted by this light.
  97119. */
  97120. set includedOnlyMeshes(value: AbstractMesh[]);
  97121. private _excludedMeshes;
  97122. /**
  97123. * Gets the meshes not impacted by this light.
  97124. */
  97125. get excludedMeshes(): AbstractMesh[];
  97126. /**
  97127. * Sets the meshes not impacted by this light.
  97128. */
  97129. set excludedMeshes(value: AbstractMesh[]);
  97130. private _excludeWithLayerMask;
  97131. /**
  97132. * Gets the layer id use to find what meshes are not impacted by the light.
  97133. * Inactive if 0
  97134. */
  97135. get excludeWithLayerMask(): number;
  97136. /**
  97137. * Sets the layer id use to find what meshes are not impacted by the light.
  97138. * Inactive if 0
  97139. */
  97140. set excludeWithLayerMask(value: number);
  97141. private _includeOnlyWithLayerMask;
  97142. /**
  97143. * Gets the layer id use to find what meshes are impacted by the light.
  97144. * Inactive if 0
  97145. */
  97146. get includeOnlyWithLayerMask(): number;
  97147. /**
  97148. * Sets the layer id use to find what meshes are impacted by the light.
  97149. * Inactive if 0
  97150. */
  97151. set includeOnlyWithLayerMask(value: number);
  97152. private _lightmapMode;
  97153. /**
  97154. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97155. */
  97156. get lightmapMode(): number;
  97157. /**
  97158. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97159. */
  97160. set lightmapMode(value: number);
  97161. /**
  97162. * Shadow generator associted to the light.
  97163. * @hidden Internal use only.
  97164. */
  97165. _shadowGenerator: Nullable<IShadowGenerator>;
  97166. /**
  97167. * @hidden Internal use only.
  97168. */
  97169. _excludedMeshesIds: string[];
  97170. /**
  97171. * @hidden Internal use only.
  97172. */
  97173. _includedOnlyMeshesIds: string[];
  97174. /**
  97175. * The current light unifom buffer.
  97176. * @hidden Internal use only.
  97177. */
  97178. _uniformBuffer: UniformBuffer;
  97179. /** @hidden */
  97180. _renderId: number;
  97181. /**
  97182. * Creates a Light object in the scene.
  97183. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97184. * @param name The firendly name of the light
  97185. * @param scene The scene the light belongs too
  97186. */
  97187. constructor(name: string, scene: Scene);
  97188. protected abstract _buildUniformLayout(): void;
  97189. /**
  97190. * Sets the passed Effect "effect" with the Light information.
  97191. * @param effect The effect to update
  97192. * @param lightIndex The index of the light in the effect to update
  97193. * @returns The light
  97194. */
  97195. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97196. /**
  97197. * Sets the passed Effect "effect" with the Light textures.
  97198. * @param effect The effect to update
  97199. * @param lightIndex The index of the light in the effect to update
  97200. * @returns The light
  97201. */
  97202. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97203. /**
  97204. * Binds the lights information from the scene to the effect for the given mesh.
  97205. * @param lightIndex Light index
  97206. * @param scene The scene where the light belongs to
  97207. * @param effect The effect we are binding the data to
  97208. * @param useSpecular Defines if specular is supported
  97209. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97210. */
  97211. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97212. /**
  97213. * Sets the passed Effect "effect" with the Light information.
  97214. * @param effect The effect to update
  97215. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97216. * @returns The light
  97217. */
  97218. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97219. /**
  97220. * Returns the string "Light".
  97221. * @returns the class name
  97222. */
  97223. getClassName(): string;
  97224. /** @hidden */
  97225. readonly _isLight: boolean;
  97226. /**
  97227. * Converts the light information to a readable string for debug purpose.
  97228. * @param fullDetails Supports for multiple levels of logging within scene loading
  97229. * @returns the human readable light info
  97230. */
  97231. toString(fullDetails?: boolean): string;
  97232. /** @hidden */
  97233. protected _syncParentEnabledState(): void;
  97234. /**
  97235. * Set the enabled state of this node.
  97236. * @param value - the new enabled state
  97237. */
  97238. setEnabled(value: boolean): void;
  97239. /**
  97240. * Returns the Light associated shadow generator if any.
  97241. * @return the associated shadow generator.
  97242. */
  97243. getShadowGenerator(): Nullable<IShadowGenerator>;
  97244. /**
  97245. * Returns a Vector3, the absolute light position in the World.
  97246. * @returns the world space position of the light
  97247. */
  97248. getAbsolutePosition(): Vector3;
  97249. /**
  97250. * Specifies if the light will affect the passed mesh.
  97251. * @param mesh The mesh to test against the light
  97252. * @return true the mesh is affected otherwise, false.
  97253. */
  97254. canAffectMesh(mesh: AbstractMesh): boolean;
  97255. /**
  97256. * Sort function to order lights for rendering.
  97257. * @param a First Light object to compare to second.
  97258. * @param b Second Light object to compare first.
  97259. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97260. */
  97261. static CompareLightsPriority(a: Light, b: Light): number;
  97262. /**
  97263. * Releases resources associated with this node.
  97264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97266. */
  97267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97268. /**
  97269. * Returns the light type ID (integer).
  97270. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97271. */
  97272. getTypeID(): number;
  97273. /**
  97274. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97275. * @returns the scaled intensity in intensity mode unit
  97276. */
  97277. getScaledIntensity(): number;
  97278. /**
  97279. * Returns a new Light object, named "name", from the current one.
  97280. * @param name The name of the cloned light
  97281. * @param newParent The parent of this light, if it has one
  97282. * @returns the new created light
  97283. */
  97284. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97285. /**
  97286. * Serializes the current light into a Serialization object.
  97287. * @returns the serialized object.
  97288. */
  97289. serialize(): any;
  97290. /**
  97291. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97292. * This new light is named "name" and added to the passed scene.
  97293. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97294. * @param name The friendly name of the light
  97295. * @param scene The scene the new light will belong to
  97296. * @returns the constructor function
  97297. */
  97298. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97299. /**
  97300. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97301. * @param parsedLight The JSON representation of the light
  97302. * @param scene The scene to create the parsed light in
  97303. * @returns the created light after parsing
  97304. */
  97305. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97306. private _hookArrayForExcluded;
  97307. private _hookArrayForIncludedOnly;
  97308. private _resyncMeshes;
  97309. /**
  97310. * Forces the meshes to update their light related information in their rendering used effects
  97311. * @hidden Internal Use Only
  97312. */
  97313. _markMeshesAsLightDirty(): void;
  97314. /**
  97315. * Recomputes the cached photometric scale if needed.
  97316. */
  97317. private _computePhotometricScale;
  97318. /**
  97319. * Returns the Photometric Scale according to the light type and intensity mode.
  97320. */
  97321. private _getPhotometricScale;
  97322. /**
  97323. * Reorder the light in the scene according to their defined priority.
  97324. * @hidden Internal Use Only
  97325. */
  97326. _reorderLightsInScene(): void;
  97327. /**
  97328. * Prepares the list of defines specific to the light type.
  97329. * @param defines the list of defines
  97330. * @param lightIndex defines the index of the light for the effect
  97331. */
  97332. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97333. }
  97334. }
  97335. declare module BABYLON {
  97336. /**
  97337. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97338. * This is the base of the follow, arc rotate cameras and Free camera
  97339. * @see https://doc.babylonjs.com/features/cameras
  97340. */
  97341. export class TargetCamera extends Camera {
  97342. private static _RigCamTransformMatrix;
  97343. private static _TargetTransformMatrix;
  97344. private static _TargetFocalPoint;
  97345. private _tmpUpVector;
  97346. private _tmpTargetVector;
  97347. /**
  97348. * Define the current direction the camera is moving to
  97349. */
  97350. cameraDirection: Vector3;
  97351. /**
  97352. * Define the current rotation the camera is rotating to
  97353. */
  97354. cameraRotation: Vector2;
  97355. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97356. ignoreParentScaling: boolean;
  97357. /**
  97358. * When set, the up vector of the camera will be updated by the rotation of the camera
  97359. */
  97360. updateUpVectorFromRotation: boolean;
  97361. private _tmpQuaternion;
  97362. /**
  97363. * Define the current rotation of the camera
  97364. */
  97365. rotation: Vector3;
  97366. /**
  97367. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97368. */
  97369. rotationQuaternion: Quaternion;
  97370. /**
  97371. * Define the current speed of the camera
  97372. */
  97373. speed: number;
  97374. /**
  97375. * Add constraint to the camera to prevent it to move freely in all directions and
  97376. * around all axis.
  97377. */
  97378. noRotationConstraint: boolean;
  97379. /**
  97380. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97381. * panning
  97382. */
  97383. invertRotation: boolean;
  97384. /**
  97385. * Speed multiplier for inverse camera panning
  97386. */
  97387. inverseRotationSpeed: number;
  97388. /**
  97389. * Define the current target of the camera as an object or a position.
  97390. */
  97391. lockedTarget: any;
  97392. /** @hidden */
  97393. _currentTarget: Vector3;
  97394. /** @hidden */
  97395. _initialFocalDistance: number;
  97396. /** @hidden */
  97397. _viewMatrix: Matrix;
  97398. /** @hidden */
  97399. _camMatrix: Matrix;
  97400. /** @hidden */
  97401. _cameraTransformMatrix: Matrix;
  97402. /** @hidden */
  97403. _cameraRotationMatrix: Matrix;
  97404. /** @hidden */
  97405. _referencePoint: Vector3;
  97406. /** @hidden */
  97407. _transformedReferencePoint: Vector3;
  97408. /** @hidden */
  97409. _reset: () => void;
  97410. private _defaultUp;
  97411. /**
  97412. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97413. * This is the base of the follow, arc rotate cameras and Free camera
  97414. * @see https://doc.babylonjs.com/features/cameras
  97415. * @param name Defines the name of the camera in the scene
  97416. * @param position Defines the start position of the camera in the scene
  97417. * @param scene Defines the scene the camera belongs to
  97418. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97419. */
  97420. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97421. /**
  97422. * Gets the position in front of the camera at a given distance.
  97423. * @param distance The distance from the camera we want the position to be
  97424. * @returns the position
  97425. */
  97426. getFrontPosition(distance: number): Vector3;
  97427. /** @hidden */
  97428. _getLockedTargetPosition(): Nullable<Vector3>;
  97429. private _storedPosition;
  97430. private _storedRotation;
  97431. private _storedRotationQuaternion;
  97432. /**
  97433. * Store current camera state of the camera (fov, position, rotation, etc..)
  97434. * @returns the camera
  97435. */
  97436. storeState(): Camera;
  97437. /**
  97438. * Restored camera state. You must call storeState() first
  97439. * @returns whether it was successful or not
  97440. * @hidden
  97441. */
  97442. _restoreStateValues(): boolean;
  97443. /** @hidden */
  97444. _initCache(): void;
  97445. /** @hidden */
  97446. _updateCache(ignoreParentClass?: boolean): void;
  97447. /** @hidden */
  97448. _isSynchronizedViewMatrix(): boolean;
  97449. /** @hidden */
  97450. _computeLocalCameraSpeed(): number;
  97451. /**
  97452. * Defines the target the camera should look at.
  97453. * @param target Defines the new target as a Vector or a mesh
  97454. */
  97455. setTarget(target: Vector3): void;
  97456. /**
  97457. * Defines the target point of the camera.
  97458. * The camera looks towards it form the radius distance.
  97459. */
  97460. get target(): Vector3;
  97461. set target(value: Vector3);
  97462. /**
  97463. * Return the current target position of the camera. This value is expressed in local space.
  97464. * @returns the target position
  97465. */
  97466. getTarget(): Vector3;
  97467. /** @hidden */
  97468. _decideIfNeedsToMove(): boolean;
  97469. /** @hidden */
  97470. _updatePosition(): void;
  97471. /** @hidden */
  97472. _checkInputs(): void;
  97473. protected _updateCameraRotationMatrix(): void;
  97474. /**
  97475. * 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)
  97476. * @returns the current camera
  97477. */
  97478. private _rotateUpVectorWithCameraRotationMatrix;
  97479. private _cachedRotationZ;
  97480. private _cachedQuaternionRotationZ;
  97481. /** @hidden */
  97482. _getViewMatrix(): Matrix;
  97483. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97484. /**
  97485. * @hidden
  97486. */
  97487. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97488. /**
  97489. * @hidden
  97490. */
  97491. _updateRigCameras(): void;
  97492. private _getRigCamPositionAndTarget;
  97493. /**
  97494. * Gets the current object class name.
  97495. * @return the class name
  97496. */
  97497. getClassName(): string;
  97498. }
  97499. }
  97500. declare module BABYLON {
  97501. /**
  97502. * Gather the list of keyboard event types as constants.
  97503. */
  97504. export class KeyboardEventTypes {
  97505. /**
  97506. * The keydown event is fired when a key becomes active (pressed).
  97507. */
  97508. static readonly KEYDOWN: number;
  97509. /**
  97510. * The keyup event is fired when a key has been released.
  97511. */
  97512. static readonly KEYUP: number;
  97513. }
  97514. /**
  97515. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97516. */
  97517. export class KeyboardInfo {
  97518. /**
  97519. * Defines the type of event (KeyboardEventTypes)
  97520. */
  97521. type: number;
  97522. /**
  97523. * Defines the related dom event
  97524. */
  97525. event: KeyboardEvent;
  97526. /**
  97527. * Instantiates a new keyboard info.
  97528. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97529. * @param type Defines the type of event (KeyboardEventTypes)
  97530. * @param event Defines the related dom event
  97531. */
  97532. constructor(
  97533. /**
  97534. * Defines the type of event (KeyboardEventTypes)
  97535. */
  97536. type: number,
  97537. /**
  97538. * Defines the related dom event
  97539. */
  97540. event: KeyboardEvent);
  97541. }
  97542. /**
  97543. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97544. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97545. */
  97546. export class KeyboardInfoPre extends KeyboardInfo {
  97547. /**
  97548. * Defines the type of event (KeyboardEventTypes)
  97549. */
  97550. type: number;
  97551. /**
  97552. * Defines the related dom event
  97553. */
  97554. event: KeyboardEvent;
  97555. /**
  97556. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97557. */
  97558. skipOnPointerObservable: boolean;
  97559. /**
  97560. * Instantiates a new keyboard pre info.
  97561. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97562. * @param type Defines the type of event (KeyboardEventTypes)
  97563. * @param event Defines the related dom event
  97564. */
  97565. constructor(
  97566. /**
  97567. * Defines the type of event (KeyboardEventTypes)
  97568. */
  97569. type: number,
  97570. /**
  97571. * Defines the related dom event
  97572. */
  97573. event: KeyboardEvent);
  97574. }
  97575. }
  97576. declare module BABYLON {
  97577. /**
  97578. * Manage the keyboard inputs to control the movement of a free camera.
  97579. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97580. */
  97581. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97582. /**
  97583. * Defines the camera the input is attached to.
  97584. */
  97585. camera: FreeCamera;
  97586. /**
  97587. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97588. */
  97589. keysUp: number[];
  97590. /**
  97591. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97592. */
  97593. keysUpward: number[];
  97594. /**
  97595. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97596. */
  97597. keysDown: number[];
  97598. /**
  97599. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97600. */
  97601. keysDownward: number[];
  97602. /**
  97603. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97604. */
  97605. keysLeft: number[];
  97606. /**
  97607. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97608. */
  97609. keysRight: number[];
  97610. private _keys;
  97611. private _onCanvasBlurObserver;
  97612. private _onKeyboardObserver;
  97613. private _engine;
  97614. private _scene;
  97615. /**
  97616. * Attach the input controls to a specific dom element to get the input from.
  97617. * @param element Defines the element the controls should be listened from
  97618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97619. */
  97620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97621. /**
  97622. * Detach the current controls from the specified dom element.
  97623. * @param element Defines the element to stop listening the inputs from
  97624. */
  97625. detachControl(element: Nullable<HTMLElement>): void;
  97626. /**
  97627. * Update the current camera state depending on the inputs that have been used this frame.
  97628. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97629. */
  97630. checkInputs(): void;
  97631. /**
  97632. * Gets the class name of the current intput.
  97633. * @returns the class name
  97634. */
  97635. getClassName(): string;
  97636. /** @hidden */
  97637. _onLostFocus(): void;
  97638. /**
  97639. * Get the friendly name associated with the input class.
  97640. * @returns the input friendly name
  97641. */
  97642. getSimpleName(): string;
  97643. }
  97644. }
  97645. declare module BABYLON {
  97646. /**
  97647. * Gather the list of pointer event types as constants.
  97648. */
  97649. export class PointerEventTypes {
  97650. /**
  97651. * 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.
  97652. */
  97653. static readonly POINTERDOWN: number;
  97654. /**
  97655. * The pointerup event is fired when a pointer is no longer active.
  97656. */
  97657. static readonly POINTERUP: number;
  97658. /**
  97659. * The pointermove event is fired when a pointer changes coordinates.
  97660. */
  97661. static readonly POINTERMOVE: number;
  97662. /**
  97663. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97664. */
  97665. static readonly POINTERWHEEL: number;
  97666. /**
  97667. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97668. */
  97669. static readonly POINTERPICK: number;
  97670. /**
  97671. * The pointertap event is fired when a the object has been touched and released without drag.
  97672. */
  97673. static readonly POINTERTAP: number;
  97674. /**
  97675. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97676. */
  97677. static readonly POINTERDOUBLETAP: number;
  97678. }
  97679. /**
  97680. * Base class of pointer info types.
  97681. */
  97682. export class PointerInfoBase {
  97683. /**
  97684. * Defines the type of event (PointerEventTypes)
  97685. */
  97686. type: number;
  97687. /**
  97688. * Defines the related dom event
  97689. */
  97690. event: PointerEvent | MouseWheelEvent;
  97691. /**
  97692. * Instantiates the base class of pointers info.
  97693. * @param type Defines the type of event (PointerEventTypes)
  97694. * @param event Defines the related dom event
  97695. */
  97696. constructor(
  97697. /**
  97698. * Defines the type of event (PointerEventTypes)
  97699. */
  97700. type: number,
  97701. /**
  97702. * Defines the related dom event
  97703. */
  97704. event: PointerEvent | MouseWheelEvent);
  97705. }
  97706. /**
  97707. * This class is used to store pointer related info for the onPrePointerObservable event.
  97708. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97709. */
  97710. export class PointerInfoPre extends PointerInfoBase {
  97711. /**
  97712. * Ray from a pointer if availible (eg. 6dof controller)
  97713. */
  97714. ray: Nullable<Ray>;
  97715. /**
  97716. * Defines the local position of the pointer on the canvas.
  97717. */
  97718. localPosition: Vector2;
  97719. /**
  97720. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97721. */
  97722. skipOnPointerObservable: boolean;
  97723. /**
  97724. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97725. * @param type Defines the type of event (PointerEventTypes)
  97726. * @param event Defines the related dom event
  97727. * @param localX Defines the local x coordinates of the pointer when the event occured
  97728. * @param localY Defines the local y coordinates of the pointer when the event occured
  97729. */
  97730. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97731. }
  97732. /**
  97733. * This type contains all the data related to a pointer event in Babylon.js.
  97734. * 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.
  97735. */
  97736. export class PointerInfo extends PointerInfoBase {
  97737. /**
  97738. * Defines the picking info associated to the info (if any)\
  97739. */
  97740. pickInfo: Nullable<PickingInfo>;
  97741. /**
  97742. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97743. * @param type Defines the type of event (PointerEventTypes)
  97744. * @param event Defines the related dom event
  97745. * @param pickInfo Defines the picking info associated to the info (if any)\
  97746. */
  97747. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97748. /**
  97749. * Defines the picking info associated to the info (if any)\
  97750. */
  97751. pickInfo: Nullable<PickingInfo>);
  97752. }
  97753. /**
  97754. * Data relating to a touch event on the screen.
  97755. */
  97756. export interface PointerTouch {
  97757. /**
  97758. * X coordinate of touch.
  97759. */
  97760. x: number;
  97761. /**
  97762. * Y coordinate of touch.
  97763. */
  97764. y: number;
  97765. /**
  97766. * Id of touch. Unique for each finger.
  97767. */
  97768. pointerId: number;
  97769. /**
  97770. * Event type passed from DOM.
  97771. */
  97772. type: any;
  97773. }
  97774. }
  97775. declare module BABYLON {
  97776. /**
  97777. * Manage the mouse inputs to control the movement of a free camera.
  97778. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97779. */
  97780. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97781. /**
  97782. * Define if touch is enabled in the mouse input
  97783. */
  97784. touchEnabled: boolean;
  97785. /**
  97786. * Defines the camera the input is attached to.
  97787. */
  97788. camera: FreeCamera;
  97789. /**
  97790. * Defines the buttons associated with the input to handle camera move.
  97791. */
  97792. buttons: number[];
  97793. /**
  97794. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97795. */
  97796. angularSensibility: number;
  97797. private _pointerInput;
  97798. private _onMouseMove;
  97799. private _observer;
  97800. private previousPosition;
  97801. /**
  97802. * Observable for when a pointer move event occurs containing the move offset
  97803. */
  97804. onPointerMovedObservable: Observable<{
  97805. offsetX: number;
  97806. offsetY: number;
  97807. }>;
  97808. /**
  97809. * @hidden
  97810. * If the camera should be rotated automatically based on pointer movement
  97811. */
  97812. _allowCameraRotation: boolean;
  97813. /**
  97814. * Manage the mouse inputs to control the movement of a free camera.
  97815. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97816. * @param touchEnabled Defines if touch is enabled or not
  97817. */
  97818. constructor(
  97819. /**
  97820. * Define if touch is enabled in the mouse input
  97821. */
  97822. touchEnabled?: boolean);
  97823. /**
  97824. * Attach the input controls to a specific dom element to get the input from.
  97825. * @param element Defines the element the controls should be listened from
  97826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97827. */
  97828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97829. /**
  97830. * Called on JS contextmenu event.
  97831. * Override this method to provide functionality.
  97832. */
  97833. protected onContextMenu(evt: PointerEvent): void;
  97834. /**
  97835. * Detach the current controls from the specified dom element.
  97836. * @param element Defines the element to stop listening the inputs from
  97837. */
  97838. detachControl(element: Nullable<HTMLElement>): void;
  97839. /**
  97840. * Gets the class name of the current intput.
  97841. * @returns the class name
  97842. */
  97843. getClassName(): string;
  97844. /**
  97845. * Get the friendly name associated with the input class.
  97846. * @returns the input friendly name
  97847. */
  97848. getSimpleName(): string;
  97849. }
  97850. }
  97851. declare module BABYLON {
  97852. /**
  97853. * Manage the touch inputs to control the movement of a free camera.
  97854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97855. */
  97856. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97857. /**
  97858. * Defines the camera the input is attached to.
  97859. */
  97860. camera: FreeCamera;
  97861. /**
  97862. * Defines the touch sensibility for rotation.
  97863. * The higher the faster.
  97864. */
  97865. touchAngularSensibility: number;
  97866. /**
  97867. * Defines the touch sensibility for move.
  97868. * The higher the faster.
  97869. */
  97870. touchMoveSensibility: number;
  97871. private _offsetX;
  97872. private _offsetY;
  97873. private _pointerPressed;
  97874. private _pointerInput;
  97875. private _observer;
  97876. private _onLostFocus;
  97877. /**
  97878. * Attach the input controls to a specific dom element to get the input from.
  97879. * @param element Defines the element the controls should be listened from
  97880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97881. */
  97882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97883. /**
  97884. * Detach the current controls from the specified dom element.
  97885. * @param element Defines the element to stop listening the inputs from
  97886. */
  97887. detachControl(element: Nullable<HTMLElement>): void;
  97888. /**
  97889. * Update the current camera state depending on the inputs that have been used this frame.
  97890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97891. */
  97892. checkInputs(): void;
  97893. /**
  97894. * Gets the class name of the current intput.
  97895. * @returns the class name
  97896. */
  97897. getClassName(): string;
  97898. /**
  97899. * Get the friendly name associated with the input class.
  97900. * @returns the input friendly name
  97901. */
  97902. getSimpleName(): string;
  97903. }
  97904. }
  97905. declare module BABYLON {
  97906. /**
  97907. * Default Inputs manager for the FreeCamera.
  97908. * It groups all the default supported inputs for ease of use.
  97909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97910. */
  97911. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97912. /**
  97913. * @hidden
  97914. */
  97915. _mouseInput: Nullable<FreeCameraMouseInput>;
  97916. /**
  97917. * Instantiates a new FreeCameraInputsManager.
  97918. * @param camera Defines the camera the inputs belong to
  97919. */
  97920. constructor(camera: FreeCamera);
  97921. /**
  97922. * Add keyboard input support to the input manager.
  97923. * @returns the current input manager
  97924. */
  97925. addKeyboard(): FreeCameraInputsManager;
  97926. /**
  97927. * Add mouse input support to the input manager.
  97928. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97929. * @returns the current input manager
  97930. */
  97931. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97932. /**
  97933. * Removes the mouse input support from the manager
  97934. * @returns the current input manager
  97935. */
  97936. removeMouse(): FreeCameraInputsManager;
  97937. /**
  97938. * Add touch input support to the input manager.
  97939. * @returns the current input manager
  97940. */
  97941. addTouch(): FreeCameraInputsManager;
  97942. /**
  97943. * Remove all attached input methods from a camera
  97944. */
  97945. clear(): void;
  97946. }
  97947. }
  97948. declare module BABYLON {
  97949. /**
  97950. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97951. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97952. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97953. */
  97954. export class FreeCamera extends TargetCamera {
  97955. /**
  97956. * Define the collision ellipsoid of the camera.
  97957. * This is helpful to simulate a camera body like the player body around the camera
  97958. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97959. */
  97960. ellipsoid: Vector3;
  97961. /**
  97962. * Define an offset for the position of the ellipsoid around the camera.
  97963. * This can be helpful to determine the center of the body near the gravity center of the body
  97964. * instead of its head.
  97965. */
  97966. ellipsoidOffset: Vector3;
  97967. /**
  97968. * Enable or disable collisions of the camera with the rest of the scene objects.
  97969. */
  97970. checkCollisions: boolean;
  97971. /**
  97972. * Enable or disable gravity on the camera.
  97973. */
  97974. applyGravity: boolean;
  97975. /**
  97976. * Define the input manager associated to the camera.
  97977. */
  97978. inputs: FreeCameraInputsManager;
  97979. /**
  97980. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97981. * Higher values reduce sensitivity.
  97982. */
  97983. get angularSensibility(): number;
  97984. /**
  97985. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97986. * Higher values reduce sensitivity.
  97987. */
  97988. set angularSensibility(value: number);
  97989. /**
  97990. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97991. */
  97992. get keysUp(): number[];
  97993. set keysUp(value: number[]);
  97994. /**
  97995. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97996. */
  97997. get keysUpward(): number[];
  97998. set keysUpward(value: number[]);
  97999. /**
  98000. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98001. */
  98002. get keysDown(): number[];
  98003. set keysDown(value: number[]);
  98004. /**
  98005. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98006. */
  98007. get keysDownward(): number[];
  98008. set keysDownward(value: number[]);
  98009. /**
  98010. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98011. */
  98012. get keysLeft(): number[];
  98013. set keysLeft(value: number[]);
  98014. /**
  98015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98016. */
  98017. get keysRight(): number[];
  98018. set keysRight(value: number[]);
  98019. /**
  98020. * Event raised when the camera collide with a mesh in the scene.
  98021. */
  98022. onCollide: (collidedMesh: AbstractMesh) => void;
  98023. private _collider;
  98024. private _needMoveForGravity;
  98025. private _oldPosition;
  98026. private _diffPosition;
  98027. private _newPosition;
  98028. /** @hidden */
  98029. _localDirection: Vector3;
  98030. /** @hidden */
  98031. _transformedDirection: Vector3;
  98032. /**
  98033. * Instantiates a Free Camera.
  98034. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98035. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98036. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98037. * @param name Define the name of the camera in the scene
  98038. * @param position Define the start position of the camera in the scene
  98039. * @param scene Define the scene the camera belongs to
  98040. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98041. */
  98042. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98043. /**
  98044. * Attached controls to the current camera.
  98045. * @param element Defines the element the controls should be listened from
  98046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98047. */
  98048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98049. /**
  98050. * Detach the current controls from the camera.
  98051. * The camera will stop reacting to inputs.
  98052. * @param element Defines the element to stop listening the inputs from
  98053. */
  98054. detachControl(element: HTMLElement): void;
  98055. private _collisionMask;
  98056. /**
  98057. * Define a collision mask to limit the list of object the camera can collide with
  98058. */
  98059. get collisionMask(): number;
  98060. set collisionMask(mask: number);
  98061. /** @hidden */
  98062. _collideWithWorld(displacement: Vector3): void;
  98063. private _onCollisionPositionChange;
  98064. /** @hidden */
  98065. _checkInputs(): void;
  98066. /** @hidden */
  98067. _decideIfNeedsToMove(): boolean;
  98068. /** @hidden */
  98069. _updatePosition(): void;
  98070. /**
  98071. * Destroy the camera and release the current resources hold by it.
  98072. */
  98073. dispose(): void;
  98074. /**
  98075. * Gets the current object class name.
  98076. * @return the class name
  98077. */
  98078. getClassName(): string;
  98079. }
  98080. }
  98081. declare module BABYLON {
  98082. /**
  98083. * Represents a gamepad control stick position
  98084. */
  98085. export class StickValues {
  98086. /**
  98087. * The x component of the control stick
  98088. */
  98089. x: number;
  98090. /**
  98091. * The y component of the control stick
  98092. */
  98093. y: number;
  98094. /**
  98095. * Initializes the gamepad x and y control stick values
  98096. * @param x The x component of the gamepad control stick value
  98097. * @param y The y component of the gamepad control stick value
  98098. */
  98099. constructor(
  98100. /**
  98101. * The x component of the control stick
  98102. */
  98103. x: number,
  98104. /**
  98105. * The y component of the control stick
  98106. */
  98107. y: number);
  98108. }
  98109. /**
  98110. * An interface which manages callbacks for gamepad button changes
  98111. */
  98112. export interface GamepadButtonChanges {
  98113. /**
  98114. * Called when a gamepad has been changed
  98115. */
  98116. changed: boolean;
  98117. /**
  98118. * Called when a gamepad press event has been triggered
  98119. */
  98120. pressChanged: boolean;
  98121. /**
  98122. * Called when a touch event has been triggered
  98123. */
  98124. touchChanged: boolean;
  98125. /**
  98126. * Called when a value has changed
  98127. */
  98128. valueChanged: boolean;
  98129. }
  98130. /**
  98131. * Represents a gamepad
  98132. */
  98133. export class Gamepad {
  98134. /**
  98135. * The id of the gamepad
  98136. */
  98137. id: string;
  98138. /**
  98139. * The index of the gamepad
  98140. */
  98141. index: number;
  98142. /**
  98143. * The browser gamepad
  98144. */
  98145. browserGamepad: any;
  98146. /**
  98147. * Specifies what type of gamepad this represents
  98148. */
  98149. type: number;
  98150. private _leftStick;
  98151. private _rightStick;
  98152. /** @hidden */
  98153. _isConnected: boolean;
  98154. private _leftStickAxisX;
  98155. private _leftStickAxisY;
  98156. private _rightStickAxisX;
  98157. private _rightStickAxisY;
  98158. /**
  98159. * Triggered when the left control stick has been changed
  98160. */
  98161. private _onleftstickchanged;
  98162. /**
  98163. * Triggered when the right control stick has been changed
  98164. */
  98165. private _onrightstickchanged;
  98166. /**
  98167. * Represents a gamepad controller
  98168. */
  98169. static GAMEPAD: number;
  98170. /**
  98171. * Represents a generic controller
  98172. */
  98173. static GENERIC: number;
  98174. /**
  98175. * Represents an XBox controller
  98176. */
  98177. static XBOX: number;
  98178. /**
  98179. * Represents a pose-enabled controller
  98180. */
  98181. static POSE_ENABLED: number;
  98182. /**
  98183. * Represents an Dual Shock controller
  98184. */
  98185. static DUALSHOCK: number;
  98186. /**
  98187. * Specifies whether the left control stick should be Y-inverted
  98188. */
  98189. protected _invertLeftStickY: boolean;
  98190. /**
  98191. * Specifies if the gamepad has been connected
  98192. */
  98193. get isConnected(): boolean;
  98194. /**
  98195. * Initializes the gamepad
  98196. * @param id The id of the gamepad
  98197. * @param index The index of the gamepad
  98198. * @param browserGamepad The browser gamepad
  98199. * @param leftStickX The x component of the left joystick
  98200. * @param leftStickY The y component of the left joystick
  98201. * @param rightStickX The x component of the right joystick
  98202. * @param rightStickY The y component of the right joystick
  98203. */
  98204. constructor(
  98205. /**
  98206. * The id of the gamepad
  98207. */
  98208. id: string,
  98209. /**
  98210. * The index of the gamepad
  98211. */
  98212. index: number,
  98213. /**
  98214. * The browser gamepad
  98215. */
  98216. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98217. /**
  98218. * Callback triggered when the left joystick has changed
  98219. * @param callback
  98220. */
  98221. onleftstickchanged(callback: (values: StickValues) => void): void;
  98222. /**
  98223. * Callback triggered when the right joystick has changed
  98224. * @param callback
  98225. */
  98226. onrightstickchanged(callback: (values: StickValues) => void): void;
  98227. /**
  98228. * Gets the left joystick
  98229. */
  98230. get leftStick(): StickValues;
  98231. /**
  98232. * Sets the left joystick values
  98233. */
  98234. set leftStick(newValues: StickValues);
  98235. /**
  98236. * Gets the right joystick
  98237. */
  98238. get rightStick(): StickValues;
  98239. /**
  98240. * Sets the right joystick value
  98241. */
  98242. set rightStick(newValues: StickValues);
  98243. /**
  98244. * Updates the gamepad joystick positions
  98245. */
  98246. update(): void;
  98247. /**
  98248. * Disposes the gamepad
  98249. */
  98250. dispose(): void;
  98251. }
  98252. /**
  98253. * Represents a generic gamepad
  98254. */
  98255. export class GenericPad extends Gamepad {
  98256. private _buttons;
  98257. private _onbuttondown;
  98258. private _onbuttonup;
  98259. /**
  98260. * Observable triggered when a button has been pressed
  98261. */
  98262. onButtonDownObservable: Observable<number>;
  98263. /**
  98264. * Observable triggered when a button has been released
  98265. */
  98266. onButtonUpObservable: Observable<number>;
  98267. /**
  98268. * Callback triggered when a button has been pressed
  98269. * @param callback Called when a button has been pressed
  98270. */
  98271. onbuttondown(callback: (buttonPressed: number) => void): void;
  98272. /**
  98273. * Callback triggered when a button has been released
  98274. * @param callback Called when a button has been released
  98275. */
  98276. onbuttonup(callback: (buttonReleased: number) => void): void;
  98277. /**
  98278. * Initializes the generic gamepad
  98279. * @param id The id of the generic gamepad
  98280. * @param index The index of the generic gamepad
  98281. * @param browserGamepad The browser gamepad
  98282. */
  98283. constructor(id: string, index: number, browserGamepad: any);
  98284. private _setButtonValue;
  98285. /**
  98286. * Updates the generic gamepad
  98287. */
  98288. update(): void;
  98289. /**
  98290. * Disposes the generic gamepad
  98291. */
  98292. dispose(): void;
  98293. }
  98294. }
  98295. declare module BABYLON {
  98296. /**
  98297. * Defines the types of pose enabled controllers that are supported
  98298. */
  98299. export enum PoseEnabledControllerType {
  98300. /**
  98301. * HTC Vive
  98302. */
  98303. VIVE = 0,
  98304. /**
  98305. * Oculus Rift
  98306. */
  98307. OCULUS = 1,
  98308. /**
  98309. * Windows mixed reality
  98310. */
  98311. WINDOWS = 2,
  98312. /**
  98313. * Samsung gear VR
  98314. */
  98315. GEAR_VR = 3,
  98316. /**
  98317. * Google Daydream
  98318. */
  98319. DAYDREAM = 4,
  98320. /**
  98321. * Generic
  98322. */
  98323. GENERIC = 5
  98324. }
  98325. /**
  98326. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98327. */
  98328. export interface MutableGamepadButton {
  98329. /**
  98330. * Value of the button/trigger
  98331. */
  98332. value: number;
  98333. /**
  98334. * If the button/trigger is currently touched
  98335. */
  98336. touched: boolean;
  98337. /**
  98338. * If the button/trigger is currently pressed
  98339. */
  98340. pressed: boolean;
  98341. }
  98342. /**
  98343. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98344. * @hidden
  98345. */
  98346. export interface ExtendedGamepadButton extends GamepadButton {
  98347. /**
  98348. * If the button/trigger is currently pressed
  98349. */
  98350. readonly pressed: boolean;
  98351. /**
  98352. * If the button/trigger is currently touched
  98353. */
  98354. readonly touched: boolean;
  98355. /**
  98356. * Value of the button/trigger
  98357. */
  98358. readonly value: number;
  98359. }
  98360. /** @hidden */
  98361. export interface _GamePadFactory {
  98362. /**
  98363. * Returns whether or not the current gamepad can be created for this type of controller.
  98364. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98365. * @returns true if it can be created, otherwise false
  98366. */
  98367. canCreate(gamepadInfo: any): boolean;
  98368. /**
  98369. * Creates a new instance of the Gamepad.
  98370. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98371. * @returns the new gamepad instance
  98372. */
  98373. create(gamepadInfo: any): Gamepad;
  98374. }
  98375. /**
  98376. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98377. */
  98378. export class PoseEnabledControllerHelper {
  98379. /** @hidden */
  98380. static _ControllerFactories: _GamePadFactory[];
  98381. /** @hidden */
  98382. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98383. /**
  98384. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98385. * @param vrGamepad the gamepad to initialized
  98386. * @returns a vr controller of the type the gamepad identified as
  98387. */
  98388. static InitiateController(vrGamepad: any): Gamepad;
  98389. }
  98390. /**
  98391. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98392. */
  98393. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98394. /**
  98395. * If the controller is used in a webXR session
  98396. */
  98397. isXR: boolean;
  98398. private _deviceRoomPosition;
  98399. private _deviceRoomRotationQuaternion;
  98400. /**
  98401. * The device position in babylon space
  98402. */
  98403. devicePosition: Vector3;
  98404. /**
  98405. * The device rotation in babylon space
  98406. */
  98407. deviceRotationQuaternion: Quaternion;
  98408. /**
  98409. * The scale factor of the device in babylon space
  98410. */
  98411. deviceScaleFactor: number;
  98412. /**
  98413. * (Likely devicePosition should be used instead) The device position in its room space
  98414. */
  98415. position: Vector3;
  98416. /**
  98417. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98418. */
  98419. rotationQuaternion: Quaternion;
  98420. /**
  98421. * The type of controller (Eg. Windows mixed reality)
  98422. */
  98423. controllerType: PoseEnabledControllerType;
  98424. protected _calculatedPosition: Vector3;
  98425. private _calculatedRotation;
  98426. /**
  98427. * The raw pose from the device
  98428. */
  98429. rawPose: DevicePose;
  98430. private _trackPosition;
  98431. private _maxRotationDistFromHeadset;
  98432. private _draggedRoomRotation;
  98433. /**
  98434. * @hidden
  98435. */
  98436. _disableTrackPosition(fixedPosition: Vector3): void;
  98437. /**
  98438. * Internal, the mesh attached to the controller
  98439. * @hidden
  98440. */
  98441. _mesh: Nullable<AbstractMesh>;
  98442. private _poseControlledCamera;
  98443. private _leftHandSystemQuaternion;
  98444. /**
  98445. * Internal, matrix used to convert room space to babylon space
  98446. * @hidden
  98447. */
  98448. _deviceToWorld: Matrix;
  98449. /**
  98450. * Node to be used when casting a ray from the controller
  98451. * @hidden
  98452. */
  98453. _pointingPoseNode: Nullable<TransformNode>;
  98454. /**
  98455. * Name of the child mesh that can be used to cast a ray from the controller
  98456. */
  98457. static readonly POINTING_POSE: string;
  98458. /**
  98459. * Creates a new PoseEnabledController from a gamepad
  98460. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98461. */
  98462. constructor(browserGamepad: any);
  98463. private _workingMatrix;
  98464. /**
  98465. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98466. */
  98467. update(): void;
  98468. /**
  98469. * Updates only the pose device and mesh without doing any button event checking
  98470. */
  98471. protected _updatePoseAndMesh(): void;
  98472. /**
  98473. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98474. * @param poseData raw pose fromthe device
  98475. */
  98476. updateFromDevice(poseData: DevicePose): void;
  98477. /**
  98478. * @hidden
  98479. */
  98480. _meshAttachedObservable: Observable<AbstractMesh>;
  98481. /**
  98482. * Attaches a mesh to the controller
  98483. * @param mesh the mesh to be attached
  98484. */
  98485. attachToMesh(mesh: AbstractMesh): void;
  98486. /**
  98487. * Attaches the controllers mesh to a camera
  98488. * @param camera the camera the mesh should be attached to
  98489. */
  98490. attachToPoseControlledCamera(camera: TargetCamera): void;
  98491. /**
  98492. * Disposes of the controller
  98493. */
  98494. dispose(): void;
  98495. /**
  98496. * The mesh that is attached to the controller
  98497. */
  98498. get mesh(): Nullable<AbstractMesh>;
  98499. /**
  98500. * Gets the ray of the controller in the direction the controller is pointing
  98501. * @param length the length the resulting ray should be
  98502. * @returns a ray in the direction the controller is pointing
  98503. */
  98504. getForwardRay(length?: number): Ray;
  98505. }
  98506. }
  98507. declare module BABYLON {
  98508. /**
  98509. * Defines the WebVRController object that represents controllers tracked in 3D space
  98510. */
  98511. export abstract class WebVRController extends PoseEnabledController {
  98512. /**
  98513. * Internal, the default controller model for the controller
  98514. */
  98515. protected _defaultModel: Nullable<AbstractMesh>;
  98516. /**
  98517. * Fired when the trigger state has changed
  98518. */
  98519. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98520. /**
  98521. * Fired when the main button state has changed
  98522. */
  98523. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98524. /**
  98525. * Fired when the secondary button state has changed
  98526. */
  98527. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98528. /**
  98529. * Fired when the pad state has changed
  98530. */
  98531. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98532. /**
  98533. * Fired when controllers stick values have changed
  98534. */
  98535. onPadValuesChangedObservable: Observable<StickValues>;
  98536. /**
  98537. * Array of button availible on the controller
  98538. */
  98539. protected _buttons: Array<MutableGamepadButton>;
  98540. private _onButtonStateChange;
  98541. /**
  98542. * Fired when a controller button's state has changed
  98543. * @param callback the callback containing the button that was modified
  98544. */
  98545. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98546. /**
  98547. * X and Y axis corresponding to the controllers joystick
  98548. */
  98549. pad: StickValues;
  98550. /**
  98551. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98552. */
  98553. hand: string;
  98554. /**
  98555. * The default controller model for the controller
  98556. */
  98557. get defaultModel(): Nullable<AbstractMesh>;
  98558. /**
  98559. * Creates a new WebVRController from a gamepad
  98560. * @param vrGamepad the gamepad that the WebVRController should be created from
  98561. */
  98562. constructor(vrGamepad: any);
  98563. /**
  98564. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98565. */
  98566. update(): void;
  98567. /**
  98568. * Function to be called when a button is modified
  98569. */
  98570. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98571. /**
  98572. * Loads a mesh and attaches it to the controller
  98573. * @param scene the scene the mesh should be added to
  98574. * @param meshLoaded callback for when the mesh has been loaded
  98575. */
  98576. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98577. private _setButtonValue;
  98578. private _changes;
  98579. private _checkChanges;
  98580. /**
  98581. * Disposes of th webVRCOntroller
  98582. */
  98583. dispose(): void;
  98584. }
  98585. }
  98586. declare module BABYLON {
  98587. /**
  98588. * The HemisphericLight simulates the ambient environment light,
  98589. * so the passed direction is the light reflection direction, not the incoming direction.
  98590. */
  98591. export class HemisphericLight extends Light {
  98592. /**
  98593. * The groundColor is the light in the opposite direction to the one specified during creation.
  98594. * 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.
  98595. */
  98596. groundColor: Color3;
  98597. /**
  98598. * The light reflection direction, not the incoming direction.
  98599. */
  98600. direction: Vector3;
  98601. /**
  98602. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98603. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98604. * The HemisphericLight can't cast shadows.
  98605. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98606. * @param name The friendly name of the light
  98607. * @param direction The direction of the light reflection
  98608. * @param scene The scene the light belongs to
  98609. */
  98610. constructor(name: string, direction: Vector3, scene: Scene);
  98611. protected _buildUniformLayout(): void;
  98612. /**
  98613. * Returns the string "HemisphericLight".
  98614. * @return The class name
  98615. */
  98616. getClassName(): string;
  98617. /**
  98618. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98619. * Returns the updated direction.
  98620. * @param target The target the direction should point to
  98621. * @return The computed direction
  98622. */
  98623. setDirectionToTarget(target: Vector3): Vector3;
  98624. /**
  98625. * Returns the shadow generator associated to the light.
  98626. * @returns Always null for hemispheric lights because it does not support shadows.
  98627. */
  98628. getShadowGenerator(): Nullable<IShadowGenerator>;
  98629. /**
  98630. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98631. * @param effect The effect to update
  98632. * @param lightIndex The index of the light in the effect to update
  98633. * @returns The hemispheric light
  98634. */
  98635. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98636. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98637. /**
  98638. * Computes the world matrix of the node
  98639. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98640. * @param useWasUpdatedFlag defines a reserved property
  98641. * @returns the world matrix
  98642. */
  98643. computeWorldMatrix(): Matrix;
  98644. /**
  98645. * Returns the integer 3.
  98646. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98647. */
  98648. getTypeID(): number;
  98649. /**
  98650. * Prepares the list of defines specific to the light type.
  98651. * @param defines the list of defines
  98652. * @param lightIndex defines the index of the light for the effect
  98653. */
  98654. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98655. }
  98656. }
  98657. declare module BABYLON {
  98658. /** @hidden */
  98659. export var vrMultiviewToSingleviewPixelShader: {
  98660. name: string;
  98661. shader: string;
  98662. };
  98663. }
  98664. declare module BABYLON {
  98665. /**
  98666. * Renders to multiple views with a single draw call
  98667. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98668. */
  98669. export class MultiviewRenderTarget extends RenderTargetTexture {
  98670. /**
  98671. * Creates a multiview render target
  98672. * @param scene scene used with the render target
  98673. * @param size the size of the render target (used for each view)
  98674. */
  98675. constructor(scene: Scene, size?: number | {
  98676. width: number;
  98677. height: number;
  98678. } | {
  98679. ratio: number;
  98680. });
  98681. /**
  98682. * @hidden
  98683. * @param faceIndex the face index, if its a cube texture
  98684. */
  98685. _bindFrameBuffer(faceIndex?: number): void;
  98686. /**
  98687. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98688. * @returns the view count
  98689. */
  98690. getViewCount(): number;
  98691. }
  98692. }
  98693. declare module BABYLON {
  98694. interface Engine {
  98695. /**
  98696. * Creates a new multiview render target
  98697. * @param width defines the width of the texture
  98698. * @param height defines the height of the texture
  98699. * @returns the created multiview texture
  98700. */
  98701. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98702. /**
  98703. * Binds a multiview framebuffer to be drawn to
  98704. * @param multiviewTexture texture to bind
  98705. */
  98706. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98707. }
  98708. interface Camera {
  98709. /**
  98710. * @hidden
  98711. * 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)
  98712. */
  98713. _useMultiviewToSingleView: boolean;
  98714. /**
  98715. * @hidden
  98716. * 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)
  98717. */
  98718. _multiviewTexture: Nullable<RenderTargetTexture>;
  98719. /**
  98720. * @hidden
  98721. * ensures the multiview texture of the camera exists and has the specified width/height
  98722. * @param width height to set on the multiview texture
  98723. * @param height width to set on the multiview texture
  98724. */
  98725. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98726. }
  98727. interface Scene {
  98728. /** @hidden */
  98729. _transformMatrixR: Matrix;
  98730. /** @hidden */
  98731. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98732. /** @hidden */
  98733. _createMultiviewUbo(): void;
  98734. /** @hidden */
  98735. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98736. /** @hidden */
  98737. _renderMultiviewToSingleView(camera: Camera): void;
  98738. }
  98739. }
  98740. declare module BABYLON {
  98741. /**
  98742. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98743. * This will not be used for webXR as it supports displaying texture arrays directly
  98744. */
  98745. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98746. /**
  98747. * Initializes a VRMultiviewToSingleview
  98748. * @param name name of the post process
  98749. * @param camera camera to be applied to
  98750. * @param scaleFactor scaling factor to the size of the output texture
  98751. */
  98752. constructor(name: string, camera: Camera, scaleFactor: number);
  98753. }
  98754. }
  98755. declare module BABYLON {
  98756. /**
  98757. * Interface used to define additional presentation attributes
  98758. */
  98759. export interface IVRPresentationAttributes {
  98760. /**
  98761. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98762. */
  98763. highRefreshRate: boolean;
  98764. /**
  98765. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98766. */
  98767. foveationLevel: number;
  98768. }
  98769. interface Engine {
  98770. /** @hidden */
  98771. _vrDisplay: any;
  98772. /** @hidden */
  98773. _vrSupported: boolean;
  98774. /** @hidden */
  98775. _oldSize: Size;
  98776. /** @hidden */
  98777. _oldHardwareScaleFactor: number;
  98778. /** @hidden */
  98779. _vrExclusivePointerMode: boolean;
  98780. /** @hidden */
  98781. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98782. /** @hidden */
  98783. _onVRDisplayPointerRestricted: () => void;
  98784. /** @hidden */
  98785. _onVRDisplayPointerUnrestricted: () => void;
  98786. /** @hidden */
  98787. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98788. /** @hidden */
  98789. _onVrDisplayDisconnect: Nullable<() => void>;
  98790. /** @hidden */
  98791. _onVrDisplayPresentChange: Nullable<() => void>;
  98792. /**
  98793. * Observable signaled when VR display mode changes
  98794. */
  98795. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98796. /**
  98797. * Observable signaled when VR request present is complete
  98798. */
  98799. onVRRequestPresentComplete: Observable<boolean>;
  98800. /**
  98801. * Observable signaled when VR request present starts
  98802. */
  98803. onVRRequestPresentStart: Observable<Engine>;
  98804. /**
  98805. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98806. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98807. */
  98808. isInVRExclusivePointerMode: boolean;
  98809. /**
  98810. * Gets a boolean indicating if a webVR device was detected
  98811. * @returns true if a webVR device was detected
  98812. */
  98813. isVRDevicePresent(): boolean;
  98814. /**
  98815. * Gets the current webVR device
  98816. * @returns the current webVR device (or null)
  98817. */
  98818. getVRDevice(): any;
  98819. /**
  98820. * Initializes a webVR display and starts listening to display change events
  98821. * The onVRDisplayChangedObservable will be notified upon these changes
  98822. * @returns A promise containing a VRDisplay and if vr is supported
  98823. */
  98824. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98825. /** @hidden */
  98826. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98827. /**
  98828. * Gets or sets the presentation attributes used to configure VR rendering
  98829. */
  98830. vrPresentationAttributes?: IVRPresentationAttributes;
  98831. /**
  98832. * Call this function to switch to webVR mode
  98833. * Will do nothing if webVR is not supported or if there is no webVR device
  98834. * @param options the webvr options provided to the camera. mainly used for multiview
  98835. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98836. */
  98837. enableVR(options: WebVROptions): void;
  98838. /** @hidden */
  98839. _onVRFullScreenTriggered(): void;
  98840. }
  98841. }
  98842. declare module BABYLON {
  98843. /**
  98844. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98845. * IMPORTANT!! The data is right-hand data.
  98846. * @export
  98847. * @interface DevicePose
  98848. */
  98849. export interface DevicePose {
  98850. /**
  98851. * The position of the device, values in array are [x,y,z].
  98852. */
  98853. readonly position: Nullable<Float32Array>;
  98854. /**
  98855. * The linearVelocity of the device, values in array are [x,y,z].
  98856. */
  98857. readonly linearVelocity: Nullable<Float32Array>;
  98858. /**
  98859. * The linearAcceleration of the device, values in array are [x,y,z].
  98860. */
  98861. readonly linearAcceleration: Nullable<Float32Array>;
  98862. /**
  98863. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98864. */
  98865. readonly orientation: Nullable<Float32Array>;
  98866. /**
  98867. * The angularVelocity of the device, values in array are [x,y,z].
  98868. */
  98869. readonly angularVelocity: Nullable<Float32Array>;
  98870. /**
  98871. * The angularAcceleration of the device, values in array are [x,y,z].
  98872. */
  98873. readonly angularAcceleration: Nullable<Float32Array>;
  98874. }
  98875. /**
  98876. * Interface representing a pose controlled object in Babylon.
  98877. * A pose controlled object has both regular pose values as well as pose values
  98878. * from an external device such as a VR head mounted display
  98879. */
  98880. export interface PoseControlled {
  98881. /**
  98882. * The position of the object in babylon space.
  98883. */
  98884. position: Vector3;
  98885. /**
  98886. * The rotation quaternion of the object in babylon space.
  98887. */
  98888. rotationQuaternion: Quaternion;
  98889. /**
  98890. * The position of the device in babylon space.
  98891. */
  98892. devicePosition?: Vector3;
  98893. /**
  98894. * The rotation quaternion of the device in babylon space.
  98895. */
  98896. deviceRotationQuaternion: Quaternion;
  98897. /**
  98898. * The raw pose coming from the device.
  98899. */
  98900. rawPose: Nullable<DevicePose>;
  98901. /**
  98902. * The scale of the device to be used when translating from device space to babylon space.
  98903. */
  98904. deviceScaleFactor: number;
  98905. /**
  98906. * Updates the poseControlled values based on the input device pose.
  98907. * @param poseData the pose data to update the object with
  98908. */
  98909. updateFromDevice(poseData: DevicePose): void;
  98910. }
  98911. /**
  98912. * Set of options to customize the webVRCamera
  98913. */
  98914. export interface WebVROptions {
  98915. /**
  98916. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98917. */
  98918. trackPosition?: boolean;
  98919. /**
  98920. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98921. */
  98922. positionScale?: number;
  98923. /**
  98924. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98925. */
  98926. displayName?: string;
  98927. /**
  98928. * Should the native controller meshes be initialized. (default: true)
  98929. */
  98930. controllerMeshes?: boolean;
  98931. /**
  98932. * Creating a default HemiLight only on controllers. (default: true)
  98933. */
  98934. defaultLightingOnControllers?: boolean;
  98935. /**
  98936. * If you don't want to use the default VR button of the helper. (default: false)
  98937. */
  98938. useCustomVRButton?: boolean;
  98939. /**
  98940. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98941. */
  98942. customVRButton?: HTMLButtonElement;
  98943. /**
  98944. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98945. */
  98946. rayLength?: number;
  98947. /**
  98948. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98949. */
  98950. defaultHeight?: number;
  98951. /**
  98952. * If multiview should be used if availible (default: false)
  98953. */
  98954. useMultiview?: boolean;
  98955. }
  98956. /**
  98957. * This represents a WebVR camera.
  98958. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98959. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98960. */
  98961. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98962. private webVROptions;
  98963. /**
  98964. * @hidden
  98965. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98966. */
  98967. _vrDevice: any;
  98968. /**
  98969. * The rawPose of the vrDevice.
  98970. */
  98971. rawPose: Nullable<DevicePose>;
  98972. private _onVREnabled;
  98973. private _specsVersion;
  98974. private _attached;
  98975. private _frameData;
  98976. protected _descendants: Array<Node>;
  98977. private _deviceRoomPosition;
  98978. /** @hidden */
  98979. _deviceRoomRotationQuaternion: Quaternion;
  98980. private _standingMatrix;
  98981. /**
  98982. * Represents device position in babylon space.
  98983. */
  98984. devicePosition: Vector3;
  98985. /**
  98986. * Represents device rotation in babylon space.
  98987. */
  98988. deviceRotationQuaternion: Quaternion;
  98989. /**
  98990. * The scale of the device to be used when translating from device space to babylon space.
  98991. */
  98992. deviceScaleFactor: number;
  98993. private _deviceToWorld;
  98994. private _worldToDevice;
  98995. /**
  98996. * References to the webVR controllers for the vrDevice.
  98997. */
  98998. controllers: Array<WebVRController>;
  98999. /**
  99000. * Emits an event when a controller is attached.
  99001. */
  99002. onControllersAttachedObservable: Observable<WebVRController[]>;
  99003. /**
  99004. * Emits an event when a controller's mesh has been loaded;
  99005. */
  99006. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99007. /**
  99008. * Emits an event when the HMD's pose has been updated.
  99009. */
  99010. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99011. private _poseSet;
  99012. /**
  99013. * If the rig cameras be used as parent instead of this camera.
  99014. */
  99015. rigParenting: boolean;
  99016. private _lightOnControllers;
  99017. private _defaultHeight?;
  99018. /**
  99019. * Instantiates a WebVRFreeCamera.
  99020. * @param name The name of the WebVRFreeCamera
  99021. * @param position The starting anchor position for the camera
  99022. * @param scene The scene the camera belongs to
  99023. * @param webVROptions a set of customizable options for the webVRCamera
  99024. */
  99025. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99026. /**
  99027. * Gets the device distance from the ground in meters.
  99028. * @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.
  99029. */
  99030. deviceDistanceToRoomGround(): number;
  99031. /**
  99032. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99033. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99034. */
  99035. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99036. /**
  99037. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99038. * @returns A promise with a boolean set to if the standing matrix is supported.
  99039. */
  99040. useStandingMatrixAsync(): Promise<boolean>;
  99041. /**
  99042. * Disposes the camera
  99043. */
  99044. dispose(): void;
  99045. /**
  99046. * Gets a vrController by name.
  99047. * @param name The name of the controller to retreive
  99048. * @returns the controller matching the name specified or null if not found
  99049. */
  99050. getControllerByName(name: string): Nullable<WebVRController>;
  99051. private _leftController;
  99052. /**
  99053. * The controller corresponding to the users left hand.
  99054. */
  99055. get leftController(): Nullable<WebVRController>;
  99056. private _rightController;
  99057. /**
  99058. * The controller corresponding to the users right hand.
  99059. */
  99060. get rightController(): Nullable<WebVRController>;
  99061. /**
  99062. * Casts a ray forward from the vrCamera's gaze.
  99063. * @param length Length of the ray (default: 100)
  99064. * @returns the ray corresponding to the gaze
  99065. */
  99066. getForwardRay(length?: number): Ray;
  99067. /**
  99068. * @hidden
  99069. * Updates the camera based on device's frame data
  99070. */
  99071. _checkInputs(): void;
  99072. /**
  99073. * Updates the poseControlled values based on the input device pose.
  99074. * @param poseData Pose coming from the device
  99075. */
  99076. updateFromDevice(poseData: DevicePose): void;
  99077. private _htmlElementAttached;
  99078. private _detachIfAttached;
  99079. /**
  99080. * WebVR's attach control will start broadcasting frames to the device.
  99081. * Note that in certain browsers (chrome for example) this function must be called
  99082. * within a user-interaction callback. Example:
  99083. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99084. *
  99085. * @param element html element to attach the vrDevice to
  99086. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99087. */
  99088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99089. /**
  99090. * Detaches the camera from the html element and disables VR
  99091. *
  99092. * @param element html element to detach from
  99093. */
  99094. detachControl(element: HTMLElement): void;
  99095. /**
  99096. * @returns the name of this class
  99097. */
  99098. getClassName(): string;
  99099. /**
  99100. * Calls resetPose on the vrDisplay
  99101. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99102. */
  99103. resetToCurrentRotation(): void;
  99104. /**
  99105. * @hidden
  99106. * Updates the rig cameras (left and right eye)
  99107. */
  99108. _updateRigCameras(): void;
  99109. private _workingVector;
  99110. private _oneVector;
  99111. private _workingMatrix;
  99112. private updateCacheCalled;
  99113. private _correctPositionIfNotTrackPosition;
  99114. /**
  99115. * @hidden
  99116. * Updates the cached values of the camera
  99117. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99118. */
  99119. _updateCache(ignoreParentClass?: boolean): void;
  99120. /**
  99121. * @hidden
  99122. * Get current device position in babylon world
  99123. */
  99124. _computeDevicePosition(): void;
  99125. /**
  99126. * Updates the current device position and rotation in the babylon world
  99127. */
  99128. update(): void;
  99129. /**
  99130. * @hidden
  99131. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99132. * @returns an identity matrix
  99133. */
  99134. _getViewMatrix(): Matrix;
  99135. private _tmpMatrix;
  99136. /**
  99137. * This function is called by the two RIG cameras.
  99138. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99139. * @hidden
  99140. */
  99141. _getWebVRViewMatrix(): Matrix;
  99142. /** @hidden */
  99143. _getWebVRProjectionMatrix(): Matrix;
  99144. private _onGamepadConnectedObserver;
  99145. private _onGamepadDisconnectedObserver;
  99146. private _updateCacheWhenTrackingDisabledObserver;
  99147. /**
  99148. * Initializes the controllers and their meshes
  99149. */
  99150. initControllers(): void;
  99151. }
  99152. }
  99153. declare module BABYLON {
  99154. /**
  99155. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99156. *
  99157. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99158. *
  99159. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99160. */
  99161. export class MaterialHelper {
  99162. /**
  99163. * Bind the current view position to an effect.
  99164. * @param effect The effect to be bound
  99165. * @param scene The scene the eyes position is used from
  99166. * @param variableName name of the shader variable that will hold the eye position
  99167. */
  99168. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99169. /**
  99170. * Helps preparing the defines values about the UVs in used in the effect.
  99171. * UVs are shared as much as we can accross channels in the shaders.
  99172. * @param texture The texture we are preparing the UVs for
  99173. * @param defines The defines to update
  99174. * @param key The channel key "diffuse", "specular"... used in the shader
  99175. */
  99176. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99177. /**
  99178. * Binds a texture matrix value to its corrsponding uniform
  99179. * @param texture The texture to bind the matrix for
  99180. * @param uniformBuffer The uniform buffer receivin the data
  99181. * @param key The channel key "diffuse", "specular"... used in the shader
  99182. */
  99183. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99184. /**
  99185. * Gets the current status of the fog (should it be enabled?)
  99186. * @param mesh defines the mesh to evaluate for fog support
  99187. * @param scene defines the hosting scene
  99188. * @returns true if fog must be enabled
  99189. */
  99190. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99191. /**
  99192. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99193. * @param mesh defines the current mesh
  99194. * @param scene defines the current scene
  99195. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99196. * @param pointsCloud defines if point cloud rendering has to be turned on
  99197. * @param fogEnabled defines if fog has to be turned on
  99198. * @param alphaTest defines if alpha testing has to be turned on
  99199. * @param defines defines the current list of defines
  99200. */
  99201. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99202. /**
  99203. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99204. * @param scene defines the current scene
  99205. * @param engine defines the current engine
  99206. * @param defines specifies the list of active defines
  99207. * @param useInstances defines if instances have to be turned on
  99208. * @param useClipPlane defines if clip plane have to be turned on
  99209. * @param useInstances defines if instances have to be turned on
  99210. * @param useThinInstances defines if thin instances have to be turned on
  99211. */
  99212. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99213. /**
  99214. * Prepares the defines for bones
  99215. * @param mesh The mesh containing the geometry data we will draw
  99216. * @param defines The defines to update
  99217. */
  99218. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99219. /**
  99220. * Prepares the defines for morph targets
  99221. * @param mesh The mesh containing the geometry data we will draw
  99222. * @param defines The defines to update
  99223. */
  99224. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99225. /**
  99226. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99227. * @param mesh The mesh containing the geometry data we will draw
  99228. * @param defines The defines to update
  99229. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99230. * @param useBones Precise whether bones should be used or not (override mesh info)
  99231. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99232. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99233. * @returns false if defines are considered not dirty and have not been checked
  99234. */
  99235. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99236. /**
  99237. * Prepares the defines related to multiview
  99238. * @param scene The scene we are intending to draw
  99239. * @param defines The defines to update
  99240. */
  99241. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99242. /**
  99243. * Prepares the defines related to the prepass
  99244. * @param scene The scene we are intending to draw
  99245. * @param defines The defines to update
  99246. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99247. */
  99248. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99249. /**
  99250. * Prepares the defines related to the light information passed in parameter
  99251. * @param scene The scene we are intending to draw
  99252. * @param mesh The mesh the effect is compiling for
  99253. * @param light The light the effect is compiling for
  99254. * @param lightIndex The index of the light
  99255. * @param defines The defines to update
  99256. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99257. * @param state Defines the current state regarding what is needed (normals, etc...)
  99258. */
  99259. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99260. needNormals: boolean;
  99261. needRebuild: boolean;
  99262. shadowEnabled: boolean;
  99263. specularEnabled: boolean;
  99264. lightmapMode: boolean;
  99265. }): void;
  99266. /**
  99267. * Prepares the defines related to the light information passed in parameter
  99268. * @param scene The scene we are intending to draw
  99269. * @param mesh The mesh the effect is compiling for
  99270. * @param defines The defines to update
  99271. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99272. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99273. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99274. * @returns true if normals will be required for the rest of the effect
  99275. */
  99276. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99277. /**
  99278. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99279. * @param lightIndex defines the light index
  99280. * @param uniformsList The uniform list
  99281. * @param samplersList The sampler list
  99282. * @param projectedLightTexture defines if projected texture must be used
  99283. * @param uniformBuffersList defines an optional list of uniform buffers
  99284. */
  99285. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99286. /**
  99287. * Prepares the uniforms and samplers list to be used in the effect
  99288. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99289. * @param samplersList The sampler list
  99290. * @param defines The defines helping in the list generation
  99291. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99292. */
  99293. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99294. /**
  99295. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99296. * @param defines The defines to update while falling back
  99297. * @param fallbacks The authorized effect fallbacks
  99298. * @param maxSimultaneousLights The maximum number of lights allowed
  99299. * @param rank the current rank of the Effect
  99300. * @returns The newly affected rank
  99301. */
  99302. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99303. private static _TmpMorphInfluencers;
  99304. /**
  99305. * Prepares the list of attributes required for morph targets according to the effect defines.
  99306. * @param attribs The current list of supported attribs
  99307. * @param mesh The mesh to prepare the morph targets attributes for
  99308. * @param influencers The number of influencers
  99309. */
  99310. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99311. /**
  99312. * Prepares the list of attributes required for morph targets according to the effect defines.
  99313. * @param attribs The current list of supported attribs
  99314. * @param mesh The mesh to prepare the morph targets attributes for
  99315. * @param defines The current Defines of the effect
  99316. */
  99317. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99318. /**
  99319. * Prepares the list of attributes required for bones according to the effect defines.
  99320. * @param attribs The current list of supported attribs
  99321. * @param mesh The mesh to prepare the bones attributes for
  99322. * @param defines The current Defines of the effect
  99323. * @param fallbacks The current efffect fallback strategy
  99324. */
  99325. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99326. /**
  99327. * Check and prepare the list of attributes required for instances according to the effect defines.
  99328. * @param attribs The current list of supported attribs
  99329. * @param defines The current MaterialDefines of the effect
  99330. */
  99331. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99332. /**
  99333. * Add the list of attributes required for instances to the attribs array.
  99334. * @param attribs The current list of supported attribs
  99335. */
  99336. static PushAttributesForInstances(attribs: string[]): void;
  99337. /**
  99338. * Binds the light information to the effect.
  99339. * @param light The light containing the generator
  99340. * @param effect The effect we are binding the data to
  99341. * @param lightIndex The light index in the effect used to render
  99342. */
  99343. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99344. /**
  99345. * Binds the lights information from the scene to the effect for the given mesh.
  99346. * @param light Light to bind
  99347. * @param lightIndex Light index
  99348. * @param scene The scene where the light belongs to
  99349. * @param effect The effect we are binding the data to
  99350. * @param useSpecular Defines if specular is supported
  99351. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99352. */
  99353. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99354. /**
  99355. * Binds the lights information from the scene to the effect for the given mesh.
  99356. * @param scene The scene the lights belongs to
  99357. * @param mesh The mesh we are binding the information to render
  99358. * @param effect The effect we are binding the data to
  99359. * @param defines The generated defines for the effect
  99360. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99361. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99362. */
  99363. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99364. private static _tempFogColor;
  99365. /**
  99366. * Binds the fog information from the scene to the effect for the given mesh.
  99367. * @param scene The scene the lights belongs to
  99368. * @param mesh The mesh we are binding the information to render
  99369. * @param effect The effect we are binding the data to
  99370. * @param linearSpace Defines if the fog effect is applied in linear space
  99371. */
  99372. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99373. /**
  99374. * Binds the bones information from the mesh to the effect.
  99375. * @param mesh The mesh we are binding the information to render
  99376. * @param effect The effect we are binding the data to
  99377. */
  99378. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99379. /**
  99380. * Binds the morph targets information from the mesh to the effect.
  99381. * @param abstractMesh The mesh we are binding the information to render
  99382. * @param effect The effect we are binding the data to
  99383. */
  99384. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99385. /**
  99386. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99387. * @param defines The generated defines used in the effect
  99388. * @param effect The effect we are binding the data to
  99389. * @param scene The scene we are willing to render with logarithmic scale for
  99390. */
  99391. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99392. /**
  99393. * Binds the clip plane information from the scene to the effect.
  99394. * @param scene The scene the clip plane information are extracted from
  99395. * @param effect The effect we are binding the data to
  99396. */
  99397. static BindClipPlane(effect: Effect, scene: Scene): void;
  99398. }
  99399. }
  99400. declare module BABYLON {
  99401. /**
  99402. * Block used to expose an input value
  99403. */
  99404. export class InputBlock extends NodeMaterialBlock {
  99405. private _mode;
  99406. private _associatedVariableName;
  99407. private _storedValue;
  99408. private _valueCallback;
  99409. private _type;
  99410. private _animationType;
  99411. /** Gets or set a value used to limit the range of float values */
  99412. min: number;
  99413. /** Gets or set a value used to limit the range of float values */
  99414. max: number;
  99415. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99416. isBoolean: boolean;
  99417. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99418. matrixMode: number;
  99419. /** @hidden */
  99420. _systemValue: Nullable<NodeMaterialSystemValues>;
  99421. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99422. visibleInInspector: boolean;
  99423. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99424. isConstant: boolean;
  99425. /** Gets or sets the group to use to display this block in the Inspector */
  99426. groupInInspector: string;
  99427. /** Gets an observable raised when the value is changed */
  99428. onValueChangedObservable: Observable<InputBlock>;
  99429. /**
  99430. * Gets or sets the connection point type (default is float)
  99431. */
  99432. get type(): NodeMaterialBlockConnectionPointTypes;
  99433. /**
  99434. * Creates a new InputBlock
  99435. * @param name defines the block name
  99436. * @param target defines the target of that block (Vertex by default)
  99437. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99438. */
  99439. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99440. /**
  99441. * Validates if a name is a reserve word.
  99442. * @param newName the new name to be given to the node.
  99443. * @returns false if the name is a reserve word, else true.
  99444. */
  99445. validateBlockName(newName: string): boolean;
  99446. /**
  99447. * Gets the output component
  99448. */
  99449. get output(): NodeMaterialConnectionPoint;
  99450. /**
  99451. * Set the source of this connection point to a vertex attribute
  99452. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99453. * @returns the current connection point
  99454. */
  99455. setAsAttribute(attributeName?: string): InputBlock;
  99456. /**
  99457. * Set the source of this connection point to a system value
  99458. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99459. * @returns the current connection point
  99460. */
  99461. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99462. /**
  99463. * Gets or sets the value of that point.
  99464. * Please note that this value will be ignored if valueCallback is defined
  99465. */
  99466. get value(): any;
  99467. set value(value: any);
  99468. /**
  99469. * Gets or sets a callback used to get the value of that point.
  99470. * Please note that setting this value will force the connection point to ignore the value property
  99471. */
  99472. get valueCallback(): () => any;
  99473. set valueCallback(value: () => any);
  99474. /**
  99475. * Gets or sets the associated variable name in the shader
  99476. */
  99477. get associatedVariableName(): string;
  99478. set associatedVariableName(value: string);
  99479. /** Gets or sets the type of animation applied to the input */
  99480. get animationType(): AnimatedInputBlockTypes;
  99481. set animationType(value: AnimatedInputBlockTypes);
  99482. /**
  99483. * Gets a boolean indicating that this connection point not defined yet
  99484. */
  99485. get isUndefined(): boolean;
  99486. /**
  99487. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99488. * In this case the connection point name must be the name of the uniform to use.
  99489. * Can only be set on inputs
  99490. */
  99491. get isUniform(): boolean;
  99492. set isUniform(value: boolean);
  99493. /**
  99494. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99495. * In this case the connection point name must be the name of the attribute to use
  99496. * Can only be set on inputs
  99497. */
  99498. get isAttribute(): boolean;
  99499. set isAttribute(value: boolean);
  99500. /**
  99501. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99502. * Can only be set on exit points
  99503. */
  99504. get isVarying(): boolean;
  99505. set isVarying(value: boolean);
  99506. /**
  99507. * Gets a boolean indicating that the current connection point is a system value
  99508. */
  99509. get isSystemValue(): boolean;
  99510. /**
  99511. * Gets or sets the current well known value or null if not defined as a system value
  99512. */
  99513. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99514. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99515. /**
  99516. * Gets the current class name
  99517. * @returns the class name
  99518. */
  99519. getClassName(): string;
  99520. /**
  99521. * Animate the input if animationType !== None
  99522. * @param scene defines the rendering scene
  99523. */
  99524. animate(scene: Scene): void;
  99525. private _emitDefine;
  99526. initialize(state: NodeMaterialBuildState): void;
  99527. /**
  99528. * Set the input block to its default value (based on its type)
  99529. */
  99530. setDefaultValue(): void;
  99531. private _emitConstant;
  99532. /** @hidden */
  99533. get _noContextSwitch(): boolean;
  99534. private _emit;
  99535. /** @hidden */
  99536. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99537. /** @hidden */
  99538. _transmit(effect: Effect, scene: Scene): void;
  99539. protected _buildBlock(state: NodeMaterialBuildState): void;
  99540. protected _dumpPropertiesCode(): string;
  99541. dispose(): void;
  99542. serialize(): any;
  99543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99544. }
  99545. }
  99546. declare module BABYLON {
  99547. /**
  99548. * Enum used to define the compatibility state between two connection points
  99549. */
  99550. export enum NodeMaterialConnectionPointCompatibilityStates {
  99551. /** Points are compatibles */
  99552. Compatible = 0,
  99553. /** Points are incompatible because of their types */
  99554. TypeIncompatible = 1,
  99555. /** Points are incompatible because of their targets (vertex vs fragment) */
  99556. TargetIncompatible = 2
  99557. }
  99558. /**
  99559. * Defines the direction of a connection point
  99560. */
  99561. export enum NodeMaterialConnectionPointDirection {
  99562. /** Input */
  99563. Input = 0,
  99564. /** Output */
  99565. Output = 1
  99566. }
  99567. /**
  99568. * Defines a connection point for a block
  99569. */
  99570. export class NodeMaterialConnectionPoint {
  99571. /** @hidden */
  99572. _ownerBlock: NodeMaterialBlock;
  99573. /** @hidden */
  99574. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99575. private _endpoints;
  99576. private _associatedVariableName;
  99577. private _direction;
  99578. /** @hidden */
  99579. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99580. /** @hidden */
  99581. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99582. private _type;
  99583. /** @hidden */
  99584. _enforceAssociatedVariableName: boolean;
  99585. /** Gets the direction of the point */
  99586. get direction(): NodeMaterialConnectionPointDirection;
  99587. /** Indicates that this connection point needs dual validation before being connected to another point */
  99588. needDualDirectionValidation: boolean;
  99589. /**
  99590. * Gets or sets the additional types supported by this connection point
  99591. */
  99592. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99593. /**
  99594. * Gets or sets the additional types excluded by this connection point
  99595. */
  99596. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99597. /**
  99598. * Observable triggered when this point is connected
  99599. */
  99600. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99601. /**
  99602. * Gets or sets the associated variable name in the shader
  99603. */
  99604. get associatedVariableName(): string;
  99605. set associatedVariableName(value: string);
  99606. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99607. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99608. /**
  99609. * Gets or sets the connection point type (default is float)
  99610. */
  99611. get type(): NodeMaterialBlockConnectionPointTypes;
  99612. set type(value: NodeMaterialBlockConnectionPointTypes);
  99613. /**
  99614. * Gets or sets the connection point name
  99615. */
  99616. name: string;
  99617. /**
  99618. * Gets or sets the connection point name
  99619. */
  99620. displayName: string;
  99621. /**
  99622. * Gets or sets a boolean indicating that this connection point can be omitted
  99623. */
  99624. isOptional: boolean;
  99625. /**
  99626. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99627. */
  99628. isExposedOnFrame: boolean;
  99629. /**
  99630. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99631. */
  99632. define: string;
  99633. /** @hidden */
  99634. _prioritizeVertex: boolean;
  99635. private _target;
  99636. /** Gets or sets the target of that connection point */
  99637. get target(): NodeMaterialBlockTargets;
  99638. set target(value: NodeMaterialBlockTargets);
  99639. /**
  99640. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99641. */
  99642. get isConnected(): boolean;
  99643. /**
  99644. * Gets a boolean indicating that the current point is connected to an input block
  99645. */
  99646. get isConnectedToInputBlock(): boolean;
  99647. /**
  99648. * Gets a the connected input block (if any)
  99649. */
  99650. get connectInputBlock(): Nullable<InputBlock>;
  99651. /** Get the other side of the connection (if any) */
  99652. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99653. /** Get the block that owns this connection point */
  99654. get ownerBlock(): NodeMaterialBlock;
  99655. /** Get the block connected on the other side of this connection (if any) */
  99656. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99657. /** Get the block connected on the endpoints of this connection (if any) */
  99658. get connectedBlocks(): Array<NodeMaterialBlock>;
  99659. /** Gets the list of connected endpoints */
  99660. get endpoints(): NodeMaterialConnectionPoint[];
  99661. /** Gets a boolean indicating if that output point is connected to at least one input */
  99662. get hasEndpoints(): boolean;
  99663. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99664. get isConnectedInVertexShader(): boolean;
  99665. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99666. get isConnectedInFragmentShader(): boolean;
  99667. /**
  99668. * Creates a block suitable to be used as an input for this input point.
  99669. * If null is returned, a block based on the point type will be created.
  99670. * @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
  99671. */
  99672. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99673. /**
  99674. * Creates a new connection point
  99675. * @param name defines the connection point name
  99676. * @param ownerBlock defines the block hosting this connection point
  99677. * @param direction defines the direction of the connection point
  99678. */
  99679. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99680. /**
  99681. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99682. * @returns the class name
  99683. */
  99684. getClassName(): string;
  99685. /**
  99686. * Gets a boolean indicating if the current point can be connected to another point
  99687. * @param connectionPoint defines the other connection point
  99688. * @returns a boolean
  99689. */
  99690. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99691. /**
  99692. * Gets a number indicating if the current point can be connected to another point
  99693. * @param connectionPoint defines the other connection point
  99694. * @returns a number defining the compatibility state
  99695. */
  99696. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99697. /**
  99698. * Connect this point to another connection point
  99699. * @param connectionPoint defines the other connection point
  99700. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99701. * @returns the current connection point
  99702. */
  99703. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99704. /**
  99705. * Disconnect this point from one of his endpoint
  99706. * @param endpoint defines the other connection point
  99707. * @returns the current connection point
  99708. */
  99709. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99710. /**
  99711. * Serializes this point in a JSON representation
  99712. * @param isInput defines if the connection point is an input (default is true)
  99713. * @returns the serialized point object
  99714. */
  99715. serialize(isInput?: boolean): any;
  99716. /**
  99717. * Release resources
  99718. */
  99719. dispose(): void;
  99720. }
  99721. }
  99722. declare module BABYLON {
  99723. /**
  99724. * Enum used to define the material modes
  99725. */
  99726. export enum NodeMaterialModes {
  99727. /** Regular material */
  99728. Material = 0,
  99729. /** For post process */
  99730. PostProcess = 1,
  99731. /** For particle system */
  99732. Particle = 2
  99733. }
  99734. }
  99735. declare module BABYLON {
  99736. /**
  99737. * Block used to read a texture from a sampler
  99738. */
  99739. export class TextureBlock extends NodeMaterialBlock {
  99740. private _defineName;
  99741. private _linearDefineName;
  99742. private _gammaDefineName;
  99743. private _tempTextureRead;
  99744. private _samplerName;
  99745. private _transformedUVName;
  99746. private _textureTransformName;
  99747. private _textureInfoName;
  99748. private _mainUVName;
  99749. private _mainUVDefineName;
  99750. private _fragmentOnly;
  99751. /**
  99752. * Gets or sets the texture associated with the node
  99753. */
  99754. texture: Nullable<Texture>;
  99755. /**
  99756. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99757. */
  99758. convertToGammaSpace: boolean;
  99759. /**
  99760. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99761. */
  99762. convertToLinearSpace: boolean;
  99763. /**
  99764. * Create a new TextureBlock
  99765. * @param name defines the block name
  99766. */
  99767. constructor(name: string, fragmentOnly?: boolean);
  99768. /**
  99769. * Gets the current class name
  99770. * @returns the class name
  99771. */
  99772. getClassName(): string;
  99773. /**
  99774. * Gets the uv input component
  99775. */
  99776. get uv(): NodeMaterialConnectionPoint;
  99777. /**
  99778. * Gets the rgba output component
  99779. */
  99780. get rgba(): NodeMaterialConnectionPoint;
  99781. /**
  99782. * Gets the rgb output component
  99783. */
  99784. get rgb(): NodeMaterialConnectionPoint;
  99785. /**
  99786. * Gets the r output component
  99787. */
  99788. get r(): NodeMaterialConnectionPoint;
  99789. /**
  99790. * Gets the g output component
  99791. */
  99792. get g(): NodeMaterialConnectionPoint;
  99793. /**
  99794. * Gets the b output component
  99795. */
  99796. get b(): NodeMaterialConnectionPoint;
  99797. /**
  99798. * Gets the a output component
  99799. */
  99800. get a(): NodeMaterialConnectionPoint;
  99801. get target(): NodeMaterialBlockTargets;
  99802. autoConfigure(material: NodeMaterial): void;
  99803. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99805. isReady(): boolean;
  99806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99807. private get _isMixed();
  99808. private _injectVertexCode;
  99809. private _writeTextureRead;
  99810. private _writeOutput;
  99811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99812. protected _dumpPropertiesCode(): string;
  99813. serialize(): any;
  99814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99815. }
  99816. }
  99817. declare module BABYLON {
  99818. /** @hidden */
  99819. export var reflectionFunction: {
  99820. name: string;
  99821. shader: string;
  99822. };
  99823. }
  99824. declare module BABYLON {
  99825. /**
  99826. * Base block used to read a reflection texture from a sampler
  99827. */
  99828. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99829. /** @hidden */
  99830. _define3DName: string;
  99831. /** @hidden */
  99832. _defineCubicName: string;
  99833. /** @hidden */
  99834. _defineExplicitName: string;
  99835. /** @hidden */
  99836. _defineProjectionName: string;
  99837. /** @hidden */
  99838. _defineLocalCubicName: string;
  99839. /** @hidden */
  99840. _defineSphericalName: string;
  99841. /** @hidden */
  99842. _definePlanarName: string;
  99843. /** @hidden */
  99844. _defineEquirectangularName: string;
  99845. /** @hidden */
  99846. _defineMirroredEquirectangularFixedName: string;
  99847. /** @hidden */
  99848. _defineEquirectangularFixedName: string;
  99849. /** @hidden */
  99850. _defineSkyboxName: string;
  99851. /** @hidden */
  99852. _defineOppositeZ: string;
  99853. /** @hidden */
  99854. _cubeSamplerName: string;
  99855. /** @hidden */
  99856. _2DSamplerName: string;
  99857. protected _positionUVWName: string;
  99858. protected _directionWName: string;
  99859. protected _reflectionVectorName: string;
  99860. /** @hidden */
  99861. _reflectionCoordsName: string;
  99862. /** @hidden */
  99863. _reflectionMatrixName: string;
  99864. protected _reflectionColorName: string;
  99865. /**
  99866. * Gets or sets the texture associated with the node
  99867. */
  99868. texture: Nullable<BaseTexture>;
  99869. /**
  99870. * Create a new ReflectionTextureBaseBlock
  99871. * @param name defines the block name
  99872. */
  99873. constructor(name: string);
  99874. /**
  99875. * Gets the current class name
  99876. * @returns the class name
  99877. */
  99878. getClassName(): string;
  99879. /**
  99880. * Gets the world position input component
  99881. */
  99882. abstract get position(): NodeMaterialConnectionPoint;
  99883. /**
  99884. * Gets the world position input component
  99885. */
  99886. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99887. /**
  99888. * Gets the world normal input component
  99889. */
  99890. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99891. /**
  99892. * Gets the world input component
  99893. */
  99894. abstract get world(): NodeMaterialConnectionPoint;
  99895. /**
  99896. * Gets the camera (or eye) position component
  99897. */
  99898. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99899. /**
  99900. * Gets the view input component
  99901. */
  99902. abstract get view(): NodeMaterialConnectionPoint;
  99903. protected _getTexture(): Nullable<BaseTexture>;
  99904. autoConfigure(material: NodeMaterial): void;
  99905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99906. isReady(): boolean;
  99907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99908. /**
  99909. * Gets the code to inject in the vertex shader
  99910. * @param state current state of the node material building
  99911. * @returns the shader code
  99912. */
  99913. handleVertexSide(state: NodeMaterialBuildState): string;
  99914. /**
  99915. * Handles the inits for the fragment code path
  99916. * @param state node material build state
  99917. */
  99918. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99919. /**
  99920. * Generates the reflection coords code for the fragment code path
  99921. * @param worldNormalVarName name of the world normal variable
  99922. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99923. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99924. * @returns the shader code
  99925. */
  99926. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99927. /**
  99928. * Generates the reflection color code for the fragment code path
  99929. * @param lodVarName name of the lod variable
  99930. * @param swizzleLookupTexture swizzle to use for the final color variable
  99931. * @returns the shader code
  99932. */
  99933. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99934. /**
  99935. * Generates the code corresponding to the connected output points
  99936. * @param state node material build state
  99937. * @param varName name of the variable to output
  99938. * @returns the shader code
  99939. */
  99940. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99941. protected _buildBlock(state: NodeMaterialBuildState): this;
  99942. protected _dumpPropertiesCode(): string;
  99943. serialize(): any;
  99944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99945. }
  99946. }
  99947. declare module BABYLON {
  99948. /**
  99949. * Defines a connection point to be used for points with a custom object type
  99950. */
  99951. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99952. private _blockType;
  99953. private _blockName;
  99954. private _nameForCheking?;
  99955. /**
  99956. * Creates a new connection point
  99957. * @param name defines the connection point name
  99958. * @param ownerBlock defines the block hosting this connection point
  99959. * @param direction defines the direction of the connection point
  99960. */
  99961. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99962. /**
  99963. * Gets a number indicating if the current point can be connected to another point
  99964. * @param connectionPoint defines the other connection point
  99965. * @returns a number defining the compatibility state
  99966. */
  99967. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99968. /**
  99969. * Creates a block suitable to be used as an input for this input point.
  99970. * If null is returned, a block based on the point type will be created.
  99971. * @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
  99972. */
  99973. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99974. }
  99975. }
  99976. declare module BABYLON {
  99977. /**
  99978. * Enum defining the type of properties that can be edited in the property pages in the NME
  99979. */
  99980. export enum PropertyTypeForEdition {
  99981. /** property is a boolean */
  99982. Boolean = 0,
  99983. /** property is a float */
  99984. Float = 1,
  99985. /** property is a Vector2 */
  99986. Vector2 = 2,
  99987. /** property is a list of values */
  99988. List = 3
  99989. }
  99990. /**
  99991. * Interface that defines an option in a variable of type list
  99992. */
  99993. export interface IEditablePropertyListOption {
  99994. /** label of the option */
  99995. "label": string;
  99996. /** value of the option */
  99997. "value": number;
  99998. }
  99999. /**
  100000. * Interface that defines the options available for an editable property
  100001. */
  100002. export interface IEditablePropertyOption {
  100003. /** min value */
  100004. "min"?: number;
  100005. /** max value */
  100006. "max"?: number;
  100007. /** notifiers: indicates which actions to take when the property is changed */
  100008. "notifiers"?: {
  100009. /** the material should be rebuilt */
  100010. "rebuild"?: boolean;
  100011. /** the preview should be updated */
  100012. "update"?: boolean;
  100013. };
  100014. /** list of the options for a variable of type list */
  100015. "options"?: IEditablePropertyListOption[];
  100016. }
  100017. /**
  100018. * Interface that describes an editable property
  100019. */
  100020. export interface IPropertyDescriptionForEdition {
  100021. /** name of the property */
  100022. "propertyName": string;
  100023. /** display name of the property */
  100024. "displayName": string;
  100025. /** type of the property */
  100026. "type": PropertyTypeForEdition;
  100027. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100028. "groupName": string;
  100029. /** options for the property */
  100030. "options": IEditablePropertyOption;
  100031. }
  100032. /**
  100033. * Decorator that flags a property in a node material block as being editable
  100034. */
  100035. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100036. }
  100037. declare module BABYLON {
  100038. /**
  100039. * Block used to implement the refraction part of the sub surface module of the PBR material
  100040. */
  100041. export class RefractionBlock extends NodeMaterialBlock {
  100042. /** @hidden */
  100043. _define3DName: string;
  100044. /** @hidden */
  100045. _refractionMatrixName: string;
  100046. /** @hidden */
  100047. _defineLODRefractionAlpha: string;
  100048. /** @hidden */
  100049. _defineLinearSpecularRefraction: string;
  100050. /** @hidden */
  100051. _defineOppositeZ: string;
  100052. /** @hidden */
  100053. _cubeSamplerName: string;
  100054. /** @hidden */
  100055. _2DSamplerName: string;
  100056. /** @hidden */
  100057. _vRefractionMicrosurfaceInfosName: string;
  100058. /** @hidden */
  100059. _vRefractionInfosName: string;
  100060. private _scene;
  100061. /**
  100062. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100063. * Materials half opaque for instance using refraction could benefit from this control.
  100064. */
  100065. linkRefractionWithTransparency: boolean;
  100066. /**
  100067. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100068. */
  100069. invertRefractionY: boolean;
  100070. /**
  100071. * Gets or sets the texture associated with the node
  100072. */
  100073. texture: Nullable<BaseTexture>;
  100074. /**
  100075. * Create a new RefractionBlock
  100076. * @param name defines the block name
  100077. */
  100078. constructor(name: string);
  100079. /**
  100080. * Gets the current class name
  100081. * @returns the class name
  100082. */
  100083. getClassName(): string;
  100084. /**
  100085. * Gets the intensity input component
  100086. */
  100087. get intensity(): NodeMaterialConnectionPoint;
  100088. /**
  100089. * Gets the index of refraction input component
  100090. */
  100091. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100092. /**
  100093. * Gets the tint at distance input component
  100094. */
  100095. get tintAtDistance(): NodeMaterialConnectionPoint;
  100096. /**
  100097. * Gets the view input component
  100098. */
  100099. get view(): NodeMaterialConnectionPoint;
  100100. /**
  100101. * Gets the refraction object output component
  100102. */
  100103. get refraction(): NodeMaterialConnectionPoint;
  100104. /**
  100105. * Returns true if the block has a texture
  100106. */
  100107. get hasTexture(): boolean;
  100108. protected _getTexture(): Nullable<BaseTexture>;
  100109. autoConfigure(material: NodeMaterial): void;
  100110. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100111. isReady(): boolean;
  100112. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100113. /**
  100114. * Gets the main code of the block (fragment side)
  100115. * @param state current state of the node material building
  100116. * @returns the shader code
  100117. */
  100118. getCode(state: NodeMaterialBuildState): string;
  100119. protected _buildBlock(state: NodeMaterialBuildState): this;
  100120. protected _dumpPropertiesCode(): string;
  100121. serialize(): any;
  100122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100123. }
  100124. }
  100125. declare module BABYLON {
  100126. /**
  100127. * Base block used as input for post process
  100128. */
  100129. export class CurrentScreenBlock extends NodeMaterialBlock {
  100130. private _samplerName;
  100131. private _linearDefineName;
  100132. private _gammaDefineName;
  100133. private _mainUVName;
  100134. private _tempTextureRead;
  100135. /**
  100136. * Gets or sets the texture associated with the node
  100137. */
  100138. texture: Nullable<BaseTexture>;
  100139. /**
  100140. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100141. */
  100142. convertToGammaSpace: boolean;
  100143. /**
  100144. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100145. */
  100146. convertToLinearSpace: boolean;
  100147. /**
  100148. * Create a new CurrentScreenBlock
  100149. * @param name defines the block name
  100150. */
  100151. constructor(name: string);
  100152. /**
  100153. * Gets the current class name
  100154. * @returns the class name
  100155. */
  100156. getClassName(): string;
  100157. /**
  100158. * Gets the uv input component
  100159. */
  100160. get uv(): NodeMaterialConnectionPoint;
  100161. /**
  100162. * Gets the rgba output component
  100163. */
  100164. get rgba(): NodeMaterialConnectionPoint;
  100165. /**
  100166. * Gets the rgb output component
  100167. */
  100168. get rgb(): NodeMaterialConnectionPoint;
  100169. /**
  100170. * Gets the r output component
  100171. */
  100172. get r(): NodeMaterialConnectionPoint;
  100173. /**
  100174. * Gets the g output component
  100175. */
  100176. get g(): NodeMaterialConnectionPoint;
  100177. /**
  100178. * Gets the b output component
  100179. */
  100180. get b(): NodeMaterialConnectionPoint;
  100181. /**
  100182. * Gets the a output component
  100183. */
  100184. get a(): NodeMaterialConnectionPoint;
  100185. /**
  100186. * Initialize the block and prepare the context for build
  100187. * @param state defines the state that will be used for the build
  100188. */
  100189. initialize(state: NodeMaterialBuildState): void;
  100190. get target(): NodeMaterialBlockTargets;
  100191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100192. isReady(): boolean;
  100193. private _injectVertexCode;
  100194. private _writeTextureRead;
  100195. private _writeOutput;
  100196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100197. serialize(): any;
  100198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100199. }
  100200. }
  100201. declare module BABYLON {
  100202. /**
  100203. * Base block used for the particle texture
  100204. */
  100205. export class ParticleTextureBlock extends NodeMaterialBlock {
  100206. private _samplerName;
  100207. private _linearDefineName;
  100208. private _gammaDefineName;
  100209. private _tempTextureRead;
  100210. /**
  100211. * Gets or sets the texture associated with the node
  100212. */
  100213. texture: Nullable<BaseTexture>;
  100214. /**
  100215. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100216. */
  100217. convertToGammaSpace: boolean;
  100218. /**
  100219. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100220. */
  100221. convertToLinearSpace: boolean;
  100222. /**
  100223. * Create a new ParticleTextureBlock
  100224. * @param name defines the block name
  100225. */
  100226. constructor(name: string);
  100227. /**
  100228. * Gets the current class name
  100229. * @returns the class name
  100230. */
  100231. getClassName(): string;
  100232. /**
  100233. * Gets the uv input component
  100234. */
  100235. get uv(): NodeMaterialConnectionPoint;
  100236. /**
  100237. * Gets the rgba output component
  100238. */
  100239. get rgba(): NodeMaterialConnectionPoint;
  100240. /**
  100241. * Gets the rgb output component
  100242. */
  100243. get rgb(): NodeMaterialConnectionPoint;
  100244. /**
  100245. * Gets the r output component
  100246. */
  100247. get r(): NodeMaterialConnectionPoint;
  100248. /**
  100249. * Gets the g output component
  100250. */
  100251. get g(): NodeMaterialConnectionPoint;
  100252. /**
  100253. * Gets the b output component
  100254. */
  100255. get b(): NodeMaterialConnectionPoint;
  100256. /**
  100257. * Gets the a output component
  100258. */
  100259. get a(): NodeMaterialConnectionPoint;
  100260. /**
  100261. * Initialize the block and prepare the context for build
  100262. * @param state defines the state that will be used for the build
  100263. */
  100264. initialize(state: NodeMaterialBuildState): void;
  100265. autoConfigure(material: NodeMaterial): void;
  100266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100267. isReady(): boolean;
  100268. private _writeOutput;
  100269. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100270. serialize(): any;
  100271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100272. }
  100273. }
  100274. declare module BABYLON {
  100275. /**
  100276. * Class used to store shared data between 2 NodeMaterialBuildState
  100277. */
  100278. export class NodeMaterialBuildStateSharedData {
  100279. /**
  100280. * Gets the list of emitted varyings
  100281. */
  100282. temps: string[];
  100283. /**
  100284. * Gets the list of emitted varyings
  100285. */
  100286. varyings: string[];
  100287. /**
  100288. * Gets the varying declaration string
  100289. */
  100290. varyingDeclaration: string;
  100291. /**
  100292. * Input blocks
  100293. */
  100294. inputBlocks: InputBlock[];
  100295. /**
  100296. * Input blocks
  100297. */
  100298. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100299. /**
  100300. * Bindable blocks (Blocks that need to set data to the effect)
  100301. */
  100302. bindableBlocks: NodeMaterialBlock[];
  100303. /**
  100304. * List of blocks that can provide a compilation fallback
  100305. */
  100306. blocksWithFallbacks: NodeMaterialBlock[];
  100307. /**
  100308. * List of blocks that can provide a define update
  100309. */
  100310. blocksWithDefines: NodeMaterialBlock[];
  100311. /**
  100312. * List of blocks that can provide a repeatable content
  100313. */
  100314. repeatableContentBlocks: NodeMaterialBlock[];
  100315. /**
  100316. * List of blocks that can provide a dynamic list of uniforms
  100317. */
  100318. dynamicUniformBlocks: NodeMaterialBlock[];
  100319. /**
  100320. * List of blocks that can block the isReady function for the material
  100321. */
  100322. blockingBlocks: NodeMaterialBlock[];
  100323. /**
  100324. * Gets the list of animated inputs
  100325. */
  100326. animatedInputs: InputBlock[];
  100327. /**
  100328. * Build Id used to avoid multiple recompilations
  100329. */
  100330. buildId: number;
  100331. /** List of emitted variables */
  100332. variableNames: {
  100333. [key: string]: number;
  100334. };
  100335. /** List of emitted defines */
  100336. defineNames: {
  100337. [key: string]: number;
  100338. };
  100339. /** Should emit comments? */
  100340. emitComments: boolean;
  100341. /** Emit build activity */
  100342. verbose: boolean;
  100343. /** Gets or sets the hosting scene */
  100344. scene: Scene;
  100345. /**
  100346. * Gets the compilation hints emitted at compilation time
  100347. */
  100348. hints: {
  100349. needWorldViewMatrix: boolean;
  100350. needWorldViewProjectionMatrix: boolean;
  100351. needAlphaBlending: boolean;
  100352. needAlphaTesting: boolean;
  100353. };
  100354. /**
  100355. * List of compilation checks
  100356. */
  100357. checks: {
  100358. emitVertex: boolean;
  100359. emitFragment: boolean;
  100360. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100361. };
  100362. /**
  100363. * Is vertex program allowed to be empty?
  100364. */
  100365. allowEmptyVertexProgram: boolean;
  100366. /** Creates a new shared data */
  100367. constructor();
  100368. /**
  100369. * Emits console errors and exceptions if there is a failing check
  100370. */
  100371. emitErrors(): void;
  100372. }
  100373. }
  100374. declare module BABYLON {
  100375. /**
  100376. * Class used to store node based material build state
  100377. */
  100378. export class NodeMaterialBuildState {
  100379. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100380. supportUniformBuffers: boolean;
  100381. /**
  100382. * Gets the list of emitted attributes
  100383. */
  100384. attributes: string[];
  100385. /**
  100386. * Gets the list of emitted uniforms
  100387. */
  100388. uniforms: string[];
  100389. /**
  100390. * Gets the list of emitted constants
  100391. */
  100392. constants: string[];
  100393. /**
  100394. * Gets the list of emitted samplers
  100395. */
  100396. samplers: string[];
  100397. /**
  100398. * Gets the list of emitted functions
  100399. */
  100400. functions: {
  100401. [key: string]: string;
  100402. };
  100403. /**
  100404. * Gets the list of emitted extensions
  100405. */
  100406. extensions: {
  100407. [key: string]: string;
  100408. };
  100409. /**
  100410. * Gets the target of the compilation state
  100411. */
  100412. target: NodeMaterialBlockTargets;
  100413. /**
  100414. * Gets the list of emitted counters
  100415. */
  100416. counters: {
  100417. [key: string]: number;
  100418. };
  100419. /**
  100420. * Shared data between multiple NodeMaterialBuildState instances
  100421. */
  100422. sharedData: NodeMaterialBuildStateSharedData;
  100423. /** @hidden */
  100424. _vertexState: NodeMaterialBuildState;
  100425. /** @hidden */
  100426. _attributeDeclaration: string;
  100427. /** @hidden */
  100428. _uniformDeclaration: string;
  100429. /** @hidden */
  100430. _constantDeclaration: string;
  100431. /** @hidden */
  100432. _samplerDeclaration: string;
  100433. /** @hidden */
  100434. _varyingTransfer: string;
  100435. /** @hidden */
  100436. _injectAtEnd: string;
  100437. private _repeatableContentAnchorIndex;
  100438. /** @hidden */
  100439. _builtCompilationString: string;
  100440. /**
  100441. * Gets the emitted compilation strings
  100442. */
  100443. compilationString: string;
  100444. /**
  100445. * Finalize the compilation strings
  100446. * @param state defines the current compilation state
  100447. */
  100448. finalize(state: NodeMaterialBuildState): void;
  100449. /** @hidden */
  100450. get _repeatableContentAnchor(): string;
  100451. /** @hidden */
  100452. _getFreeVariableName(prefix: string): string;
  100453. /** @hidden */
  100454. _getFreeDefineName(prefix: string): string;
  100455. /** @hidden */
  100456. _excludeVariableName(name: string): void;
  100457. /** @hidden */
  100458. _emit2DSampler(name: string): void;
  100459. /** @hidden */
  100460. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100461. /** @hidden */
  100462. _emitExtension(name: string, extension: string, define?: string): void;
  100463. /** @hidden */
  100464. _emitFunction(name: string, code: string, comments: string): void;
  100465. /** @hidden */
  100466. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100467. replaceStrings?: {
  100468. search: RegExp;
  100469. replace: string;
  100470. }[];
  100471. repeatKey?: string;
  100472. }): string;
  100473. /** @hidden */
  100474. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100475. repeatKey?: string;
  100476. removeAttributes?: boolean;
  100477. removeUniforms?: boolean;
  100478. removeVaryings?: boolean;
  100479. removeIfDef?: boolean;
  100480. replaceStrings?: {
  100481. search: RegExp;
  100482. replace: string;
  100483. }[];
  100484. }, storeKey?: string): void;
  100485. /** @hidden */
  100486. _registerTempVariable(name: string): boolean;
  100487. /** @hidden */
  100488. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100489. /** @hidden */
  100490. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100491. /** @hidden */
  100492. _emitFloat(value: number): string;
  100493. }
  100494. }
  100495. declare module BABYLON {
  100496. /**
  100497. * Helper class used to generate session unique ID
  100498. */
  100499. export class UniqueIdGenerator {
  100500. private static _UniqueIdCounter;
  100501. /**
  100502. * Gets an unique (relatively to the current scene) Id
  100503. */
  100504. static get UniqueId(): number;
  100505. }
  100506. }
  100507. declare module BABYLON {
  100508. /**
  100509. * Defines a block that can be used inside a node based material
  100510. */
  100511. export class NodeMaterialBlock {
  100512. private _buildId;
  100513. private _buildTarget;
  100514. private _target;
  100515. private _isFinalMerger;
  100516. private _isInput;
  100517. private _name;
  100518. protected _isUnique: boolean;
  100519. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100520. inputsAreExclusive: boolean;
  100521. /** @hidden */
  100522. _codeVariableName: string;
  100523. /** @hidden */
  100524. _inputs: NodeMaterialConnectionPoint[];
  100525. /** @hidden */
  100526. _outputs: NodeMaterialConnectionPoint[];
  100527. /** @hidden */
  100528. _preparationId: number;
  100529. /**
  100530. * Gets the name of the block
  100531. */
  100532. get name(): string;
  100533. /**
  100534. * Sets the name of the block. Will check if the name is valid.
  100535. */
  100536. set name(newName: string);
  100537. /**
  100538. * Gets or sets the unique id of the node
  100539. */
  100540. uniqueId: number;
  100541. /**
  100542. * Gets or sets the comments associated with this block
  100543. */
  100544. comments: string;
  100545. /**
  100546. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100547. */
  100548. get isUnique(): boolean;
  100549. /**
  100550. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100551. */
  100552. get isFinalMerger(): boolean;
  100553. /**
  100554. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100555. */
  100556. get isInput(): boolean;
  100557. /**
  100558. * Gets or sets the build Id
  100559. */
  100560. get buildId(): number;
  100561. set buildId(value: number);
  100562. /**
  100563. * Gets or sets the target of the block
  100564. */
  100565. get target(): NodeMaterialBlockTargets;
  100566. set target(value: NodeMaterialBlockTargets);
  100567. /**
  100568. * Gets the list of input points
  100569. */
  100570. get inputs(): NodeMaterialConnectionPoint[];
  100571. /** Gets the list of output points */
  100572. get outputs(): NodeMaterialConnectionPoint[];
  100573. /**
  100574. * Find an input by its name
  100575. * @param name defines the name of the input to look for
  100576. * @returns the input or null if not found
  100577. */
  100578. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100579. /**
  100580. * Find an output by its name
  100581. * @param name defines the name of the outputto look for
  100582. * @returns the output or null if not found
  100583. */
  100584. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100585. /**
  100586. * Creates a new NodeMaterialBlock
  100587. * @param name defines the block name
  100588. * @param target defines the target of that block (Vertex by default)
  100589. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100590. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100591. */
  100592. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100593. /**
  100594. * Initialize the block and prepare the context for build
  100595. * @param state defines the state that will be used for the build
  100596. */
  100597. initialize(state: NodeMaterialBuildState): void;
  100598. /**
  100599. * Bind data to effect. Will only be called for blocks with isBindable === true
  100600. * @param effect defines the effect to bind data to
  100601. * @param nodeMaterial defines the hosting NodeMaterial
  100602. * @param mesh defines the mesh that will be rendered
  100603. * @param subMesh defines the submesh that will be rendered
  100604. */
  100605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100606. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100607. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100608. protected _writeFloat(value: number): string;
  100609. /**
  100610. * Gets the current class name e.g. "NodeMaterialBlock"
  100611. * @returns the class name
  100612. */
  100613. getClassName(): string;
  100614. /**
  100615. * Register a new input. Must be called inside a block constructor
  100616. * @param name defines the connection point name
  100617. * @param type defines the connection point type
  100618. * @param isOptional defines a boolean indicating that this input can be omitted
  100619. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100620. * @param point an already created connection point. If not provided, create a new one
  100621. * @returns the current block
  100622. */
  100623. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100624. /**
  100625. * Register a new output. Must be called inside a block constructor
  100626. * @param name defines the connection point name
  100627. * @param type defines the connection point type
  100628. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100629. * @param point an already created connection point. If not provided, create a new one
  100630. * @returns the current block
  100631. */
  100632. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100633. /**
  100634. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100635. * @param forOutput defines an optional connection point to check compatibility with
  100636. * @returns the first available input or null
  100637. */
  100638. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100639. /**
  100640. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100641. * @param forBlock defines an optional block to check compatibility with
  100642. * @returns the first available input or null
  100643. */
  100644. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100645. /**
  100646. * Gets the sibling of the given output
  100647. * @param current defines the current output
  100648. * @returns the next output in the list or null
  100649. */
  100650. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100651. /**
  100652. * Connect current block with another block
  100653. * @param other defines the block to connect with
  100654. * @param options define the various options to help pick the right connections
  100655. * @returns the current block
  100656. */
  100657. connectTo(other: NodeMaterialBlock, options?: {
  100658. input?: string;
  100659. output?: string;
  100660. outputSwizzle?: string;
  100661. }): this | undefined;
  100662. protected _buildBlock(state: NodeMaterialBuildState): void;
  100663. /**
  100664. * Add uniforms, samplers and uniform buffers at compilation time
  100665. * @param state defines the state to update
  100666. * @param nodeMaterial defines the node material requesting the update
  100667. * @param defines defines the material defines to update
  100668. * @param uniformBuffers defines the list of uniform buffer names
  100669. */
  100670. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100671. /**
  100672. * Add potential fallbacks if shader compilation fails
  100673. * @param mesh defines the mesh to be rendered
  100674. * @param fallbacks defines the current prioritized list of fallbacks
  100675. */
  100676. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100677. /**
  100678. * Initialize defines for shader compilation
  100679. * @param mesh defines the mesh to be rendered
  100680. * @param nodeMaterial defines the node material requesting the update
  100681. * @param defines defines the material defines to update
  100682. * @param useInstances specifies that instances should be used
  100683. */
  100684. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100685. /**
  100686. * Update defines for shader compilation
  100687. * @param mesh defines the mesh to be rendered
  100688. * @param nodeMaterial defines the node material requesting the update
  100689. * @param defines defines the material defines to update
  100690. * @param useInstances specifies that instances should be used
  100691. * @param subMesh defines which submesh to render
  100692. */
  100693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100694. /**
  100695. * Lets the block try to connect some inputs automatically
  100696. * @param material defines the hosting NodeMaterial
  100697. */
  100698. autoConfigure(material: NodeMaterial): void;
  100699. /**
  100700. * Function called when a block is declared as repeatable content generator
  100701. * @param vertexShaderState defines the current compilation state for the vertex shader
  100702. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100703. * @param mesh defines the mesh to be rendered
  100704. * @param defines defines the material defines to update
  100705. */
  100706. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100707. /**
  100708. * Checks if the block is ready
  100709. * @param mesh defines the mesh to be rendered
  100710. * @param nodeMaterial defines the node material requesting the update
  100711. * @param defines defines the material defines to update
  100712. * @param useInstances specifies that instances should be used
  100713. * @returns true if the block is ready
  100714. */
  100715. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100716. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100717. private _processBuild;
  100718. /**
  100719. * Validates the new name for the block node.
  100720. * @param newName the new name to be given to the node.
  100721. * @returns false if the name is a reserve word, else true.
  100722. */
  100723. validateBlockName(newName: string): boolean;
  100724. /**
  100725. * Compile the current node and generate the shader code
  100726. * @param state defines the current compilation state (uniforms, samplers, current string)
  100727. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100728. * @returns true if already built
  100729. */
  100730. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100731. protected _inputRename(name: string): string;
  100732. protected _outputRename(name: string): string;
  100733. protected _dumpPropertiesCode(): string;
  100734. /** @hidden */
  100735. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100736. /** @hidden */
  100737. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100738. /**
  100739. * Clone the current block to a new identical block
  100740. * @param scene defines the hosting scene
  100741. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100742. * @returns a copy of the current block
  100743. */
  100744. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100745. /**
  100746. * Serializes this block in a JSON representation
  100747. * @returns the serialized block object
  100748. */
  100749. serialize(): any;
  100750. /** @hidden */
  100751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100752. private _deserializePortDisplayNamesAndExposedOnFrame;
  100753. /**
  100754. * Release resources
  100755. */
  100756. dispose(): void;
  100757. }
  100758. }
  100759. declare module BABYLON {
  100760. /**
  100761. * Base class of materials working in push mode in babylon JS
  100762. * @hidden
  100763. */
  100764. export class PushMaterial extends Material {
  100765. protected _activeEffect: Effect;
  100766. protected _normalMatrix: Matrix;
  100767. constructor(name: string, scene: Scene);
  100768. getEffect(): Effect;
  100769. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100770. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100771. /**
  100772. * Binds the given world matrix to the active effect
  100773. *
  100774. * @param world the matrix to bind
  100775. */
  100776. bindOnlyWorldMatrix(world: Matrix): void;
  100777. /**
  100778. * Binds the given normal matrix to the active effect
  100779. *
  100780. * @param normalMatrix the matrix to bind
  100781. */
  100782. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100783. bind(world: Matrix, mesh?: Mesh): void;
  100784. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100785. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100786. }
  100787. }
  100788. declare module BABYLON {
  100789. /**
  100790. * Root class for all node material optimizers
  100791. */
  100792. export class NodeMaterialOptimizer {
  100793. /**
  100794. * Function used to optimize a NodeMaterial graph
  100795. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100796. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100797. */
  100798. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100799. }
  100800. }
  100801. declare module BABYLON {
  100802. /**
  100803. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100804. */
  100805. export class TransformBlock extends NodeMaterialBlock {
  100806. /**
  100807. * Defines the value to use to complement W value to transform it to a Vector4
  100808. */
  100809. complementW: number;
  100810. /**
  100811. * Defines the value to use to complement z value to transform it to a Vector4
  100812. */
  100813. complementZ: number;
  100814. /**
  100815. * Creates a new TransformBlock
  100816. * @param name defines the block name
  100817. */
  100818. constructor(name: string);
  100819. /**
  100820. * Gets the current class name
  100821. * @returns the class name
  100822. */
  100823. getClassName(): string;
  100824. /**
  100825. * Gets the vector input
  100826. */
  100827. get vector(): NodeMaterialConnectionPoint;
  100828. /**
  100829. * Gets the output component
  100830. */
  100831. get output(): NodeMaterialConnectionPoint;
  100832. /**
  100833. * Gets the xyz output component
  100834. */
  100835. get xyz(): NodeMaterialConnectionPoint;
  100836. /**
  100837. * Gets the matrix transform input
  100838. */
  100839. get transform(): NodeMaterialConnectionPoint;
  100840. protected _buildBlock(state: NodeMaterialBuildState): this;
  100841. /**
  100842. * Update defines for shader compilation
  100843. * @param mesh defines the mesh to be rendered
  100844. * @param nodeMaterial defines the node material requesting the update
  100845. * @param defines defines the material defines to update
  100846. * @param useInstances specifies that instances should be used
  100847. * @param subMesh defines which submesh to render
  100848. */
  100849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100850. serialize(): any;
  100851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100852. protected _dumpPropertiesCode(): string;
  100853. }
  100854. }
  100855. declare module BABYLON {
  100856. /**
  100857. * Block used to output the vertex position
  100858. */
  100859. export class VertexOutputBlock extends NodeMaterialBlock {
  100860. /**
  100861. * Creates a new VertexOutputBlock
  100862. * @param name defines the block name
  100863. */
  100864. constructor(name: string);
  100865. /**
  100866. * Gets the current class name
  100867. * @returns the class name
  100868. */
  100869. getClassName(): string;
  100870. /**
  100871. * Gets the vector input component
  100872. */
  100873. get vector(): NodeMaterialConnectionPoint;
  100874. protected _buildBlock(state: NodeMaterialBuildState): this;
  100875. }
  100876. }
  100877. declare module BABYLON {
  100878. /**
  100879. * Block used to output the final color
  100880. */
  100881. export class FragmentOutputBlock extends NodeMaterialBlock {
  100882. /**
  100883. * Create a new FragmentOutputBlock
  100884. * @param name defines the block name
  100885. */
  100886. constructor(name: string);
  100887. /**
  100888. * Gets the current class name
  100889. * @returns the class name
  100890. */
  100891. getClassName(): string;
  100892. /**
  100893. * Gets the rgba input component
  100894. */
  100895. get rgba(): NodeMaterialConnectionPoint;
  100896. /**
  100897. * Gets the rgb input component
  100898. */
  100899. get rgb(): NodeMaterialConnectionPoint;
  100900. /**
  100901. * Gets the a input component
  100902. */
  100903. get a(): NodeMaterialConnectionPoint;
  100904. protected _buildBlock(state: NodeMaterialBuildState): this;
  100905. }
  100906. }
  100907. declare module BABYLON {
  100908. /**
  100909. * Block used for the particle ramp gradient section
  100910. */
  100911. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100912. /**
  100913. * Create a new ParticleRampGradientBlock
  100914. * @param name defines the block name
  100915. */
  100916. constructor(name: string);
  100917. /**
  100918. * Gets the current class name
  100919. * @returns the class name
  100920. */
  100921. getClassName(): string;
  100922. /**
  100923. * Gets the color input component
  100924. */
  100925. get color(): NodeMaterialConnectionPoint;
  100926. /**
  100927. * Gets the rampColor output component
  100928. */
  100929. get rampColor(): NodeMaterialConnectionPoint;
  100930. /**
  100931. * Initialize the block and prepare the context for build
  100932. * @param state defines the state that will be used for the build
  100933. */
  100934. initialize(state: NodeMaterialBuildState): void;
  100935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100936. }
  100937. }
  100938. declare module BABYLON {
  100939. /**
  100940. * Block used for the particle blend multiply section
  100941. */
  100942. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100943. /**
  100944. * Create a new ParticleBlendMultiplyBlock
  100945. * @param name defines the block name
  100946. */
  100947. constructor(name: string);
  100948. /**
  100949. * Gets the current class name
  100950. * @returns the class name
  100951. */
  100952. getClassName(): string;
  100953. /**
  100954. * Gets the color input component
  100955. */
  100956. get color(): NodeMaterialConnectionPoint;
  100957. /**
  100958. * Gets the alphaTexture input component
  100959. */
  100960. get alphaTexture(): NodeMaterialConnectionPoint;
  100961. /**
  100962. * Gets the alphaColor input component
  100963. */
  100964. get alphaColor(): NodeMaterialConnectionPoint;
  100965. /**
  100966. * Gets the blendColor output component
  100967. */
  100968. get blendColor(): NodeMaterialConnectionPoint;
  100969. /**
  100970. * Initialize the block and prepare the context for build
  100971. * @param state defines the state that will be used for the build
  100972. */
  100973. initialize(state: NodeMaterialBuildState): void;
  100974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100975. }
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100980. */
  100981. export class VectorMergerBlock extends NodeMaterialBlock {
  100982. /**
  100983. * Create a new VectorMergerBlock
  100984. * @param name defines the block name
  100985. */
  100986. constructor(name: string);
  100987. /**
  100988. * Gets the current class name
  100989. * @returns the class name
  100990. */
  100991. getClassName(): string;
  100992. /**
  100993. * Gets the xyz component (input)
  100994. */
  100995. get xyzIn(): NodeMaterialConnectionPoint;
  100996. /**
  100997. * Gets the xy component (input)
  100998. */
  100999. get xyIn(): NodeMaterialConnectionPoint;
  101000. /**
  101001. * Gets the x component (input)
  101002. */
  101003. get x(): NodeMaterialConnectionPoint;
  101004. /**
  101005. * Gets the y component (input)
  101006. */
  101007. get y(): NodeMaterialConnectionPoint;
  101008. /**
  101009. * Gets the z component (input)
  101010. */
  101011. get z(): NodeMaterialConnectionPoint;
  101012. /**
  101013. * Gets the w component (input)
  101014. */
  101015. get w(): NodeMaterialConnectionPoint;
  101016. /**
  101017. * Gets the xyzw component (output)
  101018. */
  101019. get xyzw(): NodeMaterialConnectionPoint;
  101020. /**
  101021. * Gets the xyz component (output)
  101022. */
  101023. get xyzOut(): NodeMaterialConnectionPoint;
  101024. /**
  101025. * Gets the xy component (output)
  101026. */
  101027. get xyOut(): NodeMaterialConnectionPoint;
  101028. /**
  101029. * Gets the xy component (output)
  101030. * @deprecated Please use xyOut instead.
  101031. */
  101032. get xy(): NodeMaterialConnectionPoint;
  101033. /**
  101034. * Gets the xyz component (output)
  101035. * @deprecated Please use xyzOut instead.
  101036. */
  101037. get xyz(): NodeMaterialConnectionPoint;
  101038. protected _buildBlock(state: NodeMaterialBuildState): this;
  101039. }
  101040. }
  101041. declare module BABYLON {
  101042. /**
  101043. * Block used to remap a float from a range to a new one
  101044. */
  101045. export class RemapBlock extends NodeMaterialBlock {
  101046. /**
  101047. * Gets or sets the source range
  101048. */
  101049. sourceRange: Vector2;
  101050. /**
  101051. * Gets or sets the target range
  101052. */
  101053. targetRange: Vector2;
  101054. /**
  101055. * Creates a new RemapBlock
  101056. * @param name defines the block name
  101057. */
  101058. constructor(name: string);
  101059. /**
  101060. * Gets the current class name
  101061. * @returns the class name
  101062. */
  101063. getClassName(): string;
  101064. /**
  101065. * Gets the input component
  101066. */
  101067. get input(): NodeMaterialConnectionPoint;
  101068. /**
  101069. * Gets the source min input component
  101070. */
  101071. get sourceMin(): NodeMaterialConnectionPoint;
  101072. /**
  101073. * Gets the source max input component
  101074. */
  101075. get sourceMax(): NodeMaterialConnectionPoint;
  101076. /**
  101077. * Gets the target min input component
  101078. */
  101079. get targetMin(): NodeMaterialConnectionPoint;
  101080. /**
  101081. * Gets the target max input component
  101082. */
  101083. get targetMax(): NodeMaterialConnectionPoint;
  101084. /**
  101085. * Gets the output component
  101086. */
  101087. get output(): NodeMaterialConnectionPoint;
  101088. protected _buildBlock(state: NodeMaterialBuildState): this;
  101089. protected _dumpPropertiesCode(): string;
  101090. serialize(): any;
  101091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101092. }
  101093. }
  101094. declare module BABYLON {
  101095. /**
  101096. * Block used to multiply 2 values
  101097. */
  101098. export class MultiplyBlock extends NodeMaterialBlock {
  101099. /**
  101100. * Creates a new MultiplyBlock
  101101. * @param name defines the block name
  101102. */
  101103. constructor(name: string);
  101104. /**
  101105. * Gets the current class name
  101106. * @returns the class name
  101107. */
  101108. getClassName(): string;
  101109. /**
  101110. * Gets the left operand input component
  101111. */
  101112. get left(): NodeMaterialConnectionPoint;
  101113. /**
  101114. * Gets the right operand input component
  101115. */
  101116. get right(): NodeMaterialConnectionPoint;
  101117. /**
  101118. * Gets the output component
  101119. */
  101120. get output(): NodeMaterialConnectionPoint;
  101121. protected _buildBlock(state: NodeMaterialBuildState): this;
  101122. }
  101123. }
  101124. declare module BABYLON {
  101125. /**
  101126. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101127. */
  101128. export class ColorSplitterBlock extends NodeMaterialBlock {
  101129. /**
  101130. * Create a new ColorSplitterBlock
  101131. * @param name defines the block name
  101132. */
  101133. constructor(name: string);
  101134. /**
  101135. * Gets the current class name
  101136. * @returns the class name
  101137. */
  101138. getClassName(): string;
  101139. /**
  101140. * Gets the rgba component (input)
  101141. */
  101142. get rgba(): NodeMaterialConnectionPoint;
  101143. /**
  101144. * Gets the rgb component (input)
  101145. */
  101146. get rgbIn(): NodeMaterialConnectionPoint;
  101147. /**
  101148. * Gets the rgb component (output)
  101149. */
  101150. get rgbOut(): NodeMaterialConnectionPoint;
  101151. /**
  101152. * Gets the r component (output)
  101153. */
  101154. get r(): NodeMaterialConnectionPoint;
  101155. /**
  101156. * Gets the g component (output)
  101157. */
  101158. get g(): NodeMaterialConnectionPoint;
  101159. /**
  101160. * Gets the b component (output)
  101161. */
  101162. get b(): NodeMaterialConnectionPoint;
  101163. /**
  101164. * Gets the a component (output)
  101165. */
  101166. get a(): NodeMaterialConnectionPoint;
  101167. protected _inputRename(name: string): string;
  101168. protected _outputRename(name: string): string;
  101169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101170. }
  101171. }
  101172. declare module BABYLON {
  101173. /**
  101174. * Interface used to configure the node material editor
  101175. */
  101176. export interface INodeMaterialEditorOptions {
  101177. /** Define the URl to load node editor script */
  101178. editorURL?: string;
  101179. }
  101180. /** @hidden */
  101181. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101182. NORMAL: boolean;
  101183. TANGENT: boolean;
  101184. UV1: boolean;
  101185. /** BONES */
  101186. NUM_BONE_INFLUENCERS: number;
  101187. BonesPerMesh: number;
  101188. BONETEXTURE: boolean;
  101189. /** MORPH TARGETS */
  101190. MORPHTARGETS: boolean;
  101191. MORPHTARGETS_NORMAL: boolean;
  101192. MORPHTARGETS_TANGENT: boolean;
  101193. MORPHTARGETS_UV: boolean;
  101194. NUM_MORPH_INFLUENCERS: number;
  101195. /** IMAGE PROCESSING */
  101196. IMAGEPROCESSING: boolean;
  101197. VIGNETTE: boolean;
  101198. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101199. VIGNETTEBLENDMODEOPAQUE: boolean;
  101200. TONEMAPPING: boolean;
  101201. TONEMAPPING_ACES: boolean;
  101202. CONTRAST: boolean;
  101203. EXPOSURE: boolean;
  101204. COLORCURVES: boolean;
  101205. COLORGRADING: boolean;
  101206. COLORGRADING3D: boolean;
  101207. SAMPLER3DGREENDEPTH: boolean;
  101208. SAMPLER3DBGRMAP: boolean;
  101209. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101210. /** MISC. */
  101211. BUMPDIRECTUV: number;
  101212. constructor();
  101213. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101214. }
  101215. /**
  101216. * Class used to configure NodeMaterial
  101217. */
  101218. export interface INodeMaterialOptions {
  101219. /**
  101220. * Defines if blocks should emit comments
  101221. */
  101222. emitComments: boolean;
  101223. }
  101224. /**
  101225. * Class used to create a node based material built by assembling shader blocks
  101226. */
  101227. export class NodeMaterial extends PushMaterial {
  101228. private static _BuildIdGenerator;
  101229. private _options;
  101230. private _vertexCompilationState;
  101231. private _fragmentCompilationState;
  101232. private _sharedData;
  101233. private _buildId;
  101234. private _buildWasSuccessful;
  101235. private _cachedWorldViewMatrix;
  101236. private _cachedWorldViewProjectionMatrix;
  101237. private _optimizers;
  101238. private _animationFrame;
  101239. /** Define the Url to load node editor script */
  101240. static EditorURL: string;
  101241. /** Define the Url to load snippets */
  101242. static SnippetUrl: string;
  101243. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101244. static IgnoreTexturesAtLoadTime: boolean;
  101245. private BJSNODEMATERIALEDITOR;
  101246. /** Get the inspector from bundle or global */
  101247. private _getGlobalNodeMaterialEditor;
  101248. /**
  101249. * Snippet ID if the material was created from the snippet server
  101250. */
  101251. snippetId: string;
  101252. /**
  101253. * Gets or sets data used by visual editor
  101254. * @see https://nme.babylonjs.com
  101255. */
  101256. editorData: any;
  101257. /**
  101258. * 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)
  101259. */
  101260. ignoreAlpha: boolean;
  101261. /**
  101262. * Defines the maximum number of lights that can be used in the material
  101263. */
  101264. maxSimultaneousLights: number;
  101265. /**
  101266. * Observable raised when the material is built
  101267. */
  101268. onBuildObservable: Observable<NodeMaterial>;
  101269. /**
  101270. * Gets or sets the root nodes of the material vertex shader
  101271. */
  101272. _vertexOutputNodes: NodeMaterialBlock[];
  101273. /**
  101274. * Gets or sets the root nodes of the material fragment (pixel) shader
  101275. */
  101276. _fragmentOutputNodes: NodeMaterialBlock[];
  101277. /** Gets or sets options to control the node material overall behavior */
  101278. get options(): INodeMaterialOptions;
  101279. set options(options: INodeMaterialOptions);
  101280. /**
  101281. * Default configuration related to image processing available in the standard Material.
  101282. */
  101283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101284. /**
  101285. * Gets the image processing configuration used either in this material.
  101286. */
  101287. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101288. /**
  101289. * Sets the Default image processing configuration used either in the this material.
  101290. *
  101291. * If sets to null, the scene one is in use.
  101292. */
  101293. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101294. /**
  101295. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101296. */
  101297. attachedBlocks: NodeMaterialBlock[];
  101298. /**
  101299. * Specifies the mode of the node material
  101300. * @hidden
  101301. */
  101302. _mode: NodeMaterialModes;
  101303. /**
  101304. * Gets the mode property
  101305. */
  101306. get mode(): NodeMaterialModes;
  101307. /**
  101308. * Create a new node based material
  101309. * @param name defines the material name
  101310. * @param scene defines the hosting scene
  101311. * @param options defines creation option
  101312. */
  101313. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101314. /**
  101315. * Gets the current class name of the material e.g. "NodeMaterial"
  101316. * @returns the class name
  101317. */
  101318. getClassName(): string;
  101319. /**
  101320. * Keep track of the image processing observer to allow dispose and replace.
  101321. */
  101322. private _imageProcessingObserver;
  101323. /**
  101324. * Attaches a new image processing configuration to the Standard Material.
  101325. * @param configuration
  101326. */
  101327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101328. /**
  101329. * Get a block by its name
  101330. * @param name defines the name of the block to retrieve
  101331. * @returns the required block or null if not found
  101332. */
  101333. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101334. /**
  101335. * Get a block by its name
  101336. * @param predicate defines the predicate used to find the good candidate
  101337. * @returns the required block or null if not found
  101338. */
  101339. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101340. /**
  101341. * Get an input block by its name
  101342. * @param predicate defines the predicate used to find the good candidate
  101343. * @returns the required input block or null if not found
  101344. */
  101345. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101346. /**
  101347. * Gets the list of input blocks attached to this material
  101348. * @returns an array of InputBlocks
  101349. */
  101350. getInputBlocks(): InputBlock[];
  101351. /**
  101352. * Adds a new optimizer to the list of optimizers
  101353. * @param optimizer defines the optimizers to add
  101354. * @returns the current material
  101355. */
  101356. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101357. /**
  101358. * Remove an optimizer from the list of optimizers
  101359. * @param optimizer defines the optimizers to remove
  101360. * @returns the current material
  101361. */
  101362. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101363. /**
  101364. * Add a new block to the list of output nodes
  101365. * @param node defines the node to add
  101366. * @returns the current material
  101367. */
  101368. addOutputNode(node: NodeMaterialBlock): this;
  101369. /**
  101370. * Remove a block from the list of root nodes
  101371. * @param node defines the node to remove
  101372. * @returns the current material
  101373. */
  101374. removeOutputNode(node: NodeMaterialBlock): this;
  101375. private _addVertexOutputNode;
  101376. private _removeVertexOutputNode;
  101377. private _addFragmentOutputNode;
  101378. private _removeFragmentOutputNode;
  101379. /**
  101380. * Specifies if the material will require alpha blending
  101381. * @returns a boolean specifying if alpha blending is needed
  101382. */
  101383. needAlphaBlending(): boolean;
  101384. /**
  101385. * Specifies if this material should be rendered in alpha test mode
  101386. * @returns a boolean specifying if an alpha test is needed.
  101387. */
  101388. needAlphaTesting(): boolean;
  101389. private _initializeBlock;
  101390. private _resetDualBlocks;
  101391. /**
  101392. * Remove a block from the current node material
  101393. * @param block defines the block to remove
  101394. */
  101395. removeBlock(block: NodeMaterialBlock): void;
  101396. /**
  101397. * Build the material and generates the inner effect
  101398. * @param verbose defines if the build should log activity
  101399. */
  101400. build(verbose?: boolean): void;
  101401. /**
  101402. * Runs an otpimization phase to try to improve the shader code
  101403. */
  101404. optimize(): void;
  101405. private _prepareDefinesForAttributes;
  101406. /**
  101407. * Create a post process from the material
  101408. * @param camera The camera to apply the render pass to.
  101409. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101411. * @param engine The engine which the post process will be applied. (default: current engine)
  101412. * @param reusable If the post process can be reused on the same frame. (default: false)
  101413. * @param textureType Type of textures used when performing the post process. (default: 0)
  101414. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101415. * @returns the post process created
  101416. */
  101417. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101418. /**
  101419. * Create the post process effect from the material
  101420. * @param postProcess The post process to create the effect for
  101421. */
  101422. createEffectForPostProcess(postProcess: PostProcess): void;
  101423. private _createEffectOrPostProcess;
  101424. private _createEffectForParticles;
  101425. /**
  101426. * Create the effect to be used as the custom effect for a particle system
  101427. * @param particleSystem Particle system to create the effect for
  101428. * @param onCompiled defines a function to call when the effect creation is successful
  101429. * @param onError defines a function to call when the effect creation has failed
  101430. */
  101431. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101432. private _processDefines;
  101433. /**
  101434. * Get if the submesh is ready to be used and all its information available.
  101435. * Child classes can use it to update shaders
  101436. * @param mesh defines the mesh to check
  101437. * @param subMesh defines which submesh to check
  101438. * @param useInstances specifies that instances should be used
  101439. * @returns a boolean indicating that the submesh is ready or not
  101440. */
  101441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101442. /**
  101443. * Get a string representing the shaders built by the current node graph
  101444. */
  101445. get compiledShaders(): string;
  101446. /**
  101447. * Binds the world matrix to the material
  101448. * @param world defines the world transformation matrix
  101449. */
  101450. bindOnlyWorldMatrix(world: Matrix): void;
  101451. /**
  101452. * Binds the submesh to this material by preparing the effect and shader to draw
  101453. * @param world defines the world transformation matrix
  101454. * @param mesh defines the mesh containing the submesh
  101455. * @param subMesh defines the submesh to bind the material to
  101456. */
  101457. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101458. /**
  101459. * Gets the active textures from the material
  101460. * @returns an array of textures
  101461. */
  101462. getActiveTextures(): BaseTexture[];
  101463. /**
  101464. * Gets the list of texture blocks
  101465. * @returns an array of texture blocks
  101466. */
  101467. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101468. /**
  101469. * Specifies if the material uses a texture
  101470. * @param texture defines the texture to check against the material
  101471. * @returns a boolean specifying if the material uses the texture
  101472. */
  101473. hasTexture(texture: BaseTexture): boolean;
  101474. /**
  101475. * Disposes the material
  101476. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101477. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101478. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101479. */
  101480. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101481. /** Creates the node editor window. */
  101482. private _createNodeEditor;
  101483. /**
  101484. * Launch the node material editor
  101485. * @param config Define the configuration of the editor
  101486. * @return a promise fulfilled when the node editor is visible
  101487. */
  101488. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101489. /**
  101490. * Clear the current material
  101491. */
  101492. clear(): void;
  101493. /**
  101494. * Clear the current material and set it to a default state
  101495. */
  101496. setToDefault(): void;
  101497. /**
  101498. * Clear the current material and set it to a default state for post process
  101499. */
  101500. setToDefaultPostProcess(): void;
  101501. /**
  101502. * Clear the current material and set it to a default state for particle
  101503. */
  101504. setToDefaultParticle(): void;
  101505. /**
  101506. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101507. * @param url defines the url to load from
  101508. * @returns a promise that will fullfil when the material is fully loaded
  101509. */
  101510. loadAsync(url: string): Promise<void>;
  101511. private _gatherBlocks;
  101512. /**
  101513. * Generate a string containing the code declaration required to create an equivalent of this material
  101514. * @returns a string
  101515. */
  101516. generateCode(): string;
  101517. /**
  101518. * Serializes this material in a JSON representation
  101519. * @returns the serialized material object
  101520. */
  101521. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101522. private _restoreConnections;
  101523. /**
  101524. * Clear the current graph and load a new one from a serialization object
  101525. * @param source defines the JSON representation of the material
  101526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101527. * @param merge defines whether or not the source must be merged or replace the current content
  101528. */
  101529. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101530. /**
  101531. * Makes a duplicate of the current material.
  101532. * @param name - name to use for the new material.
  101533. */
  101534. clone(name: string): NodeMaterial;
  101535. /**
  101536. * Creates a node material from parsed material data
  101537. * @param source defines the JSON representation of the material
  101538. * @param scene defines the hosting scene
  101539. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101540. * @returns a new node material
  101541. */
  101542. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101543. /**
  101544. * Creates a node material from a snippet saved in a remote file
  101545. * @param name defines the name of the material to create
  101546. * @param url defines the url to load from
  101547. * @param scene defines the hosting scene
  101548. * @returns a promise that will resolve to the new node material
  101549. */
  101550. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101551. /**
  101552. * Creates a node material from a snippet saved by the node material editor
  101553. * @param snippetId defines the snippet to load
  101554. * @param scene defines the hosting scene
  101555. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101556. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101557. * @returns a promise that will resolve to the new node material
  101558. */
  101559. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101560. /**
  101561. * Creates a new node material set to default basic configuration
  101562. * @param name defines the name of the material
  101563. * @param scene defines the hosting scene
  101564. * @returns a new NodeMaterial
  101565. */
  101566. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101567. }
  101568. }
  101569. declare module BABYLON {
  101570. /**
  101571. * Size options for a post process
  101572. */
  101573. export type PostProcessOptions = {
  101574. width: number;
  101575. height: number;
  101576. };
  101577. /**
  101578. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101579. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101580. */
  101581. export class PostProcess {
  101582. /** Name of the PostProcess. */
  101583. name: string;
  101584. /**
  101585. * Gets or sets the unique id of the post process
  101586. */
  101587. uniqueId: number;
  101588. /**
  101589. * Width of the texture to apply the post process on
  101590. */
  101591. width: number;
  101592. /**
  101593. * Height of the texture to apply the post process on
  101594. */
  101595. height: number;
  101596. /**
  101597. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101598. */
  101599. nodeMaterialSource: Nullable<NodeMaterial>;
  101600. /**
  101601. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101602. * @hidden
  101603. */
  101604. _outputTexture: Nullable<InternalTexture>;
  101605. /**
  101606. * Sampling mode used by the shader
  101607. * See https://doc.babylonjs.com/classes/3.1/texture
  101608. */
  101609. renderTargetSamplingMode: number;
  101610. /**
  101611. * Clear color to use when screen clearing
  101612. */
  101613. clearColor: Color4;
  101614. /**
  101615. * If the buffer needs to be cleared before applying the post process. (default: true)
  101616. * Should be set to false if shader will overwrite all previous pixels.
  101617. */
  101618. autoClear: boolean;
  101619. /**
  101620. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101621. */
  101622. alphaMode: number;
  101623. /**
  101624. * Sets the setAlphaBlendConstants of the babylon engine
  101625. */
  101626. alphaConstants: Color4;
  101627. /**
  101628. * Animations to be used for the post processing
  101629. */
  101630. animations: Animation[];
  101631. /**
  101632. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101633. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101634. */
  101635. enablePixelPerfectMode: boolean;
  101636. /**
  101637. * Force the postprocess to be applied without taking in account viewport
  101638. */
  101639. forceFullscreenViewport: boolean;
  101640. /**
  101641. * List of inspectable custom properties (used by the Inspector)
  101642. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101643. */
  101644. inspectableCustomProperties: IInspectable[];
  101645. /**
  101646. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101647. *
  101648. * | Value | Type | Description |
  101649. * | ----- | ----------------------------------- | ----------- |
  101650. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101651. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101652. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101653. *
  101654. */
  101655. scaleMode: number;
  101656. /**
  101657. * Force textures to be a power of two (default: false)
  101658. */
  101659. alwaysForcePOT: boolean;
  101660. private _samples;
  101661. /**
  101662. * Number of sample textures (default: 1)
  101663. */
  101664. get samples(): number;
  101665. set samples(n: number);
  101666. /**
  101667. * Modify the scale of the post process to be the same as the viewport (default: false)
  101668. */
  101669. adaptScaleToCurrentViewport: boolean;
  101670. private _camera;
  101671. protected _scene: Scene;
  101672. private _engine;
  101673. private _options;
  101674. private _reusable;
  101675. private _textureType;
  101676. private _textureFormat;
  101677. /**
  101678. * Smart array of input and output textures for the post process.
  101679. * @hidden
  101680. */
  101681. _textures: SmartArray<InternalTexture>;
  101682. /**
  101683. * The index in _textures that corresponds to the output texture.
  101684. * @hidden
  101685. */
  101686. _currentRenderTextureInd: number;
  101687. private _effect;
  101688. private _samplers;
  101689. private _fragmentUrl;
  101690. private _vertexUrl;
  101691. private _parameters;
  101692. private _scaleRatio;
  101693. protected _indexParameters: any;
  101694. private _shareOutputWithPostProcess;
  101695. private _texelSize;
  101696. private _forcedOutputTexture;
  101697. /**
  101698. * Returns the fragment url or shader name used in the post process.
  101699. * @returns the fragment url or name in the shader store.
  101700. */
  101701. getEffectName(): string;
  101702. /**
  101703. * An event triggered when the postprocess is activated.
  101704. */
  101705. onActivateObservable: Observable<Camera>;
  101706. private _onActivateObserver;
  101707. /**
  101708. * A function that is added to the onActivateObservable
  101709. */
  101710. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101711. /**
  101712. * An event triggered when the postprocess changes its size.
  101713. */
  101714. onSizeChangedObservable: Observable<PostProcess>;
  101715. private _onSizeChangedObserver;
  101716. /**
  101717. * A function that is added to the onSizeChangedObservable
  101718. */
  101719. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101720. /**
  101721. * An event triggered when the postprocess applies its effect.
  101722. */
  101723. onApplyObservable: Observable<Effect>;
  101724. private _onApplyObserver;
  101725. /**
  101726. * A function that is added to the onApplyObservable
  101727. */
  101728. set onApply(callback: (effect: Effect) => void);
  101729. /**
  101730. * An event triggered before rendering the postprocess
  101731. */
  101732. onBeforeRenderObservable: Observable<Effect>;
  101733. private _onBeforeRenderObserver;
  101734. /**
  101735. * A function that is added to the onBeforeRenderObservable
  101736. */
  101737. set onBeforeRender(callback: (effect: Effect) => void);
  101738. /**
  101739. * An event triggered after rendering the postprocess
  101740. */
  101741. onAfterRenderObservable: Observable<Effect>;
  101742. private _onAfterRenderObserver;
  101743. /**
  101744. * A function that is added to the onAfterRenderObservable
  101745. */
  101746. set onAfterRender(callback: (efect: Effect) => void);
  101747. /**
  101748. * 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
  101749. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101750. */
  101751. get inputTexture(): InternalTexture;
  101752. set inputTexture(value: InternalTexture);
  101753. /**
  101754. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101755. * the only way to unset it is to use this function to restore its internal state
  101756. */
  101757. restoreDefaultInputTexture(): void;
  101758. /**
  101759. * Gets the camera which post process is applied to.
  101760. * @returns The camera the post process is applied to.
  101761. */
  101762. getCamera(): Camera;
  101763. /**
  101764. * Gets the texel size of the postprocess.
  101765. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101766. */
  101767. get texelSize(): Vector2;
  101768. /**
  101769. * Creates a new instance PostProcess
  101770. * @param name The name of the PostProcess.
  101771. * @param fragmentUrl The url of the fragment shader to be used.
  101772. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101773. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101774. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101775. * @param camera The camera to apply the render pass to.
  101776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101777. * @param engine The engine which the post process will be applied. (default: current engine)
  101778. * @param reusable If the post process can be reused on the same frame. (default: false)
  101779. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101780. * @param textureType Type of textures used when performing the post process. (default: 0)
  101781. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101782. * @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
  101783. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101784. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101785. */
  101786. constructor(
  101787. /** Name of the PostProcess. */
  101788. 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);
  101789. /**
  101790. * Gets a string idenfifying the name of the class
  101791. * @returns "PostProcess" string
  101792. */
  101793. getClassName(): string;
  101794. /**
  101795. * Gets the engine which this post process belongs to.
  101796. * @returns The engine the post process was enabled with.
  101797. */
  101798. getEngine(): Engine;
  101799. /**
  101800. * The effect that is created when initializing the post process.
  101801. * @returns The created effect corresponding the the postprocess.
  101802. */
  101803. getEffect(): Effect;
  101804. /**
  101805. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101806. * @param postProcess The post process to share the output with.
  101807. * @returns This post process.
  101808. */
  101809. shareOutputWith(postProcess: PostProcess): PostProcess;
  101810. /**
  101811. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101812. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101813. */
  101814. useOwnOutput(): void;
  101815. /**
  101816. * Updates the effect with the current post process compile time values and recompiles the shader.
  101817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101820. * @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
  101821. * @param onCompiled Called when the shader has been compiled.
  101822. * @param onError Called if there is an error when compiling a shader.
  101823. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101824. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101825. */
  101826. 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;
  101827. /**
  101828. * The post process is reusable if it can be used multiple times within one frame.
  101829. * @returns If the post process is reusable
  101830. */
  101831. isReusable(): boolean;
  101832. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101833. markTextureDirty(): void;
  101834. /**
  101835. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101836. * 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.
  101837. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101838. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101839. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101840. * @returns The target texture that was bound to be written to.
  101841. */
  101842. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101843. /**
  101844. * If the post process is supported.
  101845. */
  101846. get isSupported(): boolean;
  101847. /**
  101848. * The aspect ratio of the output texture.
  101849. */
  101850. get aspectRatio(): number;
  101851. /**
  101852. * Get a value indicating if the post-process is ready to be used
  101853. * @returns true if the post-process is ready (shader is compiled)
  101854. */
  101855. isReady(): boolean;
  101856. /**
  101857. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101858. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101859. */
  101860. apply(): Nullable<Effect>;
  101861. private _disposeTextures;
  101862. /**
  101863. * Disposes the post process.
  101864. * @param camera The camera to dispose the post process on.
  101865. */
  101866. dispose(camera?: Camera): void;
  101867. }
  101868. }
  101869. declare module BABYLON {
  101870. /** @hidden */
  101871. export var kernelBlurVaryingDeclaration: {
  101872. name: string;
  101873. shader: string;
  101874. };
  101875. }
  101876. declare module BABYLON {
  101877. /** @hidden */
  101878. export var kernelBlurFragment: {
  101879. name: string;
  101880. shader: string;
  101881. };
  101882. }
  101883. declare module BABYLON {
  101884. /** @hidden */
  101885. export var kernelBlurFragment2: {
  101886. name: string;
  101887. shader: string;
  101888. };
  101889. }
  101890. declare module BABYLON {
  101891. /** @hidden */
  101892. export var kernelBlurPixelShader: {
  101893. name: string;
  101894. shader: string;
  101895. };
  101896. }
  101897. declare module BABYLON {
  101898. /** @hidden */
  101899. export var kernelBlurVertex: {
  101900. name: string;
  101901. shader: string;
  101902. };
  101903. }
  101904. declare module BABYLON {
  101905. /** @hidden */
  101906. export var kernelBlurVertexShader: {
  101907. name: string;
  101908. shader: string;
  101909. };
  101910. }
  101911. declare module BABYLON {
  101912. /**
  101913. * The Blur Post Process which blurs an image based on a kernel and direction.
  101914. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101915. */
  101916. export class BlurPostProcess extends PostProcess {
  101917. /** The direction in which to blur the image. */
  101918. direction: Vector2;
  101919. private blockCompilation;
  101920. protected _kernel: number;
  101921. protected _idealKernel: number;
  101922. protected _packedFloat: boolean;
  101923. private _staticDefines;
  101924. /**
  101925. * Sets the length in pixels of the blur sample region
  101926. */
  101927. set kernel(v: number);
  101928. /**
  101929. * Gets the length in pixels of the blur sample region
  101930. */
  101931. get kernel(): number;
  101932. /**
  101933. * Sets wether or not the blur needs to unpack/repack floats
  101934. */
  101935. set packedFloat(v: boolean);
  101936. /**
  101937. * Gets wether or not the blur is unpacking/repacking floats
  101938. */
  101939. get packedFloat(): boolean;
  101940. /**
  101941. * Creates a new instance BlurPostProcess
  101942. * @param name The name of the effect.
  101943. * @param direction The direction in which to blur the image.
  101944. * @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.
  101945. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101946. * @param camera The camera to apply the render pass to.
  101947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101948. * @param engine The engine which the post process will be applied. (default: current engine)
  101949. * @param reusable If the post process can be reused on the same frame. (default: false)
  101950. * @param textureType Type of textures used when performing the post process. (default: 0)
  101951. * @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)
  101952. */
  101953. constructor(name: string,
  101954. /** The direction in which to blur the image. */
  101955. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101956. /**
  101957. * Updates the effect with the current post process compile time values and recompiles the shader.
  101958. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101959. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101960. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101961. * @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
  101962. * @param onCompiled Called when the shader has been compiled.
  101963. * @param onError Called if there is an error when compiling a shader.
  101964. */
  101965. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101966. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101967. /**
  101968. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101969. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101970. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101971. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101972. * The gaps between physical kernels are compensated for in the weighting of the samples
  101973. * @param idealKernel Ideal blur kernel.
  101974. * @return Nearest best kernel.
  101975. */
  101976. protected _nearestBestKernel(idealKernel: number): number;
  101977. /**
  101978. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101979. * @param x The point on the Gaussian distribution to sample.
  101980. * @return the value of the Gaussian function at x.
  101981. */
  101982. protected _gaussianWeight(x: number): number;
  101983. /**
  101984. * Generates a string that can be used as a floating point number in GLSL.
  101985. * @param x Value to print.
  101986. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101987. * @return GLSL float string.
  101988. */
  101989. protected _glslFloat(x: number, decimalFigures?: number): string;
  101990. }
  101991. }
  101992. declare module BABYLON {
  101993. /**
  101994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101996. * You can then easily use it as a reflectionTexture on a flat surface.
  101997. * In case the surface is not a plane, please consider relying on reflection probes.
  101998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101999. */
  102000. export class MirrorTexture extends RenderTargetTexture {
  102001. private scene;
  102002. /**
  102003. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102004. * 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.
  102005. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102006. */
  102007. mirrorPlane: Plane;
  102008. /**
  102009. * Define the blur ratio used to blur the reflection if needed.
  102010. */
  102011. set blurRatio(value: number);
  102012. get blurRatio(): number;
  102013. /**
  102014. * Define the adaptive blur kernel used to blur the reflection if needed.
  102015. * This will autocompute the closest best match for the `blurKernel`
  102016. */
  102017. set adaptiveBlurKernel(value: number);
  102018. /**
  102019. * Define the blur kernel used to blur the reflection if needed.
  102020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102021. */
  102022. set blurKernel(value: number);
  102023. /**
  102024. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102025. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102026. */
  102027. set blurKernelX(value: number);
  102028. get blurKernelX(): number;
  102029. /**
  102030. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102031. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102032. */
  102033. set blurKernelY(value: number);
  102034. get blurKernelY(): number;
  102035. private _autoComputeBlurKernel;
  102036. protected _onRatioRescale(): void;
  102037. private _updateGammaSpace;
  102038. private _imageProcessingConfigChangeObserver;
  102039. private _transformMatrix;
  102040. private _mirrorMatrix;
  102041. private _savedViewMatrix;
  102042. private _blurX;
  102043. private _blurY;
  102044. private _adaptiveBlurKernel;
  102045. private _blurKernelX;
  102046. private _blurKernelY;
  102047. private _blurRatio;
  102048. /**
  102049. * Instantiates a Mirror Texture.
  102050. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102051. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102052. * You can then easily use it as a reflectionTexture on a flat surface.
  102053. * In case the surface is not a plane, please consider relying on reflection probes.
  102054. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102055. * @param name
  102056. * @param size
  102057. * @param scene
  102058. * @param generateMipMaps
  102059. * @param type
  102060. * @param samplingMode
  102061. * @param generateDepthBuffer
  102062. */
  102063. constructor(name: string, size: number | {
  102064. width: number;
  102065. height: number;
  102066. } | {
  102067. ratio: number;
  102068. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102069. private _preparePostProcesses;
  102070. /**
  102071. * Clone the mirror texture.
  102072. * @returns the cloned texture
  102073. */
  102074. clone(): MirrorTexture;
  102075. /**
  102076. * Serialize the texture to a JSON representation you could use in Parse later on
  102077. * @returns the serialized JSON representation
  102078. */
  102079. serialize(): any;
  102080. /**
  102081. * Dispose the texture and release its associated resources.
  102082. */
  102083. dispose(): void;
  102084. }
  102085. }
  102086. declare module BABYLON {
  102087. /**
  102088. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102089. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102090. */
  102091. export class Texture extends BaseTexture {
  102092. /**
  102093. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102094. */
  102095. static SerializeBuffers: boolean;
  102096. /** @hidden */
  102097. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102098. /** @hidden */
  102099. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102100. /** @hidden */
  102101. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102102. /** nearest is mag = nearest and min = nearest and mip = linear */
  102103. static readonly NEAREST_SAMPLINGMODE: number;
  102104. /** nearest is mag = nearest and min = nearest and mip = linear */
  102105. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102106. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102107. static readonly BILINEAR_SAMPLINGMODE: number;
  102108. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102109. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102110. /** Trilinear is mag = linear and min = linear and mip = linear */
  102111. static readonly TRILINEAR_SAMPLINGMODE: number;
  102112. /** Trilinear is mag = linear and min = linear and mip = linear */
  102113. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102114. /** mag = nearest and min = nearest and mip = nearest */
  102115. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102116. /** mag = nearest and min = linear and mip = nearest */
  102117. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102118. /** mag = nearest and min = linear and mip = linear */
  102119. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102120. /** mag = nearest and min = linear and mip = none */
  102121. static readonly NEAREST_LINEAR: number;
  102122. /** mag = nearest and min = nearest and mip = none */
  102123. static readonly NEAREST_NEAREST: number;
  102124. /** mag = linear and min = nearest and mip = nearest */
  102125. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102126. /** mag = linear and min = nearest and mip = linear */
  102127. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102128. /** mag = linear and min = linear and mip = none */
  102129. static readonly LINEAR_LINEAR: number;
  102130. /** mag = linear and min = nearest and mip = none */
  102131. static readonly LINEAR_NEAREST: number;
  102132. /** Explicit coordinates mode */
  102133. static readonly EXPLICIT_MODE: number;
  102134. /** Spherical coordinates mode */
  102135. static readonly SPHERICAL_MODE: number;
  102136. /** Planar coordinates mode */
  102137. static readonly PLANAR_MODE: number;
  102138. /** Cubic coordinates mode */
  102139. static readonly CUBIC_MODE: number;
  102140. /** Projection coordinates mode */
  102141. static readonly PROJECTION_MODE: number;
  102142. /** Inverse Cubic coordinates mode */
  102143. static readonly SKYBOX_MODE: number;
  102144. /** Inverse Cubic coordinates mode */
  102145. static readonly INVCUBIC_MODE: number;
  102146. /** Equirectangular coordinates mode */
  102147. static readonly EQUIRECTANGULAR_MODE: number;
  102148. /** Equirectangular Fixed coordinates mode */
  102149. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102150. /** Equirectangular Fixed Mirrored coordinates mode */
  102151. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102152. /** Texture is not repeating outside of 0..1 UVs */
  102153. static readonly CLAMP_ADDRESSMODE: number;
  102154. /** Texture is repeating outside of 0..1 UVs */
  102155. static readonly WRAP_ADDRESSMODE: number;
  102156. /** Texture is repeating and mirrored */
  102157. static readonly MIRROR_ADDRESSMODE: number;
  102158. /**
  102159. * 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
  102160. */
  102161. static UseSerializedUrlIfAny: boolean;
  102162. /**
  102163. * Define the url of the texture.
  102164. */
  102165. url: Nullable<string>;
  102166. /**
  102167. * Define an offset on the texture to offset the u coordinates of the UVs
  102168. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102169. */
  102170. uOffset: number;
  102171. /**
  102172. * Define an offset on the texture to offset the v coordinates of the UVs
  102173. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  102174. */
  102175. vOffset: number;
  102176. /**
  102177. * Define an offset on the texture to scale the u coordinates of the UVs
  102178. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102179. */
  102180. uScale: number;
  102181. /**
  102182. * Define an offset on the texture to scale the v coordinates of the UVs
  102183. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102184. */
  102185. vScale: number;
  102186. /**
  102187. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102188. * @see https://doc.babylonjs.com/how_to/more_materials
  102189. */
  102190. uAng: number;
  102191. /**
  102192. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102193. * @see https://doc.babylonjs.com/how_to/more_materials
  102194. */
  102195. vAng: number;
  102196. /**
  102197. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102198. * @see https://doc.babylonjs.com/how_to/more_materials
  102199. */
  102200. wAng: number;
  102201. /**
  102202. * Defines the center of rotation (U)
  102203. */
  102204. uRotationCenter: number;
  102205. /**
  102206. * Defines the center of rotation (V)
  102207. */
  102208. vRotationCenter: number;
  102209. /**
  102210. * Defines the center of rotation (W)
  102211. */
  102212. wRotationCenter: number;
  102213. /**
  102214. * Are mip maps generated for this texture or not.
  102215. */
  102216. get noMipmap(): boolean;
  102217. /**
  102218. * List of inspectable custom properties (used by the Inspector)
  102219. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102220. */
  102221. inspectableCustomProperties: Nullable<IInspectable[]>;
  102222. private _noMipmap;
  102223. /** @hidden */
  102224. _invertY: boolean;
  102225. private _rowGenerationMatrix;
  102226. private _cachedTextureMatrix;
  102227. private _projectionModeMatrix;
  102228. private _t0;
  102229. private _t1;
  102230. private _t2;
  102231. private _cachedUOffset;
  102232. private _cachedVOffset;
  102233. private _cachedUScale;
  102234. private _cachedVScale;
  102235. private _cachedUAng;
  102236. private _cachedVAng;
  102237. private _cachedWAng;
  102238. private _cachedProjectionMatrixId;
  102239. private _cachedCoordinatesMode;
  102240. /** @hidden */
  102241. protected _initialSamplingMode: number;
  102242. /** @hidden */
  102243. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102244. private _deleteBuffer;
  102245. protected _format: Nullable<number>;
  102246. private _delayedOnLoad;
  102247. private _delayedOnError;
  102248. private _mimeType?;
  102249. /**
  102250. * Observable triggered once the texture has been loaded.
  102251. */
  102252. onLoadObservable: Observable<Texture>;
  102253. protected _isBlocking: boolean;
  102254. /**
  102255. * Is the texture preventing material to render while loading.
  102256. * If false, a default texture will be used instead of the loading one during the preparation step.
  102257. */
  102258. set isBlocking(value: boolean);
  102259. get isBlocking(): boolean;
  102260. /**
  102261. * Get the current sampling mode associated with the texture.
  102262. */
  102263. get samplingMode(): number;
  102264. /**
  102265. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102266. */
  102267. get invertY(): boolean;
  102268. /**
  102269. * Instantiates a new texture.
  102270. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102271. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102272. * @param url defines the url of the picture to load as a texture
  102273. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102274. * @param noMipmap defines if the texture will require mip maps or not
  102275. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102276. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102277. * @param onLoad defines a callback triggered when the texture has been loaded
  102278. * @param onError defines a callback triggered when an error occurred during the loading session
  102279. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102280. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102281. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102282. * @param mimeType defines an optional mime type information
  102283. */
  102284. 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);
  102285. /**
  102286. * Update the url (and optional buffer) of this texture if url was null during construction.
  102287. * @param url the url of the texture
  102288. * @param buffer the buffer of the texture (defaults to null)
  102289. * @param onLoad callback called when the texture is loaded (defaults to null)
  102290. */
  102291. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102292. /**
  102293. * Finish the loading sequence of a texture flagged as delayed load.
  102294. * @hidden
  102295. */
  102296. delayLoad(): void;
  102297. private _prepareRowForTextureGeneration;
  102298. /**
  102299. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102300. * @returns the transform matrix of the texture.
  102301. */
  102302. getTextureMatrix(uBase?: number): Matrix;
  102303. /**
  102304. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102305. * @returns The reflection texture transform
  102306. */
  102307. getReflectionTextureMatrix(): Matrix;
  102308. /**
  102309. * Clones the texture.
  102310. * @returns the cloned texture
  102311. */
  102312. clone(): Texture;
  102313. /**
  102314. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102315. * @returns The JSON representation of the texture
  102316. */
  102317. serialize(): any;
  102318. /**
  102319. * Get the current class name of the texture useful for serialization or dynamic coding.
  102320. * @returns "Texture"
  102321. */
  102322. getClassName(): string;
  102323. /**
  102324. * Dispose the texture and release its associated resources.
  102325. */
  102326. dispose(): void;
  102327. /**
  102328. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102329. * @param parsedTexture Define the JSON representation of the texture
  102330. * @param scene Define the scene the parsed texture should be instantiated in
  102331. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102332. * @returns The parsed texture if successful
  102333. */
  102334. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102335. /**
  102336. * Creates a texture from its base 64 representation.
  102337. * @param data Define the base64 payload without the data: prefix
  102338. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102339. * @param scene Define the scene the texture should belong to
  102340. * @param noMipmap Forces the texture to not create mip map information if true
  102341. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102342. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102343. * @param onLoad define a callback triggered when the texture has been loaded
  102344. * @param onError define a callback triggered when an error occurred during the loading session
  102345. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102346. * @returns the created texture
  102347. */
  102348. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102349. /**
  102350. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102351. * @param data Define the base64 payload without the data: prefix
  102352. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102353. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102354. * @param scene Define the scene the texture should belong to
  102355. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102356. * @param noMipmap Forces the texture to not create mip map information if true
  102357. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102358. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102359. * @param onLoad define a callback triggered when the texture has been loaded
  102360. * @param onError define a callback triggered when an error occurred during the loading session
  102361. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102362. * @returns the created texture
  102363. */
  102364. 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;
  102365. }
  102366. }
  102367. declare module BABYLON {
  102368. /**
  102369. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102370. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102371. */
  102372. export class PostProcessManager {
  102373. private _scene;
  102374. private _indexBuffer;
  102375. private _vertexBuffers;
  102376. /**
  102377. * Creates a new instance PostProcess
  102378. * @param scene The scene that the post process is associated with.
  102379. */
  102380. constructor(scene: Scene);
  102381. private _prepareBuffers;
  102382. private _buildIndexBuffer;
  102383. /**
  102384. * Rebuilds the vertex buffers of the manager.
  102385. * @hidden
  102386. */
  102387. _rebuild(): void;
  102388. /**
  102389. * Prepares a frame to be run through a post process.
  102390. * @param sourceTexture The input texture to the post procesess. (default: null)
  102391. * @param postProcesses An array of post processes to be run. (default: null)
  102392. * @returns True if the post processes were able to be run.
  102393. * @hidden
  102394. */
  102395. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102396. /**
  102397. * Manually render a set of post processes to a texture.
  102398. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102399. * @param postProcesses An array of post processes to be run.
  102400. * @param targetTexture The target texture to render to.
  102401. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102402. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102403. * @param lodLevel defines which lod of the texture to render to
  102404. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102405. */
  102406. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102407. /**
  102408. * Finalize the result of the output of the postprocesses.
  102409. * @param doNotPresent If true the result will not be displayed to the screen.
  102410. * @param targetTexture The target texture to render to.
  102411. * @param faceIndex The index of the face to bind the target texture to.
  102412. * @param postProcesses The array of post processes to render.
  102413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102414. * @hidden
  102415. */
  102416. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102417. /**
  102418. * Disposes of the post process manager.
  102419. */
  102420. dispose(): void;
  102421. }
  102422. }
  102423. declare module BABYLON {
  102424. /**
  102425. * This Helps creating a texture that will be created from a camera in your scene.
  102426. * It is basically a dynamic texture that could be used to create special effects for instance.
  102427. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102428. */
  102429. export class RenderTargetTexture extends Texture {
  102430. isCube: boolean;
  102431. /**
  102432. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102433. */
  102434. static readonly REFRESHRATE_RENDER_ONCE: number;
  102435. /**
  102436. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102437. */
  102438. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102439. /**
  102440. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102441. * the central point of your effect and can save a lot of performances.
  102442. */
  102443. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102444. /**
  102445. * Use this predicate to dynamically define the list of mesh you want to render.
  102446. * If set, the renderList property will be overwritten.
  102447. */
  102448. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102449. private _renderList;
  102450. /**
  102451. * Use this list to define the list of mesh you want to render.
  102452. */
  102453. get renderList(): Nullable<Array<AbstractMesh>>;
  102454. set renderList(value: Nullable<Array<AbstractMesh>>);
  102455. /**
  102456. * Use this function to overload the renderList array at rendering time.
  102457. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102458. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102459. * the cube (if the RTT is a cube, else layerOrFace=0).
  102460. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102461. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102462. * hold dummy elements!
  102463. */
  102464. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102465. private _hookArray;
  102466. /**
  102467. * Define if particles should be rendered in your texture.
  102468. */
  102469. renderParticles: boolean;
  102470. /**
  102471. * Define if sprites should be rendered in your texture.
  102472. */
  102473. renderSprites: boolean;
  102474. /**
  102475. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102476. */
  102477. coordinatesMode: number;
  102478. /**
  102479. * Define the camera used to render the texture.
  102480. */
  102481. activeCamera: Nullable<Camera>;
  102482. /**
  102483. * Override the mesh isReady function with your own one.
  102484. */
  102485. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102486. /**
  102487. * Override the render function of the texture with your own one.
  102488. */
  102489. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102490. /**
  102491. * Define if camera post processes should be use while rendering the texture.
  102492. */
  102493. useCameraPostProcesses: boolean;
  102494. /**
  102495. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102496. */
  102497. ignoreCameraViewport: boolean;
  102498. private _postProcessManager;
  102499. private _postProcesses;
  102500. private _resizeObserver;
  102501. /**
  102502. * An event triggered when the texture is unbind.
  102503. */
  102504. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102505. /**
  102506. * An event triggered when the texture is unbind.
  102507. */
  102508. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102509. private _onAfterUnbindObserver;
  102510. /**
  102511. * Set a after unbind callback in the texture.
  102512. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102513. */
  102514. set onAfterUnbind(callback: () => void);
  102515. /**
  102516. * An event triggered before rendering the texture
  102517. */
  102518. onBeforeRenderObservable: Observable<number>;
  102519. private _onBeforeRenderObserver;
  102520. /**
  102521. * Set a before render callback in the texture.
  102522. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102523. */
  102524. set onBeforeRender(callback: (faceIndex: number) => void);
  102525. /**
  102526. * An event triggered after rendering the texture
  102527. */
  102528. onAfterRenderObservable: Observable<number>;
  102529. private _onAfterRenderObserver;
  102530. /**
  102531. * Set a after render callback in the texture.
  102532. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102533. */
  102534. set onAfterRender(callback: (faceIndex: number) => void);
  102535. /**
  102536. * An event triggered after the texture clear
  102537. */
  102538. onClearObservable: Observable<Engine>;
  102539. private _onClearObserver;
  102540. /**
  102541. * Set a clear callback in the texture.
  102542. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102543. */
  102544. set onClear(callback: (Engine: Engine) => void);
  102545. /**
  102546. * An event triggered when the texture is resized.
  102547. */
  102548. onResizeObservable: Observable<RenderTargetTexture>;
  102549. /**
  102550. * Define the clear color of the Render Target if it should be different from the scene.
  102551. */
  102552. clearColor: Color4;
  102553. protected _size: number | {
  102554. width: number;
  102555. height: number;
  102556. layers?: number;
  102557. };
  102558. protected _initialSizeParameter: number | {
  102559. width: number;
  102560. height: number;
  102561. } | {
  102562. ratio: number;
  102563. };
  102564. protected _sizeRatio: Nullable<number>;
  102565. /** @hidden */
  102566. _generateMipMaps: boolean;
  102567. protected _renderingManager: RenderingManager;
  102568. /** @hidden */
  102569. _waitingRenderList: string[];
  102570. protected _doNotChangeAspectRatio: boolean;
  102571. protected _currentRefreshId: number;
  102572. protected _refreshRate: number;
  102573. protected _textureMatrix: Matrix;
  102574. protected _samples: number;
  102575. protected _renderTargetOptions: RenderTargetCreationOptions;
  102576. /**
  102577. * Gets render target creation options that were used.
  102578. */
  102579. get renderTargetOptions(): RenderTargetCreationOptions;
  102580. protected _onRatioRescale(): void;
  102581. /**
  102582. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102583. * It must define where the camera used to render the texture is set
  102584. */
  102585. boundingBoxPosition: Vector3;
  102586. private _boundingBoxSize;
  102587. /**
  102588. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102589. * When defined, the cubemap will switch to local mode
  102590. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102591. * @example https://www.babylonjs-playground.com/#RNASML
  102592. */
  102593. set boundingBoxSize(value: Vector3);
  102594. get boundingBoxSize(): Vector3;
  102595. /**
  102596. * In case the RTT has been created with a depth texture, get the associated
  102597. * depth texture.
  102598. * Otherwise, return null.
  102599. */
  102600. get depthStencilTexture(): Nullable<InternalTexture>;
  102601. /**
  102602. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102603. * or used a shadow, depth texture...
  102604. * @param name The friendly name of the texture
  102605. * @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)
  102606. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102607. * @param generateMipMaps True if mip maps need to be generated after render.
  102608. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102609. * @param type The type of the buffer in the RTT (int, half float, float...)
  102610. * @param isCube True if a cube texture needs to be created
  102611. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102612. * @param generateDepthBuffer True to generate a depth buffer
  102613. * @param generateStencilBuffer True to generate a stencil buffer
  102614. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102615. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102616. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102617. */
  102618. constructor(name: string, size: number | {
  102619. width: number;
  102620. height: number;
  102621. layers?: number;
  102622. } | {
  102623. ratio: number;
  102624. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102625. /**
  102626. * Creates a depth stencil texture.
  102627. * This is only available in WebGL 2 or with the depth texture extension available.
  102628. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102629. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102630. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102631. */
  102632. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102633. private _processSizeParameter;
  102634. /**
  102635. * Define the number of samples to use in case of MSAA.
  102636. * It defaults to one meaning no MSAA has been enabled.
  102637. */
  102638. get samples(): number;
  102639. set samples(value: number);
  102640. /**
  102641. * Resets the refresh counter of the texture and start bak from scratch.
  102642. * Could be useful to regenerate the texture if it is setup to render only once.
  102643. */
  102644. resetRefreshCounter(): void;
  102645. /**
  102646. * Define the refresh rate of the texture or the rendering frequency.
  102647. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102648. */
  102649. get refreshRate(): number;
  102650. set refreshRate(value: number);
  102651. /**
  102652. * Adds a post process to the render target rendering passes.
  102653. * @param postProcess define the post process to add
  102654. */
  102655. addPostProcess(postProcess: PostProcess): void;
  102656. /**
  102657. * Clear all the post processes attached to the render target
  102658. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102659. */
  102660. clearPostProcesses(dispose?: boolean): void;
  102661. /**
  102662. * Remove one of the post process from the list of attached post processes to the texture
  102663. * @param postProcess define the post process to remove from the list
  102664. */
  102665. removePostProcess(postProcess: PostProcess): void;
  102666. /** @hidden */
  102667. _shouldRender(): boolean;
  102668. /**
  102669. * Gets the actual render size of the texture.
  102670. * @returns the width of the render size
  102671. */
  102672. getRenderSize(): number;
  102673. /**
  102674. * Gets the actual render width of the texture.
  102675. * @returns the width of the render size
  102676. */
  102677. getRenderWidth(): number;
  102678. /**
  102679. * Gets the actual render height of the texture.
  102680. * @returns the height of the render size
  102681. */
  102682. getRenderHeight(): number;
  102683. /**
  102684. * Gets the actual number of layers of the texture.
  102685. * @returns the number of layers
  102686. */
  102687. getRenderLayers(): number;
  102688. /**
  102689. * Get if the texture can be rescaled or not.
  102690. */
  102691. get canRescale(): boolean;
  102692. /**
  102693. * Resize the texture using a ratio.
  102694. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102695. */
  102696. scale(ratio: number): void;
  102697. /**
  102698. * Get the texture reflection matrix used to rotate/transform the reflection.
  102699. * @returns the reflection matrix
  102700. */
  102701. getReflectionTextureMatrix(): Matrix;
  102702. /**
  102703. * Resize the texture to a new desired size.
  102704. * Be carrefull as it will recreate all the data in the new texture.
  102705. * @param size Define the new size. It can be:
  102706. * - a number for squared texture,
  102707. * - an object containing { width: number, height: number }
  102708. * - or an object containing a ratio { ratio: number }
  102709. */
  102710. resize(size: number | {
  102711. width: number;
  102712. height: number;
  102713. } | {
  102714. ratio: number;
  102715. }): void;
  102716. private _defaultRenderListPrepared;
  102717. /**
  102718. * Renders all the objects from the render list into the texture.
  102719. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102720. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102721. */
  102722. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102723. private _bestReflectionRenderTargetDimension;
  102724. private _prepareRenderingManager;
  102725. /**
  102726. * @hidden
  102727. * @param faceIndex face index to bind to if this is a cubetexture
  102728. * @param layer defines the index of the texture to bind in the array
  102729. */
  102730. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102731. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102732. private renderToTarget;
  102733. /**
  102734. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102735. * This allowed control for front to back rendering or reversly depending of the special needs.
  102736. *
  102737. * @param renderingGroupId The rendering group id corresponding to its index
  102738. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102739. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102740. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102741. */
  102742. 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;
  102743. /**
  102744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102745. *
  102746. * @param renderingGroupId The rendering group id corresponding to its index
  102747. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102748. */
  102749. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102750. /**
  102751. * Clones the texture.
  102752. * @returns the cloned texture
  102753. */
  102754. clone(): RenderTargetTexture;
  102755. /**
  102756. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102757. * @returns The JSON representation of the texture
  102758. */
  102759. serialize(): any;
  102760. /**
  102761. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102762. */
  102763. disposeFramebufferObjects(): void;
  102764. /**
  102765. * Dispose the texture and release its associated resources.
  102766. */
  102767. dispose(): void;
  102768. /** @hidden */
  102769. _rebuild(): void;
  102770. /**
  102771. * Clear the info related to rendering groups preventing retention point in material dispose.
  102772. */
  102773. freeRenderingGroups(): void;
  102774. /**
  102775. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102776. * @returns the view count
  102777. */
  102778. getViewCount(): number;
  102779. }
  102780. }
  102781. declare module BABYLON {
  102782. /**
  102783. * Class used to manipulate GUIDs
  102784. */
  102785. export class GUID {
  102786. /**
  102787. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102788. * Be aware Math.random() could cause collisions, but:
  102789. * "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"
  102790. * @returns a pseudo random id
  102791. */
  102792. static RandomId(): string;
  102793. }
  102794. }
  102795. declare module BABYLON {
  102796. /**
  102797. * Options to be used when creating a shadow depth material
  102798. */
  102799. export interface IIOptionShadowDepthMaterial {
  102800. /** Variables in the vertex shader code that need to have their names remapped.
  102801. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102802. * "var_name" should be either: worldPos or vNormalW
  102803. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102804. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102805. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102806. */
  102807. remappedVariables?: string[];
  102808. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102809. standalone?: boolean;
  102810. }
  102811. /**
  102812. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102813. */
  102814. export class ShadowDepthWrapper {
  102815. private _scene;
  102816. private _options?;
  102817. private _baseMaterial;
  102818. private _onEffectCreatedObserver;
  102819. private _subMeshToEffect;
  102820. private _subMeshToDepthEffect;
  102821. private _meshes;
  102822. /** @hidden */
  102823. _matriceNames: any;
  102824. /** Gets the standalone status of the wrapper */
  102825. get standalone(): boolean;
  102826. /** Gets the base material the wrapper is built upon */
  102827. get baseMaterial(): Material;
  102828. /**
  102829. * Instantiate a new shadow depth wrapper.
  102830. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102831. * generate the shadow depth map. For more information, please refer to the documentation:
  102832. * https://doc.babylonjs.com/babylon101/shadows
  102833. * @param baseMaterial Material to wrap
  102834. * @param scene Define the scene the material belongs to
  102835. * @param options Options used to create the wrapper
  102836. */
  102837. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102838. /**
  102839. * Gets the effect to use to generate the depth map
  102840. * @param subMesh subMesh to get the effect for
  102841. * @param shadowGenerator shadow generator to get the effect for
  102842. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102843. */
  102844. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102845. /**
  102846. * Specifies that the submesh is ready to be used for depth rendering
  102847. * @param subMesh submesh to check
  102848. * @param defines the list of defines to take into account when checking the effect
  102849. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102850. * @param useInstances specifies that instances should be used
  102851. * @returns a boolean indicating that the submesh is ready or not
  102852. */
  102853. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102854. /**
  102855. * Disposes the resources
  102856. */
  102857. dispose(): void;
  102858. private _makeEffect;
  102859. }
  102860. }
  102861. declare module BABYLON {
  102862. interface ThinEngine {
  102863. /**
  102864. * Unbind a list of render target textures from the webGL context
  102865. * This is used only when drawBuffer extension or webGL2 are active
  102866. * @param textures defines the render target textures to unbind
  102867. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102868. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102869. */
  102870. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102871. /**
  102872. * Create a multi render target texture
  102873. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102874. * @param size defines the size of the texture
  102875. * @param options defines the creation options
  102876. * @returns the cube texture as an InternalTexture
  102877. */
  102878. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102879. /**
  102880. * Update the sample count for a given multiple render target texture
  102881. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102882. * @param textures defines the textures to update
  102883. * @param samples defines the sample count to set
  102884. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102885. */
  102886. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102887. /**
  102888. * Select a subsets of attachments to draw to.
  102889. * @param attachments gl attachments
  102890. */
  102891. bindAttachments(attachments: number[]): void;
  102892. }
  102893. }
  102894. declare module BABYLON {
  102895. /**
  102896. * Creation options of the multi render target texture.
  102897. */
  102898. export interface IMultiRenderTargetOptions {
  102899. /**
  102900. * Define if the texture needs to create mip maps after render.
  102901. */
  102902. generateMipMaps?: boolean;
  102903. /**
  102904. * Define the types of all the draw buffers we want to create
  102905. */
  102906. types?: number[];
  102907. /**
  102908. * Define the sampling modes of all the draw buffers we want to create
  102909. */
  102910. samplingModes?: number[];
  102911. /**
  102912. * Define if a depth buffer is required
  102913. */
  102914. generateDepthBuffer?: boolean;
  102915. /**
  102916. * Define if a stencil buffer is required
  102917. */
  102918. generateStencilBuffer?: boolean;
  102919. /**
  102920. * Define if a depth texture is required instead of a depth buffer
  102921. */
  102922. generateDepthTexture?: boolean;
  102923. /**
  102924. * Define the number of desired draw buffers
  102925. */
  102926. textureCount?: number;
  102927. /**
  102928. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102929. */
  102930. doNotChangeAspectRatio?: boolean;
  102931. /**
  102932. * Define the default type of the buffers we are creating
  102933. */
  102934. defaultType?: number;
  102935. }
  102936. /**
  102937. * A multi render target, like a render target provides the ability to render to a texture.
  102938. * Unlike the render target, it can render to several draw buffers in one draw.
  102939. * This is specially interesting in deferred rendering or for any effects requiring more than
  102940. * just one color from a single pass.
  102941. */
  102942. export class MultiRenderTarget extends RenderTargetTexture {
  102943. private _internalTextures;
  102944. private _textures;
  102945. private _multiRenderTargetOptions;
  102946. private _count;
  102947. /**
  102948. * Get if draw buffers are currently supported by the used hardware and browser.
  102949. */
  102950. get isSupported(): boolean;
  102951. /**
  102952. * Get the list of textures generated by the multi render target.
  102953. */
  102954. get textures(): Texture[];
  102955. /**
  102956. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102957. */
  102958. get count(): number;
  102959. /**
  102960. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102961. */
  102962. get depthTexture(): Texture;
  102963. /**
  102964. * Set the wrapping mode on U of all the textures we are rendering to.
  102965. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102966. */
  102967. set wrapU(wrap: number);
  102968. /**
  102969. * Set the wrapping mode on V of all the textures we are rendering to.
  102970. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102971. */
  102972. set wrapV(wrap: number);
  102973. /**
  102974. * Instantiate a new multi render target texture.
  102975. * A multi render target, like a render target provides the ability to render to a texture.
  102976. * Unlike the render target, it can render to several draw buffers in one draw.
  102977. * This is specially interesting in deferred rendering or for any effects requiring more than
  102978. * just one color from a single pass.
  102979. * @param name Define the name of the texture
  102980. * @param size Define the size of the buffers to render to
  102981. * @param count Define the number of target we are rendering into
  102982. * @param scene Define the scene the texture belongs to
  102983. * @param options Define the options used to create the multi render target
  102984. */
  102985. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102986. /** @hidden */
  102987. _rebuild(): void;
  102988. private _createInternalTextures;
  102989. private _createTextures;
  102990. /**
  102991. * Define the number of samples used if MSAA is enabled.
  102992. */
  102993. get samples(): number;
  102994. set samples(value: number);
  102995. /**
  102996. * Resize all the textures in the multi render target.
  102997. * Be carrefull as it will recreate all the data in the new texture.
  102998. * @param size Define the new size
  102999. */
  103000. resize(size: any): void;
  103001. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103002. /**
  103003. * Dispose the render targets and their associated resources
  103004. */
  103005. dispose(): void;
  103006. /**
  103007. * Release all the underlying texture used as draw buffers.
  103008. */
  103009. releaseInternalTextures(): void;
  103010. }
  103011. }
  103012. declare module BABYLON {
  103013. /** @hidden */
  103014. export var imageProcessingPixelShader: {
  103015. name: string;
  103016. shader: string;
  103017. };
  103018. }
  103019. declare module BABYLON {
  103020. /**
  103021. * ImageProcessingPostProcess
  103022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103023. */
  103024. export class ImageProcessingPostProcess extends PostProcess {
  103025. /**
  103026. * Default configuration related to image processing available in the PBR Material.
  103027. */
  103028. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103029. /**
  103030. * Gets the image processing configuration used either in this material.
  103031. */
  103032. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103033. /**
  103034. * Sets the Default image processing configuration used either in the this material.
  103035. *
  103036. * If sets to null, the scene one is in use.
  103037. */
  103038. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103039. /**
  103040. * Keep track of the image processing observer to allow dispose and replace.
  103041. */
  103042. private _imageProcessingObserver;
  103043. /**
  103044. * Attaches a new image processing configuration to the PBR Material.
  103045. * @param configuration
  103046. */
  103047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103048. /**
  103049. * If the post process is supported.
  103050. */
  103051. get isSupported(): boolean;
  103052. /**
  103053. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103054. */
  103055. get colorCurves(): Nullable<ColorCurves>;
  103056. /**
  103057. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103058. */
  103059. set colorCurves(value: Nullable<ColorCurves>);
  103060. /**
  103061. * Gets wether the color curves effect is enabled.
  103062. */
  103063. get colorCurvesEnabled(): boolean;
  103064. /**
  103065. * Sets wether the color curves effect is enabled.
  103066. */
  103067. set colorCurvesEnabled(value: boolean);
  103068. /**
  103069. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103070. */
  103071. get colorGradingTexture(): Nullable<BaseTexture>;
  103072. /**
  103073. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103074. */
  103075. set colorGradingTexture(value: Nullable<BaseTexture>);
  103076. /**
  103077. * Gets wether the color grading effect is enabled.
  103078. */
  103079. get colorGradingEnabled(): boolean;
  103080. /**
  103081. * Gets wether the color grading effect is enabled.
  103082. */
  103083. set colorGradingEnabled(value: boolean);
  103084. /**
  103085. * Gets exposure used in the effect.
  103086. */
  103087. get exposure(): number;
  103088. /**
  103089. * Sets exposure used in the effect.
  103090. */
  103091. set exposure(value: number);
  103092. /**
  103093. * Gets wether tonemapping is enabled or not.
  103094. */
  103095. get toneMappingEnabled(): boolean;
  103096. /**
  103097. * Sets wether tonemapping is enabled or not
  103098. */
  103099. set toneMappingEnabled(value: boolean);
  103100. /**
  103101. * Gets the type of tone mapping effect.
  103102. */
  103103. get toneMappingType(): number;
  103104. /**
  103105. * Sets the type of tone mapping effect.
  103106. */
  103107. set toneMappingType(value: number);
  103108. /**
  103109. * Gets contrast used in the effect.
  103110. */
  103111. get contrast(): number;
  103112. /**
  103113. * Sets contrast used in the effect.
  103114. */
  103115. set contrast(value: number);
  103116. /**
  103117. * Gets Vignette stretch size.
  103118. */
  103119. get vignetteStretch(): number;
  103120. /**
  103121. * Sets Vignette stretch size.
  103122. */
  103123. set vignetteStretch(value: number);
  103124. /**
  103125. * Gets Vignette centre X Offset.
  103126. */
  103127. get vignetteCentreX(): number;
  103128. /**
  103129. * Sets Vignette centre X Offset.
  103130. */
  103131. set vignetteCentreX(value: number);
  103132. /**
  103133. * Gets Vignette centre Y Offset.
  103134. */
  103135. get vignetteCentreY(): number;
  103136. /**
  103137. * Sets Vignette centre Y Offset.
  103138. */
  103139. set vignetteCentreY(value: number);
  103140. /**
  103141. * Gets Vignette weight or intensity of the vignette effect.
  103142. */
  103143. get vignetteWeight(): number;
  103144. /**
  103145. * Sets Vignette weight or intensity of the vignette effect.
  103146. */
  103147. set vignetteWeight(value: number);
  103148. /**
  103149. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103150. * if vignetteEnabled is set to true.
  103151. */
  103152. get vignetteColor(): Color4;
  103153. /**
  103154. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103155. * if vignetteEnabled is set to true.
  103156. */
  103157. set vignetteColor(value: Color4);
  103158. /**
  103159. * Gets Camera field of view used by the Vignette effect.
  103160. */
  103161. get vignetteCameraFov(): number;
  103162. /**
  103163. * Sets Camera field of view used by the Vignette effect.
  103164. */
  103165. set vignetteCameraFov(value: number);
  103166. /**
  103167. * Gets the vignette blend mode allowing different kind of effect.
  103168. */
  103169. get vignetteBlendMode(): number;
  103170. /**
  103171. * Sets the vignette blend mode allowing different kind of effect.
  103172. */
  103173. set vignetteBlendMode(value: number);
  103174. /**
  103175. * Gets wether the vignette effect is enabled.
  103176. */
  103177. get vignetteEnabled(): boolean;
  103178. /**
  103179. * Sets wether the vignette effect is enabled.
  103180. */
  103181. set vignetteEnabled(value: boolean);
  103182. private _fromLinearSpace;
  103183. /**
  103184. * Gets wether the input of the processing is in Gamma or Linear Space.
  103185. */
  103186. get fromLinearSpace(): boolean;
  103187. /**
  103188. * Sets wether the input of the processing is in Gamma or Linear Space.
  103189. */
  103190. set fromLinearSpace(value: boolean);
  103191. /**
  103192. * Defines cache preventing GC.
  103193. */
  103194. private _defines;
  103195. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103196. /**
  103197. * "ImageProcessingPostProcess"
  103198. * @returns "ImageProcessingPostProcess"
  103199. */
  103200. getClassName(): string;
  103201. /**
  103202. * @hidden
  103203. */
  103204. _updateParameters(): void;
  103205. dispose(camera?: Camera): void;
  103206. }
  103207. }
  103208. declare module BABYLON {
  103209. /** @hidden */
  103210. export var fibonacci: {
  103211. name: string;
  103212. shader: string;
  103213. };
  103214. }
  103215. declare module BABYLON {
  103216. /** @hidden */
  103217. export var subSurfaceScatteringFunctions: {
  103218. name: string;
  103219. shader: string;
  103220. };
  103221. }
  103222. declare module BABYLON {
  103223. /** @hidden */
  103224. export var diffusionProfile: {
  103225. name: string;
  103226. shader: string;
  103227. };
  103228. }
  103229. declare module BABYLON {
  103230. /** @hidden */
  103231. export var subSurfaceScatteringPixelShader: {
  103232. name: string;
  103233. shader: string;
  103234. };
  103235. }
  103236. declare module BABYLON {
  103237. /**
  103238. * Sub surface scattering post process
  103239. */
  103240. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103241. /** @hidden */
  103242. texelWidth: number;
  103243. /** @hidden */
  103244. texelHeight: number;
  103245. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103246. }
  103247. }
  103248. declare module BABYLON {
  103249. /**
  103250. * Interface for defining prepass effects in the prepass post-process pipeline
  103251. */
  103252. export interface PrePassEffectConfiguration {
  103253. /**
  103254. * Post process to attach for this effect
  103255. */
  103256. postProcess: PostProcess;
  103257. /**
  103258. * Is the effect enabled
  103259. */
  103260. enabled: boolean;
  103261. /**
  103262. * Disposes the effect configuration
  103263. */
  103264. dispose(): void;
  103265. /**
  103266. * Disposes the effect configuration
  103267. */
  103268. createPostProcess: () => PostProcess;
  103269. }
  103270. }
  103271. declare module BABYLON {
  103272. /**
  103273. * Contains all parameters needed for the prepass to perform
  103274. * screen space subsurface scattering
  103275. */
  103276. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103277. private _ssDiffusionS;
  103278. private _ssFilterRadii;
  103279. private _ssDiffusionD;
  103280. /**
  103281. * Post process to attach for screen space subsurface scattering
  103282. */
  103283. postProcess: SubSurfaceScatteringPostProcess;
  103284. /**
  103285. * Diffusion profile color for subsurface scattering
  103286. */
  103287. get ssDiffusionS(): number[];
  103288. /**
  103289. * Diffusion profile max color channel value for subsurface scattering
  103290. */
  103291. get ssDiffusionD(): number[];
  103292. /**
  103293. * Diffusion profile filter radius for subsurface scattering
  103294. */
  103295. get ssFilterRadii(): number[];
  103296. /**
  103297. * Is subsurface enabled
  103298. */
  103299. enabled: boolean;
  103300. /**
  103301. * Diffusion profile colors for subsurface scattering
  103302. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103303. * See ...
  103304. * Note that you can only store up to 5 of them
  103305. */
  103306. ssDiffusionProfileColors: Color3[];
  103307. /**
  103308. * Defines the ratio real world => scene units.
  103309. * Used for subsurface scattering
  103310. */
  103311. metersPerUnit: number;
  103312. private _scene;
  103313. /**
  103314. * Builds a subsurface configuration object
  103315. * @param scene The scene
  103316. */
  103317. constructor(scene: Scene);
  103318. /**
  103319. * Adds a new diffusion profile.
  103320. * Useful for more realistic subsurface scattering on diverse materials.
  103321. * @param color The color of the diffusion profile. Should be the average color of the material.
  103322. * @return The index of the diffusion profile for the material subsurface configuration
  103323. */
  103324. addDiffusionProfile(color: Color3): number;
  103325. /**
  103326. * Creates the sss post process
  103327. * @return The created post process
  103328. */
  103329. createPostProcess(): SubSurfaceScatteringPostProcess;
  103330. /**
  103331. * Deletes all diffusion profiles.
  103332. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103333. */
  103334. clearAllDiffusionProfiles(): void;
  103335. /**
  103336. * Disposes this object
  103337. */
  103338. dispose(): void;
  103339. /**
  103340. * @hidden
  103341. * https://zero-radiance.github.io/post/sampling-diffusion/
  103342. *
  103343. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103344. * ------------------------------------------------------------------------------------
  103345. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103346. * PDF[r, phi, s] = r * R[r, phi, s]
  103347. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103348. * ------------------------------------------------------------------------------------
  103349. * We importance sample the color channel with the widest scattering distance.
  103350. */
  103351. getDiffusionProfileParameters(color: Color3): number;
  103352. /**
  103353. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103354. * 'u' is the random number (the value of the CDF): [0, 1).
  103355. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103356. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103357. */
  103358. private _sampleBurleyDiffusionProfile;
  103359. }
  103360. }
  103361. declare module BABYLON {
  103362. /**
  103363. * Renders a pre pass of the scene
  103364. * This means every mesh in the scene will be rendered to a render target texture
  103365. * And then this texture will be composited to the rendering canvas with post processes
  103366. * It is necessary for effects like subsurface scattering or deferred shading
  103367. */
  103368. export class PrePassRenderer {
  103369. /** @hidden */
  103370. static _SceneComponentInitialization: (scene: Scene) => void;
  103371. private _scene;
  103372. private _engine;
  103373. private _isDirty;
  103374. /**
  103375. * Number of textures in the multi render target texture where the scene is directly rendered
  103376. */
  103377. readonly mrtCount: number;
  103378. /**
  103379. * The render target where the scene is directly rendered
  103380. */
  103381. prePassRT: MultiRenderTarget;
  103382. private _mrtTypes;
  103383. private _multiRenderAttachments;
  103384. private _defaultAttachments;
  103385. private _clearAttachments;
  103386. private _postProcesses;
  103387. private readonly _clearColor;
  103388. /**
  103389. * Image processing post process for composition
  103390. */
  103391. imageProcessingPostProcess: ImageProcessingPostProcess;
  103392. /**
  103393. * Configuration for sub surface scattering post process
  103394. */
  103395. subSurfaceConfiguration: SubSurfaceConfiguration;
  103396. /**
  103397. * Should materials render their geometry on the MRT
  103398. */
  103399. materialsShouldRenderGeometry: boolean;
  103400. /**
  103401. * Should materials render the irradiance information on the MRT
  103402. */
  103403. materialsShouldRenderIrradiance: boolean;
  103404. private _enabled;
  103405. /**
  103406. * Indicates if the prepass is enabled
  103407. */
  103408. get enabled(): boolean;
  103409. /**
  103410. * How many samples are used for MSAA of the scene render target
  103411. */
  103412. get samples(): number;
  103413. set samples(n: number);
  103414. /**
  103415. * Instanciates a prepass renderer
  103416. * @param scene The scene
  103417. */
  103418. constructor(scene: Scene);
  103419. private _initializeAttachments;
  103420. private _createCompositionEffect;
  103421. /**
  103422. * Indicates if rendering a prepass is supported
  103423. */
  103424. get isSupported(): boolean;
  103425. /**
  103426. * Sets the proper output textures to draw in the engine.
  103427. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103428. */
  103429. bindAttachmentsForEffect(effect: Effect): void;
  103430. /**
  103431. * @hidden
  103432. */
  103433. _beforeCameraDraw(): void;
  103434. /**
  103435. * @hidden
  103436. */
  103437. _afterCameraDraw(): void;
  103438. private _checkRTSize;
  103439. private _bindFrameBuffer;
  103440. /**
  103441. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103442. */
  103443. clear(): void;
  103444. private _setState;
  103445. private _enable;
  103446. private _disable;
  103447. private _resetPostProcessChain;
  103448. private _bindPostProcessChain;
  103449. /**
  103450. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103451. */
  103452. markAsDirty(): void;
  103453. private _update;
  103454. /**
  103455. * Disposes the prepass renderer.
  103456. */
  103457. dispose(): void;
  103458. }
  103459. }
  103460. declare module BABYLON {
  103461. /**
  103462. * Options for compiling materials.
  103463. */
  103464. export interface IMaterialCompilationOptions {
  103465. /**
  103466. * Defines whether clip planes are enabled.
  103467. */
  103468. clipPlane: boolean;
  103469. /**
  103470. * Defines whether instances are enabled.
  103471. */
  103472. useInstances: boolean;
  103473. }
  103474. /**
  103475. * Options passed when calling customShaderNameResolve
  103476. */
  103477. export interface ICustomShaderNameResolveOptions {
  103478. /**
  103479. * 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
  103480. */
  103481. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103482. }
  103483. /**
  103484. * Base class for the main features of a material in Babylon.js
  103485. */
  103486. export class Material implements IAnimatable {
  103487. /**
  103488. * Returns the triangle fill mode
  103489. */
  103490. static readonly TriangleFillMode: number;
  103491. /**
  103492. * Returns the wireframe mode
  103493. */
  103494. static readonly WireFrameFillMode: number;
  103495. /**
  103496. * Returns the point fill mode
  103497. */
  103498. static readonly PointFillMode: number;
  103499. /**
  103500. * Returns the point list draw mode
  103501. */
  103502. static readonly PointListDrawMode: number;
  103503. /**
  103504. * Returns the line list draw mode
  103505. */
  103506. static readonly LineListDrawMode: number;
  103507. /**
  103508. * Returns the line loop draw mode
  103509. */
  103510. static readonly LineLoopDrawMode: number;
  103511. /**
  103512. * Returns the line strip draw mode
  103513. */
  103514. static readonly LineStripDrawMode: number;
  103515. /**
  103516. * Returns the triangle strip draw mode
  103517. */
  103518. static readonly TriangleStripDrawMode: number;
  103519. /**
  103520. * Returns the triangle fan draw mode
  103521. */
  103522. static readonly TriangleFanDrawMode: number;
  103523. /**
  103524. * Stores the clock-wise side orientation
  103525. */
  103526. static readonly ClockWiseSideOrientation: number;
  103527. /**
  103528. * Stores the counter clock-wise side orientation
  103529. */
  103530. static readonly CounterClockWiseSideOrientation: number;
  103531. /**
  103532. * The dirty texture flag value
  103533. */
  103534. static readonly TextureDirtyFlag: number;
  103535. /**
  103536. * The dirty light flag value
  103537. */
  103538. static readonly LightDirtyFlag: number;
  103539. /**
  103540. * The dirty fresnel flag value
  103541. */
  103542. static readonly FresnelDirtyFlag: number;
  103543. /**
  103544. * The dirty attribute flag value
  103545. */
  103546. static readonly AttributesDirtyFlag: number;
  103547. /**
  103548. * The dirty misc flag value
  103549. */
  103550. static readonly MiscDirtyFlag: number;
  103551. /**
  103552. * The all dirty flag value
  103553. */
  103554. static readonly AllDirtyFlag: number;
  103555. /**
  103556. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103557. */
  103558. static readonly MATERIAL_OPAQUE: number;
  103559. /**
  103560. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103561. */
  103562. static readonly MATERIAL_ALPHATEST: number;
  103563. /**
  103564. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103565. */
  103566. static readonly MATERIAL_ALPHABLEND: number;
  103567. /**
  103568. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103569. * They are also discarded below the alpha cutoff threshold to improve performances.
  103570. */
  103571. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103572. /**
  103573. * The Whiteout method is used to blend normals.
  103574. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103575. */
  103576. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103577. /**
  103578. * The Reoriented Normal Mapping method is used to blend normals.
  103579. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103580. */
  103581. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103582. /**
  103583. * Custom callback helping to override the default shader used in the material.
  103584. */
  103585. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103586. /**
  103587. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103588. */
  103589. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103590. /**
  103591. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103592. * This means that the material can keep using a previous shader while a new one is being compiled.
  103593. * This is mostly used when shader parallel compilation is supported (true by default)
  103594. */
  103595. allowShaderHotSwapping: boolean;
  103596. /**
  103597. * The ID of the material
  103598. */
  103599. id: string;
  103600. /**
  103601. * Gets or sets the unique id of the material
  103602. */
  103603. uniqueId: number;
  103604. /**
  103605. * The name of the material
  103606. */
  103607. name: string;
  103608. /**
  103609. * Gets or sets user defined metadata
  103610. */
  103611. metadata: any;
  103612. /**
  103613. * For internal use only. Please do not use.
  103614. */
  103615. reservedDataStore: any;
  103616. /**
  103617. * Specifies if the ready state should be checked on each call
  103618. */
  103619. checkReadyOnEveryCall: boolean;
  103620. /**
  103621. * Specifies if the ready state should be checked once
  103622. */
  103623. checkReadyOnlyOnce: boolean;
  103624. /**
  103625. * The state of the material
  103626. */
  103627. state: string;
  103628. /**
  103629. * If the material can be rendered to several textures with MRT extension
  103630. */
  103631. get canRenderToMRT(): boolean;
  103632. /**
  103633. * The alpha value of the material
  103634. */
  103635. protected _alpha: number;
  103636. /**
  103637. * List of inspectable custom properties (used by the Inspector)
  103638. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103639. */
  103640. inspectableCustomProperties: IInspectable[];
  103641. /**
  103642. * Sets the alpha value of the material
  103643. */
  103644. set alpha(value: number);
  103645. /**
  103646. * Gets the alpha value of the material
  103647. */
  103648. get alpha(): number;
  103649. /**
  103650. * Specifies if back face culling is enabled
  103651. */
  103652. protected _backFaceCulling: boolean;
  103653. /**
  103654. * Sets the back-face culling state
  103655. */
  103656. set backFaceCulling(value: boolean);
  103657. /**
  103658. * Gets the back-face culling state
  103659. */
  103660. get backFaceCulling(): boolean;
  103661. /**
  103662. * Stores the value for side orientation
  103663. */
  103664. sideOrientation: number;
  103665. /**
  103666. * Callback triggered when the material is compiled
  103667. */
  103668. onCompiled: Nullable<(effect: Effect) => void>;
  103669. /**
  103670. * Callback triggered when an error occurs
  103671. */
  103672. onError: Nullable<(effect: Effect, errors: string) => void>;
  103673. /**
  103674. * Callback triggered to get the render target textures
  103675. */
  103676. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103677. /**
  103678. * Gets a boolean indicating that current material needs to register RTT
  103679. */
  103680. get hasRenderTargetTextures(): boolean;
  103681. /**
  103682. * Specifies if the material should be serialized
  103683. */
  103684. doNotSerialize: boolean;
  103685. /**
  103686. * @hidden
  103687. */
  103688. _storeEffectOnSubMeshes: boolean;
  103689. /**
  103690. * Stores the animations for the material
  103691. */
  103692. animations: Nullable<Array<Animation>>;
  103693. /**
  103694. * An event triggered when the material is disposed
  103695. */
  103696. onDisposeObservable: Observable<Material>;
  103697. /**
  103698. * An observer which watches for dispose events
  103699. */
  103700. private _onDisposeObserver;
  103701. private _onUnBindObservable;
  103702. /**
  103703. * Called during a dispose event
  103704. */
  103705. set onDispose(callback: () => void);
  103706. private _onBindObservable;
  103707. /**
  103708. * An event triggered when the material is bound
  103709. */
  103710. get onBindObservable(): Observable<AbstractMesh>;
  103711. /**
  103712. * An observer which watches for bind events
  103713. */
  103714. private _onBindObserver;
  103715. /**
  103716. * Called during a bind event
  103717. */
  103718. set onBind(callback: (Mesh: AbstractMesh) => void);
  103719. /**
  103720. * An event triggered when the material is unbound
  103721. */
  103722. get onUnBindObservable(): Observable<Material>;
  103723. protected _onEffectCreatedObservable: Nullable<Observable<{
  103724. effect: Effect;
  103725. subMesh: Nullable<SubMesh>;
  103726. }>>;
  103727. /**
  103728. * An event triggered when the effect is (re)created
  103729. */
  103730. get onEffectCreatedObservable(): Observable<{
  103731. effect: Effect;
  103732. subMesh: Nullable<SubMesh>;
  103733. }>;
  103734. /**
  103735. * Stores the value of the alpha mode
  103736. */
  103737. private _alphaMode;
  103738. /**
  103739. * Sets the value of the alpha mode.
  103740. *
  103741. * | Value | Type | Description |
  103742. * | --- | --- | --- |
  103743. * | 0 | ALPHA_DISABLE | |
  103744. * | 1 | ALPHA_ADD | |
  103745. * | 2 | ALPHA_COMBINE | |
  103746. * | 3 | ALPHA_SUBTRACT | |
  103747. * | 4 | ALPHA_MULTIPLY | |
  103748. * | 5 | ALPHA_MAXIMIZED | |
  103749. * | 6 | ALPHA_ONEONE | |
  103750. * | 7 | ALPHA_PREMULTIPLIED | |
  103751. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103752. * | 9 | ALPHA_INTERPOLATE | |
  103753. * | 10 | ALPHA_SCREENMODE | |
  103754. *
  103755. */
  103756. set alphaMode(value: number);
  103757. /**
  103758. * Gets the value of the alpha mode
  103759. */
  103760. get alphaMode(): number;
  103761. /**
  103762. * Stores the state of the need depth pre-pass value
  103763. */
  103764. private _needDepthPrePass;
  103765. /**
  103766. * Sets the need depth pre-pass value
  103767. */
  103768. set needDepthPrePass(value: boolean);
  103769. /**
  103770. * Gets the depth pre-pass value
  103771. */
  103772. get needDepthPrePass(): boolean;
  103773. /**
  103774. * Specifies if depth writing should be disabled
  103775. */
  103776. disableDepthWrite: boolean;
  103777. /**
  103778. * Specifies if color writing should be disabled
  103779. */
  103780. disableColorWrite: boolean;
  103781. /**
  103782. * Specifies if depth writing should be forced
  103783. */
  103784. forceDepthWrite: boolean;
  103785. /**
  103786. * Specifies the depth function that should be used. 0 means the default engine function
  103787. */
  103788. depthFunction: number;
  103789. /**
  103790. * Specifies if there should be a separate pass for culling
  103791. */
  103792. separateCullingPass: boolean;
  103793. /**
  103794. * Stores the state specifing if fog should be enabled
  103795. */
  103796. private _fogEnabled;
  103797. /**
  103798. * Sets the state for enabling fog
  103799. */
  103800. set fogEnabled(value: boolean);
  103801. /**
  103802. * Gets the value of the fog enabled state
  103803. */
  103804. get fogEnabled(): boolean;
  103805. /**
  103806. * Stores the size of points
  103807. */
  103808. pointSize: number;
  103809. /**
  103810. * Stores the z offset value
  103811. */
  103812. zOffset: number;
  103813. get wireframe(): boolean;
  103814. /**
  103815. * Sets the state of wireframe mode
  103816. */
  103817. set wireframe(value: boolean);
  103818. /**
  103819. * Gets the value specifying if point clouds are enabled
  103820. */
  103821. get pointsCloud(): boolean;
  103822. /**
  103823. * Sets the state of point cloud mode
  103824. */
  103825. set pointsCloud(value: boolean);
  103826. /**
  103827. * Gets the material fill mode
  103828. */
  103829. get fillMode(): number;
  103830. /**
  103831. * Sets the material fill mode
  103832. */
  103833. set fillMode(value: number);
  103834. /**
  103835. * @hidden
  103836. * Stores the effects for the material
  103837. */
  103838. _effect: Nullable<Effect>;
  103839. /**
  103840. * Specifies if uniform buffers should be used
  103841. */
  103842. private _useUBO;
  103843. /**
  103844. * Stores a reference to the scene
  103845. */
  103846. private _scene;
  103847. /**
  103848. * Stores the fill mode state
  103849. */
  103850. private _fillMode;
  103851. /**
  103852. * Specifies if the depth write state should be cached
  103853. */
  103854. private _cachedDepthWriteState;
  103855. /**
  103856. * Specifies if the color write state should be cached
  103857. */
  103858. private _cachedColorWriteState;
  103859. /**
  103860. * Specifies if the depth function state should be cached
  103861. */
  103862. private _cachedDepthFunctionState;
  103863. /**
  103864. * Stores the uniform buffer
  103865. */
  103866. protected _uniformBuffer: UniformBuffer;
  103867. /** @hidden */
  103868. _indexInSceneMaterialArray: number;
  103869. /** @hidden */
  103870. meshMap: Nullable<{
  103871. [id: string]: AbstractMesh | undefined;
  103872. }>;
  103873. /**
  103874. * Creates a material instance
  103875. * @param name defines the name of the material
  103876. * @param scene defines the scene to reference
  103877. * @param doNotAdd specifies if the material should be added to the scene
  103878. */
  103879. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103880. /**
  103881. * Returns a string representation of the current material
  103882. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103883. * @returns a string with material information
  103884. */
  103885. toString(fullDetails?: boolean): string;
  103886. /**
  103887. * Gets the class name of the material
  103888. * @returns a string with the class name of the material
  103889. */
  103890. getClassName(): string;
  103891. /**
  103892. * Specifies if updates for the material been locked
  103893. */
  103894. get isFrozen(): boolean;
  103895. /**
  103896. * Locks updates for the material
  103897. */
  103898. freeze(): void;
  103899. /**
  103900. * Unlocks updates for the material
  103901. */
  103902. unfreeze(): void;
  103903. /**
  103904. * Specifies if the material is ready to be used
  103905. * @param mesh defines the mesh to check
  103906. * @param useInstances specifies if instances should be used
  103907. * @returns a boolean indicating if the material is ready to be used
  103908. */
  103909. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103910. /**
  103911. * Specifies that the submesh is ready to be used
  103912. * @param mesh defines the mesh to check
  103913. * @param subMesh defines which submesh to check
  103914. * @param useInstances specifies that instances should be used
  103915. * @returns a boolean indicating that the submesh is ready or not
  103916. */
  103917. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103918. /**
  103919. * Returns the material effect
  103920. * @returns the effect associated with the material
  103921. */
  103922. getEffect(): Nullable<Effect>;
  103923. /**
  103924. * Returns the current scene
  103925. * @returns a Scene
  103926. */
  103927. getScene(): Scene;
  103928. /**
  103929. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103930. */
  103931. protected _forceAlphaTest: boolean;
  103932. /**
  103933. * The transparency mode of the material.
  103934. */
  103935. protected _transparencyMode: Nullable<number>;
  103936. /**
  103937. * Gets the current transparency mode.
  103938. */
  103939. get transparencyMode(): Nullable<number>;
  103940. /**
  103941. * Sets the transparency mode of the material.
  103942. *
  103943. * | Value | Type | Description |
  103944. * | ----- | ----------------------------------- | ----------- |
  103945. * | 0 | OPAQUE | |
  103946. * | 1 | ALPHATEST | |
  103947. * | 2 | ALPHABLEND | |
  103948. * | 3 | ALPHATESTANDBLEND | |
  103949. *
  103950. */
  103951. set transparencyMode(value: Nullable<number>);
  103952. /**
  103953. * Returns true if alpha blending should be disabled.
  103954. */
  103955. protected get _disableAlphaBlending(): boolean;
  103956. /**
  103957. * Specifies whether or not this material should be rendered in alpha blend mode.
  103958. * @returns a boolean specifying if alpha blending is needed
  103959. */
  103960. needAlphaBlending(): boolean;
  103961. /**
  103962. * Specifies if the mesh will require alpha blending
  103963. * @param mesh defines the mesh to check
  103964. * @returns a boolean specifying if alpha blending is needed for the mesh
  103965. */
  103966. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103967. /**
  103968. * Specifies whether or not this material should be rendered in alpha test mode.
  103969. * @returns a boolean specifying if an alpha test is needed.
  103970. */
  103971. needAlphaTesting(): boolean;
  103972. /**
  103973. * Specifies if material alpha testing should be turned on for the mesh
  103974. * @param mesh defines the mesh to check
  103975. */
  103976. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103977. /**
  103978. * Gets the texture used for the alpha test
  103979. * @returns the texture to use for alpha testing
  103980. */
  103981. getAlphaTestTexture(): Nullable<BaseTexture>;
  103982. /**
  103983. * Marks the material to indicate that it needs to be re-calculated
  103984. */
  103985. markDirty(): void;
  103986. /** @hidden */
  103987. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103988. /**
  103989. * Binds the material to the mesh
  103990. * @param world defines the world transformation matrix
  103991. * @param mesh defines the mesh to bind the material to
  103992. */
  103993. bind(world: Matrix, mesh?: Mesh): void;
  103994. /**
  103995. * Binds the submesh to the material
  103996. * @param world defines the world transformation matrix
  103997. * @param mesh defines the mesh containing the submesh
  103998. * @param subMesh defines the submesh to bind the material to
  103999. */
  104000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104001. /**
  104002. * Binds the world matrix to the material
  104003. * @param world defines the world transformation matrix
  104004. */
  104005. bindOnlyWorldMatrix(world: Matrix): void;
  104006. /**
  104007. * Binds the scene's uniform buffer to the effect.
  104008. * @param effect defines the effect to bind to the scene uniform buffer
  104009. * @param sceneUbo defines the uniform buffer storing scene data
  104010. */
  104011. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104012. /**
  104013. * Binds the view matrix to the effect
  104014. * @param effect defines the effect to bind the view matrix to
  104015. */
  104016. bindView(effect: Effect): void;
  104017. /**
  104018. * Binds the view projection matrix to the effect
  104019. * @param effect defines the effect to bind the view projection matrix to
  104020. */
  104021. bindViewProjection(effect: Effect): void;
  104022. /**
  104023. * Processes to execute after binding the material to a mesh
  104024. * @param mesh defines the rendered mesh
  104025. */
  104026. protected _afterBind(mesh?: Mesh): void;
  104027. /**
  104028. * Unbinds the material from the mesh
  104029. */
  104030. unbind(): void;
  104031. /**
  104032. * Gets the active textures from the material
  104033. * @returns an array of textures
  104034. */
  104035. getActiveTextures(): BaseTexture[];
  104036. /**
  104037. * Specifies if the material uses a texture
  104038. * @param texture defines the texture to check against the material
  104039. * @returns a boolean specifying if the material uses the texture
  104040. */
  104041. hasTexture(texture: BaseTexture): boolean;
  104042. /**
  104043. * Makes a duplicate of the material, and gives it a new name
  104044. * @param name defines the new name for the duplicated material
  104045. * @returns the cloned material
  104046. */
  104047. clone(name: string): Nullable<Material>;
  104048. /**
  104049. * Gets the meshes bound to the material
  104050. * @returns an array of meshes bound to the material
  104051. */
  104052. getBindedMeshes(): AbstractMesh[];
  104053. /**
  104054. * Force shader compilation
  104055. * @param mesh defines the mesh associated with this material
  104056. * @param onCompiled defines a function to execute once the material is compiled
  104057. * @param options defines the options to configure the compilation
  104058. * @param onError defines a function to execute if the material fails compiling
  104059. */
  104060. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104061. /**
  104062. * Force shader compilation
  104063. * @param mesh defines the mesh that will use this material
  104064. * @param options defines additional options for compiling the shaders
  104065. * @returns a promise that resolves when the compilation completes
  104066. */
  104067. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104068. private static readonly _AllDirtyCallBack;
  104069. private static readonly _ImageProcessingDirtyCallBack;
  104070. private static readonly _TextureDirtyCallBack;
  104071. private static readonly _FresnelDirtyCallBack;
  104072. private static readonly _MiscDirtyCallBack;
  104073. private static readonly _LightsDirtyCallBack;
  104074. private static readonly _AttributeDirtyCallBack;
  104075. private static _FresnelAndMiscDirtyCallBack;
  104076. private static _TextureAndMiscDirtyCallBack;
  104077. private static readonly _DirtyCallbackArray;
  104078. private static readonly _RunDirtyCallBacks;
  104079. /**
  104080. * Marks a define in the material to indicate that it needs to be re-computed
  104081. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104082. */
  104083. markAsDirty(flag: number): void;
  104084. /**
  104085. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104086. * @param func defines a function which checks material defines against the submeshes
  104087. */
  104088. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104089. /**
  104090. * Indicates that the scene should check if the rendering now needs a prepass
  104091. */
  104092. protected _markScenePrePassDirty(): void;
  104093. /**
  104094. * Indicates that we need to re-calculated for all submeshes
  104095. */
  104096. protected _markAllSubMeshesAsAllDirty(): void;
  104097. /**
  104098. * Indicates that image processing needs to be re-calculated for all submeshes
  104099. */
  104100. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104101. /**
  104102. * Indicates that textures need to be re-calculated for all submeshes
  104103. */
  104104. protected _markAllSubMeshesAsTexturesDirty(): void;
  104105. /**
  104106. * Indicates that fresnel needs to be re-calculated for all submeshes
  104107. */
  104108. protected _markAllSubMeshesAsFresnelDirty(): void;
  104109. /**
  104110. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104111. */
  104112. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104113. /**
  104114. * Indicates that lights need to be re-calculated for all submeshes
  104115. */
  104116. protected _markAllSubMeshesAsLightsDirty(): void;
  104117. /**
  104118. * Indicates that attributes need to be re-calculated for all submeshes
  104119. */
  104120. protected _markAllSubMeshesAsAttributesDirty(): void;
  104121. /**
  104122. * Indicates that misc needs to be re-calculated for all submeshes
  104123. */
  104124. protected _markAllSubMeshesAsMiscDirty(): void;
  104125. /**
  104126. * Indicates that textures and misc need to be re-calculated for all submeshes
  104127. */
  104128. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104129. /**
  104130. * Sets the required values to the prepass renderer.
  104131. * @param prePassRenderer defines the prepass renderer to setup.
  104132. * @returns true if the pre pass is needed.
  104133. */
  104134. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104135. /**
  104136. * Disposes the material
  104137. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104138. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104139. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104140. */
  104141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104142. /** @hidden */
  104143. private releaseVertexArrayObject;
  104144. /**
  104145. * Serializes this material
  104146. * @returns the serialized material object
  104147. */
  104148. serialize(): any;
  104149. /**
  104150. * Creates a material from parsed material data
  104151. * @param parsedMaterial defines parsed material data
  104152. * @param scene defines the hosting scene
  104153. * @param rootUrl defines the root URL to use to load textures
  104154. * @returns a new material
  104155. */
  104156. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104157. }
  104158. }
  104159. declare module BABYLON {
  104160. /**
  104161. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104162. * separate meshes. This can be use to improve performances.
  104163. * @see https://doc.babylonjs.com/how_to/multi_materials
  104164. */
  104165. export class MultiMaterial extends Material {
  104166. private _subMaterials;
  104167. /**
  104168. * Gets or Sets the list of Materials used within the multi material.
  104169. * They need to be ordered according to the submeshes order in the associated mesh
  104170. */
  104171. get subMaterials(): Nullable<Material>[];
  104172. set subMaterials(value: Nullable<Material>[]);
  104173. /**
  104174. * Function used to align with Node.getChildren()
  104175. * @returns the list of Materials used within the multi material
  104176. */
  104177. getChildren(): Nullable<Material>[];
  104178. /**
  104179. * Instantiates a new Multi Material
  104180. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104181. * separate meshes. This can be use to improve performances.
  104182. * @see https://doc.babylonjs.com/how_to/multi_materials
  104183. * @param name Define the name in the scene
  104184. * @param scene Define the scene the material belongs to
  104185. */
  104186. constructor(name: string, scene: Scene);
  104187. private _hookArray;
  104188. /**
  104189. * Get one of the submaterial by its index in the submaterials array
  104190. * @param index The index to look the sub material at
  104191. * @returns The Material if the index has been defined
  104192. */
  104193. getSubMaterial(index: number): Nullable<Material>;
  104194. /**
  104195. * Get the list of active textures for the whole sub materials list.
  104196. * @returns All the textures that will be used during the rendering
  104197. */
  104198. getActiveTextures(): BaseTexture[];
  104199. /**
  104200. * Gets the current class name of the material e.g. "MultiMaterial"
  104201. * Mainly use in serialization.
  104202. * @returns the class name
  104203. */
  104204. getClassName(): string;
  104205. /**
  104206. * Checks if the material is ready to render the requested sub mesh
  104207. * @param mesh Define the mesh the submesh belongs to
  104208. * @param subMesh Define the sub mesh to look readyness for
  104209. * @param useInstances Define whether or not the material is used with instances
  104210. * @returns true if ready, otherwise false
  104211. */
  104212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104213. /**
  104214. * Clones the current material and its related sub materials
  104215. * @param name Define the name of the newly cloned material
  104216. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104217. * @returns the cloned material
  104218. */
  104219. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104220. /**
  104221. * Serializes the materials into a JSON representation.
  104222. * @returns the JSON representation
  104223. */
  104224. serialize(): any;
  104225. /**
  104226. * Dispose the material and release its associated resources
  104227. * @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)
  104228. * @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)
  104229. * @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)
  104230. */
  104231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104232. /**
  104233. * Creates a MultiMaterial from parsed MultiMaterial data.
  104234. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104235. * @param scene defines the hosting scene
  104236. * @returns a new MultiMaterial
  104237. */
  104238. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104239. }
  104240. }
  104241. declare module BABYLON {
  104242. /**
  104243. * Defines a subdivision inside a mesh
  104244. */
  104245. export class SubMesh implements ICullable {
  104246. /** the material index to use */
  104247. materialIndex: number;
  104248. /** vertex index start */
  104249. verticesStart: number;
  104250. /** vertices count */
  104251. verticesCount: number;
  104252. /** index start */
  104253. indexStart: number;
  104254. /** indices count */
  104255. indexCount: number;
  104256. /** @hidden */
  104257. _materialDefines: Nullable<MaterialDefines>;
  104258. /** @hidden */
  104259. _materialEffect: Nullable<Effect>;
  104260. /** @hidden */
  104261. _effectOverride: Nullable<Effect>;
  104262. /**
  104263. * Gets material defines used by the effect associated to the sub mesh
  104264. */
  104265. get materialDefines(): Nullable<MaterialDefines>;
  104266. /**
  104267. * Sets material defines used by the effect associated to the sub mesh
  104268. */
  104269. set materialDefines(defines: Nullable<MaterialDefines>);
  104270. /**
  104271. * Gets associated effect
  104272. */
  104273. get effect(): Nullable<Effect>;
  104274. /**
  104275. * Sets associated effect (effect used to render this submesh)
  104276. * @param effect defines the effect to associate with
  104277. * @param defines defines the set of defines used to compile this effect
  104278. */
  104279. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104280. /** @hidden */
  104281. _linesIndexCount: number;
  104282. private _mesh;
  104283. private _renderingMesh;
  104284. private _boundingInfo;
  104285. private _linesIndexBuffer;
  104286. /** @hidden */
  104287. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104288. /** @hidden */
  104289. _trianglePlanes: Plane[];
  104290. /** @hidden */
  104291. _lastColliderTransformMatrix: Nullable<Matrix>;
  104292. /** @hidden */
  104293. _renderId: number;
  104294. /** @hidden */
  104295. _alphaIndex: number;
  104296. /** @hidden */
  104297. _distanceToCamera: number;
  104298. /** @hidden */
  104299. _id: number;
  104300. private _currentMaterial;
  104301. /**
  104302. * Add a new submesh to a mesh
  104303. * @param materialIndex defines the material index to use
  104304. * @param verticesStart defines vertex index start
  104305. * @param verticesCount defines vertices count
  104306. * @param indexStart defines index start
  104307. * @param indexCount defines indices count
  104308. * @param mesh defines the parent mesh
  104309. * @param renderingMesh defines an optional rendering mesh
  104310. * @param createBoundingBox defines if bounding box should be created for this submesh
  104311. * @returns the new submesh
  104312. */
  104313. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104314. /**
  104315. * Creates a new submesh
  104316. * @param materialIndex defines the material index to use
  104317. * @param verticesStart defines vertex index start
  104318. * @param verticesCount defines vertices count
  104319. * @param indexStart defines index start
  104320. * @param indexCount defines indices count
  104321. * @param mesh defines the parent mesh
  104322. * @param renderingMesh defines an optional rendering mesh
  104323. * @param createBoundingBox defines if bounding box should be created for this submesh
  104324. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104325. */
  104326. constructor(
  104327. /** the material index to use */
  104328. materialIndex: number,
  104329. /** vertex index start */
  104330. verticesStart: number,
  104331. /** vertices count */
  104332. verticesCount: number,
  104333. /** index start */
  104334. indexStart: number,
  104335. /** indices count */
  104336. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104337. /**
  104338. * Returns true if this submesh covers the entire parent mesh
  104339. * @ignorenaming
  104340. */
  104341. get IsGlobal(): boolean;
  104342. /**
  104343. * Returns the submesh BoudingInfo object
  104344. * @returns current bounding info (or mesh's one if the submesh is global)
  104345. */
  104346. getBoundingInfo(): BoundingInfo;
  104347. /**
  104348. * Sets the submesh BoundingInfo
  104349. * @param boundingInfo defines the new bounding info to use
  104350. * @returns the SubMesh
  104351. */
  104352. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104353. /**
  104354. * Returns the mesh of the current submesh
  104355. * @return the parent mesh
  104356. */
  104357. getMesh(): AbstractMesh;
  104358. /**
  104359. * Returns the rendering mesh of the submesh
  104360. * @returns the rendering mesh (could be different from parent mesh)
  104361. */
  104362. getRenderingMesh(): Mesh;
  104363. /**
  104364. * Returns the replacement mesh of the submesh
  104365. * @returns the replacement mesh (could be different from parent mesh)
  104366. */
  104367. getReplacementMesh(): Nullable<AbstractMesh>;
  104368. /**
  104369. * Returns the effective mesh of the submesh
  104370. * @returns the effective mesh (could be different from parent mesh)
  104371. */
  104372. getEffectiveMesh(): AbstractMesh;
  104373. /**
  104374. * Returns the submesh material
  104375. * @returns null or the current material
  104376. */
  104377. getMaterial(): Nullable<Material>;
  104378. private _IsMultiMaterial;
  104379. /**
  104380. * Sets a new updated BoundingInfo object to the submesh
  104381. * @param data defines an optional position array to use to determine the bounding info
  104382. * @returns the SubMesh
  104383. */
  104384. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104385. /** @hidden */
  104386. _checkCollision(collider: Collider): boolean;
  104387. /**
  104388. * Updates the submesh BoundingInfo
  104389. * @param world defines the world matrix to use to update the bounding info
  104390. * @returns the submesh
  104391. */
  104392. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104393. /**
  104394. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104395. * @param frustumPlanes defines the frustum planes
  104396. * @returns true if the submesh is intersecting with the frustum
  104397. */
  104398. isInFrustum(frustumPlanes: Plane[]): boolean;
  104399. /**
  104400. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104401. * @param frustumPlanes defines the frustum planes
  104402. * @returns true if the submesh is inside the frustum
  104403. */
  104404. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104405. /**
  104406. * Renders the submesh
  104407. * @param enableAlphaMode defines if alpha needs to be used
  104408. * @returns the submesh
  104409. */
  104410. render(enableAlphaMode: boolean): SubMesh;
  104411. /**
  104412. * @hidden
  104413. */
  104414. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104415. /**
  104416. * Checks if the submesh intersects with a ray
  104417. * @param ray defines the ray to test
  104418. * @returns true is the passed ray intersects the submesh bounding box
  104419. */
  104420. canIntersects(ray: Ray): boolean;
  104421. /**
  104422. * Intersects current submesh with a ray
  104423. * @param ray defines the ray to test
  104424. * @param positions defines mesh's positions array
  104425. * @param indices defines mesh's indices array
  104426. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104427. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104428. * @returns intersection info or null if no intersection
  104429. */
  104430. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104431. /** @hidden */
  104432. private _intersectLines;
  104433. /** @hidden */
  104434. private _intersectUnIndexedLines;
  104435. /** @hidden */
  104436. private _intersectTriangles;
  104437. /** @hidden */
  104438. private _intersectUnIndexedTriangles;
  104439. /** @hidden */
  104440. _rebuild(): void;
  104441. /**
  104442. * Creates a new submesh from the passed mesh
  104443. * @param newMesh defines the new hosting mesh
  104444. * @param newRenderingMesh defines an optional rendering mesh
  104445. * @returns the new submesh
  104446. */
  104447. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104448. /**
  104449. * Release associated resources
  104450. */
  104451. dispose(): void;
  104452. /**
  104453. * Gets the class name
  104454. * @returns the string "SubMesh".
  104455. */
  104456. getClassName(): string;
  104457. /**
  104458. * Creates a new submesh from indices data
  104459. * @param materialIndex the index of the main mesh material
  104460. * @param startIndex the index where to start the copy in the mesh indices array
  104461. * @param indexCount the number of indices to copy then from the startIndex
  104462. * @param mesh the main mesh to create the submesh from
  104463. * @param renderingMesh the optional rendering mesh
  104464. * @returns a new submesh
  104465. */
  104466. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104467. }
  104468. }
  104469. declare module BABYLON {
  104470. /**
  104471. * Class used to represent data loading progression
  104472. */
  104473. export class SceneLoaderFlags {
  104474. private static _ForceFullSceneLoadingForIncremental;
  104475. private static _ShowLoadingScreen;
  104476. private static _CleanBoneMatrixWeights;
  104477. private static _loggingLevel;
  104478. /**
  104479. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104480. */
  104481. static get ForceFullSceneLoadingForIncremental(): boolean;
  104482. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104483. /**
  104484. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104485. */
  104486. static get ShowLoadingScreen(): boolean;
  104487. static set ShowLoadingScreen(value: boolean);
  104488. /**
  104489. * Defines the current logging level (while loading the scene)
  104490. * @ignorenaming
  104491. */
  104492. static get loggingLevel(): number;
  104493. static set loggingLevel(value: number);
  104494. /**
  104495. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104496. */
  104497. static get CleanBoneMatrixWeights(): boolean;
  104498. static set CleanBoneMatrixWeights(value: boolean);
  104499. }
  104500. }
  104501. declare module BABYLON {
  104502. /**
  104503. * Class used to store geometry data (vertex buffers + index buffer)
  104504. */
  104505. export class Geometry implements IGetSetVerticesData {
  104506. /**
  104507. * Gets or sets the ID of the geometry
  104508. */
  104509. id: string;
  104510. /**
  104511. * Gets or sets the unique ID of the geometry
  104512. */
  104513. uniqueId: number;
  104514. /**
  104515. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104516. */
  104517. delayLoadState: number;
  104518. /**
  104519. * Gets the file containing the data to load when running in delay load state
  104520. */
  104521. delayLoadingFile: Nullable<string>;
  104522. /**
  104523. * Callback called when the geometry is updated
  104524. */
  104525. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104526. private _scene;
  104527. private _engine;
  104528. private _meshes;
  104529. private _totalVertices;
  104530. /** @hidden */
  104531. _indices: IndicesArray;
  104532. /** @hidden */
  104533. _vertexBuffers: {
  104534. [key: string]: VertexBuffer;
  104535. };
  104536. private _isDisposed;
  104537. private _extend;
  104538. private _boundingBias;
  104539. /** @hidden */
  104540. _delayInfo: Array<string>;
  104541. private _indexBuffer;
  104542. private _indexBufferIsUpdatable;
  104543. /** @hidden */
  104544. _boundingInfo: Nullable<BoundingInfo>;
  104545. /** @hidden */
  104546. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104547. /** @hidden */
  104548. _softwareSkinningFrameId: number;
  104549. private _vertexArrayObjects;
  104550. private _updatable;
  104551. /** @hidden */
  104552. _positions: Nullable<Vector3[]>;
  104553. /**
  104554. * 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
  104555. */
  104556. get boundingBias(): Vector2;
  104557. /**
  104558. * 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
  104559. */
  104560. set boundingBias(value: Vector2);
  104561. /**
  104562. * Static function used to attach a new empty geometry to a mesh
  104563. * @param mesh defines the mesh to attach the geometry to
  104564. * @returns the new Geometry
  104565. */
  104566. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104567. /** Get the list of meshes using this geometry */
  104568. get meshes(): Mesh[];
  104569. /**
  104570. * 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
  104571. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104572. */
  104573. useBoundingInfoFromGeometry: boolean;
  104574. /**
  104575. * Creates a new geometry
  104576. * @param id defines the unique ID
  104577. * @param scene defines the hosting scene
  104578. * @param vertexData defines the VertexData used to get geometry data
  104579. * @param updatable defines if geometry must be updatable (false by default)
  104580. * @param mesh defines the mesh that will be associated with the geometry
  104581. */
  104582. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104583. /**
  104584. * Gets the current extend of the geometry
  104585. */
  104586. get extend(): {
  104587. minimum: Vector3;
  104588. maximum: Vector3;
  104589. };
  104590. /**
  104591. * Gets the hosting scene
  104592. * @returns the hosting Scene
  104593. */
  104594. getScene(): Scene;
  104595. /**
  104596. * Gets the hosting engine
  104597. * @returns the hosting Engine
  104598. */
  104599. getEngine(): Engine;
  104600. /**
  104601. * Defines if the geometry is ready to use
  104602. * @returns true if the geometry is ready to be used
  104603. */
  104604. isReady(): boolean;
  104605. /**
  104606. * Gets a value indicating that the geometry should not be serialized
  104607. */
  104608. get doNotSerialize(): boolean;
  104609. /** @hidden */
  104610. _rebuild(): void;
  104611. /**
  104612. * Affects all geometry data in one call
  104613. * @param vertexData defines the geometry data
  104614. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104615. */
  104616. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104617. /**
  104618. * Set specific vertex data
  104619. * @param kind defines the data kind (Position, normal, etc...)
  104620. * @param data defines the vertex data to use
  104621. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104622. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104623. */
  104624. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104625. /**
  104626. * Removes a specific vertex data
  104627. * @param kind defines the data kind (Position, normal, etc...)
  104628. */
  104629. removeVerticesData(kind: string): void;
  104630. /**
  104631. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104632. * @param buffer defines the vertex buffer to use
  104633. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104634. */
  104635. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104636. /**
  104637. * Update a specific vertex buffer
  104638. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104639. * It will do nothing if the buffer is not updatable
  104640. * @param kind defines the data kind (Position, normal, etc...)
  104641. * @param data defines the data to use
  104642. * @param offset defines the offset in the target buffer where to store the data
  104643. * @param useBytes set to true if the offset is in bytes
  104644. */
  104645. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104646. /**
  104647. * Update a specific vertex buffer
  104648. * This function will create a new buffer if the current one is not updatable
  104649. * @param kind defines the data kind (Position, normal, etc...)
  104650. * @param data defines the data to use
  104651. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104652. */
  104653. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104654. private _updateBoundingInfo;
  104655. /** @hidden */
  104656. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104657. /**
  104658. * Gets total number of vertices
  104659. * @returns the total number of vertices
  104660. */
  104661. getTotalVertices(): number;
  104662. /**
  104663. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104664. * @param kind defines the data kind (Position, normal, etc...)
  104665. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104667. * @returns a float array containing vertex data
  104668. */
  104669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104670. /**
  104671. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104672. * @param kind defines the data kind (Position, normal, etc...)
  104673. * @returns true if the vertex buffer with the specified kind is updatable
  104674. */
  104675. isVertexBufferUpdatable(kind: string): boolean;
  104676. /**
  104677. * Gets a specific vertex buffer
  104678. * @param kind defines the data kind (Position, normal, etc...)
  104679. * @returns a VertexBuffer
  104680. */
  104681. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104682. /**
  104683. * Returns all vertex buffers
  104684. * @return an object holding all vertex buffers indexed by kind
  104685. */
  104686. getVertexBuffers(): Nullable<{
  104687. [key: string]: VertexBuffer;
  104688. }>;
  104689. /**
  104690. * Gets a boolean indicating if specific vertex buffer is present
  104691. * @param kind defines the data kind (Position, normal, etc...)
  104692. * @returns true if data is present
  104693. */
  104694. isVerticesDataPresent(kind: string): boolean;
  104695. /**
  104696. * Gets a list of all attached data kinds (Position, normal, etc...)
  104697. * @returns a list of string containing all kinds
  104698. */
  104699. getVerticesDataKinds(): string[];
  104700. /**
  104701. * Update index buffer
  104702. * @param indices defines the indices to store in the index buffer
  104703. * @param offset defines the offset in the target buffer where to store the data
  104704. * @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)
  104705. */
  104706. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104707. /**
  104708. * Creates a new index buffer
  104709. * @param indices defines the indices to store in the index buffer
  104710. * @param totalVertices defines the total number of vertices (could be null)
  104711. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104712. */
  104713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104714. /**
  104715. * Return the total number of indices
  104716. * @returns the total number of indices
  104717. */
  104718. getTotalIndices(): number;
  104719. /**
  104720. * Gets the index buffer array
  104721. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104723. * @returns the index buffer array
  104724. */
  104725. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104726. /**
  104727. * Gets the index buffer
  104728. * @return the index buffer
  104729. */
  104730. getIndexBuffer(): Nullable<DataBuffer>;
  104731. /** @hidden */
  104732. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104733. /**
  104734. * Release the associated resources for a specific mesh
  104735. * @param mesh defines the source mesh
  104736. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104737. */
  104738. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104739. /**
  104740. * Apply current geometry to a given mesh
  104741. * @param mesh defines the mesh to apply geometry to
  104742. */
  104743. applyToMesh(mesh: Mesh): void;
  104744. private _updateExtend;
  104745. private _applyToMesh;
  104746. private notifyUpdate;
  104747. /**
  104748. * Load the geometry if it was flagged as delay loaded
  104749. * @param scene defines the hosting scene
  104750. * @param onLoaded defines a callback called when the geometry is loaded
  104751. */
  104752. load(scene: Scene, onLoaded?: () => void): void;
  104753. private _queueLoad;
  104754. /**
  104755. * Invert the geometry to move from a right handed system to a left handed one.
  104756. */
  104757. toLeftHanded(): void;
  104758. /** @hidden */
  104759. _resetPointsArrayCache(): void;
  104760. /** @hidden */
  104761. _generatePointsArray(): boolean;
  104762. /**
  104763. * Gets a value indicating if the geometry is disposed
  104764. * @returns true if the geometry was disposed
  104765. */
  104766. isDisposed(): boolean;
  104767. private _disposeVertexArrayObjects;
  104768. /**
  104769. * Free all associated resources
  104770. */
  104771. dispose(): void;
  104772. /**
  104773. * Clone the current geometry into a new geometry
  104774. * @param id defines the unique ID of the new geometry
  104775. * @returns a new geometry object
  104776. */
  104777. copy(id: string): Geometry;
  104778. /**
  104779. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104780. * @return a JSON representation of the current geometry data (without the vertices data)
  104781. */
  104782. serialize(): any;
  104783. private toNumberArray;
  104784. /**
  104785. * Serialize all vertices data into a JSON oject
  104786. * @returns a JSON representation of the current geometry data
  104787. */
  104788. serializeVerticeData(): any;
  104789. /**
  104790. * Extracts a clone of a mesh geometry
  104791. * @param mesh defines the source mesh
  104792. * @param id defines the unique ID of the new geometry object
  104793. * @returns the new geometry object
  104794. */
  104795. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104796. /**
  104797. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104798. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104799. * Be aware Math.random() could cause collisions, but:
  104800. * "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"
  104801. * @returns a string containing a new GUID
  104802. */
  104803. static RandomId(): string;
  104804. /** @hidden */
  104805. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104806. private static _CleanMatricesWeights;
  104807. /**
  104808. * Create a new geometry from persisted data (Using .babylon file format)
  104809. * @param parsedVertexData defines the persisted data
  104810. * @param scene defines the hosting scene
  104811. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104812. * @returns the new geometry object
  104813. */
  104814. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104815. }
  104816. }
  104817. declare module BABYLON {
  104818. /**
  104819. * Define an interface for all classes that will get and set the data on vertices
  104820. */
  104821. export interface IGetSetVerticesData {
  104822. /**
  104823. * Gets a boolean indicating if specific vertex data is present
  104824. * @param kind defines the vertex data kind to use
  104825. * @returns true is data kind is present
  104826. */
  104827. isVerticesDataPresent(kind: string): boolean;
  104828. /**
  104829. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104830. * @param kind defines the data kind (Position, normal, etc...)
  104831. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104832. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104833. * @returns a float array containing vertex data
  104834. */
  104835. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104836. /**
  104837. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104838. * @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.
  104839. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104840. * @returns the indices array or an empty array if the mesh has no geometry
  104841. */
  104842. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104843. /**
  104844. * Set specific vertex data
  104845. * @param kind defines the data kind (Position, normal, etc...)
  104846. * @param data defines the vertex data to use
  104847. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104848. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104849. */
  104850. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104851. /**
  104852. * Update a specific associated vertex buffer
  104853. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104854. * - VertexBuffer.PositionKind
  104855. * - VertexBuffer.UVKind
  104856. * - VertexBuffer.UV2Kind
  104857. * - VertexBuffer.UV3Kind
  104858. * - VertexBuffer.UV4Kind
  104859. * - VertexBuffer.UV5Kind
  104860. * - VertexBuffer.UV6Kind
  104861. * - VertexBuffer.ColorKind
  104862. * - VertexBuffer.MatricesIndicesKind
  104863. * - VertexBuffer.MatricesIndicesExtraKind
  104864. * - VertexBuffer.MatricesWeightsKind
  104865. * - VertexBuffer.MatricesWeightsExtraKind
  104866. * @param data defines the data source
  104867. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104868. * @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)
  104869. */
  104870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104871. /**
  104872. * Creates a new index buffer
  104873. * @param indices defines the indices to store in the index buffer
  104874. * @param totalVertices defines the total number of vertices (could be null)
  104875. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104876. */
  104877. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104878. }
  104879. /**
  104880. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104881. */
  104882. export class VertexData {
  104883. /**
  104884. * Mesh side orientation : usually the external or front surface
  104885. */
  104886. static readonly FRONTSIDE: number;
  104887. /**
  104888. * Mesh side orientation : usually the internal or back surface
  104889. */
  104890. static readonly BACKSIDE: number;
  104891. /**
  104892. * Mesh side orientation : both internal and external or front and back surfaces
  104893. */
  104894. static readonly DOUBLESIDE: number;
  104895. /**
  104896. * Mesh side orientation : by default, `FRONTSIDE`
  104897. */
  104898. static readonly DEFAULTSIDE: number;
  104899. /**
  104900. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104901. */
  104902. positions: Nullable<FloatArray>;
  104903. /**
  104904. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104905. */
  104906. normals: Nullable<FloatArray>;
  104907. /**
  104908. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104909. */
  104910. tangents: Nullable<FloatArray>;
  104911. /**
  104912. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104913. */
  104914. uvs: Nullable<FloatArray>;
  104915. /**
  104916. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104917. */
  104918. uvs2: Nullable<FloatArray>;
  104919. /**
  104920. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104921. */
  104922. uvs3: Nullable<FloatArray>;
  104923. /**
  104924. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104925. */
  104926. uvs4: Nullable<FloatArray>;
  104927. /**
  104928. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104929. */
  104930. uvs5: Nullable<FloatArray>;
  104931. /**
  104932. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104933. */
  104934. uvs6: Nullable<FloatArray>;
  104935. /**
  104936. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104937. */
  104938. colors: Nullable<FloatArray>;
  104939. /**
  104940. * 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).
  104941. */
  104942. matricesIndices: Nullable<FloatArray>;
  104943. /**
  104944. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104945. */
  104946. matricesWeights: Nullable<FloatArray>;
  104947. /**
  104948. * An array extending the number of possible indices
  104949. */
  104950. matricesIndicesExtra: Nullable<FloatArray>;
  104951. /**
  104952. * An array extending the number of possible weights when the number of indices is extended
  104953. */
  104954. matricesWeightsExtra: Nullable<FloatArray>;
  104955. /**
  104956. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104957. */
  104958. indices: Nullable<IndicesArray>;
  104959. /**
  104960. * Uses the passed data array to set the set the values for the specified kind of data
  104961. * @param data a linear array of floating numbers
  104962. * @param kind the type of data that is being set, eg positions, colors etc
  104963. */
  104964. set(data: FloatArray, kind: string): void;
  104965. /**
  104966. * Associates the vertexData to the passed Mesh.
  104967. * Sets it as updatable or not (default `false`)
  104968. * @param mesh the mesh the vertexData is applied to
  104969. * @param updatable when used and having the value true allows new data to update the vertexData
  104970. * @returns the VertexData
  104971. */
  104972. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104973. /**
  104974. * Associates the vertexData to the passed Geometry.
  104975. * Sets it as updatable or not (default `false`)
  104976. * @param geometry the geometry the vertexData is applied to
  104977. * @param updatable when used and having the value true allows new data to update the vertexData
  104978. * @returns VertexData
  104979. */
  104980. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104981. /**
  104982. * Updates the associated mesh
  104983. * @param mesh the mesh to be updated
  104984. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104985. * @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
  104986. * @returns VertexData
  104987. */
  104988. updateMesh(mesh: Mesh): VertexData;
  104989. /**
  104990. * Updates the associated geometry
  104991. * @param geometry the geometry to be updated
  104992. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104993. * @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
  104994. * @returns VertexData.
  104995. */
  104996. updateGeometry(geometry: Geometry): VertexData;
  104997. private _applyTo;
  104998. private _update;
  104999. /**
  105000. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105001. * @param matrix the transforming matrix
  105002. * @returns the VertexData
  105003. */
  105004. transform(matrix: Matrix): VertexData;
  105005. /**
  105006. * Merges the passed VertexData into the current one
  105007. * @param other the VertexData to be merged into the current one
  105008. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105009. * @returns the modified VertexData
  105010. */
  105011. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105012. private _mergeElement;
  105013. private _validate;
  105014. /**
  105015. * Serializes the VertexData
  105016. * @returns a serialized object
  105017. */
  105018. serialize(): any;
  105019. /**
  105020. * Extracts the vertexData from a mesh
  105021. * @param mesh the mesh from which to extract the VertexData
  105022. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105023. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105024. * @returns the object VertexData associated to the passed mesh
  105025. */
  105026. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105027. /**
  105028. * Extracts the vertexData from the geometry
  105029. * @param geometry the geometry from which to extract the VertexData
  105030. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105031. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105032. * @returns the object VertexData associated to the passed mesh
  105033. */
  105034. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105035. private static _ExtractFrom;
  105036. /**
  105037. * Creates the VertexData for a Ribbon
  105038. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105039. * * pathArray array of paths, each of which an array of successive Vector3
  105040. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105041. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105042. * * 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
  105043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105044. * * 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)
  105045. * * 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)
  105046. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105047. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105048. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105049. * @returns the VertexData of the ribbon
  105050. */
  105051. static CreateRibbon(options: {
  105052. pathArray: Vector3[][];
  105053. closeArray?: boolean;
  105054. closePath?: boolean;
  105055. offset?: number;
  105056. sideOrientation?: number;
  105057. frontUVs?: Vector4;
  105058. backUVs?: Vector4;
  105059. invertUV?: boolean;
  105060. uvs?: Vector2[];
  105061. colors?: Color4[];
  105062. }): VertexData;
  105063. /**
  105064. * Creates the VertexData for a box
  105065. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105066. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105067. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105068. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105069. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105070. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105071. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105073. * * 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)
  105074. * * 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)
  105075. * @returns the VertexData of the box
  105076. */
  105077. static CreateBox(options: {
  105078. size?: number;
  105079. width?: number;
  105080. height?: number;
  105081. depth?: number;
  105082. faceUV?: Vector4[];
  105083. faceColors?: Color4[];
  105084. sideOrientation?: number;
  105085. frontUVs?: Vector4;
  105086. backUVs?: Vector4;
  105087. }): VertexData;
  105088. /**
  105089. * Creates the VertexData for a tiled box
  105090. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105091. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105092. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105093. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105095. * @returns the VertexData of the box
  105096. */
  105097. static CreateTiledBox(options: {
  105098. pattern?: number;
  105099. width?: number;
  105100. height?: number;
  105101. depth?: number;
  105102. tileSize?: number;
  105103. tileWidth?: number;
  105104. tileHeight?: number;
  105105. alignHorizontal?: number;
  105106. alignVertical?: number;
  105107. faceUV?: Vector4[];
  105108. faceColors?: Color4[];
  105109. sideOrientation?: number;
  105110. }): VertexData;
  105111. /**
  105112. * Creates the VertexData for a tiled plane
  105113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105114. * * pattern a limited pattern arrangement depending on the number
  105115. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105116. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105117. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105119. * * 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)
  105120. * * 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)
  105121. * @returns the VertexData of the tiled plane
  105122. */
  105123. static CreateTiledPlane(options: {
  105124. pattern?: number;
  105125. tileSize?: number;
  105126. tileWidth?: number;
  105127. tileHeight?: number;
  105128. size?: number;
  105129. width?: number;
  105130. height?: number;
  105131. alignHorizontal?: number;
  105132. alignVertical?: number;
  105133. sideOrientation?: number;
  105134. frontUVs?: Vector4;
  105135. backUVs?: Vector4;
  105136. }): VertexData;
  105137. /**
  105138. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105139. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105140. * * segments sets the number of horizontal strips optional, default 32
  105141. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105142. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105143. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105144. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105145. * * 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
  105146. * * 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
  105147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105148. * * 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)
  105149. * * 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)
  105150. * @returns the VertexData of the ellipsoid
  105151. */
  105152. static CreateSphere(options: {
  105153. segments?: number;
  105154. diameter?: number;
  105155. diameterX?: number;
  105156. diameterY?: number;
  105157. diameterZ?: number;
  105158. arc?: number;
  105159. slice?: number;
  105160. sideOrientation?: number;
  105161. frontUVs?: Vector4;
  105162. backUVs?: Vector4;
  105163. }): VertexData;
  105164. /**
  105165. * Creates the VertexData for a cylinder, cone or prism
  105166. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105167. * * height sets the height (y direction) of the cylinder, optional, default 2
  105168. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  105169. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  105170. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  105171. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105172. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  105173. * * 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
  105174. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105175. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105176. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105177. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105179. * * 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)
  105180. * * 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)
  105181. * @returns the VertexData of the cylinder, cone or prism
  105182. */
  105183. static CreateCylinder(options: {
  105184. height?: number;
  105185. diameterTop?: number;
  105186. diameterBottom?: number;
  105187. diameter?: number;
  105188. tessellation?: number;
  105189. subdivisions?: number;
  105190. arc?: number;
  105191. faceColors?: Color4[];
  105192. faceUV?: Vector4[];
  105193. hasRings?: boolean;
  105194. enclose?: boolean;
  105195. sideOrientation?: number;
  105196. frontUVs?: Vector4;
  105197. backUVs?: Vector4;
  105198. }): VertexData;
  105199. /**
  105200. * Creates the VertexData for a torus
  105201. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105202. * * diameter the diameter of the torus, optional default 1
  105203. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105204. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105206. * * 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)
  105207. * * 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)
  105208. * @returns the VertexData of the torus
  105209. */
  105210. static CreateTorus(options: {
  105211. diameter?: number;
  105212. thickness?: number;
  105213. tessellation?: number;
  105214. sideOrientation?: number;
  105215. frontUVs?: Vector4;
  105216. backUVs?: Vector4;
  105217. }): VertexData;
  105218. /**
  105219. * Creates the VertexData of the LineSystem
  105220. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105221. * - lines an array of lines, each line being an array of successive Vector3
  105222. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105223. * @returns the VertexData of the LineSystem
  105224. */
  105225. static CreateLineSystem(options: {
  105226. lines: Vector3[][];
  105227. colors?: Nullable<Color4[][]>;
  105228. }): VertexData;
  105229. /**
  105230. * Create the VertexData for a DashedLines
  105231. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105232. * - points an array successive Vector3
  105233. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105234. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105235. * - dashNb the intended total number of dashes, optional, default 200
  105236. * @returns the VertexData for the DashedLines
  105237. */
  105238. static CreateDashedLines(options: {
  105239. points: Vector3[];
  105240. dashSize?: number;
  105241. gapSize?: number;
  105242. dashNb?: number;
  105243. }): VertexData;
  105244. /**
  105245. * Creates the VertexData for a Ground
  105246. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105247. * - width the width (x direction) of the ground, optional, default 1
  105248. * - height the height (z direction) of the ground, optional, default 1
  105249. * - subdivisions the number of subdivisions per side, optional, default 1
  105250. * @returns the VertexData of the Ground
  105251. */
  105252. static CreateGround(options: {
  105253. width?: number;
  105254. height?: number;
  105255. subdivisions?: number;
  105256. subdivisionsX?: number;
  105257. subdivisionsY?: number;
  105258. }): VertexData;
  105259. /**
  105260. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105261. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105262. * * xmin the ground minimum X coordinate, optional, default -1
  105263. * * zmin the ground minimum Z coordinate, optional, default -1
  105264. * * xmax the ground maximum X coordinate, optional, default 1
  105265. * * zmax the ground maximum Z coordinate, optional, default 1
  105266. * * 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}
  105267. * * 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}
  105268. * @returns the VertexData of the TiledGround
  105269. */
  105270. static CreateTiledGround(options: {
  105271. xmin: number;
  105272. zmin: number;
  105273. xmax: number;
  105274. zmax: number;
  105275. subdivisions?: {
  105276. w: number;
  105277. h: number;
  105278. };
  105279. precision?: {
  105280. w: number;
  105281. h: number;
  105282. };
  105283. }): VertexData;
  105284. /**
  105285. * Creates the VertexData of the Ground designed from a heightmap
  105286. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105287. * * width the width (x direction) of the ground
  105288. * * height the height (z direction) of the ground
  105289. * * subdivisions the number of subdivisions per side
  105290. * * minHeight the minimum altitude on the ground, optional, default 0
  105291. * * maxHeight the maximum altitude on the ground, optional default 1
  105292. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105293. * * buffer the array holding the image color data
  105294. * * bufferWidth the width of image
  105295. * * bufferHeight the height of image
  105296. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105297. * @returns the VertexData of the Ground designed from a heightmap
  105298. */
  105299. static CreateGroundFromHeightMap(options: {
  105300. width: number;
  105301. height: number;
  105302. subdivisions: number;
  105303. minHeight: number;
  105304. maxHeight: number;
  105305. colorFilter: Color3;
  105306. buffer: Uint8Array;
  105307. bufferWidth: number;
  105308. bufferHeight: number;
  105309. alphaFilter: number;
  105310. }): VertexData;
  105311. /**
  105312. * Creates the VertexData for a Plane
  105313. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105314. * * size sets the width and height of the plane to the value of size, optional default 1
  105315. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105316. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105318. * * 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)
  105319. * * 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)
  105320. * @returns the VertexData of the box
  105321. */
  105322. static CreatePlane(options: {
  105323. size?: number;
  105324. width?: number;
  105325. height?: number;
  105326. sideOrientation?: number;
  105327. frontUVs?: Vector4;
  105328. backUVs?: Vector4;
  105329. }): VertexData;
  105330. /**
  105331. * Creates the VertexData of the Disc or regular Polygon
  105332. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105333. * * radius the radius of the disc, optional default 0.5
  105334. * * tessellation the number of polygon sides, optional, default 64
  105335. * * 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
  105336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105337. * * 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)
  105338. * * 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)
  105339. * @returns the VertexData of the box
  105340. */
  105341. static CreateDisc(options: {
  105342. radius?: number;
  105343. tessellation?: number;
  105344. arc?: number;
  105345. sideOrientation?: number;
  105346. frontUVs?: Vector4;
  105347. backUVs?: Vector4;
  105348. }): VertexData;
  105349. /**
  105350. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105351. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105352. * @param polygon a mesh built from polygonTriangulation.build()
  105353. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105354. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105355. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105356. * @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)
  105357. * @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)
  105358. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105359. * @returns the VertexData of the Polygon
  105360. */
  105361. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105362. /**
  105363. * Creates the VertexData of the IcoSphere
  105364. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105365. * * radius the radius of the IcoSphere, optional default 1
  105366. * * radiusX allows stretching in the x direction, optional, default radius
  105367. * * radiusY allows stretching in the y direction, optional, default radius
  105368. * * radiusZ allows stretching in the z direction, optional, default radius
  105369. * * flat when true creates a flat shaded mesh, optional, default true
  105370. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105372. * * 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)
  105373. * * 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)
  105374. * @returns the VertexData of the IcoSphere
  105375. */
  105376. static CreateIcoSphere(options: {
  105377. radius?: number;
  105378. radiusX?: number;
  105379. radiusY?: number;
  105380. radiusZ?: number;
  105381. flat?: boolean;
  105382. subdivisions?: number;
  105383. sideOrientation?: number;
  105384. frontUVs?: Vector4;
  105385. backUVs?: Vector4;
  105386. }): VertexData;
  105387. /**
  105388. * Creates the VertexData for a Polyhedron
  105389. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105390. * * type provided types are:
  105391. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105392. * * 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)
  105393. * * size the size of the IcoSphere, optional default 1
  105394. * * sizeX allows stretching in the x direction, optional, default size
  105395. * * sizeY allows stretching in the y direction, optional, default size
  105396. * * sizeZ allows stretching in the z direction, optional, default size
  105397. * * 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
  105398. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105399. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105400. * * flat when true creates a flat shaded mesh, optional, default true
  105401. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105403. * * 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)
  105404. * * 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)
  105405. * @returns the VertexData of the Polyhedron
  105406. */
  105407. static CreatePolyhedron(options: {
  105408. type?: number;
  105409. size?: number;
  105410. sizeX?: number;
  105411. sizeY?: number;
  105412. sizeZ?: number;
  105413. custom?: any;
  105414. faceUV?: Vector4[];
  105415. faceColors?: Color4[];
  105416. flat?: boolean;
  105417. sideOrientation?: number;
  105418. frontUVs?: Vector4;
  105419. backUVs?: Vector4;
  105420. }): VertexData;
  105421. /**
  105422. * Creates the VertexData for a TorusKnot
  105423. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105424. * * radius the radius of the torus knot, optional, default 2
  105425. * * tube the thickness of the tube, optional, default 0.5
  105426. * * radialSegments the number of sides on each tube segments, optional, default 32
  105427. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105428. * * p the number of windings around the z axis, optional, default 2
  105429. * * q the number of windings around the x axis, optional, default 3
  105430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105431. * * 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)
  105432. * * 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)
  105433. * @returns the VertexData of the Torus Knot
  105434. */
  105435. static CreateTorusKnot(options: {
  105436. radius?: number;
  105437. tube?: number;
  105438. radialSegments?: number;
  105439. tubularSegments?: number;
  105440. p?: number;
  105441. q?: number;
  105442. sideOrientation?: number;
  105443. frontUVs?: Vector4;
  105444. backUVs?: Vector4;
  105445. }): VertexData;
  105446. /**
  105447. * Compute normals for given positions and indices
  105448. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105449. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105450. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105451. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105452. * * facetNormals : optional array of facet normals (vector3)
  105453. * * facetPositions : optional array of facet positions (vector3)
  105454. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105455. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105456. * * bInfo : optional bounding info, required for facetPartitioning computation
  105457. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105458. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105459. * * useRightHandedSystem: optional boolean to for right handed system computation
  105460. * * depthSort : optional boolean to enable the facet depth sort computation
  105461. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105462. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105463. */
  105464. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105465. facetNormals?: any;
  105466. facetPositions?: any;
  105467. facetPartitioning?: any;
  105468. ratio?: number;
  105469. bInfo?: any;
  105470. bbSize?: Vector3;
  105471. subDiv?: any;
  105472. useRightHandedSystem?: boolean;
  105473. depthSort?: boolean;
  105474. distanceTo?: Vector3;
  105475. depthSortedFacets?: any;
  105476. }): void;
  105477. /** @hidden */
  105478. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105479. /**
  105480. * Applies VertexData created from the imported parameters to the geometry
  105481. * @param parsedVertexData the parsed data from an imported file
  105482. * @param geometry the geometry to apply the VertexData to
  105483. */
  105484. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105485. }
  105486. }
  105487. declare module BABYLON {
  105488. /**
  105489. * Defines a target to use with MorphTargetManager
  105490. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105491. */
  105492. export class MorphTarget implements IAnimatable {
  105493. /** defines the name of the target */
  105494. name: string;
  105495. /**
  105496. * Gets or sets the list of animations
  105497. */
  105498. animations: Animation[];
  105499. private _scene;
  105500. private _positions;
  105501. private _normals;
  105502. private _tangents;
  105503. private _uvs;
  105504. private _influence;
  105505. private _uniqueId;
  105506. /**
  105507. * Observable raised when the influence changes
  105508. */
  105509. onInfluenceChanged: Observable<boolean>;
  105510. /** @hidden */
  105511. _onDataLayoutChanged: Observable<void>;
  105512. /**
  105513. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105514. */
  105515. get influence(): number;
  105516. set influence(influence: number);
  105517. /**
  105518. * Gets or sets the id of the morph Target
  105519. */
  105520. id: string;
  105521. private _animationPropertiesOverride;
  105522. /**
  105523. * Gets or sets the animation properties override
  105524. */
  105525. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105526. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105527. /**
  105528. * Creates a new MorphTarget
  105529. * @param name defines the name of the target
  105530. * @param influence defines the influence to use
  105531. * @param scene defines the scene the morphtarget belongs to
  105532. */
  105533. constructor(
  105534. /** defines the name of the target */
  105535. name: string, influence?: number, scene?: Nullable<Scene>);
  105536. /**
  105537. * Gets the unique ID of this manager
  105538. */
  105539. get uniqueId(): number;
  105540. /**
  105541. * Gets a boolean defining if the target contains position data
  105542. */
  105543. get hasPositions(): boolean;
  105544. /**
  105545. * Gets a boolean defining if the target contains normal data
  105546. */
  105547. get hasNormals(): boolean;
  105548. /**
  105549. * Gets a boolean defining if the target contains tangent data
  105550. */
  105551. get hasTangents(): boolean;
  105552. /**
  105553. * Gets a boolean defining if the target contains texture coordinates data
  105554. */
  105555. get hasUVs(): boolean;
  105556. /**
  105557. * Affects position data to this target
  105558. * @param data defines the position data to use
  105559. */
  105560. setPositions(data: Nullable<FloatArray>): void;
  105561. /**
  105562. * Gets the position data stored in this target
  105563. * @returns a FloatArray containing the position data (or null if not present)
  105564. */
  105565. getPositions(): Nullable<FloatArray>;
  105566. /**
  105567. * Affects normal data to this target
  105568. * @param data defines the normal data to use
  105569. */
  105570. setNormals(data: Nullable<FloatArray>): void;
  105571. /**
  105572. * Gets the normal data stored in this target
  105573. * @returns a FloatArray containing the normal data (or null if not present)
  105574. */
  105575. getNormals(): Nullable<FloatArray>;
  105576. /**
  105577. * Affects tangent data to this target
  105578. * @param data defines the tangent data to use
  105579. */
  105580. setTangents(data: Nullable<FloatArray>): void;
  105581. /**
  105582. * Gets the tangent data stored in this target
  105583. * @returns a FloatArray containing the tangent data (or null if not present)
  105584. */
  105585. getTangents(): Nullable<FloatArray>;
  105586. /**
  105587. * Affects texture coordinates data to this target
  105588. * @param data defines the texture coordinates data to use
  105589. */
  105590. setUVs(data: Nullable<FloatArray>): void;
  105591. /**
  105592. * Gets the texture coordinates data stored in this target
  105593. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105594. */
  105595. getUVs(): Nullable<FloatArray>;
  105596. /**
  105597. * Clone the current target
  105598. * @returns a new MorphTarget
  105599. */
  105600. clone(): MorphTarget;
  105601. /**
  105602. * Serializes the current target into a Serialization object
  105603. * @returns the serialized object
  105604. */
  105605. serialize(): any;
  105606. /**
  105607. * Returns the string "MorphTarget"
  105608. * @returns "MorphTarget"
  105609. */
  105610. getClassName(): string;
  105611. /**
  105612. * Creates a new target from serialized data
  105613. * @param serializationObject defines the serialized data to use
  105614. * @returns a new MorphTarget
  105615. */
  105616. static Parse(serializationObject: any): MorphTarget;
  105617. /**
  105618. * Creates a MorphTarget from mesh data
  105619. * @param mesh defines the source mesh
  105620. * @param name defines the name to use for the new target
  105621. * @param influence defines the influence to attach to the target
  105622. * @returns a new MorphTarget
  105623. */
  105624. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105625. }
  105626. }
  105627. declare module BABYLON {
  105628. /**
  105629. * This class is used to deform meshes using morphing between different targets
  105630. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105631. */
  105632. export class MorphTargetManager {
  105633. private _targets;
  105634. private _targetInfluenceChangedObservers;
  105635. private _targetDataLayoutChangedObservers;
  105636. private _activeTargets;
  105637. private _scene;
  105638. private _influences;
  105639. private _supportsNormals;
  105640. private _supportsTangents;
  105641. private _supportsUVs;
  105642. private _vertexCount;
  105643. private _uniqueId;
  105644. private _tempInfluences;
  105645. /**
  105646. * Gets or sets a boolean indicating if normals must be morphed
  105647. */
  105648. enableNormalMorphing: boolean;
  105649. /**
  105650. * Gets or sets a boolean indicating if tangents must be morphed
  105651. */
  105652. enableTangentMorphing: boolean;
  105653. /**
  105654. * Gets or sets a boolean indicating if UV must be morphed
  105655. */
  105656. enableUVMorphing: boolean;
  105657. /**
  105658. * Creates a new MorphTargetManager
  105659. * @param scene defines the current scene
  105660. */
  105661. constructor(scene?: Nullable<Scene>);
  105662. /**
  105663. * Gets the unique ID of this manager
  105664. */
  105665. get uniqueId(): number;
  105666. /**
  105667. * Gets the number of vertices handled by this manager
  105668. */
  105669. get vertexCount(): number;
  105670. /**
  105671. * Gets a boolean indicating if this manager supports morphing of normals
  105672. */
  105673. get supportsNormals(): boolean;
  105674. /**
  105675. * Gets a boolean indicating if this manager supports morphing of tangents
  105676. */
  105677. get supportsTangents(): boolean;
  105678. /**
  105679. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105680. */
  105681. get supportsUVs(): boolean;
  105682. /**
  105683. * Gets the number of targets stored in this manager
  105684. */
  105685. get numTargets(): number;
  105686. /**
  105687. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105688. */
  105689. get numInfluencers(): number;
  105690. /**
  105691. * Gets the list of influences (one per target)
  105692. */
  105693. get influences(): Float32Array;
  105694. /**
  105695. * Gets the active target at specified index. An active target is a target with an influence > 0
  105696. * @param index defines the index to check
  105697. * @returns the requested target
  105698. */
  105699. getActiveTarget(index: number): MorphTarget;
  105700. /**
  105701. * Gets the target at specified index
  105702. * @param index defines the index to check
  105703. * @returns the requested target
  105704. */
  105705. getTarget(index: number): MorphTarget;
  105706. /**
  105707. * Add a new target to this manager
  105708. * @param target defines the target to add
  105709. */
  105710. addTarget(target: MorphTarget): void;
  105711. /**
  105712. * Removes a target from the manager
  105713. * @param target defines the target to remove
  105714. */
  105715. removeTarget(target: MorphTarget): void;
  105716. /**
  105717. * Clone the current manager
  105718. * @returns a new MorphTargetManager
  105719. */
  105720. clone(): MorphTargetManager;
  105721. /**
  105722. * Serializes the current manager into a Serialization object
  105723. * @returns the serialized object
  105724. */
  105725. serialize(): any;
  105726. private _syncActiveTargets;
  105727. /**
  105728. * Syncrhonize the targets with all the meshes using this morph target manager
  105729. */
  105730. synchronize(): void;
  105731. /**
  105732. * Creates a new MorphTargetManager from serialized data
  105733. * @param serializationObject defines the serialized data
  105734. * @param scene defines the hosting scene
  105735. * @returns the new MorphTargetManager
  105736. */
  105737. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105738. }
  105739. }
  105740. declare module BABYLON {
  105741. /**
  105742. * Class used to represent a specific level of detail of a mesh
  105743. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105744. */
  105745. export class MeshLODLevel {
  105746. /** Defines the distance where this level should start being displayed */
  105747. distance: number;
  105748. /** Defines the mesh to use to render this level */
  105749. mesh: Nullable<Mesh>;
  105750. /**
  105751. * Creates a new LOD level
  105752. * @param distance defines the distance where this level should star being displayed
  105753. * @param mesh defines the mesh to use to render this level
  105754. */
  105755. constructor(
  105756. /** Defines the distance where this level should start being displayed */
  105757. distance: number,
  105758. /** Defines the mesh to use to render this level */
  105759. mesh: Nullable<Mesh>);
  105760. }
  105761. }
  105762. declare module BABYLON {
  105763. /**
  105764. * Helper class used to generate a canvas to manipulate images
  105765. */
  105766. export class CanvasGenerator {
  105767. /**
  105768. * Create a new canvas (or offscreen canvas depending on the context)
  105769. * @param width defines the expected width
  105770. * @param height defines the expected height
  105771. * @return a new canvas or offscreen canvas
  105772. */
  105773. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105774. }
  105775. }
  105776. declare module BABYLON {
  105777. /**
  105778. * Mesh representing the gorund
  105779. */
  105780. export class GroundMesh extends Mesh {
  105781. /** If octree should be generated */
  105782. generateOctree: boolean;
  105783. private _heightQuads;
  105784. /** @hidden */
  105785. _subdivisionsX: number;
  105786. /** @hidden */
  105787. _subdivisionsY: number;
  105788. /** @hidden */
  105789. _width: number;
  105790. /** @hidden */
  105791. _height: number;
  105792. /** @hidden */
  105793. _minX: number;
  105794. /** @hidden */
  105795. _maxX: number;
  105796. /** @hidden */
  105797. _minZ: number;
  105798. /** @hidden */
  105799. _maxZ: number;
  105800. constructor(name: string, scene: Scene);
  105801. /**
  105802. * "GroundMesh"
  105803. * @returns "GroundMesh"
  105804. */
  105805. getClassName(): string;
  105806. /**
  105807. * The minimum of x and y subdivisions
  105808. */
  105809. get subdivisions(): number;
  105810. /**
  105811. * X subdivisions
  105812. */
  105813. get subdivisionsX(): number;
  105814. /**
  105815. * Y subdivisions
  105816. */
  105817. get subdivisionsY(): number;
  105818. /**
  105819. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105820. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105821. * @param chunksCount the number of subdivisions for x and y
  105822. * @param octreeBlocksSize (Default: 32)
  105823. */
  105824. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105825. /**
  105826. * Returns a height (y) value in the Worl system :
  105827. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105828. * @param x x coordinate
  105829. * @param z z coordinate
  105830. * @returns the ground y position if (x, z) are outside the ground surface.
  105831. */
  105832. getHeightAtCoordinates(x: number, z: number): number;
  105833. /**
  105834. * Returns a normalized vector (Vector3) orthogonal to the ground
  105835. * at the ground coordinates (x, z) expressed in the World system.
  105836. * @param x x coordinate
  105837. * @param z z coordinate
  105838. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105839. */
  105840. getNormalAtCoordinates(x: number, z: number): Vector3;
  105841. /**
  105842. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105843. * at the ground coordinates (x, z) expressed in the World system.
  105844. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105845. * @param x x coordinate
  105846. * @param z z coordinate
  105847. * @param ref vector to store the result
  105848. * @returns the GroundMesh.
  105849. */
  105850. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105851. /**
  105852. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105853. * if the ground has been updated.
  105854. * This can be used in the render loop.
  105855. * @returns the GroundMesh.
  105856. */
  105857. updateCoordinateHeights(): GroundMesh;
  105858. private _getFacetAt;
  105859. private _initHeightQuads;
  105860. private _computeHeightQuads;
  105861. /**
  105862. * Serializes this ground mesh
  105863. * @param serializationObject object to write serialization to
  105864. */
  105865. serialize(serializationObject: any): void;
  105866. /**
  105867. * Parses a serialized ground mesh
  105868. * @param parsedMesh the serialized mesh
  105869. * @param scene the scene to create the ground mesh in
  105870. * @returns the created ground mesh
  105871. */
  105872. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105873. }
  105874. }
  105875. declare module BABYLON {
  105876. /**
  105877. * Interface for Physics-Joint data
  105878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105879. */
  105880. export interface PhysicsJointData {
  105881. /**
  105882. * The main pivot of the joint
  105883. */
  105884. mainPivot?: Vector3;
  105885. /**
  105886. * The connected pivot of the joint
  105887. */
  105888. connectedPivot?: Vector3;
  105889. /**
  105890. * The main axis of the joint
  105891. */
  105892. mainAxis?: Vector3;
  105893. /**
  105894. * The connected axis of the joint
  105895. */
  105896. connectedAxis?: Vector3;
  105897. /**
  105898. * The collision of the joint
  105899. */
  105900. collision?: boolean;
  105901. /**
  105902. * Native Oimo/Cannon/Energy data
  105903. */
  105904. nativeParams?: any;
  105905. }
  105906. /**
  105907. * This is a holder class for the physics joint created by the physics plugin
  105908. * It holds a set of functions to control the underlying joint
  105909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105910. */
  105911. export class PhysicsJoint {
  105912. /**
  105913. * The type of the physics joint
  105914. */
  105915. type: number;
  105916. /**
  105917. * The data for the physics joint
  105918. */
  105919. jointData: PhysicsJointData;
  105920. private _physicsJoint;
  105921. protected _physicsPlugin: IPhysicsEnginePlugin;
  105922. /**
  105923. * Initializes the physics joint
  105924. * @param type The type of the physics joint
  105925. * @param jointData The data for the physics joint
  105926. */
  105927. constructor(
  105928. /**
  105929. * The type of the physics joint
  105930. */
  105931. type: number,
  105932. /**
  105933. * The data for the physics joint
  105934. */
  105935. jointData: PhysicsJointData);
  105936. /**
  105937. * Gets the physics joint
  105938. */
  105939. get physicsJoint(): any;
  105940. /**
  105941. * Sets the physics joint
  105942. */
  105943. set physicsJoint(newJoint: any);
  105944. /**
  105945. * Sets the physics plugin
  105946. */
  105947. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105948. /**
  105949. * Execute a function that is physics-plugin specific.
  105950. * @param {Function} func the function that will be executed.
  105951. * It accepts two parameters: the physics world and the physics joint
  105952. */
  105953. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105954. /**
  105955. * Distance-Joint type
  105956. */
  105957. static DistanceJoint: number;
  105958. /**
  105959. * Hinge-Joint type
  105960. */
  105961. static HingeJoint: number;
  105962. /**
  105963. * Ball-and-Socket joint type
  105964. */
  105965. static BallAndSocketJoint: number;
  105966. /**
  105967. * Wheel-Joint type
  105968. */
  105969. static WheelJoint: number;
  105970. /**
  105971. * Slider-Joint type
  105972. */
  105973. static SliderJoint: number;
  105974. /**
  105975. * Prismatic-Joint type
  105976. */
  105977. static PrismaticJoint: number;
  105978. /**
  105979. * Universal-Joint type
  105980. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105981. */
  105982. static UniversalJoint: number;
  105983. /**
  105984. * Hinge-Joint 2 type
  105985. */
  105986. static Hinge2Joint: number;
  105987. /**
  105988. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105989. */
  105990. static PointToPointJoint: number;
  105991. /**
  105992. * Spring-Joint type
  105993. */
  105994. static SpringJoint: number;
  105995. /**
  105996. * Lock-Joint type
  105997. */
  105998. static LockJoint: number;
  105999. }
  106000. /**
  106001. * A class representing a physics distance joint
  106002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106003. */
  106004. export class DistanceJoint extends PhysicsJoint {
  106005. /**
  106006. *
  106007. * @param jointData The data for the Distance-Joint
  106008. */
  106009. constructor(jointData: DistanceJointData);
  106010. /**
  106011. * Update the predefined distance.
  106012. * @param maxDistance The maximum preferred distance
  106013. * @param minDistance The minimum preferred distance
  106014. */
  106015. updateDistance(maxDistance: number, minDistance?: number): void;
  106016. }
  106017. /**
  106018. * Represents a Motor-Enabled Joint
  106019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106020. */
  106021. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106022. /**
  106023. * Initializes the Motor-Enabled Joint
  106024. * @param type The type of the joint
  106025. * @param jointData The physica joint data for the joint
  106026. */
  106027. constructor(type: number, jointData: PhysicsJointData);
  106028. /**
  106029. * Set the motor values.
  106030. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106031. * @param force the force to apply
  106032. * @param maxForce max force for this motor.
  106033. */
  106034. setMotor(force?: number, maxForce?: number): void;
  106035. /**
  106036. * Set the motor's limits.
  106037. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106038. * @param upperLimit The upper limit of the motor
  106039. * @param lowerLimit The lower limit of the motor
  106040. */
  106041. setLimit(upperLimit: number, lowerLimit?: number): void;
  106042. }
  106043. /**
  106044. * This class represents a single physics Hinge-Joint
  106045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106046. */
  106047. export class HingeJoint extends MotorEnabledJoint {
  106048. /**
  106049. * Initializes the Hinge-Joint
  106050. * @param jointData The joint data for the Hinge-Joint
  106051. */
  106052. constructor(jointData: PhysicsJointData);
  106053. /**
  106054. * Set the motor values.
  106055. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106056. * @param {number} force the force to apply
  106057. * @param {number} maxForce max force for this motor.
  106058. */
  106059. setMotor(force?: number, maxForce?: number): void;
  106060. /**
  106061. * Set the motor's limits.
  106062. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106063. * @param upperLimit The upper limit of the motor
  106064. * @param lowerLimit The lower limit of the motor
  106065. */
  106066. setLimit(upperLimit: number, lowerLimit?: number): void;
  106067. }
  106068. /**
  106069. * This class represents a dual hinge physics joint (same as wheel joint)
  106070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106071. */
  106072. export class Hinge2Joint extends MotorEnabledJoint {
  106073. /**
  106074. * Initializes the Hinge2-Joint
  106075. * @param jointData The joint data for the Hinge2-Joint
  106076. */
  106077. constructor(jointData: PhysicsJointData);
  106078. /**
  106079. * Set the motor values.
  106080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106081. * @param {number} targetSpeed the speed the motor is to reach
  106082. * @param {number} maxForce max force for this motor.
  106083. * @param {motorIndex} the motor's index, 0 or 1.
  106084. */
  106085. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106086. /**
  106087. * Set the motor limits.
  106088. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106089. * @param {number} upperLimit the upper limit
  106090. * @param {number} lowerLimit lower limit
  106091. * @param {motorIndex} the motor's index, 0 or 1.
  106092. */
  106093. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106094. }
  106095. /**
  106096. * Interface for a motor enabled joint
  106097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106098. */
  106099. export interface IMotorEnabledJoint {
  106100. /**
  106101. * Physics joint
  106102. */
  106103. physicsJoint: any;
  106104. /**
  106105. * Sets the motor of the motor-enabled joint
  106106. * @param force The force of the motor
  106107. * @param maxForce The maximum force of the motor
  106108. * @param motorIndex The index of the motor
  106109. */
  106110. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106111. /**
  106112. * Sets the limit of the motor
  106113. * @param upperLimit The upper limit of the motor
  106114. * @param lowerLimit The lower limit of the motor
  106115. * @param motorIndex The index of the motor
  106116. */
  106117. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106118. }
  106119. /**
  106120. * Joint data for a Distance-Joint
  106121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106122. */
  106123. export interface DistanceJointData extends PhysicsJointData {
  106124. /**
  106125. * Max distance the 2 joint objects can be apart
  106126. */
  106127. maxDistance: number;
  106128. }
  106129. /**
  106130. * Joint data from a spring joint
  106131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106132. */
  106133. export interface SpringJointData extends PhysicsJointData {
  106134. /**
  106135. * Length of the spring
  106136. */
  106137. length: number;
  106138. /**
  106139. * Stiffness of the spring
  106140. */
  106141. stiffness: number;
  106142. /**
  106143. * Damping of the spring
  106144. */
  106145. damping: number;
  106146. /** this callback will be called when applying the force to the impostors. */
  106147. forceApplicationCallback: () => void;
  106148. }
  106149. }
  106150. declare module BABYLON {
  106151. /**
  106152. * Holds the data for the raycast result
  106153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106154. */
  106155. export class PhysicsRaycastResult {
  106156. private _hasHit;
  106157. private _hitDistance;
  106158. private _hitNormalWorld;
  106159. private _hitPointWorld;
  106160. private _rayFromWorld;
  106161. private _rayToWorld;
  106162. /**
  106163. * Gets if there was a hit
  106164. */
  106165. get hasHit(): boolean;
  106166. /**
  106167. * Gets the distance from the hit
  106168. */
  106169. get hitDistance(): number;
  106170. /**
  106171. * Gets the hit normal/direction in the world
  106172. */
  106173. get hitNormalWorld(): Vector3;
  106174. /**
  106175. * Gets the hit point in the world
  106176. */
  106177. get hitPointWorld(): Vector3;
  106178. /**
  106179. * Gets the ray "start point" of the ray in the world
  106180. */
  106181. get rayFromWorld(): Vector3;
  106182. /**
  106183. * Gets the ray "end point" of the ray in the world
  106184. */
  106185. get rayToWorld(): Vector3;
  106186. /**
  106187. * Sets the hit data (normal & point in world space)
  106188. * @param hitNormalWorld defines the normal in world space
  106189. * @param hitPointWorld defines the point in world space
  106190. */
  106191. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106192. /**
  106193. * Sets the distance from the start point to the hit point
  106194. * @param distance
  106195. */
  106196. setHitDistance(distance: number): void;
  106197. /**
  106198. * Calculates the distance manually
  106199. */
  106200. calculateHitDistance(): void;
  106201. /**
  106202. * Resets all the values to default
  106203. * @param from The from point on world space
  106204. * @param to The to point on world space
  106205. */
  106206. reset(from?: Vector3, to?: Vector3): void;
  106207. }
  106208. /**
  106209. * Interface for the size containing width and height
  106210. */
  106211. interface IXYZ {
  106212. /**
  106213. * X
  106214. */
  106215. x: number;
  106216. /**
  106217. * Y
  106218. */
  106219. y: number;
  106220. /**
  106221. * Z
  106222. */
  106223. z: number;
  106224. }
  106225. }
  106226. declare module BABYLON {
  106227. /**
  106228. * Interface used to describe a physics joint
  106229. */
  106230. export interface PhysicsImpostorJoint {
  106231. /** Defines the main impostor to which the joint is linked */
  106232. mainImpostor: PhysicsImpostor;
  106233. /** Defines the impostor that is connected to the main impostor using this joint */
  106234. connectedImpostor: PhysicsImpostor;
  106235. /** Defines the joint itself */
  106236. joint: PhysicsJoint;
  106237. }
  106238. /** @hidden */
  106239. export interface IPhysicsEnginePlugin {
  106240. world: any;
  106241. name: string;
  106242. setGravity(gravity: Vector3): void;
  106243. setTimeStep(timeStep: number): void;
  106244. getTimeStep(): number;
  106245. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106246. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106247. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106248. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106249. removePhysicsBody(impostor: PhysicsImpostor): void;
  106250. generateJoint(joint: PhysicsImpostorJoint): void;
  106251. removeJoint(joint: PhysicsImpostorJoint): void;
  106252. isSupported(): boolean;
  106253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106254. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106255. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106256. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106257. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106258. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106259. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106260. getBodyMass(impostor: PhysicsImpostor): number;
  106261. getBodyFriction(impostor: PhysicsImpostor): number;
  106262. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106263. getBodyRestitution(impostor: PhysicsImpostor): number;
  106264. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106265. getBodyPressure?(impostor: PhysicsImpostor): number;
  106266. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106267. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106268. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106269. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106270. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106271. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106272. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106273. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106274. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106275. sleepBody(impostor: PhysicsImpostor): void;
  106276. wakeUpBody(impostor: PhysicsImpostor): void;
  106277. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106278. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106279. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106280. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106281. getRadius(impostor: PhysicsImpostor): number;
  106282. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106283. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106284. dispose(): void;
  106285. }
  106286. /**
  106287. * Interface used to define a physics engine
  106288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106289. */
  106290. export interface IPhysicsEngine {
  106291. /**
  106292. * Gets the gravity vector used by the simulation
  106293. */
  106294. gravity: Vector3;
  106295. /**
  106296. * Sets the gravity vector used by the simulation
  106297. * @param gravity defines the gravity vector to use
  106298. */
  106299. setGravity(gravity: Vector3): void;
  106300. /**
  106301. * Set the time step of the physics engine.
  106302. * Default is 1/60.
  106303. * To slow it down, enter 1/600 for example.
  106304. * To speed it up, 1/30
  106305. * @param newTimeStep the new timestep to apply to this world.
  106306. */
  106307. setTimeStep(newTimeStep: number): void;
  106308. /**
  106309. * Get the time step of the physics engine.
  106310. * @returns the current time step
  106311. */
  106312. getTimeStep(): number;
  106313. /**
  106314. * Set the sub time step of the physics engine.
  106315. * Default is 0 meaning there is no sub steps
  106316. * To increase physics resolution precision, set a small value (like 1 ms)
  106317. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106318. */
  106319. setSubTimeStep(subTimeStep: number): void;
  106320. /**
  106321. * Get the sub time step of the physics engine.
  106322. * @returns the current sub time step
  106323. */
  106324. getSubTimeStep(): number;
  106325. /**
  106326. * Release all resources
  106327. */
  106328. dispose(): void;
  106329. /**
  106330. * Gets the name of the current physics plugin
  106331. * @returns the name of the plugin
  106332. */
  106333. getPhysicsPluginName(): string;
  106334. /**
  106335. * Adding a new impostor for the impostor tracking.
  106336. * This will be done by the impostor itself.
  106337. * @param impostor the impostor to add
  106338. */
  106339. addImpostor(impostor: PhysicsImpostor): void;
  106340. /**
  106341. * Remove an impostor from the engine.
  106342. * This impostor and its mesh will not longer be updated by the physics engine.
  106343. * @param impostor the impostor to remove
  106344. */
  106345. removeImpostor(impostor: PhysicsImpostor): void;
  106346. /**
  106347. * Add a joint to the physics engine
  106348. * @param mainImpostor defines the main impostor to which the joint is added.
  106349. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106350. * @param joint defines the joint that will connect both impostors.
  106351. */
  106352. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106353. /**
  106354. * Removes a joint from the simulation
  106355. * @param mainImpostor defines the impostor used with the joint
  106356. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106357. * @param joint defines the joint to remove
  106358. */
  106359. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106360. /**
  106361. * Gets the current plugin used to run the simulation
  106362. * @returns current plugin
  106363. */
  106364. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106365. /**
  106366. * Gets the list of physic impostors
  106367. * @returns an array of PhysicsImpostor
  106368. */
  106369. getImpostors(): Array<PhysicsImpostor>;
  106370. /**
  106371. * Gets the impostor for a physics enabled object
  106372. * @param object defines the object impersonated by the impostor
  106373. * @returns the PhysicsImpostor or null if not found
  106374. */
  106375. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106376. /**
  106377. * Gets the impostor for a physics body object
  106378. * @param body defines physics body used by the impostor
  106379. * @returns the PhysicsImpostor or null if not found
  106380. */
  106381. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106382. /**
  106383. * Does a raycast in the physics world
  106384. * @param from when should the ray start?
  106385. * @param to when should the ray end?
  106386. * @returns PhysicsRaycastResult
  106387. */
  106388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106389. /**
  106390. * Called by the scene. No need to call it.
  106391. * @param delta defines the timespam between frames
  106392. */
  106393. _step(delta: number): void;
  106394. }
  106395. }
  106396. declare module BABYLON {
  106397. /**
  106398. * The interface for the physics imposter parameters
  106399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106400. */
  106401. export interface PhysicsImpostorParameters {
  106402. /**
  106403. * The mass of the physics imposter
  106404. */
  106405. mass: number;
  106406. /**
  106407. * The friction of the physics imposter
  106408. */
  106409. friction?: number;
  106410. /**
  106411. * The coefficient of restitution of the physics imposter
  106412. */
  106413. restitution?: number;
  106414. /**
  106415. * The native options of the physics imposter
  106416. */
  106417. nativeOptions?: any;
  106418. /**
  106419. * Specifies if the parent should be ignored
  106420. */
  106421. ignoreParent?: boolean;
  106422. /**
  106423. * Specifies if bi-directional transformations should be disabled
  106424. */
  106425. disableBidirectionalTransformation?: boolean;
  106426. /**
  106427. * The pressure inside the physics imposter, soft object only
  106428. */
  106429. pressure?: number;
  106430. /**
  106431. * The stiffness the physics imposter, soft object only
  106432. */
  106433. stiffness?: number;
  106434. /**
  106435. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106436. */
  106437. velocityIterations?: number;
  106438. /**
  106439. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106440. */
  106441. positionIterations?: number;
  106442. /**
  106443. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106444. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106445. * Add to fix multiple points
  106446. */
  106447. fixedPoints?: number;
  106448. /**
  106449. * The collision margin around a soft object
  106450. */
  106451. margin?: number;
  106452. /**
  106453. * The collision margin around a soft object
  106454. */
  106455. damping?: number;
  106456. /**
  106457. * The path for a rope based on an extrusion
  106458. */
  106459. path?: any;
  106460. /**
  106461. * The shape of an extrusion used for a rope based on an extrusion
  106462. */
  106463. shape?: any;
  106464. }
  106465. /**
  106466. * Interface for a physics-enabled object
  106467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106468. */
  106469. export interface IPhysicsEnabledObject {
  106470. /**
  106471. * The position of the physics-enabled object
  106472. */
  106473. position: Vector3;
  106474. /**
  106475. * The rotation of the physics-enabled object
  106476. */
  106477. rotationQuaternion: Nullable<Quaternion>;
  106478. /**
  106479. * The scale of the physics-enabled object
  106480. */
  106481. scaling: Vector3;
  106482. /**
  106483. * The rotation of the physics-enabled object
  106484. */
  106485. rotation?: Vector3;
  106486. /**
  106487. * The parent of the physics-enabled object
  106488. */
  106489. parent?: any;
  106490. /**
  106491. * The bounding info of the physics-enabled object
  106492. * @returns The bounding info of the physics-enabled object
  106493. */
  106494. getBoundingInfo(): BoundingInfo;
  106495. /**
  106496. * Computes the world matrix
  106497. * @param force Specifies if the world matrix should be computed by force
  106498. * @returns A world matrix
  106499. */
  106500. computeWorldMatrix(force: boolean): Matrix;
  106501. /**
  106502. * Gets the world matrix
  106503. * @returns A world matrix
  106504. */
  106505. getWorldMatrix?(): Matrix;
  106506. /**
  106507. * Gets the child meshes
  106508. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106509. * @returns An array of abstract meshes
  106510. */
  106511. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106512. /**
  106513. * Gets the vertex data
  106514. * @param kind The type of vertex data
  106515. * @returns A nullable array of numbers, or a float32 array
  106516. */
  106517. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106518. /**
  106519. * Gets the indices from the mesh
  106520. * @returns A nullable array of index arrays
  106521. */
  106522. getIndices?(): Nullable<IndicesArray>;
  106523. /**
  106524. * Gets the scene from the mesh
  106525. * @returns the indices array or null
  106526. */
  106527. getScene?(): Scene;
  106528. /**
  106529. * Gets the absolute position from the mesh
  106530. * @returns the absolute position
  106531. */
  106532. getAbsolutePosition(): Vector3;
  106533. /**
  106534. * Gets the absolute pivot point from the mesh
  106535. * @returns the absolute pivot point
  106536. */
  106537. getAbsolutePivotPoint(): Vector3;
  106538. /**
  106539. * Rotates the mesh
  106540. * @param axis The axis of rotation
  106541. * @param amount The amount of rotation
  106542. * @param space The space of the rotation
  106543. * @returns The rotation transform node
  106544. */
  106545. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106546. /**
  106547. * Translates the mesh
  106548. * @param axis The axis of translation
  106549. * @param distance The distance of translation
  106550. * @param space The space of the translation
  106551. * @returns The transform node
  106552. */
  106553. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106554. /**
  106555. * Sets the absolute position of the mesh
  106556. * @param absolutePosition The absolute position of the mesh
  106557. * @returns The transform node
  106558. */
  106559. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106560. /**
  106561. * Gets the class name of the mesh
  106562. * @returns The class name
  106563. */
  106564. getClassName(): string;
  106565. }
  106566. /**
  106567. * Represents a physics imposter
  106568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106569. */
  106570. export class PhysicsImpostor {
  106571. /**
  106572. * The physics-enabled object used as the physics imposter
  106573. */
  106574. object: IPhysicsEnabledObject;
  106575. /**
  106576. * The type of the physics imposter
  106577. */
  106578. type: number;
  106579. private _options;
  106580. private _scene?;
  106581. /**
  106582. * The default object size of the imposter
  106583. */
  106584. static DEFAULT_OBJECT_SIZE: Vector3;
  106585. /**
  106586. * The identity quaternion of the imposter
  106587. */
  106588. static IDENTITY_QUATERNION: Quaternion;
  106589. /** @hidden */
  106590. _pluginData: any;
  106591. private _physicsEngine;
  106592. private _physicsBody;
  106593. private _bodyUpdateRequired;
  106594. private _onBeforePhysicsStepCallbacks;
  106595. private _onAfterPhysicsStepCallbacks;
  106596. /** @hidden */
  106597. _onPhysicsCollideCallbacks: Array<{
  106598. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106599. otherImpostors: Array<PhysicsImpostor>;
  106600. }>;
  106601. private _deltaPosition;
  106602. private _deltaRotation;
  106603. private _deltaRotationConjugated;
  106604. /** @hidden */
  106605. _isFromLine: boolean;
  106606. private _parent;
  106607. private _isDisposed;
  106608. private static _tmpVecs;
  106609. private static _tmpQuat;
  106610. /**
  106611. * Specifies if the physics imposter is disposed
  106612. */
  106613. get isDisposed(): boolean;
  106614. /**
  106615. * Gets the mass of the physics imposter
  106616. */
  106617. get mass(): number;
  106618. set mass(value: number);
  106619. /**
  106620. * Gets the coefficient of friction
  106621. */
  106622. get friction(): number;
  106623. /**
  106624. * Sets the coefficient of friction
  106625. */
  106626. set friction(value: number);
  106627. /**
  106628. * Gets the coefficient of restitution
  106629. */
  106630. get restitution(): number;
  106631. /**
  106632. * Sets the coefficient of restitution
  106633. */
  106634. set restitution(value: number);
  106635. /**
  106636. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106637. */
  106638. get pressure(): number;
  106639. /**
  106640. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106641. */
  106642. set pressure(value: number);
  106643. /**
  106644. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106645. */
  106646. get stiffness(): number;
  106647. /**
  106648. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106649. */
  106650. set stiffness(value: number);
  106651. /**
  106652. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106653. */
  106654. get velocityIterations(): number;
  106655. /**
  106656. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106657. */
  106658. set velocityIterations(value: number);
  106659. /**
  106660. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106661. */
  106662. get positionIterations(): number;
  106663. /**
  106664. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106665. */
  106666. set positionIterations(value: number);
  106667. /**
  106668. * The unique id of the physics imposter
  106669. * set by the physics engine when adding this impostor to the array
  106670. */
  106671. uniqueId: number;
  106672. /**
  106673. * @hidden
  106674. */
  106675. soft: boolean;
  106676. /**
  106677. * @hidden
  106678. */
  106679. segments: number;
  106680. private _joints;
  106681. /**
  106682. * Initializes the physics imposter
  106683. * @param object The physics-enabled object used as the physics imposter
  106684. * @param type The type of the physics imposter
  106685. * @param _options The options for the physics imposter
  106686. * @param _scene The Babylon scene
  106687. */
  106688. constructor(
  106689. /**
  106690. * The physics-enabled object used as the physics imposter
  106691. */
  106692. object: IPhysicsEnabledObject,
  106693. /**
  106694. * The type of the physics imposter
  106695. */
  106696. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106697. /**
  106698. * This function will completly initialize this impostor.
  106699. * It will create a new body - but only if this mesh has no parent.
  106700. * If it has, this impostor will not be used other than to define the impostor
  106701. * of the child mesh.
  106702. * @hidden
  106703. */
  106704. _init(): void;
  106705. private _getPhysicsParent;
  106706. /**
  106707. * Should a new body be generated.
  106708. * @returns boolean specifying if body initialization is required
  106709. */
  106710. isBodyInitRequired(): boolean;
  106711. /**
  106712. * Sets the updated scaling
  106713. * @param updated Specifies if the scaling is updated
  106714. */
  106715. setScalingUpdated(): void;
  106716. /**
  106717. * Force a regeneration of this or the parent's impostor's body.
  106718. * Use under cautious - This will remove all joints already implemented.
  106719. */
  106720. forceUpdate(): void;
  106721. /**
  106722. * Gets the body that holds this impostor. Either its own, or its parent.
  106723. */
  106724. get physicsBody(): any;
  106725. /**
  106726. * Get the parent of the physics imposter
  106727. * @returns Physics imposter or null
  106728. */
  106729. get parent(): Nullable<PhysicsImpostor>;
  106730. /**
  106731. * Sets the parent of the physics imposter
  106732. */
  106733. set parent(value: Nullable<PhysicsImpostor>);
  106734. /**
  106735. * Set the physics body. Used mainly by the physics engine/plugin
  106736. */
  106737. set physicsBody(physicsBody: any);
  106738. /**
  106739. * Resets the update flags
  106740. */
  106741. resetUpdateFlags(): void;
  106742. /**
  106743. * Gets the object extend size
  106744. * @returns the object extend size
  106745. */
  106746. getObjectExtendSize(): Vector3;
  106747. /**
  106748. * Gets the object center
  106749. * @returns The object center
  106750. */
  106751. getObjectCenter(): Vector3;
  106752. /**
  106753. * Get a specific parameter from the options parameters
  106754. * @param paramName The object parameter name
  106755. * @returns The object parameter
  106756. */
  106757. getParam(paramName: string): any;
  106758. /**
  106759. * Sets a specific parameter in the options given to the physics plugin
  106760. * @param paramName The parameter name
  106761. * @param value The value of the parameter
  106762. */
  106763. setParam(paramName: string, value: number): void;
  106764. /**
  106765. * Specifically change the body's mass option. Won't recreate the physics body object
  106766. * @param mass The mass of the physics imposter
  106767. */
  106768. setMass(mass: number): void;
  106769. /**
  106770. * Gets the linear velocity
  106771. * @returns linear velocity or null
  106772. */
  106773. getLinearVelocity(): Nullable<Vector3>;
  106774. /**
  106775. * Sets the linear velocity
  106776. * @param velocity linear velocity or null
  106777. */
  106778. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106779. /**
  106780. * Gets the angular velocity
  106781. * @returns angular velocity or null
  106782. */
  106783. getAngularVelocity(): Nullable<Vector3>;
  106784. /**
  106785. * Sets the angular velocity
  106786. * @param velocity The velocity or null
  106787. */
  106788. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106789. /**
  106790. * Execute a function with the physics plugin native code
  106791. * Provide a function the will have two variables - the world object and the physics body object
  106792. * @param func The function to execute with the physics plugin native code
  106793. */
  106794. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106795. /**
  106796. * Register a function that will be executed before the physics world is stepping forward
  106797. * @param func The function to execute before the physics world is stepped forward
  106798. */
  106799. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106800. /**
  106801. * Unregister a function that will be executed before the physics world is stepping forward
  106802. * @param func The function to execute before the physics world is stepped forward
  106803. */
  106804. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106805. /**
  106806. * Register a function that will be executed after the physics step
  106807. * @param func The function to execute after physics step
  106808. */
  106809. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106810. /**
  106811. * Unregisters a function that will be executed after the physics step
  106812. * @param func The function to execute after physics step
  106813. */
  106814. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106815. /**
  106816. * register a function that will be executed when this impostor collides against a different body
  106817. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106818. * @param func Callback that is executed on collision
  106819. */
  106820. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106821. /**
  106822. * Unregisters the physics imposter on contact
  106823. * @param collideAgainst The physics object to collide against
  106824. * @param func Callback to execute on collision
  106825. */
  106826. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106827. private _tmpQuat;
  106828. private _tmpQuat2;
  106829. /**
  106830. * Get the parent rotation
  106831. * @returns The parent rotation
  106832. */
  106833. getParentsRotation(): Quaternion;
  106834. /**
  106835. * this function is executed by the physics engine.
  106836. */
  106837. beforeStep: () => void;
  106838. /**
  106839. * this function is executed by the physics engine
  106840. */
  106841. afterStep: () => void;
  106842. /**
  106843. * Legacy collision detection event support
  106844. */
  106845. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106846. /**
  106847. * event and body object due to cannon's event-based architecture.
  106848. */
  106849. onCollide: (e: {
  106850. body: any;
  106851. }) => void;
  106852. /**
  106853. * Apply a force
  106854. * @param force The force to apply
  106855. * @param contactPoint The contact point for the force
  106856. * @returns The physics imposter
  106857. */
  106858. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106859. /**
  106860. * Apply an impulse
  106861. * @param force The impulse force
  106862. * @param contactPoint The contact point for the impulse force
  106863. * @returns The physics imposter
  106864. */
  106865. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106866. /**
  106867. * A help function to create a joint
  106868. * @param otherImpostor A physics imposter used to create a joint
  106869. * @param jointType The type of joint
  106870. * @param jointData The data for the joint
  106871. * @returns The physics imposter
  106872. */
  106873. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106874. /**
  106875. * Add a joint to this impostor with a different impostor
  106876. * @param otherImpostor A physics imposter used to add a joint
  106877. * @param joint The joint to add
  106878. * @returns The physics imposter
  106879. */
  106880. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106881. /**
  106882. * Add an anchor to a cloth impostor
  106883. * @param otherImpostor rigid impostor to anchor to
  106884. * @param width ratio across width from 0 to 1
  106885. * @param height ratio up height from 0 to 1
  106886. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106887. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106888. * @returns impostor the soft imposter
  106889. */
  106890. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106891. /**
  106892. * Add a hook to a rope impostor
  106893. * @param otherImpostor rigid impostor to anchor to
  106894. * @param length ratio across rope from 0 to 1
  106895. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106896. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106897. * @returns impostor the rope imposter
  106898. */
  106899. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106900. /**
  106901. * Will keep this body still, in a sleep mode.
  106902. * @returns the physics imposter
  106903. */
  106904. sleep(): PhysicsImpostor;
  106905. /**
  106906. * Wake the body up.
  106907. * @returns The physics imposter
  106908. */
  106909. wakeUp(): PhysicsImpostor;
  106910. /**
  106911. * Clones the physics imposter
  106912. * @param newObject The physics imposter clones to this physics-enabled object
  106913. * @returns A nullable physics imposter
  106914. */
  106915. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106916. /**
  106917. * Disposes the physics imposter
  106918. */
  106919. dispose(): void;
  106920. /**
  106921. * Sets the delta position
  106922. * @param position The delta position amount
  106923. */
  106924. setDeltaPosition(position: Vector3): void;
  106925. /**
  106926. * Sets the delta rotation
  106927. * @param rotation The delta rotation amount
  106928. */
  106929. setDeltaRotation(rotation: Quaternion): void;
  106930. /**
  106931. * Gets the box size of the physics imposter and stores the result in the input parameter
  106932. * @param result Stores the box size
  106933. * @returns The physics imposter
  106934. */
  106935. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106936. /**
  106937. * Gets the radius of the physics imposter
  106938. * @returns Radius of the physics imposter
  106939. */
  106940. getRadius(): number;
  106941. /**
  106942. * Sync a bone with this impostor
  106943. * @param bone The bone to sync to the impostor.
  106944. * @param boneMesh The mesh that the bone is influencing.
  106945. * @param jointPivot The pivot of the joint / bone in local space.
  106946. * @param distToJoint Optional distance from the impostor to the joint.
  106947. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106948. */
  106949. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106950. /**
  106951. * Sync impostor to a bone
  106952. * @param bone The bone that the impostor will be synced to.
  106953. * @param boneMesh The mesh that the bone is influencing.
  106954. * @param jointPivot The pivot of the joint / bone in local space.
  106955. * @param distToJoint Optional distance from the impostor to the joint.
  106956. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106957. * @param boneAxis Optional vector3 axis the bone is aligned with
  106958. */
  106959. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106960. /**
  106961. * No-Imposter type
  106962. */
  106963. static NoImpostor: number;
  106964. /**
  106965. * Sphere-Imposter type
  106966. */
  106967. static SphereImpostor: number;
  106968. /**
  106969. * Box-Imposter type
  106970. */
  106971. static BoxImpostor: number;
  106972. /**
  106973. * Plane-Imposter type
  106974. */
  106975. static PlaneImpostor: number;
  106976. /**
  106977. * Mesh-imposter type
  106978. */
  106979. static MeshImpostor: number;
  106980. /**
  106981. * Capsule-Impostor type (Ammo.js plugin only)
  106982. */
  106983. static CapsuleImpostor: number;
  106984. /**
  106985. * Cylinder-Imposter type
  106986. */
  106987. static CylinderImpostor: number;
  106988. /**
  106989. * Particle-Imposter type
  106990. */
  106991. static ParticleImpostor: number;
  106992. /**
  106993. * Heightmap-Imposter type
  106994. */
  106995. static HeightmapImpostor: number;
  106996. /**
  106997. * ConvexHull-Impostor type (Ammo.js plugin only)
  106998. */
  106999. static ConvexHullImpostor: number;
  107000. /**
  107001. * Custom-Imposter type (Ammo.js plugin only)
  107002. */
  107003. static CustomImpostor: number;
  107004. /**
  107005. * Rope-Imposter type
  107006. */
  107007. static RopeImpostor: number;
  107008. /**
  107009. * Cloth-Imposter type
  107010. */
  107011. static ClothImpostor: number;
  107012. /**
  107013. * Softbody-Imposter type
  107014. */
  107015. static SoftbodyImpostor: number;
  107016. }
  107017. }
  107018. declare module BABYLON {
  107019. /**
  107020. * @hidden
  107021. **/
  107022. export class _CreationDataStorage {
  107023. closePath?: boolean;
  107024. closeArray?: boolean;
  107025. idx: number[];
  107026. dashSize: number;
  107027. gapSize: number;
  107028. path3D: Path3D;
  107029. pathArray: Vector3[][];
  107030. arc: number;
  107031. radius: number;
  107032. cap: number;
  107033. tessellation: number;
  107034. }
  107035. /**
  107036. * @hidden
  107037. **/
  107038. class _InstanceDataStorage {
  107039. visibleInstances: any;
  107040. batchCache: _InstancesBatch;
  107041. instancesBufferSize: number;
  107042. instancesBuffer: Nullable<Buffer>;
  107043. instancesData: Float32Array;
  107044. overridenInstanceCount: number;
  107045. isFrozen: boolean;
  107046. previousBatch: Nullable<_InstancesBatch>;
  107047. hardwareInstancedRendering: boolean;
  107048. sideOrientation: number;
  107049. manualUpdate: boolean;
  107050. }
  107051. /**
  107052. * @hidden
  107053. **/
  107054. export class _InstancesBatch {
  107055. mustReturn: boolean;
  107056. visibleInstances: Nullable<InstancedMesh[]>[];
  107057. renderSelf: boolean[];
  107058. hardwareInstancedRendering: boolean[];
  107059. }
  107060. /**
  107061. * @hidden
  107062. **/
  107063. class _ThinInstanceDataStorage {
  107064. instancesCount: number;
  107065. matrixBuffer: Nullable<Buffer>;
  107066. matrixBufferSize: number;
  107067. matrixData: Nullable<Float32Array>;
  107068. boundingVectors: Array<Vector3>;
  107069. worldMatrices: Nullable<Matrix[]>;
  107070. }
  107071. /**
  107072. * Class used to represent renderable models
  107073. */
  107074. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107075. /**
  107076. * Mesh side orientation : usually the external or front surface
  107077. */
  107078. static readonly FRONTSIDE: number;
  107079. /**
  107080. * Mesh side orientation : usually the internal or back surface
  107081. */
  107082. static readonly BACKSIDE: number;
  107083. /**
  107084. * Mesh side orientation : both internal and external or front and back surfaces
  107085. */
  107086. static readonly DOUBLESIDE: number;
  107087. /**
  107088. * Mesh side orientation : by default, `FRONTSIDE`
  107089. */
  107090. static readonly DEFAULTSIDE: number;
  107091. /**
  107092. * Mesh cap setting : no cap
  107093. */
  107094. static readonly NO_CAP: number;
  107095. /**
  107096. * Mesh cap setting : one cap at the beginning of the mesh
  107097. */
  107098. static readonly CAP_START: number;
  107099. /**
  107100. * Mesh cap setting : one cap at the end of the mesh
  107101. */
  107102. static readonly CAP_END: number;
  107103. /**
  107104. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107105. */
  107106. static readonly CAP_ALL: number;
  107107. /**
  107108. * Mesh pattern setting : no flip or rotate
  107109. */
  107110. static readonly NO_FLIP: number;
  107111. /**
  107112. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107113. */
  107114. static readonly FLIP_TILE: number;
  107115. /**
  107116. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107117. */
  107118. static readonly ROTATE_TILE: number;
  107119. /**
  107120. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107121. */
  107122. static readonly FLIP_ROW: number;
  107123. /**
  107124. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107125. */
  107126. static readonly ROTATE_ROW: number;
  107127. /**
  107128. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107129. */
  107130. static readonly FLIP_N_ROTATE_TILE: number;
  107131. /**
  107132. * Mesh pattern setting : rotate pattern and rotate
  107133. */
  107134. static readonly FLIP_N_ROTATE_ROW: number;
  107135. /**
  107136. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107137. */
  107138. static readonly CENTER: number;
  107139. /**
  107140. * Mesh tile positioning : part tiles on left
  107141. */
  107142. static readonly LEFT: number;
  107143. /**
  107144. * Mesh tile positioning : part tiles on right
  107145. */
  107146. static readonly RIGHT: number;
  107147. /**
  107148. * Mesh tile positioning : part tiles on top
  107149. */
  107150. static readonly TOP: number;
  107151. /**
  107152. * Mesh tile positioning : part tiles on bottom
  107153. */
  107154. static readonly BOTTOM: number;
  107155. /**
  107156. * Gets the default side orientation.
  107157. * @param orientation the orientation to value to attempt to get
  107158. * @returns the default orientation
  107159. * @hidden
  107160. */
  107161. static _GetDefaultSideOrientation(orientation?: number): number;
  107162. private _internalMeshDataInfo;
  107163. get computeBonesUsingShaders(): boolean;
  107164. set computeBonesUsingShaders(value: boolean);
  107165. /**
  107166. * An event triggered before rendering the mesh
  107167. */
  107168. get onBeforeRenderObservable(): Observable<Mesh>;
  107169. /**
  107170. * An event triggered before binding the mesh
  107171. */
  107172. get onBeforeBindObservable(): Observable<Mesh>;
  107173. /**
  107174. * An event triggered after rendering the mesh
  107175. */
  107176. get onAfterRenderObservable(): Observable<Mesh>;
  107177. /**
  107178. * An event triggered before drawing the mesh
  107179. */
  107180. get onBeforeDrawObservable(): Observable<Mesh>;
  107181. private _onBeforeDrawObserver;
  107182. /**
  107183. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107184. */
  107185. set onBeforeDraw(callback: () => void);
  107186. get hasInstances(): boolean;
  107187. get hasThinInstances(): boolean;
  107188. /**
  107189. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107190. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107191. */
  107192. delayLoadState: number;
  107193. /**
  107194. * Gets the list of instances created from this mesh
  107195. * it is not supposed to be modified manually.
  107196. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107197. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107198. */
  107199. instances: InstancedMesh[];
  107200. /**
  107201. * Gets the file containing delay loading data for this mesh
  107202. */
  107203. delayLoadingFile: string;
  107204. /** @hidden */
  107205. _binaryInfo: any;
  107206. /**
  107207. * User defined function used to change how LOD level selection is done
  107208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107209. */
  107210. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107211. /**
  107212. * Gets or sets the morph target manager
  107213. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107214. */
  107215. get morphTargetManager(): Nullable<MorphTargetManager>;
  107216. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107217. /** @hidden */
  107218. _creationDataStorage: Nullable<_CreationDataStorage>;
  107219. /** @hidden */
  107220. _geometry: Nullable<Geometry>;
  107221. /** @hidden */
  107222. _delayInfo: Array<string>;
  107223. /** @hidden */
  107224. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107225. /** @hidden */
  107226. _instanceDataStorage: _InstanceDataStorage;
  107227. /** @hidden */
  107228. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107229. private _effectiveMaterial;
  107230. /** @hidden */
  107231. _shouldGenerateFlatShading: boolean;
  107232. /** @hidden */
  107233. _originalBuilderSideOrientation: number;
  107234. /**
  107235. * Use this property to change the original side orientation defined at construction time
  107236. */
  107237. overrideMaterialSideOrientation: Nullable<number>;
  107238. /**
  107239. * Gets the source mesh (the one used to clone this one from)
  107240. */
  107241. get source(): Nullable<Mesh>;
  107242. /**
  107243. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107244. */
  107245. get isUnIndexed(): boolean;
  107246. set isUnIndexed(value: boolean);
  107247. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107248. get worldMatrixInstancedBuffer(): Float32Array;
  107249. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107250. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107251. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107252. /**
  107253. * @constructor
  107254. * @param name The value used by scene.getMeshByName() to do a lookup.
  107255. * @param scene The scene to add this mesh to.
  107256. * @param parent The parent of this mesh, if it has one
  107257. * @param source An optional Mesh from which geometry is shared, cloned.
  107258. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107259. * When false, achieved by calling a clone(), also passing False.
  107260. * This will make creation of children, recursive.
  107261. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107262. */
  107263. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107264. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107265. doNotInstantiate: boolean;
  107266. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107267. /**
  107268. * Gets the class name
  107269. * @returns the string "Mesh".
  107270. */
  107271. getClassName(): string;
  107272. /** @hidden */
  107273. get _isMesh(): boolean;
  107274. /**
  107275. * Returns a description of this mesh
  107276. * @param fullDetails define if full details about this mesh must be used
  107277. * @returns a descriptive string representing this mesh
  107278. */
  107279. toString(fullDetails?: boolean): string;
  107280. /** @hidden */
  107281. _unBindEffect(): void;
  107282. /**
  107283. * Gets a boolean indicating if this mesh has LOD
  107284. */
  107285. get hasLODLevels(): boolean;
  107286. /**
  107287. * Gets the list of MeshLODLevel associated with the current mesh
  107288. * @returns an array of MeshLODLevel
  107289. */
  107290. getLODLevels(): MeshLODLevel[];
  107291. private _sortLODLevels;
  107292. /**
  107293. * Add a mesh as LOD level triggered at the given distance.
  107294. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107295. * @param distance The distance from the center of the object to show this level
  107296. * @param mesh The mesh to be added as LOD level (can be null)
  107297. * @return This mesh (for chaining)
  107298. */
  107299. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107300. /**
  107301. * Returns the LOD level mesh at the passed distance or null if not found.
  107302. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107303. * @param distance The distance from the center of the object to show this level
  107304. * @returns a Mesh or `null`
  107305. */
  107306. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107307. /**
  107308. * Remove a mesh from the LOD array
  107309. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107310. * @param mesh defines the mesh to be removed
  107311. * @return This mesh (for chaining)
  107312. */
  107313. removeLODLevel(mesh: Mesh): Mesh;
  107314. /**
  107315. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107316. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107317. * @param camera defines the camera to use to compute distance
  107318. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107319. * @return This mesh (for chaining)
  107320. */
  107321. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107322. /**
  107323. * Gets the mesh internal Geometry object
  107324. */
  107325. get geometry(): Nullable<Geometry>;
  107326. /**
  107327. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107328. * @returns the total number of vertices
  107329. */
  107330. getTotalVertices(): number;
  107331. /**
  107332. * Returns the content of an associated vertex buffer
  107333. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107334. * - VertexBuffer.PositionKind
  107335. * - VertexBuffer.UVKind
  107336. * - VertexBuffer.UV2Kind
  107337. * - VertexBuffer.UV3Kind
  107338. * - VertexBuffer.UV4Kind
  107339. * - VertexBuffer.UV5Kind
  107340. * - VertexBuffer.UV6Kind
  107341. * - VertexBuffer.ColorKind
  107342. * - VertexBuffer.MatricesIndicesKind
  107343. * - VertexBuffer.MatricesIndicesExtraKind
  107344. * - VertexBuffer.MatricesWeightsKind
  107345. * - VertexBuffer.MatricesWeightsExtraKind
  107346. * @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
  107347. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107348. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107349. */
  107350. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107351. /**
  107352. * Returns the mesh VertexBuffer object from the requested `kind`
  107353. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107354. * - VertexBuffer.PositionKind
  107355. * - VertexBuffer.NormalKind
  107356. * - VertexBuffer.UVKind
  107357. * - VertexBuffer.UV2Kind
  107358. * - VertexBuffer.UV3Kind
  107359. * - VertexBuffer.UV4Kind
  107360. * - VertexBuffer.UV5Kind
  107361. * - VertexBuffer.UV6Kind
  107362. * - VertexBuffer.ColorKind
  107363. * - VertexBuffer.MatricesIndicesKind
  107364. * - VertexBuffer.MatricesIndicesExtraKind
  107365. * - VertexBuffer.MatricesWeightsKind
  107366. * - VertexBuffer.MatricesWeightsExtraKind
  107367. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107368. */
  107369. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107370. /**
  107371. * Tests if a specific vertex buffer is associated with this mesh
  107372. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107373. * - VertexBuffer.PositionKind
  107374. * - VertexBuffer.NormalKind
  107375. * - VertexBuffer.UVKind
  107376. * - VertexBuffer.UV2Kind
  107377. * - VertexBuffer.UV3Kind
  107378. * - VertexBuffer.UV4Kind
  107379. * - VertexBuffer.UV5Kind
  107380. * - VertexBuffer.UV6Kind
  107381. * - VertexBuffer.ColorKind
  107382. * - VertexBuffer.MatricesIndicesKind
  107383. * - VertexBuffer.MatricesIndicesExtraKind
  107384. * - VertexBuffer.MatricesWeightsKind
  107385. * - VertexBuffer.MatricesWeightsExtraKind
  107386. * @returns a boolean
  107387. */
  107388. isVerticesDataPresent(kind: string): boolean;
  107389. /**
  107390. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107391. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107392. * - VertexBuffer.PositionKind
  107393. * - VertexBuffer.UVKind
  107394. * - VertexBuffer.UV2Kind
  107395. * - VertexBuffer.UV3Kind
  107396. * - VertexBuffer.UV4Kind
  107397. * - VertexBuffer.UV5Kind
  107398. * - VertexBuffer.UV6Kind
  107399. * - VertexBuffer.ColorKind
  107400. * - VertexBuffer.MatricesIndicesKind
  107401. * - VertexBuffer.MatricesIndicesExtraKind
  107402. * - VertexBuffer.MatricesWeightsKind
  107403. * - VertexBuffer.MatricesWeightsExtraKind
  107404. * @returns a boolean
  107405. */
  107406. isVertexBufferUpdatable(kind: string): boolean;
  107407. /**
  107408. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107409. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107410. * - VertexBuffer.PositionKind
  107411. * - VertexBuffer.NormalKind
  107412. * - VertexBuffer.UVKind
  107413. * - VertexBuffer.UV2Kind
  107414. * - VertexBuffer.UV3Kind
  107415. * - VertexBuffer.UV4Kind
  107416. * - VertexBuffer.UV5Kind
  107417. * - VertexBuffer.UV6Kind
  107418. * - VertexBuffer.ColorKind
  107419. * - VertexBuffer.MatricesIndicesKind
  107420. * - VertexBuffer.MatricesIndicesExtraKind
  107421. * - VertexBuffer.MatricesWeightsKind
  107422. * - VertexBuffer.MatricesWeightsExtraKind
  107423. * @returns an array of strings
  107424. */
  107425. getVerticesDataKinds(): string[];
  107426. /**
  107427. * Returns a positive integer : the total number of indices in this mesh geometry.
  107428. * @returns the numner of indices or zero if the mesh has no geometry.
  107429. */
  107430. getTotalIndices(): number;
  107431. /**
  107432. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107433. * @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.
  107434. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107435. * @returns the indices array or an empty array if the mesh has no geometry
  107436. */
  107437. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107438. get isBlocked(): boolean;
  107439. /**
  107440. * Determine if the current mesh is ready to be rendered
  107441. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107442. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107443. * @returns true if all associated assets are ready (material, textures, shaders)
  107444. */
  107445. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107446. /**
  107447. * 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.
  107448. */
  107449. get areNormalsFrozen(): boolean;
  107450. /**
  107451. * 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.
  107452. * @returns the current mesh
  107453. */
  107454. freezeNormals(): Mesh;
  107455. /**
  107456. * 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
  107457. * @returns the current mesh
  107458. */
  107459. unfreezeNormals(): Mesh;
  107460. /**
  107461. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107462. */
  107463. set overridenInstanceCount(count: number);
  107464. /** @hidden */
  107465. _preActivate(): Mesh;
  107466. /** @hidden */
  107467. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107468. /** @hidden */
  107469. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107470. protected _afterComputeWorldMatrix(): void;
  107471. /** @hidden */
  107472. _postActivate(): void;
  107473. /**
  107474. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107475. * This means the mesh underlying bounding box and sphere are recomputed.
  107476. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107477. * @returns the current mesh
  107478. */
  107479. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107480. /** @hidden */
  107481. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107482. /**
  107483. * This function will subdivide the mesh into multiple submeshes
  107484. * @param count defines the expected number of submeshes
  107485. */
  107486. subdivide(count: number): void;
  107487. /**
  107488. * Copy a FloatArray into a specific associated vertex buffer
  107489. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107490. * - VertexBuffer.PositionKind
  107491. * - VertexBuffer.UVKind
  107492. * - VertexBuffer.UV2Kind
  107493. * - VertexBuffer.UV3Kind
  107494. * - VertexBuffer.UV4Kind
  107495. * - VertexBuffer.UV5Kind
  107496. * - VertexBuffer.UV6Kind
  107497. * - VertexBuffer.ColorKind
  107498. * - VertexBuffer.MatricesIndicesKind
  107499. * - VertexBuffer.MatricesIndicesExtraKind
  107500. * - VertexBuffer.MatricesWeightsKind
  107501. * - VertexBuffer.MatricesWeightsExtraKind
  107502. * @param data defines the data source
  107503. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107504. * @param stride defines the data stride size (can be null)
  107505. * @returns the current mesh
  107506. */
  107507. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107508. /**
  107509. * Delete a vertex buffer associated with this mesh
  107510. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107511. * - VertexBuffer.PositionKind
  107512. * - VertexBuffer.UVKind
  107513. * - VertexBuffer.UV2Kind
  107514. * - VertexBuffer.UV3Kind
  107515. * - VertexBuffer.UV4Kind
  107516. * - VertexBuffer.UV5Kind
  107517. * - VertexBuffer.UV6Kind
  107518. * - VertexBuffer.ColorKind
  107519. * - VertexBuffer.MatricesIndicesKind
  107520. * - VertexBuffer.MatricesIndicesExtraKind
  107521. * - VertexBuffer.MatricesWeightsKind
  107522. * - VertexBuffer.MatricesWeightsExtraKind
  107523. */
  107524. removeVerticesData(kind: string): void;
  107525. /**
  107526. * Flags an associated vertex buffer as updatable
  107527. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107528. * - VertexBuffer.PositionKind
  107529. * - VertexBuffer.UVKind
  107530. * - VertexBuffer.UV2Kind
  107531. * - VertexBuffer.UV3Kind
  107532. * - VertexBuffer.UV4Kind
  107533. * - VertexBuffer.UV5Kind
  107534. * - VertexBuffer.UV6Kind
  107535. * - VertexBuffer.ColorKind
  107536. * - VertexBuffer.MatricesIndicesKind
  107537. * - VertexBuffer.MatricesIndicesExtraKind
  107538. * - VertexBuffer.MatricesWeightsKind
  107539. * - VertexBuffer.MatricesWeightsExtraKind
  107540. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107541. */
  107542. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107543. /**
  107544. * Sets the mesh global Vertex Buffer
  107545. * @param buffer defines the buffer to use
  107546. * @returns the current mesh
  107547. */
  107548. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107549. /**
  107550. * Update a specific associated vertex buffer
  107551. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107552. * - VertexBuffer.PositionKind
  107553. * - VertexBuffer.UVKind
  107554. * - VertexBuffer.UV2Kind
  107555. * - VertexBuffer.UV3Kind
  107556. * - VertexBuffer.UV4Kind
  107557. * - VertexBuffer.UV5Kind
  107558. * - VertexBuffer.UV6Kind
  107559. * - VertexBuffer.ColorKind
  107560. * - VertexBuffer.MatricesIndicesKind
  107561. * - VertexBuffer.MatricesIndicesExtraKind
  107562. * - VertexBuffer.MatricesWeightsKind
  107563. * - VertexBuffer.MatricesWeightsExtraKind
  107564. * @param data defines the data source
  107565. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107566. * @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)
  107567. * @returns the current mesh
  107568. */
  107569. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107570. /**
  107571. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107572. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107573. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107574. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107575. * @returns the current mesh
  107576. */
  107577. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107578. /**
  107579. * Creates a un-shared specific occurence of the geometry for the mesh.
  107580. * @returns the current mesh
  107581. */
  107582. makeGeometryUnique(): Mesh;
  107583. /**
  107584. * Set the index buffer of this mesh
  107585. * @param indices defines the source data
  107586. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107587. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107588. * @returns the current mesh
  107589. */
  107590. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107591. /**
  107592. * Update the current index buffer
  107593. * @param indices defines the source data
  107594. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107595. * @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)
  107596. * @returns the current mesh
  107597. */
  107598. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107599. /**
  107600. * Invert the geometry to move from a right handed system to a left handed one.
  107601. * @returns the current mesh
  107602. */
  107603. toLeftHanded(): Mesh;
  107604. /** @hidden */
  107605. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107606. /** @hidden */
  107607. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107608. /**
  107609. * Registers for this mesh a javascript function called just before the rendering process
  107610. * @param func defines the function to call before rendering this mesh
  107611. * @returns the current mesh
  107612. */
  107613. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107614. /**
  107615. * Disposes a previously registered javascript function called before the rendering
  107616. * @param func defines the function to remove
  107617. * @returns the current mesh
  107618. */
  107619. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107620. /**
  107621. * Registers for this mesh a javascript function called just after the rendering is complete
  107622. * @param func defines the function to call after rendering this mesh
  107623. * @returns the current mesh
  107624. */
  107625. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107626. /**
  107627. * Disposes a previously registered javascript function called after the rendering.
  107628. * @param func defines the function to remove
  107629. * @returns the current mesh
  107630. */
  107631. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107632. /** @hidden */
  107633. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107634. /** @hidden */
  107635. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107636. /** @hidden */
  107637. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107638. /** @hidden */
  107639. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107640. /** @hidden */
  107641. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107642. /** @hidden */
  107643. _rebuild(): void;
  107644. /** @hidden */
  107645. _freeze(): void;
  107646. /** @hidden */
  107647. _unFreeze(): void;
  107648. /**
  107649. * 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
  107650. * @param subMesh defines the subMesh to render
  107651. * @param enableAlphaMode defines if alpha mode can be changed
  107652. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107653. * @returns the current mesh
  107654. */
  107655. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107656. private _onBeforeDraw;
  107657. /**
  107658. * Renormalize the mesh and patch it up if there are no weights
  107659. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107660. * However in the case of zero weights then we set just a single influence to 1.
  107661. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107662. */
  107663. cleanMatrixWeights(): void;
  107664. private normalizeSkinFourWeights;
  107665. private normalizeSkinWeightsAndExtra;
  107666. /**
  107667. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107668. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107669. * the user know there was an issue with importing the mesh
  107670. * @returns a validation object with skinned, valid and report string
  107671. */
  107672. validateSkinning(): {
  107673. skinned: boolean;
  107674. valid: boolean;
  107675. report: string;
  107676. };
  107677. /** @hidden */
  107678. _checkDelayState(): Mesh;
  107679. private _queueLoad;
  107680. /**
  107681. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107682. * A mesh is in the frustum if its bounding box intersects the frustum
  107683. * @param frustumPlanes defines the frustum to test
  107684. * @returns true if the mesh is in the frustum planes
  107685. */
  107686. isInFrustum(frustumPlanes: Plane[]): boolean;
  107687. /**
  107688. * Sets the mesh material by the material or multiMaterial `id` property
  107689. * @param id is a string identifying the material or the multiMaterial
  107690. * @returns the current mesh
  107691. */
  107692. setMaterialByID(id: string): Mesh;
  107693. /**
  107694. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107695. * @returns an array of IAnimatable
  107696. */
  107697. getAnimatables(): IAnimatable[];
  107698. /**
  107699. * Modifies the mesh geometry according to the passed transformation matrix.
  107700. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107701. * The mesh normals are modified using the same transformation.
  107702. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107703. * @param transform defines the transform matrix to use
  107704. * @see https://doc.babylonjs.com/resources/baking_transformations
  107705. * @returns the current mesh
  107706. */
  107707. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107708. /**
  107709. * Modifies the mesh geometry according to its own current World Matrix.
  107710. * The mesh World Matrix is then reset.
  107711. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107712. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107713. * @see https://doc.babylonjs.com/resources/baking_transformations
  107714. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107715. * @returns the current mesh
  107716. */
  107717. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107718. /** @hidden */
  107719. get _positions(): Nullable<Vector3[]>;
  107720. /** @hidden */
  107721. _resetPointsArrayCache(): Mesh;
  107722. /** @hidden */
  107723. _generatePointsArray(): boolean;
  107724. /**
  107725. * Returns a new Mesh object generated from the current mesh properties.
  107726. * This method must not get confused with createInstance()
  107727. * @param name is a string, the name given to the new mesh
  107728. * @param newParent can be any Node object (default `null`)
  107729. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107730. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107731. * @returns a new mesh
  107732. */
  107733. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107734. /**
  107735. * Releases resources associated with this mesh.
  107736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107738. */
  107739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107740. /** @hidden */
  107741. _disposeInstanceSpecificData(): void;
  107742. /** @hidden */
  107743. _disposeThinInstanceSpecificData(): void;
  107744. /**
  107745. * Modifies the mesh geometry according to a displacement map.
  107746. * 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.
  107747. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107748. * @param url is a string, the URL from the image file is to be downloaded.
  107749. * @param minHeight is the lower limit of the displacement.
  107750. * @param maxHeight is the upper limit of the displacement.
  107751. * @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.
  107752. * @param uvOffset is an optional vector2 used to offset UV.
  107753. * @param uvScale is an optional vector2 used to scale UV.
  107754. * @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.
  107755. * @returns the Mesh.
  107756. */
  107757. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107758. /**
  107759. * Modifies the mesh geometry according to a displacementMap buffer.
  107760. * 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.
  107761. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107762. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107763. * @param heightMapWidth is the width of the buffer image.
  107764. * @param heightMapHeight is the height of the buffer image.
  107765. * @param minHeight is the lower limit of the displacement.
  107766. * @param maxHeight is the upper limit of the displacement.
  107767. * @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.
  107768. * @param uvOffset is an optional vector2 used to offset UV.
  107769. * @param uvScale is an optional vector2 used to scale UV.
  107770. * @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.
  107771. * @returns the Mesh.
  107772. */
  107773. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107774. /**
  107775. * Modify the mesh to get a flat shading rendering.
  107776. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107777. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107778. * @returns current mesh
  107779. */
  107780. convertToFlatShadedMesh(): Mesh;
  107781. /**
  107782. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107783. * In other words, more vertices, no more indices and a single bigger VBO.
  107784. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107785. * @returns current mesh
  107786. */
  107787. convertToUnIndexedMesh(): Mesh;
  107788. /**
  107789. * Inverses facet orientations.
  107790. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107791. * @param flipNormals will also inverts the normals
  107792. * @returns current mesh
  107793. */
  107794. flipFaces(flipNormals?: boolean): Mesh;
  107795. /**
  107796. * Increase the number of facets and hence vertices in a mesh
  107797. * Vertex normals are interpolated from existing vertex normals
  107798. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107799. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107800. */
  107801. increaseVertices(numberPerEdge: number): void;
  107802. /**
  107803. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107804. * This will undo any application of covertToFlatShadedMesh
  107805. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107806. */
  107807. forceSharedVertices(): void;
  107808. /** @hidden */
  107809. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107810. /** @hidden */
  107811. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107812. /**
  107813. * Creates a new InstancedMesh object from the mesh model.
  107814. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107815. * @param name defines the name of the new instance
  107816. * @returns a new InstancedMesh
  107817. */
  107818. createInstance(name: string): InstancedMesh;
  107819. /**
  107820. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107821. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107822. * @returns the current mesh
  107823. */
  107824. synchronizeInstances(): Mesh;
  107825. /**
  107826. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107827. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107828. * This should be used together with the simplification to avoid disappearing triangles.
  107829. * @param successCallback an optional success callback to be called after the optimization finished.
  107830. * @returns the current mesh
  107831. */
  107832. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107833. /**
  107834. * Serialize current mesh
  107835. * @param serializationObject defines the object which will receive the serialization data
  107836. */
  107837. serialize(serializationObject: any): void;
  107838. /** @hidden */
  107839. _syncGeometryWithMorphTargetManager(): void;
  107840. /** @hidden */
  107841. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107842. /**
  107843. * Returns a new Mesh object parsed from the source provided.
  107844. * @param parsedMesh is the source
  107845. * @param scene defines the hosting scene
  107846. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107847. * @returns a new Mesh
  107848. */
  107849. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107850. /**
  107851. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107852. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107853. * @param name defines the name of the mesh to create
  107854. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107855. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107856. * @param closePath creates a seam between the first and the last points of each path of the path array
  107857. * @param offset is taken in account only if the `pathArray` is containing a single path
  107858. * @param scene defines the hosting scene
  107859. * @param updatable defines if the mesh must be flagged as updatable
  107860. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107861. * @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)
  107862. * @returns a new Mesh
  107863. */
  107864. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107865. /**
  107866. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107867. * @param name defines the name of the mesh to create
  107868. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107869. * @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
  107870. * @param scene defines the hosting scene
  107871. * @param updatable defines if the mesh must be flagged as updatable
  107872. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107873. * @returns a new Mesh
  107874. */
  107875. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107876. /**
  107877. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107878. * @param name defines the name of the mesh to create
  107879. * @param size sets the size (float) of each box side (default 1)
  107880. * @param scene defines the hosting scene
  107881. * @param updatable defines if the mesh must be flagged as updatable
  107882. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107883. * @returns a new Mesh
  107884. */
  107885. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107886. /**
  107887. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107888. * @param name defines the name of the mesh to create
  107889. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107890. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107891. * @param scene defines the hosting scene
  107892. * @param updatable defines if the mesh must be flagged as updatable
  107893. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107894. * @returns a new Mesh
  107895. */
  107896. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107897. /**
  107898. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107899. * @param name defines the name of the mesh to create
  107900. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107901. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107902. * @param scene defines the hosting scene
  107903. * @returns a new Mesh
  107904. */
  107905. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107906. /**
  107907. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107908. * @param name defines the name of the mesh to create
  107909. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107910. * @param diameterTop set the top cap diameter (floats, default 1)
  107911. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107912. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107913. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107914. * @param scene defines the hosting scene
  107915. * @param updatable defines if the mesh must be flagged as updatable
  107916. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107917. * @returns a new Mesh
  107918. */
  107919. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107920. /**
  107921. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107922. * @param name defines the name of the mesh to create
  107923. * @param diameter sets the diameter size (float) of the torus (default 1)
  107924. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107925. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107926. * @param scene defines the hosting scene
  107927. * @param updatable defines if the mesh must be flagged as updatable
  107928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107929. * @returns a new Mesh
  107930. */
  107931. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107932. /**
  107933. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107934. * @param name defines the name of the mesh to create
  107935. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107936. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107937. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107938. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107939. * @param p the number of windings on X axis (positive integers, default 2)
  107940. * @param q the number of windings on Y axis (positive integers, default 3)
  107941. * @param scene defines the hosting scene
  107942. * @param updatable defines if the mesh must be flagged as updatable
  107943. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107944. * @returns a new Mesh
  107945. */
  107946. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107947. /**
  107948. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107949. * @param name defines the name of the mesh to create
  107950. * @param points is an array successive Vector3
  107951. * @param scene defines the hosting scene
  107952. * @param updatable defines if the mesh must be flagged as updatable
  107953. * @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).
  107954. * @returns a new Mesh
  107955. */
  107956. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107957. /**
  107958. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107959. * @param name defines the name of the mesh to create
  107960. * @param points is an array successive Vector3
  107961. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107962. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107963. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107964. * @param scene defines the hosting scene
  107965. * @param updatable defines if the mesh must be flagged as updatable
  107966. * @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)
  107967. * @returns a new Mesh
  107968. */
  107969. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107970. /**
  107971. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107972. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107973. * 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.
  107974. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107975. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107976. * Remember you can only change the shape positions, not their number when updating a polygon.
  107977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107978. * @param name defines the name of the mesh to create
  107979. * @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
  107980. * @param scene defines the hosting scene
  107981. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107982. * @param updatable defines if the mesh must be flagged as updatable
  107983. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107984. * @param earcutInjection can be used to inject your own earcut reference
  107985. * @returns a new Mesh
  107986. */
  107987. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107988. /**
  107989. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107991. * @param name defines the name of the mesh to create
  107992. * @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
  107993. * @param depth defines the height of extrusion
  107994. * @param scene defines the hosting scene
  107995. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107996. * @param updatable defines if the mesh must be flagged as updatable
  107997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107998. * @param earcutInjection can be used to inject your own earcut reference
  107999. * @returns a new Mesh
  108000. */
  108001. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108002. /**
  108003. * Creates an extruded shape mesh.
  108004. * 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
  108005. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108007. * @param name defines the name of the mesh to create
  108008. * @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
  108009. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108010. * @param scale is the value to scale the shape
  108011. * @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
  108012. * @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
  108013. * @param scene defines the hosting scene
  108014. * @param updatable defines if the mesh must be flagged as updatable
  108015. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108016. * @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)
  108017. * @returns a new Mesh
  108018. */
  108019. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108020. /**
  108021. * Creates an custom extruded shape mesh.
  108022. * The custom extrusion is a parametric shape.
  108023. * It has no predefined shape. Its final shape will depend on the input parameters.
  108024. * Please consider using the same method from the MeshBuilder class instead
  108025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108026. * @param name defines the name of the mesh to create
  108027. * @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
  108028. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108029. * @param scaleFunction is a custom Javascript function called on each path point
  108030. * @param rotationFunction is a custom Javascript function called on each path point
  108031. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108032. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108033. * @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
  108034. * @param scene defines the hosting scene
  108035. * @param updatable defines if the mesh must be flagged as updatable
  108036. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108037. * @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)
  108038. * @returns a new Mesh
  108039. */
  108040. 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;
  108041. /**
  108042. * Creates lathe mesh.
  108043. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108044. * Please consider using the same method from the MeshBuilder class instead
  108045. * @param name defines the name of the mesh to create
  108046. * @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
  108047. * @param radius is the radius value of the lathe
  108048. * @param tessellation is the side number of the lathe.
  108049. * @param scene defines the hosting scene
  108050. * @param updatable defines if the mesh must be flagged as updatable
  108051. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108052. * @returns a new Mesh
  108053. */
  108054. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108055. /**
  108056. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108057. * @param name defines the name of the mesh to create
  108058. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108059. * @param scene defines the hosting scene
  108060. * @param updatable defines if the mesh must be flagged as updatable
  108061. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108062. * @returns a new Mesh
  108063. */
  108064. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108065. /**
  108066. * Creates a ground mesh.
  108067. * Please consider using the same method from the MeshBuilder class instead
  108068. * @param name defines the name of the mesh to create
  108069. * @param width set the width of the ground
  108070. * @param height set the height of the ground
  108071. * @param subdivisions sets the number of subdivisions per side
  108072. * @param scene defines the hosting scene
  108073. * @param updatable defines if the mesh must be flagged as updatable
  108074. * @returns a new Mesh
  108075. */
  108076. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108077. /**
  108078. * Creates a tiled ground mesh.
  108079. * Please consider using the same method from the MeshBuilder class instead
  108080. * @param name defines the name of the mesh to create
  108081. * @param xmin set the ground minimum X coordinate
  108082. * @param zmin set the ground minimum Y coordinate
  108083. * @param xmax set the ground maximum X coordinate
  108084. * @param zmax set the ground maximum Z coordinate
  108085. * @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
  108086. * @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
  108087. * @param scene defines the hosting scene
  108088. * @param updatable defines if the mesh must be flagged as updatable
  108089. * @returns a new Mesh
  108090. */
  108091. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108092. w: number;
  108093. h: number;
  108094. }, precision: {
  108095. w: number;
  108096. h: number;
  108097. }, scene: Scene, updatable?: boolean): Mesh;
  108098. /**
  108099. * Creates a ground mesh from a height map.
  108100. * Please consider using the same method from the MeshBuilder class instead
  108101. * @see https://doc.babylonjs.com/babylon101/height_map
  108102. * @param name defines the name of the mesh to create
  108103. * @param url sets the URL of the height map image resource
  108104. * @param width set the ground width size
  108105. * @param height set the ground height size
  108106. * @param subdivisions sets the number of subdivision per side
  108107. * @param minHeight is the minimum altitude on the ground
  108108. * @param maxHeight is the maximum altitude on the ground
  108109. * @param scene defines the hosting scene
  108110. * @param updatable defines if the mesh must be flagged as updatable
  108111. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108112. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108113. * @returns a new Mesh
  108114. */
  108115. 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;
  108116. /**
  108117. * Creates a tube mesh.
  108118. * The tube is a parametric shape.
  108119. * It has no predefined shape. Its final shape will depend on the input parameters.
  108120. * Please consider using the same method from the MeshBuilder class instead
  108121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108122. * @param name defines the name of the mesh to create
  108123. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108124. * @param radius sets the tube radius size
  108125. * @param tessellation is the number of sides on the tubular surface
  108126. * @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
  108127. * @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
  108128. * @param scene defines the hosting scene
  108129. * @param updatable defines if the mesh must be flagged as updatable
  108130. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108131. * @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)
  108132. * @returns a new Mesh
  108133. */
  108134. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108135. (i: number, distance: number): number;
  108136. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108137. /**
  108138. * Creates a polyhedron mesh.
  108139. * Please consider using the same method from the MeshBuilder class instead.
  108140. * * 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
  108141. * * The parameter `size` (positive float, default 1) sets the polygon size
  108142. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108143. * * 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`
  108144. * * 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
  108145. * * 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)`)
  108146. * * 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
  108147. * * 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
  108148. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108151. * @param name defines the name of the mesh to create
  108152. * @param options defines the options used to create the mesh
  108153. * @param scene defines the hosting scene
  108154. * @returns a new Mesh
  108155. */
  108156. static CreatePolyhedron(name: string, options: {
  108157. type?: number;
  108158. size?: number;
  108159. sizeX?: number;
  108160. sizeY?: number;
  108161. sizeZ?: number;
  108162. custom?: any;
  108163. faceUV?: Vector4[];
  108164. faceColors?: Color4[];
  108165. updatable?: boolean;
  108166. sideOrientation?: number;
  108167. }, scene: Scene): Mesh;
  108168. /**
  108169. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  108170. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  108171. * * 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`)
  108172. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  108173. * * 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
  108174. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108177. * @param name defines the name of the mesh
  108178. * @param options defines the options used to create the mesh
  108179. * @param scene defines the hosting scene
  108180. * @returns a new Mesh
  108181. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108182. */
  108183. static CreateIcoSphere(name: string, options: {
  108184. radius?: number;
  108185. flat?: boolean;
  108186. subdivisions?: number;
  108187. sideOrientation?: number;
  108188. updatable?: boolean;
  108189. }, scene: Scene): Mesh;
  108190. /**
  108191. * Creates a decal mesh.
  108192. * Please consider using the same method from the MeshBuilder class instead.
  108193. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108194. * @param name defines the name of the mesh
  108195. * @param sourceMesh defines the mesh receiving the decal
  108196. * @param position sets the position of the decal in world coordinates
  108197. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108198. * @param size sets the decal scaling
  108199. * @param angle sets the angle to rotate the decal
  108200. * @returns a new Mesh
  108201. */
  108202. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108203. /**
  108204. * Prepare internal position array for software CPU skinning
  108205. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108206. */
  108207. setPositionsForCPUSkinning(): Float32Array;
  108208. /**
  108209. * Prepare internal normal array for software CPU skinning
  108210. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108211. */
  108212. setNormalsForCPUSkinning(): Float32Array;
  108213. /**
  108214. * Updates the vertex buffer by applying transformation from the bones
  108215. * @param skeleton defines the skeleton to apply to current mesh
  108216. * @returns the current mesh
  108217. */
  108218. applySkeleton(skeleton: Skeleton): Mesh;
  108219. /**
  108220. * 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
  108221. * @param meshes defines the list of meshes to scan
  108222. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108223. */
  108224. static MinMax(meshes: AbstractMesh[]): {
  108225. min: Vector3;
  108226. max: Vector3;
  108227. };
  108228. /**
  108229. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108230. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108231. * @returns a vector3
  108232. */
  108233. static Center(meshesOrMinMaxVector: {
  108234. min: Vector3;
  108235. max: Vector3;
  108236. } | AbstractMesh[]): Vector3;
  108237. /**
  108238. * Merge the array of meshes into a single mesh for performance reasons.
  108239. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108240. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108241. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108242. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108243. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108244. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108245. * @returns a new mesh
  108246. */
  108247. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108248. /** @hidden */
  108249. addInstance(instance: InstancedMesh): void;
  108250. /** @hidden */
  108251. removeInstance(instance: InstancedMesh): void;
  108252. }
  108253. }
  108254. declare module BABYLON {
  108255. /**
  108256. * This is the base class of all the camera used in the application.
  108257. * @see https://doc.babylonjs.com/features/cameras
  108258. */
  108259. export class Camera extends Node {
  108260. /** @hidden */
  108261. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108262. /**
  108263. * This is the default projection mode used by the cameras.
  108264. * It helps recreating a feeling of perspective and better appreciate depth.
  108265. * This is the best way to simulate real life cameras.
  108266. */
  108267. static readonly PERSPECTIVE_CAMERA: number;
  108268. /**
  108269. * This helps creating camera with an orthographic mode.
  108270. * 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.
  108271. */
  108272. static readonly ORTHOGRAPHIC_CAMERA: number;
  108273. /**
  108274. * This is the default FOV mode for perspective cameras.
  108275. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108276. */
  108277. static readonly FOVMODE_VERTICAL_FIXED: number;
  108278. /**
  108279. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108280. */
  108281. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108282. /**
  108283. * This specifies ther is no need for a camera rig.
  108284. * Basically only one eye is rendered corresponding to the camera.
  108285. */
  108286. static readonly RIG_MODE_NONE: number;
  108287. /**
  108288. * Simulates a camera Rig with one blue eye and one red eye.
  108289. * This can be use with 3d blue and red glasses.
  108290. */
  108291. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108292. /**
  108293. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108294. */
  108295. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108296. /**
  108297. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108298. */
  108299. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108300. /**
  108301. * Defines that both eyes of the camera will be rendered over under each other.
  108302. */
  108303. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108304. /**
  108305. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108306. */
  108307. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108308. /**
  108309. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108310. */
  108311. static readonly RIG_MODE_VR: number;
  108312. /**
  108313. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108314. */
  108315. static readonly RIG_MODE_WEBVR: number;
  108316. /**
  108317. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108318. */
  108319. static readonly RIG_MODE_CUSTOM: number;
  108320. /**
  108321. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108322. */
  108323. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108324. /**
  108325. * Define the input manager associated with the camera.
  108326. */
  108327. inputs: CameraInputsManager<Camera>;
  108328. /** @hidden */
  108329. _position: Vector3;
  108330. /**
  108331. * Define the current local position of the camera in the scene
  108332. */
  108333. get position(): Vector3;
  108334. set position(newPosition: Vector3);
  108335. /**
  108336. * The vector the camera should consider as up.
  108337. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108338. */
  108339. upVector: Vector3;
  108340. /**
  108341. * Define the current limit on the left side for an orthographic camera
  108342. * In scene unit
  108343. */
  108344. orthoLeft: Nullable<number>;
  108345. /**
  108346. * Define the current limit on the right side for an orthographic camera
  108347. * In scene unit
  108348. */
  108349. orthoRight: Nullable<number>;
  108350. /**
  108351. * Define the current limit on the bottom side for an orthographic camera
  108352. * In scene unit
  108353. */
  108354. orthoBottom: Nullable<number>;
  108355. /**
  108356. * Define the current limit on the top side for an orthographic camera
  108357. * In scene unit
  108358. */
  108359. orthoTop: Nullable<number>;
  108360. /**
  108361. * Field Of View is set in Radians. (default is 0.8)
  108362. */
  108363. fov: number;
  108364. /**
  108365. * Define the minimum distance the camera can see from.
  108366. * This is important to note that the depth buffer are not infinite and the closer it starts
  108367. * the more your scene might encounter depth fighting issue.
  108368. */
  108369. minZ: number;
  108370. /**
  108371. * Define the maximum distance the camera can see to.
  108372. * This is important to note that the depth buffer are not infinite and the further it end
  108373. * the more your scene might encounter depth fighting issue.
  108374. */
  108375. maxZ: number;
  108376. /**
  108377. * Define the default inertia of the camera.
  108378. * This helps giving a smooth feeling to the camera movement.
  108379. */
  108380. inertia: number;
  108381. /**
  108382. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108383. */
  108384. mode: number;
  108385. /**
  108386. * Define whether the camera is intermediate.
  108387. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108388. */
  108389. isIntermediate: boolean;
  108390. /**
  108391. * Define the viewport of the camera.
  108392. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108393. */
  108394. viewport: Viewport;
  108395. /**
  108396. * Restricts the camera to viewing objects with the same layerMask.
  108397. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108398. */
  108399. layerMask: number;
  108400. /**
  108401. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108402. */
  108403. fovMode: number;
  108404. /**
  108405. * Rig mode of the camera.
  108406. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108407. * This is normally controlled byt the camera themselves as internal use.
  108408. */
  108409. cameraRigMode: number;
  108410. /**
  108411. * Defines the distance between both "eyes" in case of a RIG
  108412. */
  108413. interaxialDistance: number;
  108414. /**
  108415. * Defines if stereoscopic rendering is done side by side or over under.
  108416. */
  108417. isStereoscopicSideBySide: boolean;
  108418. /**
  108419. * 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
  108420. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108421. * else in the scene. (Eg. security camera)
  108422. *
  108423. * 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)
  108424. */
  108425. customRenderTargets: RenderTargetTexture[];
  108426. /**
  108427. * When set, the camera will render to this render target instead of the default canvas
  108428. *
  108429. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108430. */
  108431. outputRenderTarget: Nullable<RenderTargetTexture>;
  108432. /**
  108433. * Observable triggered when the camera view matrix has changed.
  108434. */
  108435. onViewMatrixChangedObservable: Observable<Camera>;
  108436. /**
  108437. * Observable triggered when the camera Projection matrix has changed.
  108438. */
  108439. onProjectionMatrixChangedObservable: Observable<Camera>;
  108440. /**
  108441. * Observable triggered when the inputs have been processed.
  108442. */
  108443. onAfterCheckInputsObservable: Observable<Camera>;
  108444. /**
  108445. * Observable triggered when reset has been called and applied to the camera.
  108446. */
  108447. onRestoreStateObservable: Observable<Camera>;
  108448. /**
  108449. * Is this camera a part of a rig system?
  108450. */
  108451. isRigCamera: boolean;
  108452. /**
  108453. * If isRigCamera set to true this will be set with the parent camera.
  108454. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108455. */
  108456. rigParent?: Camera;
  108457. /** @hidden */
  108458. _cameraRigParams: any;
  108459. /** @hidden */
  108460. _rigCameras: Camera[];
  108461. /** @hidden */
  108462. _rigPostProcess: Nullable<PostProcess>;
  108463. protected _webvrViewMatrix: Matrix;
  108464. /** @hidden */
  108465. _skipRendering: boolean;
  108466. /** @hidden */
  108467. _projectionMatrix: Matrix;
  108468. /** @hidden */
  108469. _postProcesses: Nullable<PostProcess>[];
  108470. /** @hidden */
  108471. _activeMeshes: SmartArray<AbstractMesh>;
  108472. protected _globalPosition: Vector3;
  108473. /** @hidden */
  108474. _computedViewMatrix: Matrix;
  108475. private _doNotComputeProjectionMatrix;
  108476. private _transformMatrix;
  108477. private _frustumPlanes;
  108478. private _refreshFrustumPlanes;
  108479. private _storedFov;
  108480. private _stateStored;
  108481. /**
  108482. * Instantiates a new camera object.
  108483. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108484. * @see https://doc.babylonjs.com/features/cameras
  108485. * @param name Defines the name of the camera in the scene
  108486. * @param position Defines the position of the camera
  108487. * @param scene Defines the scene the camera belongs too
  108488. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108489. */
  108490. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108491. /**
  108492. * Store current camera state (fov, position, etc..)
  108493. * @returns the camera
  108494. */
  108495. storeState(): Camera;
  108496. /**
  108497. * Restores the camera state values if it has been stored. You must call storeState() first
  108498. */
  108499. protected _restoreStateValues(): boolean;
  108500. /**
  108501. * Restored camera state. You must call storeState() first.
  108502. * @returns true if restored and false otherwise
  108503. */
  108504. restoreState(): boolean;
  108505. /**
  108506. * Gets the class name of the camera.
  108507. * @returns the class name
  108508. */
  108509. getClassName(): string;
  108510. /** @hidden */
  108511. readonly _isCamera: boolean;
  108512. /**
  108513. * Gets a string representation of the camera useful for debug purpose.
  108514. * @param fullDetails Defines that a more verboe level of logging is required
  108515. * @returns the string representation
  108516. */
  108517. toString(fullDetails?: boolean): string;
  108518. /**
  108519. * Gets the current world space position of the camera.
  108520. */
  108521. get globalPosition(): Vector3;
  108522. /**
  108523. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108524. * @returns the active meshe list
  108525. */
  108526. getActiveMeshes(): SmartArray<AbstractMesh>;
  108527. /**
  108528. * Check whether a mesh is part of the current active mesh list of the camera
  108529. * @param mesh Defines the mesh to check
  108530. * @returns true if active, false otherwise
  108531. */
  108532. isActiveMesh(mesh: Mesh): boolean;
  108533. /**
  108534. * Is this camera ready to be used/rendered
  108535. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108536. * @return true if the camera is ready
  108537. */
  108538. isReady(completeCheck?: boolean): boolean;
  108539. /** @hidden */
  108540. _initCache(): void;
  108541. /** @hidden */
  108542. _updateCache(ignoreParentClass?: boolean): void;
  108543. /** @hidden */
  108544. _isSynchronized(): boolean;
  108545. /** @hidden */
  108546. _isSynchronizedViewMatrix(): boolean;
  108547. /** @hidden */
  108548. _isSynchronizedProjectionMatrix(): boolean;
  108549. /**
  108550. * Attach the input controls to a specific dom element to get the input from.
  108551. * @param element Defines the element the controls should be listened from
  108552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108553. */
  108554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108555. /**
  108556. * Detach the current controls from the specified dom element.
  108557. * @param element Defines the element to stop listening the inputs from
  108558. */
  108559. detachControl(element: HTMLElement): void;
  108560. /**
  108561. * Update the camera state according to the different inputs gathered during the frame.
  108562. */
  108563. update(): void;
  108564. /** @hidden */
  108565. _checkInputs(): void;
  108566. /** @hidden */
  108567. get rigCameras(): Camera[];
  108568. /**
  108569. * Gets the post process used by the rig cameras
  108570. */
  108571. get rigPostProcess(): Nullable<PostProcess>;
  108572. /**
  108573. * Internal, gets the first post proces.
  108574. * @returns the first post process to be run on this camera.
  108575. */
  108576. _getFirstPostProcess(): Nullable<PostProcess>;
  108577. private _cascadePostProcessesToRigCams;
  108578. /**
  108579. * Attach a post process to the camera.
  108580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108581. * @param postProcess The post process to attach to the camera
  108582. * @param insertAt The position of the post process in case several of them are in use in the scene
  108583. * @returns the position the post process has been inserted at
  108584. */
  108585. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108586. /**
  108587. * Detach a post process to the camera.
  108588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108589. * @param postProcess The post process to detach from the camera
  108590. */
  108591. detachPostProcess(postProcess: PostProcess): void;
  108592. /**
  108593. * Gets the current world matrix of the camera
  108594. */
  108595. getWorldMatrix(): Matrix;
  108596. /** @hidden */
  108597. _getViewMatrix(): Matrix;
  108598. /**
  108599. * Gets the current view matrix of the camera.
  108600. * @param force forces the camera to recompute the matrix without looking at the cached state
  108601. * @returns the view matrix
  108602. */
  108603. getViewMatrix(force?: boolean): Matrix;
  108604. /**
  108605. * Freeze the projection matrix.
  108606. * It will prevent the cache check of the camera projection compute and can speed up perf
  108607. * if no parameter of the camera are meant to change
  108608. * @param projection Defines manually a projection if necessary
  108609. */
  108610. freezeProjectionMatrix(projection?: Matrix): void;
  108611. /**
  108612. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108613. */
  108614. unfreezeProjectionMatrix(): void;
  108615. /**
  108616. * Gets the current projection matrix of the camera.
  108617. * @param force forces the camera to recompute the matrix without looking at the cached state
  108618. * @returns the projection matrix
  108619. */
  108620. getProjectionMatrix(force?: boolean): Matrix;
  108621. /**
  108622. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108623. * @returns a Matrix
  108624. */
  108625. getTransformationMatrix(): Matrix;
  108626. private _updateFrustumPlanes;
  108627. /**
  108628. * Checks if a cullable object (mesh...) is in the camera frustum
  108629. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108630. * @param target The object to check
  108631. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108632. * @returns true if the object is in frustum otherwise false
  108633. */
  108634. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108635. /**
  108636. * Checks if a cullable object (mesh...) is in the camera frustum
  108637. * Unlike isInFrustum this cheks the full bounding box
  108638. * @param target The object to check
  108639. * @returns true if the object is in frustum otherwise false
  108640. */
  108641. isCompletelyInFrustum(target: ICullable): boolean;
  108642. /**
  108643. * Gets a ray in the forward direction from the camera.
  108644. * @param length Defines the length of the ray to create
  108645. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108646. * @param origin Defines the start point of the ray which defaults to the camera position
  108647. * @returns the forward ray
  108648. */
  108649. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108650. /**
  108651. * Gets a ray in the forward direction from the camera.
  108652. * @param refRay the ray to (re)use when setting the values
  108653. * @param length Defines the length of the ray to create
  108654. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108655. * @param origin Defines the start point of the ray which defaults to the camera position
  108656. * @returns the forward ray
  108657. */
  108658. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108659. /**
  108660. * Releases resources associated with this node.
  108661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108663. */
  108664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108665. /** @hidden */
  108666. _isLeftCamera: boolean;
  108667. /**
  108668. * Gets the left camera of a rig setup in case of Rigged Camera
  108669. */
  108670. get isLeftCamera(): boolean;
  108671. /** @hidden */
  108672. _isRightCamera: boolean;
  108673. /**
  108674. * Gets the right camera of a rig setup in case of Rigged Camera
  108675. */
  108676. get isRightCamera(): boolean;
  108677. /**
  108678. * Gets the left camera of a rig setup in case of Rigged Camera
  108679. */
  108680. get leftCamera(): Nullable<FreeCamera>;
  108681. /**
  108682. * Gets the right camera of a rig setup in case of Rigged Camera
  108683. */
  108684. get rightCamera(): Nullable<FreeCamera>;
  108685. /**
  108686. * Gets the left camera target of a rig setup in case of Rigged Camera
  108687. * @returns the target position
  108688. */
  108689. getLeftTarget(): Nullable<Vector3>;
  108690. /**
  108691. * Gets the right camera target of a rig setup in case of Rigged Camera
  108692. * @returns the target position
  108693. */
  108694. getRightTarget(): Nullable<Vector3>;
  108695. /**
  108696. * @hidden
  108697. */
  108698. setCameraRigMode(mode: number, rigParams: any): void;
  108699. /** @hidden */
  108700. static _setStereoscopicRigMode(camera: Camera): void;
  108701. /** @hidden */
  108702. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108703. /** @hidden */
  108704. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108705. /** @hidden */
  108706. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108707. /** @hidden */
  108708. _getVRProjectionMatrix(): Matrix;
  108709. protected _updateCameraRotationMatrix(): void;
  108710. protected _updateWebVRCameraRotationMatrix(): void;
  108711. /**
  108712. * This function MUST be overwritten by the different WebVR cameras available.
  108713. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108714. * @hidden
  108715. */
  108716. _getWebVRProjectionMatrix(): Matrix;
  108717. /**
  108718. * This function MUST be overwritten by the different WebVR cameras available.
  108719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108720. * @hidden
  108721. */
  108722. _getWebVRViewMatrix(): Matrix;
  108723. /** @hidden */
  108724. setCameraRigParameter(name: string, value: any): void;
  108725. /**
  108726. * needs to be overridden by children so sub has required properties to be copied
  108727. * @hidden
  108728. */
  108729. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108730. /**
  108731. * May need to be overridden by children
  108732. * @hidden
  108733. */
  108734. _updateRigCameras(): void;
  108735. /** @hidden */
  108736. _setupInputs(): void;
  108737. /**
  108738. * Serialiaze the camera setup to a json represention
  108739. * @returns the JSON representation
  108740. */
  108741. serialize(): any;
  108742. /**
  108743. * Clones the current camera.
  108744. * @param name The cloned camera name
  108745. * @returns the cloned camera
  108746. */
  108747. clone(name: string): Camera;
  108748. /**
  108749. * Gets the direction of the camera relative to a given local axis.
  108750. * @param localAxis Defines the reference axis to provide a relative direction.
  108751. * @return the direction
  108752. */
  108753. getDirection(localAxis: Vector3): Vector3;
  108754. /**
  108755. * Returns the current camera absolute rotation
  108756. */
  108757. get absoluteRotation(): Quaternion;
  108758. /**
  108759. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108760. * @param localAxis Defines the reference axis to provide a relative direction.
  108761. * @param result Defines the vector to store the result in
  108762. */
  108763. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108764. /**
  108765. * Gets a camera constructor for a given camera type
  108766. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108767. * @param name The name of the camera the result will be able to instantiate
  108768. * @param scene The scene the result will construct the camera in
  108769. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108770. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108771. * @returns a factory method to construc the camera
  108772. */
  108773. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108774. /**
  108775. * Compute the world matrix of the camera.
  108776. * @returns the camera world matrix
  108777. */
  108778. computeWorldMatrix(): Matrix;
  108779. /**
  108780. * Parse a JSON and creates the camera from the parsed information
  108781. * @param parsedCamera The JSON to parse
  108782. * @param scene The scene to instantiate the camera in
  108783. * @returns the newly constructed camera
  108784. */
  108785. static Parse(parsedCamera: any, scene: Scene): Camera;
  108786. }
  108787. }
  108788. declare module BABYLON {
  108789. /**
  108790. * Class containing static functions to help procedurally build meshes
  108791. */
  108792. export class DiscBuilder {
  108793. /**
  108794. * Creates a plane polygonal mesh. By default, this is a disc
  108795. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108796. * * 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
  108797. * * 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
  108798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108801. * @param name defines the name of the mesh
  108802. * @param options defines the options used to create the mesh
  108803. * @param scene defines the hosting scene
  108804. * @returns the plane polygonal mesh
  108805. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108806. */
  108807. static CreateDisc(name: string, options: {
  108808. radius?: number;
  108809. tessellation?: number;
  108810. arc?: number;
  108811. updatable?: boolean;
  108812. sideOrientation?: number;
  108813. frontUVs?: Vector4;
  108814. backUVs?: Vector4;
  108815. }, scene?: Nullable<Scene>): Mesh;
  108816. }
  108817. }
  108818. declare module BABYLON {
  108819. /**
  108820. * Options to be used when creating a FresnelParameters.
  108821. */
  108822. export type IFresnelParametersCreationOptions = {
  108823. /**
  108824. * Define the color used on edges (grazing angle)
  108825. */
  108826. leftColor?: Color3;
  108827. /**
  108828. * Define the color used on center
  108829. */
  108830. rightColor?: Color3;
  108831. /**
  108832. * Define bias applied to computed fresnel term
  108833. */
  108834. bias?: number;
  108835. /**
  108836. * Defined the power exponent applied to fresnel term
  108837. */
  108838. power?: number;
  108839. /**
  108840. * Define if the fresnel effect is enable or not.
  108841. */
  108842. isEnabled?: boolean;
  108843. };
  108844. /**
  108845. * Serialized format for FresnelParameters.
  108846. */
  108847. export type IFresnelParametersSerialized = {
  108848. /**
  108849. * Define the color used on edges (grazing angle) [as an array]
  108850. */
  108851. leftColor: number[];
  108852. /**
  108853. * Define the color used on center [as an array]
  108854. */
  108855. rightColor: number[];
  108856. /**
  108857. * Define bias applied to computed fresnel term
  108858. */
  108859. bias: number;
  108860. /**
  108861. * Defined the power exponent applied to fresnel term
  108862. */
  108863. power?: number;
  108864. /**
  108865. * Define if the fresnel effect is enable or not.
  108866. */
  108867. isEnabled: boolean;
  108868. };
  108869. /**
  108870. * This represents all the required information to add a fresnel effect on a material:
  108871. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108872. */
  108873. export class FresnelParameters {
  108874. private _isEnabled;
  108875. /**
  108876. * Define if the fresnel effect is enable or not.
  108877. */
  108878. get isEnabled(): boolean;
  108879. set isEnabled(value: boolean);
  108880. /**
  108881. * Define the color used on edges (grazing angle)
  108882. */
  108883. leftColor: Color3;
  108884. /**
  108885. * Define the color used on center
  108886. */
  108887. rightColor: Color3;
  108888. /**
  108889. * Define bias applied to computed fresnel term
  108890. */
  108891. bias: number;
  108892. /**
  108893. * Defined the power exponent applied to fresnel term
  108894. */
  108895. power: number;
  108896. /**
  108897. * Creates a new FresnelParameters object.
  108898. *
  108899. * @param options provide your own settings to optionally to override defaults
  108900. */
  108901. constructor(options?: IFresnelParametersCreationOptions);
  108902. /**
  108903. * Clones the current fresnel and its valuues
  108904. * @returns a clone fresnel configuration
  108905. */
  108906. clone(): FresnelParameters;
  108907. /**
  108908. * Determines equality between FresnelParameters objects
  108909. * @param otherFresnelParameters defines the second operand
  108910. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108911. */
  108912. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108913. /**
  108914. * Serializes the current fresnel parameters to a JSON representation.
  108915. * @return the JSON serialization
  108916. */
  108917. serialize(): IFresnelParametersSerialized;
  108918. /**
  108919. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108920. * @param parsedFresnelParameters Define the JSON representation
  108921. * @returns the parsed parameters
  108922. */
  108923. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108924. }
  108925. }
  108926. declare module BABYLON {
  108927. /**
  108928. * This groups all the flags used to control the materials channel.
  108929. */
  108930. export class MaterialFlags {
  108931. private static _DiffuseTextureEnabled;
  108932. /**
  108933. * Are diffuse textures enabled in the application.
  108934. */
  108935. static get DiffuseTextureEnabled(): boolean;
  108936. static set DiffuseTextureEnabled(value: boolean);
  108937. private static _DetailTextureEnabled;
  108938. /**
  108939. * Are detail textures enabled in the application.
  108940. */
  108941. static get DetailTextureEnabled(): boolean;
  108942. static set DetailTextureEnabled(value: boolean);
  108943. private static _AmbientTextureEnabled;
  108944. /**
  108945. * Are ambient textures enabled in the application.
  108946. */
  108947. static get AmbientTextureEnabled(): boolean;
  108948. static set AmbientTextureEnabled(value: boolean);
  108949. private static _OpacityTextureEnabled;
  108950. /**
  108951. * Are opacity textures enabled in the application.
  108952. */
  108953. static get OpacityTextureEnabled(): boolean;
  108954. static set OpacityTextureEnabled(value: boolean);
  108955. private static _ReflectionTextureEnabled;
  108956. /**
  108957. * Are reflection textures enabled in the application.
  108958. */
  108959. static get ReflectionTextureEnabled(): boolean;
  108960. static set ReflectionTextureEnabled(value: boolean);
  108961. private static _EmissiveTextureEnabled;
  108962. /**
  108963. * Are emissive textures enabled in the application.
  108964. */
  108965. static get EmissiveTextureEnabled(): boolean;
  108966. static set EmissiveTextureEnabled(value: boolean);
  108967. private static _SpecularTextureEnabled;
  108968. /**
  108969. * Are specular textures enabled in the application.
  108970. */
  108971. static get SpecularTextureEnabled(): boolean;
  108972. static set SpecularTextureEnabled(value: boolean);
  108973. private static _BumpTextureEnabled;
  108974. /**
  108975. * Are bump textures enabled in the application.
  108976. */
  108977. static get BumpTextureEnabled(): boolean;
  108978. static set BumpTextureEnabled(value: boolean);
  108979. private static _LightmapTextureEnabled;
  108980. /**
  108981. * Are lightmap textures enabled in the application.
  108982. */
  108983. static get LightmapTextureEnabled(): boolean;
  108984. static set LightmapTextureEnabled(value: boolean);
  108985. private static _RefractionTextureEnabled;
  108986. /**
  108987. * Are refraction textures enabled in the application.
  108988. */
  108989. static get RefractionTextureEnabled(): boolean;
  108990. static set RefractionTextureEnabled(value: boolean);
  108991. private static _ColorGradingTextureEnabled;
  108992. /**
  108993. * Are color grading textures enabled in the application.
  108994. */
  108995. static get ColorGradingTextureEnabled(): boolean;
  108996. static set ColorGradingTextureEnabled(value: boolean);
  108997. private static _FresnelEnabled;
  108998. /**
  108999. * Are fresnels enabled in the application.
  109000. */
  109001. static get FresnelEnabled(): boolean;
  109002. static set FresnelEnabled(value: boolean);
  109003. private static _ClearCoatTextureEnabled;
  109004. /**
  109005. * Are clear coat textures enabled in the application.
  109006. */
  109007. static get ClearCoatTextureEnabled(): boolean;
  109008. static set ClearCoatTextureEnabled(value: boolean);
  109009. private static _ClearCoatBumpTextureEnabled;
  109010. /**
  109011. * Are clear coat bump textures enabled in the application.
  109012. */
  109013. static get ClearCoatBumpTextureEnabled(): boolean;
  109014. static set ClearCoatBumpTextureEnabled(value: boolean);
  109015. private static _ClearCoatTintTextureEnabled;
  109016. /**
  109017. * Are clear coat tint textures enabled in the application.
  109018. */
  109019. static get ClearCoatTintTextureEnabled(): boolean;
  109020. static set ClearCoatTintTextureEnabled(value: boolean);
  109021. private static _SheenTextureEnabled;
  109022. /**
  109023. * Are sheen textures enabled in the application.
  109024. */
  109025. static get SheenTextureEnabled(): boolean;
  109026. static set SheenTextureEnabled(value: boolean);
  109027. private static _AnisotropicTextureEnabled;
  109028. /**
  109029. * Are anisotropic textures enabled in the application.
  109030. */
  109031. static get AnisotropicTextureEnabled(): boolean;
  109032. static set AnisotropicTextureEnabled(value: boolean);
  109033. private static _ThicknessTextureEnabled;
  109034. /**
  109035. * Are thickness textures enabled in the application.
  109036. */
  109037. static get ThicknessTextureEnabled(): boolean;
  109038. static set ThicknessTextureEnabled(value: boolean);
  109039. }
  109040. }
  109041. declare module BABYLON {
  109042. /** @hidden */
  109043. export var defaultFragmentDeclaration: {
  109044. name: string;
  109045. shader: string;
  109046. };
  109047. }
  109048. declare module BABYLON {
  109049. /** @hidden */
  109050. export var defaultUboDeclaration: {
  109051. name: string;
  109052. shader: string;
  109053. };
  109054. }
  109055. declare module BABYLON {
  109056. /** @hidden */
  109057. export var prePassDeclaration: {
  109058. name: string;
  109059. shader: string;
  109060. };
  109061. }
  109062. declare module BABYLON {
  109063. /** @hidden */
  109064. export var lightFragmentDeclaration: {
  109065. name: string;
  109066. shader: string;
  109067. };
  109068. }
  109069. declare module BABYLON {
  109070. /** @hidden */
  109071. export var lightUboDeclaration: {
  109072. name: string;
  109073. shader: string;
  109074. };
  109075. }
  109076. declare module BABYLON {
  109077. /** @hidden */
  109078. export var lightsFragmentFunctions: {
  109079. name: string;
  109080. shader: string;
  109081. };
  109082. }
  109083. declare module BABYLON {
  109084. /** @hidden */
  109085. export var shadowsFragmentFunctions: {
  109086. name: string;
  109087. shader: string;
  109088. };
  109089. }
  109090. declare module BABYLON {
  109091. /** @hidden */
  109092. export var fresnelFunction: {
  109093. name: string;
  109094. shader: string;
  109095. };
  109096. }
  109097. declare module BABYLON {
  109098. /** @hidden */
  109099. export var bumpFragmentMainFunctions: {
  109100. name: string;
  109101. shader: string;
  109102. };
  109103. }
  109104. declare module BABYLON {
  109105. /** @hidden */
  109106. export var bumpFragmentFunctions: {
  109107. name: string;
  109108. shader: string;
  109109. };
  109110. }
  109111. declare module BABYLON {
  109112. /** @hidden */
  109113. export var logDepthDeclaration: {
  109114. name: string;
  109115. shader: string;
  109116. };
  109117. }
  109118. declare module BABYLON {
  109119. /** @hidden */
  109120. export var bumpFragment: {
  109121. name: string;
  109122. shader: string;
  109123. };
  109124. }
  109125. declare module BABYLON {
  109126. /** @hidden */
  109127. export var depthPrePass: {
  109128. name: string;
  109129. shader: string;
  109130. };
  109131. }
  109132. declare module BABYLON {
  109133. /** @hidden */
  109134. export var lightFragment: {
  109135. name: string;
  109136. shader: string;
  109137. };
  109138. }
  109139. declare module BABYLON {
  109140. /** @hidden */
  109141. export var logDepthFragment: {
  109142. name: string;
  109143. shader: string;
  109144. };
  109145. }
  109146. declare module BABYLON {
  109147. /** @hidden */
  109148. export var defaultPixelShader: {
  109149. name: string;
  109150. shader: string;
  109151. };
  109152. }
  109153. declare module BABYLON {
  109154. /** @hidden */
  109155. export var defaultVertexDeclaration: {
  109156. name: string;
  109157. shader: string;
  109158. };
  109159. }
  109160. declare module BABYLON {
  109161. /** @hidden */
  109162. export var bumpVertexDeclaration: {
  109163. name: string;
  109164. shader: string;
  109165. };
  109166. }
  109167. declare module BABYLON {
  109168. /** @hidden */
  109169. export var bumpVertex: {
  109170. name: string;
  109171. shader: string;
  109172. };
  109173. }
  109174. declare module BABYLON {
  109175. /** @hidden */
  109176. export var fogVertex: {
  109177. name: string;
  109178. shader: string;
  109179. };
  109180. }
  109181. declare module BABYLON {
  109182. /** @hidden */
  109183. export var shadowsVertex: {
  109184. name: string;
  109185. shader: string;
  109186. };
  109187. }
  109188. declare module BABYLON {
  109189. /** @hidden */
  109190. export var pointCloudVertex: {
  109191. name: string;
  109192. shader: string;
  109193. };
  109194. }
  109195. declare module BABYLON {
  109196. /** @hidden */
  109197. export var logDepthVertex: {
  109198. name: string;
  109199. shader: string;
  109200. };
  109201. }
  109202. declare module BABYLON {
  109203. /** @hidden */
  109204. export var defaultVertexShader: {
  109205. name: string;
  109206. shader: string;
  109207. };
  109208. }
  109209. declare module BABYLON {
  109210. /**
  109211. * @hidden
  109212. */
  109213. export interface IMaterialDetailMapDefines {
  109214. DETAIL: boolean;
  109215. DETAILDIRECTUV: number;
  109216. DETAIL_NORMALBLENDMETHOD: number;
  109217. /** @hidden */
  109218. _areTexturesDirty: boolean;
  109219. }
  109220. /**
  109221. * Define the code related to the detail map parameters of a material
  109222. *
  109223. * Inspired from:
  109224. * 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
  109225. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109226. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109227. */
  109228. export class DetailMapConfiguration {
  109229. private _texture;
  109230. /**
  109231. * The detail texture of the material.
  109232. */
  109233. texture: Nullable<BaseTexture>;
  109234. /**
  109235. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109236. * Bigger values mean stronger blending
  109237. */
  109238. diffuseBlendLevel: number;
  109239. /**
  109240. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109241. * Bigger values mean stronger blending. Only used with PBR materials
  109242. */
  109243. roughnessBlendLevel: number;
  109244. /**
  109245. * Defines how strong the bump effect from the detail map is
  109246. * Bigger values mean stronger effect
  109247. */
  109248. bumpLevel: number;
  109249. private _normalBlendMethod;
  109250. /**
  109251. * The method used to blend the bump and detail normals together
  109252. */
  109253. normalBlendMethod: number;
  109254. private _isEnabled;
  109255. /**
  109256. * Enable or disable the detail map on this material
  109257. */
  109258. isEnabled: boolean;
  109259. /** @hidden */
  109260. private _internalMarkAllSubMeshesAsTexturesDirty;
  109261. /** @hidden */
  109262. _markAllSubMeshesAsTexturesDirty(): void;
  109263. /**
  109264. * Instantiate a new detail map
  109265. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109266. */
  109267. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109268. /**
  109269. * Gets whether the submesh is ready to be used or not.
  109270. * @param defines the list of "defines" to update.
  109271. * @param scene defines the scene the material belongs to.
  109272. * @returns - boolean indicating that the submesh is ready or not.
  109273. */
  109274. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109275. /**
  109276. * Update the defines for detail map usage
  109277. * @param defines the list of "defines" to update.
  109278. * @param scene defines the scene the material belongs to.
  109279. */
  109280. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109281. /**
  109282. * Binds the material data.
  109283. * @param uniformBuffer defines the Uniform buffer to fill in.
  109284. * @param scene defines the scene the material belongs to.
  109285. * @param isFrozen defines whether the material is frozen or not.
  109286. */
  109287. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109288. /**
  109289. * Checks to see if a texture is used in the material.
  109290. * @param texture - Base texture to use.
  109291. * @returns - Boolean specifying if a texture is used in the material.
  109292. */
  109293. hasTexture(texture: BaseTexture): boolean;
  109294. /**
  109295. * Returns an array of the actively used textures.
  109296. * @param activeTextures Array of BaseTextures
  109297. */
  109298. getActiveTextures(activeTextures: BaseTexture[]): void;
  109299. /**
  109300. * Returns the animatable textures.
  109301. * @param animatables Array of animatable textures.
  109302. */
  109303. getAnimatables(animatables: IAnimatable[]): void;
  109304. /**
  109305. * Disposes the resources of the material.
  109306. * @param forceDisposeTextures - Forces the disposal of all textures.
  109307. */
  109308. dispose(forceDisposeTextures?: boolean): void;
  109309. /**
  109310. * Get the current class name useful for serialization or dynamic coding.
  109311. * @returns "DetailMap"
  109312. */
  109313. getClassName(): string;
  109314. /**
  109315. * Add the required uniforms to the current list.
  109316. * @param uniforms defines the current uniform list.
  109317. */
  109318. static AddUniforms(uniforms: string[]): void;
  109319. /**
  109320. * Add the required samplers to the current list.
  109321. * @param samplers defines the current sampler list.
  109322. */
  109323. static AddSamplers(samplers: string[]): void;
  109324. /**
  109325. * Add the required uniforms to the current buffer.
  109326. * @param uniformBuffer defines the current uniform buffer.
  109327. */
  109328. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109329. /**
  109330. * Makes a duplicate of the current instance into another one.
  109331. * @param detailMap define the instance where to copy the info
  109332. */
  109333. copyTo(detailMap: DetailMapConfiguration): void;
  109334. /**
  109335. * Serializes this detail map instance
  109336. * @returns - An object with the serialized instance.
  109337. */
  109338. serialize(): any;
  109339. /**
  109340. * Parses a detail map setting from a serialized object.
  109341. * @param source - Serialized object.
  109342. * @param scene Defines the scene we are parsing for
  109343. * @param rootUrl Defines the rootUrl to load from
  109344. */
  109345. parse(source: any, scene: Scene, rootUrl: string): void;
  109346. }
  109347. }
  109348. declare module BABYLON {
  109349. /** @hidden */
  109350. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109351. MAINUV1: boolean;
  109352. MAINUV2: boolean;
  109353. DIFFUSE: boolean;
  109354. DIFFUSEDIRECTUV: number;
  109355. DETAIL: boolean;
  109356. DETAILDIRECTUV: number;
  109357. DETAIL_NORMALBLENDMETHOD: number;
  109358. AMBIENT: boolean;
  109359. AMBIENTDIRECTUV: number;
  109360. OPACITY: boolean;
  109361. OPACITYDIRECTUV: number;
  109362. OPACITYRGB: boolean;
  109363. REFLECTION: boolean;
  109364. EMISSIVE: boolean;
  109365. EMISSIVEDIRECTUV: number;
  109366. SPECULAR: boolean;
  109367. SPECULARDIRECTUV: number;
  109368. BUMP: boolean;
  109369. BUMPDIRECTUV: number;
  109370. PARALLAX: boolean;
  109371. PARALLAXOCCLUSION: boolean;
  109372. SPECULAROVERALPHA: boolean;
  109373. CLIPPLANE: boolean;
  109374. CLIPPLANE2: boolean;
  109375. CLIPPLANE3: boolean;
  109376. CLIPPLANE4: boolean;
  109377. CLIPPLANE5: boolean;
  109378. CLIPPLANE6: boolean;
  109379. ALPHATEST: boolean;
  109380. DEPTHPREPASS: boolean;
  109381. ALPHAFROMDIFFUSE: boolean;
  109382. POINTSIZE: boolean;
  109383. FOG: boolean;
  109384. SPECULARTERM: boolean;
  109385. DIFFUSEFRESNEL: boolean;
  109386. OPACITYFRESNEL: boolean;
  109387. REFLECTIONFRESNEL: boolean;
  109388. REFRACTIONFRESNEL: boolean;
  109389. EMISSIVEFRESNEL: boolean;
  109390. FRESNEL: boolean;
  109391. NORMAL: boolean;
  109392. UV1: boolean;
  109393. UV2: boolean;
  109394. VERTEXCOLOR: boolean;
  109395. VERTEXALPHA: boolean;
  109396. NUM_BONE_INFLUENCERS: number;
  109397. BonesPerMesh: number;
  109398. BONETEXTURE: boolean;
  109399. INSTANCES: boolean;
  109400. THIN_INSTANCES: boolean;
  109401. GLOSSINESS: boolean;
  109402. ROUGHNESS: boolean;
  109403. EMISSIVEASILLUMINATION: boolean;
  109404. LINKEMISSIVEWITHDIFFUSE: boolean;
  109405. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109406. LIGHTMAP: boolean;
  109407. LIGHTMAPDIRECTUV: number;
  109408. OBJECTSPACE_NORMALMAP: boolean;
  109409. USELIGHTMAPASSHADOWMAP: boolean;
  109410. REFLECTIONMAP_3D: boolean;
  109411. REFLECTIONMAP_SPHERICAL: boolean;
  109412. REFLECTIONMAP_PLANAR: boolean;
  109413. REFLECTIONMAP_CUBIC: boolean;
  109414. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109415. REFLECTIONMAP_PROJECTION: boolean;
  109416. REFLECTIONMAP_SKYBOX: boolean;
  109417. REFLECTIONMAP_EXPLICIT: boolean;
  109418. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109419. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109420. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109421. INVERTCUBICMAP: boolean;
  109422. LOGARITHMICDEPTH: boolean;
  109423. REFRACTION: boolean;
  109424. REFRACTIONMAP_3D: boolean;
  109425. REFLECTIONOVERALPHA: boolean;
  109426. TWOSIDEDLIGHTING: boolean;
  109427. SHADOWFLOAT: boolean;
  109428. MORPHTARGETS: boolean;
  109429. MORPHTARGETS_NORMAL: boolean;
  109430. MORPHTARGETS_TANGENT: boolean;
  109431. MORPHTARGETS_UV: boolean;
  109432. NUM_MORPH_INFLUENCERS: number;
  109433. NONUNIFORMSCALING: boolean;
  109434. PREMULTIPLYALPHA: boolean;
  109435. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109436. ALPHABLEND: boolean;
  109437. PREPASS: boolean;
  109438. SCENE_MRT_COUNT: number;
  109439. RGBDLIGHTMAP: boolean;
  109440. RGBDREFLECTION: boolean;
  109441. RGBDREFRACTION: boolean;
  109442. IMAGEPROCESSING: boolean;
  109443. VIGNETTE: boolean;
  109444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109445. VIGNETTEBLENDMODEOPAQUE: boolean;
  109446. TONEMAPPING: boolean;
  109447. TONEMAPPING_ACES: boolean;
  109448. CONTRAST: boolean;
  109449. COLORCURVES: boolean;
  109450. COLORGRADING: boolean;
  109451. COLORGRADING3D: boolean;
  109452. SAMPLER3DGREENDEPTH: boolean;
  109453. SAMPLER3DBGRMAP: boolean;
  109454. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109455. MULTIVIEW: boolean;
  109456. /**
  109457. * If the reflection texture on this material is in linear color space
  109458. * @hidden
  109459. */
  109460. IS_REFLECTION_LINEAR: boolean;
  109461. /**
  109462. * If the refraction texture on this material is in linear color space
  109463. * @hidden
  109464. */
  109465. IS_REFRACTION_LINEAR: boolean;
  109466. EXPOSURE: boolean;
  109467. constructor();
  109468. setReflectionMode(modeToEnable: string): void;
  109469. }
  109470. /**
  109471. * This is the default material used in Babylon. It is the best trade off between quality
  109472. * and performances.
  109473. * @see https://doc.babylonjs.com/babylon101/materials
  109474. */
  109475. export class StandardMaterial extends PushMaterial {
  109476. private _diffuseTexture;
  109477. /**
  109478. * The basic texture of the material as viewed under a light.
  109479. */
  109480. diffuseTexture: Nullable<BaseTexture>;
  109481. private _ambientTexture;
  109482. /**
  109483. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109484. */
  109485. ambientTexture: Nullable<BaseTexture>;
  109486. private _opacityTexture;
  109487. /**
  109488. * Define the transparency of the material from a texture.
  109489. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109490. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109491. */
  109492. opacityTexture: Nullable<BaseTexture>;
  109493. private _reflectionTexture;
  109494. /**
  109495. * Define the texture used to display the reflection.
  109496. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109497. */
  109498. reflectionTexture: Nullable<BaseTexture>;
  109499. private _emissiveTexture;
  109500. /**
  109501. * Define texture of the material as if self lit.
  109502. * This will be mixed in the final result even in the absence of light.
  109503. */
  109504. emissiveTexture: Nullable<BaseTexture>;
  109505. private _specularTexture;
  109506. /**
  109507. * Define how the color and intensity of the highlight given by the light in the material.
  109508. */
  109509. specularTexture: Nullable<BaseTexture>;
  109510. private _bumpTexture;
  109511. /**
  109512. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109513. * 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.
  109514. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109515. */
  109516. bumpTexture: Nullable<BaseTexture>;
  109517. private _lightmapTexture;
  109518. /**
  109519. * Complex lighting can be computationally expensive to compute at runtime.
  109520. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109521. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109522. */
  109523. lightmapTexture: Nullable<BaseTexture>;
  109524. private _refractionTexture;
  109525. /**
  109526. * Define the texture used to display the refraction.
  109527. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109528. */
  109529. refractionTexture: Nullable<BaseTexture>;
  109530. /**
  109531. * The color of the material lit by the environmental background lighting.
  109532. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109533. */
  109534. ambientColor: Color3;
  109535. /**
  109536. * The basic color of the material as viewed under a light.
  109537. */
  109538. diffuseColor: Color3;
  109539. /**
  109540. * Define how the color and intensity of the highlight given by the light in the material.
  109541. */
  109542. specularColor: Color3;
  109543. /**
  109544. * Define the color of the material as if self lit.
  109545. * This will be mixed in the final result even in the absence of light.
  109546. */
  109547. emissiveColor: Color3;
  109548. /**
  109549. * Defines how sharp are the highlights in the material.
  109550. * The bigger the value the sharper giving a more glossy feeling to the result.
  109551. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109552. */
  109553. specularPower: number;
  109554. private _useAlphaFromDiffuseTexture;
  109555. /**
  109556. * Does the transparency come from the diffuse texture alpha channel.
  109557. */
  109558. useAlphaFromDiffuseTexture: boolean;
  109559. private _useEmissiveAsIllumination;
  109560. /**
  109561. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109562. */
  109563. useEmissiveAsIllumination: boolean;
  109564. private _linkEmissiveWithDiffuse;
  109565. /**
  109566. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109567. * the emissive level when the final color is close to one.
  109568. */
  109569. linkEmissiveWithDiffuse: boolean;
  109570. private _useSpecularOverAlpha;
  109571. /**
  109572. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109574. */
  109575. useSpecularOverAlpha: boolean;
  109576. private _useReflectionOverAlpha;
  109577. /**
  109578. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109579. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109580. */
  109581. useReflectionOverAlpha: boolean;
  109582. private _disableLighting;
  109583. /**
  109584. * Does lights from the scene impacts this material.
  109585. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109586. */
  109587. disableLighting: boolean;
  109588. private _useObjectSpaceNormalMap;
  109589. /**
  109590. * Allows using an object space normal map (instead of tangent space).
  109591. */
  109592. useObjectSpaceNormalMap: boolean;
  109593. private _useParallax;
  109594. /**
  109595. * Is parallax enabled or not.
  109596. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109597. */
  109598. useParallax: boolean;
  109599. private _useParallaxOcclusion;
  109600. /**
  109601. * Is parallax occlusion enabled or not.
  109602. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109603. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109604. */
  109605. useParallaxOcclusion: boolean;
  109606. /**
  109607. * 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.
  109608. */
  109609. parallaxScaleBias: number;
  109610. private _roughness;
  109611. /**
  109612. * Helps to define how blurry the reflections should appears in the material.
  109613. */
  109614. roughness: number;
  109615. /**
  109616. * In case of refraction, define the value of the index of refraction.
  109617. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109618. */
  109619. indexOfRefraction: number;
  109620. /**
  109621. * Invert the refraction texture alongside the y axis.
  109622. * It can be useful with procedural textures or probe for instance.
  109623. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109624. */
  109625. invertRefractionY: boolean;
  109626. /**
  109627. * Defines the alpha limits in alpha test mode.
  109628. */
  109629. alphaCutOff: number;
  109630. private _useLightmapAsShadowmap;
  109631. /**
  109632. * In case of light mapping, define whether the map contains light or shadow informations.
  109633. */
  109634. useLightmapAsShadowmap: boolean;
  109635. private _diffuseFresnelParameters;
  109636. /**
  109637. * Define the diffuse fresnel parameters of the material.
  109638. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109639. */
  109640. diffuseFresnelParameters: FresnelParameters;
  109641. private _opacityFresnelParameters;
  109642. /**
  109643. * Define the opacity fresnel parameters of the material.
  109644. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109645. */
  109646. opacityFresnelParameters: FresnelParameters;
  109647. private _reflectionFresnelParameters;
  109648. /**
  109649. * Define the reflection fresnel parameters of the material.
  109650. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109651. */
  109652. reflectionFresnelParameters: FresnelParameters;
  109653. private _refractionFresnelParameters;
  109654. /**
  109655. * Define the refraction fresnel parameters of the material.
  109656. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109657. */
  109658. refractionFresnelParameters: FresnelParameters;
  109659. private _emissiveFresnelParameters;
  109660. /**
  109661. * Define the emissive fresnel parameters of the material.
  109662. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109663. */
  109664. emissiveFresnelParameters: FresnelParameters;
  109665. private _useReflectionFresnelFromSpecular;
  109666. /**
  109667. * If true automatically deducts the fresnels values from the material specularity.
  109668. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109669. */
  109670. useReflectionFresnelFromSpecular: boolean;
  109671. private _useGlossinessFromSpecularMapAlpha;
  109672. /**
  109673. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109674. */
  109675. useGlossinessFromSpecularMapAlpha: boolean;
  109676. private _maxSimultaneousLights;
  109677. /**
  109678. * Defines the maximum number of lights that can be used in the material
  109679. */
  109680. maxSimultaneousLights: number;
  109681. private _invertNormalMapX;
  109682. /**
  109683. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109684. */
  109685. invertNormalMapX: boolean;
  109686. private _invertNormalMapY;
  109687. /**
  109688. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109689. */
  109690. invertNormalMapY: boolean;
  109691. private _twoSidedLighting;
  109692. /**
  109693. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109694. */
  109695. twoSidedLighting: boolean;
  109696. /**
  109697. * Default configuration related to image processing available in the standard Material.
  109698. */
  109699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109700. /**
  109701. * Gets the image processing configuration used either in this material.
  109702. */
  109703. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109704. /**
  109705. * Sets the Default image processing configuration used either in the this material.
  109706. *
  109707. * If sets to null, the scene one is in use.
  109708. */
  109709. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109710. /**
  109711. * Keep track of the image processing observer to allow dispose and replace.
  109712. */
  109713. private _imageProcessingObserver;
  109714. /**
  109715. * Attaches a new image processing configuration to the Standard Material.
  109716. * @param configuration
  109717. */
  109718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109719. /**
  109720. * Gets wether the color curves effect is enabled.
  109721. */
  109722. get cameraColorCurvesEnabled(): boolean;
  109723. /**
  109724. * Sets wether the color curves effect is enabled.
  109725. */
  109726. set cameraColorCurvesEnabled(value: boolean);
  109727. /**
  109728. * Gets wether the color grading effect is enabled.
  109729. */
  109730. get cameraColorGradingEnabled(): boolean;
  109731. /**
  109732. * Gets wether the color grading effect is enabled.
  109733. */
  109734. set cameraColorGradingEnabled(value: boolean);
  109735. /**
  109736. * Gets wether tonemapping is enabled or not.
  109737. */
  109738. get cameraToneMappingEnabled(): boolean;
  109739. /**
  109740. * Sets wether tonemapping is enabled or not
  109741. */
  109742. set cameraToneMappingEnabled(value: boolean);
  109743. /**
  109744. * The camera exposure used on this material.
  109745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109746. * This corresponds to a photographic exposure.
  109747. */
  109748. get cameraExposure(): number;
  109749. /**
  109750. * The camera exposure used on this material.
  109751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109752. * This corresponds to a photographic exposure.
  109753. */
  109754. set cameraExposure(value: number);
  109755. /**
  109756. * Gets The camera contrast used on this material.
  109757. */
  109758. get cameraContrast(): number;
  109759. /**
  109760. * Sets The camera contrast used on this material.
  109761. */
  109762. set cameraContrast(value: number);
  109763. /**
  109764. * Gets the Color Grading 2D Lookup Texture.
  109765. */
  109766. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109767. /**
  109768. * Sets the Color Grading 2D Lookup Texture.
  109769. */
  109770. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109771. /**
  109772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109774. * 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;
  109775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109776. */
  109777. get cameraColorCurves(): Nullable<ColorCurves>;
  109778. /**
  109779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109781. * 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;
  109782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109783. */
  109784. set cameraColorCurves(value: Nullable<ColorCurves>);
  109785. /**
  109786. * Can this material render to several textures at once
  109787. */
  109788. get canRenderToMRT(): boolean;
  109789. /**
  109790. * Defines the detail map parameters for the material.
  109791. */
  109792. readonly detailMap: DetailMapConfiguration;
  109793. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109794. protected _worldViewProjectionMatrix: Matrix;
  109795. protected _globalAmbientColor: Color3;
  109796. protected _useLogarithmicDepth: boolean;
  109797. protected _rebuildInParallel: boolean;
  109798. /**
  109799. * Instantiates a new standard material.
  109800. * This is the default material used in Babylon. It is the best trade off between quality
  109801. * and performances.
  109802. * @see https://doc.babylonjs.com/babylon101/materials
  109803. * @param name Define the name of the material in the scene
  109804. * @param scene Define the scene the material belong to
  109805. */
  109806. constructor(name: string, scene: Scene);
  109807. /**
  109808. * Gets a boolean indicating that current material needs to register RTT
  109809. */
  109810. get hasRenderTargetTextures(): boolean;
  109811. /**
  109812. * Gets the current class name of the material e.g. "StandardMaterial"
  109813. * Mainly use in serialization.
  109814. * @returns the class name
  109815. */
  109816. getClassName(): string;
  109817. /**
  109818. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109819. * You can try switching to logarithmic depth.
  109820. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109821. */
  109822. get useLogarithmicDepth(): boolean;
  109823. set useLogarithmicDepth(value: boolean);
  109824. /**
  109825. * Specifies if the material will require alpha blending
  109826. * @returns a boolean specifying if alpha blending is needed
  109827. */
  109828. needAlphaBlending(): boolean;
  109829. /**
  109830. * Specifies if this material should be rendered in alpha test mode
  109831. * @returns a boolean specifying if an alpha test is needed.
  109832. */
  109833. needAlphaTesting(): boolean;
  109834. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109835. /**
  109836. * Get the texture used for alpha test purpose.
  109837. * @returns the diffuse texture in case of the standard material.
  109838. */
  109839. getAlphaTestTexture(): Nullable<BaseTexture>;
  109840. /**
  109841. * Get if the submesh is ready to be used and all its information available.
  109842. * Child classes can use it to update shaders
  109843. * @param mesh defines the mesh to check
  109844. * @param subMesh defines which submesh to check
  109845. * @param useInstances specifies that instances should be used
  109846. * @returns a boolean indicating that the submesh is ready or not
  109847. */
  109848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109849. /**
  109850. * Builds the material UBO layouts.
  109851. * Used internally during the effect preparation.
  109852. */
  109853. buildUniformLayout(): void;
  109854. /**
  109855. * Unbinds the material from the mesh
  109856. */
  109857. unbind(): void;
  109858. /**
  109859. * Binds the submesh to this material by preparing the effect and shader to draw
  109860. * @param world defines the world transformation matrix
  109861. * @param mesh defines the mesh containing the submesh
  109862. * @param subMesh defines the submesh to bind the material to
  109863. */
  109864. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109865. /**
  109866. * Get the list of animatables in the material.
  109867. * @returns the list of animatables object used in the material
  109868. */
  109869. getAnimatables(): IAnimatable[];
  109870. /**
  109871. * Gets the active textures from the material
  109872. * @returns an array of textures
  109873. */
  109874. getActiveTextures(): BaseTexture[];
  109875. /**
  109876. * Specifies if the material uses a texture
  109877. * @param texture defines the texture to check against the material
  109878. * @returns a boolean specifying if the material uses the texture
  109879. */
  109880. hasTexture(texture: BaseTexture): boolean;
  109881. /**
  109882. * Disposes the material
  109883. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109884. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109885. */
  109886. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109887. /**
  109888. * Makes a duplicate of the material, and gives it a new name
  109889. * @param name defines the new name for the duplicated material
  109890. * @returns the cloned material
  109891. */
  109892. clone(name: string): StandardMaterial;
  109893. /**
  109894. * Serializes this material in a JSON representation
  109895. * @returns the serialized material object
  109896. */
  109897. serialize(): any;
  109898. /**
  109899. * Creates a standard material from parsed material data
  109900. * @param source defines the JSON representation of the material
  109901. * @param scene defines the hosting scene
  109902. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109903. * @returns a new standard material
  109904. */
  109905. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109906. /**
  109907. * Are diffuse textures enabled in the application.
  109908. */
  109909. static get DiffuseTextureEnabled(): boolean;
  109910. static set DiffuseTextureEnabled(value: boolean);
  109911. /**
  109912. * Are detail textures enabled in the application.
  109913. */
  109914. static get DetailTextureEnabled(): boolean;
  109915. static set DetailTextureEnabled(value: boolean);
  109916. /**
  109917. * Are ambient textures enabled in the application.
  109918. */
  109919. static get AmbientTextureEnabled(): boolean;
  109920. static set AmbientTextureEnabled(value: boolean);
  109921. /**
  109922. * Are opacity textures enabled in the application.
  109923. */
  109924. static get OpacityTextureEnabled(): boolean;
  109925. static set OpacityTextureEnabled(value: boolean);
  109926. /**
  109927. * Are reflection textures enabled in the application.
  109928. */
  109929. static get ReflectionTextureEnabled(): boolean;
  109930. static set ReflectionTextureEnabled(value: boolean);
  109931. /**
  109932. * Are emissive textures enabled in the application.
  109933. */
  109934. static get EmissiveTextureEnabled(): boolean;
  109935. static set EmissiveTextureEnabled(value: boolean);
  109936. /**
  109937. * Are specular textures enabled in the application.
  109938. */
  109939. static get SpecularTextureEnabled(): boolean;
  109940. static set SpecularTextureEnabled(value: boolean);
  109941. /**
  109942. * Are bump textures enabled in the application.
  109943. */
  109944. static get BumpTextureEnabled(): boolean;
  109945. static set BumpTextureEnabled(value: boolean);
  109946. /**
  109947. * Are lightmap textures enabled in the application.
  109948. */
  109949. static get LightmapTextureEnabled(): boolean;
  109950. static set LightmapTextureEnabled(value: boolean);
  109951. /**
  109952. * Are refraction textures enabled in the application.
  109953. */
  109954. static get RefractionTextureEnabled(): boolean;
  109955. static set RefractionTextureEnabled(value: boolean);
  109956. /**
  109957. * Are color grading textures enabled in the application.
  109958. */
  109959. static get ColorGradingTextureEnabled(): boolean;
  109960. static set ColorGradingTextureEnabled(value: boolean);
  109961. /**
  109962. * Are fresnels enabled in the application.
  109963. */
  109964. static get FresnelEnabled(): boolean;
  109965. static set FresnelEnabled(value: boolean);
  109966. }
  109967. }
  109968. declare module BABYLON {
  109969. /**
  109970. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109971. *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.
  109972. * The SPS is also a particle system. It provides some methods to manage the particles.
  109973. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109974. *
  109975. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109976. */
  109977. export class SolidParticleSystem implements IDisposable {
  109978. /**
  109979. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109980. * Example : var p = SPS.particles[i];
  109981. */
  109982. particles: SolidParticle[];
  109983. /**
  109984. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109985. */
  109986. nbParticles: number;
  109987. /**
  109988. * If the particles must ever face the camera (default false). Useful for planar particles.
  109989. */
  109990. billboard: boolean;
  109991. /**
  109992. * Recompute normals when adding a shape
  109993. */
  109994. recomputeNormals: boolean;
  109995. /**
  109996. * This a counter ofr your own usage. It's not set by any SPS functions.
  109997. */
  109998. counter: number;
  109999. /**
  110000. * The SPS name. This name is also given to the underlying mesh.
  110001. */
  110002. name: string;
  110003. /**
  110004. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110005. */
  110006. mesh: Mesh;
  110007. /**
  110008. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110009. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110010. */
  110011. vars: any;
  110012. /**
  110013. * This array is populated when the SPS is set as 'pickable'.
  110014. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110015. * Each element of this array is an object `{idx: int, faceId: int}`.
  110016. * `idx` is the picked particle index in the `SPS.particles` array
  110017. * `faceId` is the picked face index counted within this particle.
  110018. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110019. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110020. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110021. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110022. */
  110023. pickedParticles: {
  110024. idx: number;
  110025. faceId: number;
  110026. }[];
  110027. /**
  110028. * This array is populated when the SPS is set as 'pickable'
  110029. * Each key of this array is a submesh index.
  110030. * Each element of this array is a second array defined like this :
  110031. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110032. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110033. * `idx` is the picked particle index in the `SPS.particles` array
  110034. * `faceId` is the picked face index counted within this particle.
  110035. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110036. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110037. */
  110038. pickedBySubMesh: {
  110039. idx: number;
  110040. faceId: number;
  110041. }[][];
  110042. /**
  110043. * This array is populated when `enableDepthSort` is set to true.
  110044. * Each element of this array is an instance of the class DepthSortedParticle.
  110045. */
  110046. depthSortedParticles: DepthSortedParticle[];
  110047. /**
  110048. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110049. * @hidden
  110050. */
  110051. _bSphereOnly: boolean;
  110052. /**
  110053. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110054. * @hidden
  110055. */
  110056. _bSphereRadiusFactor: number;
  110057. private _scene;
  110058. private _positions;
  110059. private _indices;
  110060. private _normals;
  110061. private _colors;
  110062. private _uvs;
  110063. private _indices32;
  110064. private _positions32;
  110065. private _normals32;
  110066. private _fixedNormal32;
  110067. private _colors32;
  110068. private _uvs32;
  110069. private _index;
  110070. private _updatable;
  110071. private _pickable;
  110072. private _isVisibilityBoxLocked;
  110073. private _alwaysVisible;
  110074. private _depthSort;
  110075. private _expandable;
  110076. private _shapeCounter;
  110077. private _copy;
  110078. private _color;
  110079. private _computeParticleColor;
  110080. private _computeParticleTexture;
  110081. private _computeParticleRotation;
  110082. private _computeParticleVertex;
  110083. private _computeBoundingBox;
  110084. private _depthSortParticles;
  110085. private _camera;
  110086. private _mustUnrotateFixedNormals;
  110087. private _particlesIntersect;
  110088. private _needs32Bits;
  110089. private _isNotBuilt;
  110090. private _lastParticleId;
  110091. private _idxOfId;
  110092. private _multimaterialEnabled;
  110093. private _useModelMaterial;
  110094. private _indicesByMaterial;
  110095. private _materialIndexes;
  110096. private _depthSortFunction;
  110097. private _materialSortFunction;
  110098. private _materials;
  110099. private _multimaterial;
  110100. private _materialIndexesById;
  110101. private _defaultMaterial;
  110102. private _autoUpdateSubMeshes;
  110103. private _tmpVertex;
  110104. /**
  110105. * Creates a SPS (Solid Particle System) object.
  110106. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110107. * @param scene (Scene) is the scene in which the SPS is added.
  110108. * @param options defines the options of the sps e.g.
  110109. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110110. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110111. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110112. * * 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.
  110113. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110114. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110115. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110116. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110117. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110118. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110119. */
  110120. constructor(name: string, scene: Scene, options?: {
  110121. updatable?: boolean;
  110122. isPickable?: boolean;
  110123. enableDepthSort?: boolean;
  110124. particleIntersection?: boolean;
  110125. boundingSphereOnly?: boolean;
  110126. bSphereRadiusFactor?: number;
  110127. expandable?: boolean;
  110128. useModelMaterial?: boolean;
  110129. enableMultiMaterial?: boolean;
  110130. });
  110131. /**
  110132. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110133. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110134. * @returns the created mesh
  110135. */
  110136. buildMesh(): Mesh;
  110137. /**
  110138. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110139. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110140. * Thus the particles generated from `digest()` have their property `position` set yet.
  110141. * @param mesh ( Mesh ) is the mesh to be digested
  110142. * @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
  110143. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110144. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110145. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110146. * @returns the current SPS
  110147. */
  110148. digest(mesh: Mesh, options?: {
  110149. facetNb?: number;
  110150. number?: number;
  110151. delta?: number;
  110152. storage?: [];
  110153. }): SolidParticleSystem;
  110154. /**
  110155. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  110156. * @hidden
  110157. */
  110158. private _unrotateFixedNormals;
  110159. /**
  110160. * Resets the temporary working copy particle
  110161. * @hidden
  110162. */
  110163. private _resetCopy;
  110164. /**
  110165. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  110166. * @param p the current index in the positions array to be updated
  110167. * @param ind the current index in the indices array
  110168. * @param shape a Vector3 array, the shape geometry
  110169. * @param positions the positions array to be updated
  110170. * @param meshInd the shape indices array
  110171. * @param indices the indices array to be updated
  110172. * @param meshUV the shape uv array
  110173. * @param uvs the uv array to be updated
  110174. * @param meshCol the shape color array
  110175. * @param colors the color array to be updated
  110176. * @param meshNor the shape normals array
  110177. * @param normals the normals array to be updated
  110178. * @param idx the particle index
  110179. * @param idxInShape the particle index in its shape
  110180. * @param options the addShape() method passed options
  110181. * @model the particle model
  110182. * @hidden
  110183. */
  110184. private _meshBuilder;
  110185. /**
  110186. * Returns a shape Vector3 array from positions float array
  110187. * @param positions float array
  110188. * @returns a vector3 array
  110189. * @hidden
  110190. */
  110191. private _posToShape;
  110192. /**
  110193. * Returns a shapeUV array from a float uvs (array deep copy)
  110194. * @param uvs as a float array
  110195. * @returns a shapeUV array
  110196. * @hidden
  110197. */
  110198. private _uvsToShapeUV;
  110199. /**
  110200. * Adds a new particle object in the particles array
  110201. * @param idx particle index in particles array
  110202. * @param id particle id
  110203. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110204. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110205. * @param model particle ModelShape object
  110206. * @param shapeId model shape identifier
  110207. * @param idxInShape index of the particle in the current model
  110208. * @param bInfo model bounding info object
  110209. * @param storage target storage array, if any
  110210. * @hidden
  110211. */
  110212. private _addParticle;
  110213. /**
  110214. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110215. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110216. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110217. * @param nb (positive integer) the number of particles to be created from this model
  110218. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110219. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110220. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110221. * @returns the number of shapes in the system
  110222. */
  110223. addShape(mesh: Mesh, nb: number, options?: {
  110224. positionFunction?: any;
  110225. vertexFunction?: any;
  110226. storage?: [];
  110227. }): number;
  110228. /**
  110229. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110230. * @hidden
  110231. */
  110232. private _rebuildParticle;
  110233. /**
  110234. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110235. * @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.
  110236. * @returns the SPS.
  110237. */
  110238. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110239. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110240. * Returns an array with the removed particles.
  110241. * 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.
  110242. * The SPS can't be empty so at least one particle needs to remain in place.
  110243. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110244. * @param start index of the first particle to remove
  110245. * @param end index of the last particle to remove (included)
  110246. * @returns an array populated with the removed particles
  110247. */
  110248. removeParticles(start: number, end: number): SolidParticle[];
  110249. /**
  110250. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110251. * @param solidParticleArray an array populated with Solid Particles objects
  110252. * @returns the SPS
  110253. */
  110254. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110255. /**
  110256. * Creates a new particle and modifies the SPS mesh geometry :
  110257. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110258. * - calls _addParticle() to populate the particle array
  110259. * factorized code from addShape() and insertParticlesFromArray()
  110260. * @param idx particle index in the particles array
  110261. * @param i particle index in its shape
  110262. * @param modelShape particle ModelShape object
  110263. * @param shape shape vertex array
  110264. * @param meshInd shape indices array
  110265. * @param meshUV shape uv array
  110266. * @param meshCol shape color array
  110267. * @param meshNor shape normals array
  110268. * @param bbInfo shape bounding info
  110269. * @param storage target particle storage
  110270. * @options addShape() passed options
  110271. * @hidden
  110272. */
  110273. private _insertNewParticle;
  110274. /**
  110275. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110276. * This method calls `updateParticle()` for each particle of the SPS.
  110277. * For an animated SPS, it is usually called within the render loop.
  110278. * 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.
  110279. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110280. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110281. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110282. * @returns the SPS.
  110283. */
  110284. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110285. /**
  110286. * Disposes the SPS.
  110287. */
  110288. dispose(): void;
  110289. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110290. * idx is the particle index in the SPS
  110291. * faceId is the picked face index counted within this particle.
  110292. * Returns null if the pickInfo can't identify a picked particle.
  110293. * @param pickingInfo (PickingInfo object)
  110294. * @returns {idx: number, faceId: number} or null
  110295. */
  110296. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110297. idx: number;
  110298. faceId: number;
  110299. }>;
  110300. /**
  110301. * Returns a SolidParticle object from its identifier : particle.id
  110302. * @param id (integer) the particle Id
  110303. * @returns the searched particle or null if not found in the SPS.
  110304. */
  110305. getParticleById(id: number): Nullable<SolidParticle>;
  110306. /**
  110307. * Returns a new array populated with the particles having the passed shapeId.
  110308. * @param shapeId (integer) the shape identifier
  110309. * @returns a new solid particle array
  110310. */
  110311. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110312. /**
  110313. * Populates the passed array "ref" with the particles having the passed shapeId.
  110314. * @param shapeId the shape identifier
  110315. * @returns the SPS
  110316. * @param ref
  110317. */
  110318. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110319. /**
  110320. * Computes the required SubMeshes according the materials assigned to the particles.
  110321. * @returns the solid particle system.
  110322. * Does nothing if called before the SPS mesh is built.
  110323. */
  110324. computeSubMeshes(): SolidParticleSystem;
  110325. /**
  110326. * Sorts the solid particles by material when MultiMaterial is enabled.
  110327. * Updates the indices32 array.
  110328. * Updates the indicesByMaterial array.
  110329. * Updates the mesh indices array.
  110330. * @returns the SPS
  110331. * @hidden
  110332. */
  110333. private _sortParticlesByMaterial;
  110334. /**
  110335. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110336. * @hidden
  110337. */
  110338. private _setMaterialIndexesById;
  110339. /**
  110340. * Returns an array with unique values of Materials from the passed array
  110341. * @param array the material array to be checked and filtered
  110342. * @hidden
  110343. */
  110344. private _filterUniqueMaterialId;
  110345. /**
  110346. * Sets a new Standard Material as _defaultMaterial if not already set.
  110347. * @hidden
  110348. */
  110349. private _setDefaultMaterial;
  110350. /**
  110351. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110352. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110353. * @returns the SPS.
  110354. */
  110355. refreshVisibleSize(): SolidParticleSystem;
  110356. /**
  110357. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110358. * @param size the size (float) of the visibility box
  110359. * note : this doesn't lock the SPS mesh bounding box.
  110360. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110361. */
  110362. setVisibilityBox(size: number): void;
  110363. /**
  110364. * Gets whether the SPS as always visible or not
  110365. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110366. */
  110367. get isAlwaysVisible(): boolean;
  110368. /**
  110369. * Sets the SPS as always visible or not
  110370. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110371. */
  110372. set isAlwaysVisible(val: boolean);
  110373. /**
  110374. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110375. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110376. */
  110377. set isVisibilityBoxLocked(val: boolean);
  110378. /**
  110379. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110380. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110381. */
  110382. get isVisibilityBoxLocked(): boolean;
  110383. /**
  110384. * Tells to `setParticles()` to compute the particle rotations or not.
  110385. * Default value : true. The SPS is faster when it's set to false.
  110386. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110387. */
  110388. set computeParticleRotation(val: boolean);
  110389. /**
  110390. * Tells to `setParticles()` to compute the particle colors or not.
  110391. * Default value : true. The SPS is faster when it's set to false.
  110392. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110393. */
  110394. set computeParticleColor(val: boolean);
  110395. set computeParticleTexture(val: boolean);
  110396. /**
  110397. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110398. * Default value : false. The SPS is faster when it's set to false.
  110399. * Note : the particle custom vertex positions aren't stored values.
  110400. */
  110401. set computeParticleVertex(val: boolean);
  110402. /**
  110403. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110404. */
  110405. set computeBoundingBox(val: boolean);
  110406. /**
  110407. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110408. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110409. * Default : `true`
  110410. */
  110411. set depthSortParticles(val: boolean);
  110412. /**
  110413. * Gets if `setParticles()` computes the particle rotations or not.
  110414. * Default value : true. The SPS is faster when it's set to false.
  110415. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110416. */
  110417. get computeParticleRotation(): boolean;
  110418. /**
  110419. * Gets if `setParticles()` computes the particle colors or not.
  110420. * Default value : true. The SPS is faster when it's set to false.
  110421. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110422. */
  110423. get computeParticleColor(): boolean;
  110424. /**
  110425. * Gets if `setParticles()` computes the particle textures or not.
  110426. * Default value : true. The SPS is faster when it's set to false.
  110427. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110428. */
  110429. get computeParticleTexture(): boolean;
  110430. /**
  110431. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110432. * Default value : false. The SPS is faster when it's set to false.
  110433. * Note : the particle custom vertex positions aren't stored values.
  110434. */
  110435. get computeParticleVertex(): boolean;
  110436. /**
  110437. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110438. */
  110439. get computeBoundingBox(): boolean;
  110440. /**
  110441. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110442. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110443. * Default : `true`
  110444. */
  110445. get depthSortParticles(): boolean;
  110446. /**
  110447. * Gets if the SPS is created as expandable at construction time.
  110448. * Default : `false`
  110449. */
  110450. get expandable(): boolean;
  110451. /**
  110452. * Gets if the SPS supports the Multi Materials
  110453. */
  110454. get multimaterialEnabled(): boolean;
  110455. /**
  110456. * Gets if the SPS uses the model materials for its own multimaterial.
  110457. */
  110458. get useModelMaterial(): boolean;
  110459. /**
  110460. * The SPS used material array.
  110461. */
  110462. get materials(): Material[];
  110463. /**
  110464. * Sets the SPS MultiMaterial from the passed materials.
  110465. * Note : the passed array is internally copied and not used then by reference.
  110466. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110467. */
  110468. setMultiMaterial(materials: Material[]): void;
  110469. /**
  110470. * The SPS computed multimaterial object
  110471. */
  110472. get multimaterial(): MultiMaterial;
  110473. set multimaterial(mm: MultiMaterial);
  110474. /**
  110475. * If the subMeshes must be updated on the next call to setParticles()
  110476. */
  110477. get autoUpdateSubMeshes(): boolean;
  110478. set autoUpdateSubMeshes(val: boolean);
  110479. /**
  110480. * This function does nothing. It may be overwritten to set all the particle first values.
  110481. * The SPS doesn't call this function, you may have to call it by your own.
  110482. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110483. */
  110484. initParticles(): void;
  110485. /**
  110486. * This function does nothing. It may be overwritten to recycle a particle.
  110487. * The SPS doesn't call this function, you may have to call it by your own.
  110488. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110489. * @param particle The particle to recycle
  110490. * @returns the recycled particle
  110491. */
  110492. recycleParticle(particle: SolidParticle): SolidParticle;
  110493. /**
  110494. * Updates a particle : this function should be overwritten by the user.
  110495. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110496. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110497. * @example : just set a particle position or velocity and recycle conditions
  110498. * @param particle The particle to update
  110499. * @returns the updated particle
  110500. */
  110501. updateParticle(particle: SolidParticle): SolidParticle;
  110502. /**
  110503. * Updates a vertex of a particle : it can be overwritten by the user.
  110504. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110505. * @param particle the current particle
  110506. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110507. * @param pt the index of the current vertex in the particle shape
  110508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110509. * @example : just set a vertex particle position or color
  110510. * @returns the sps
  110511. */
  110512. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110513. /**
  110514. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110515. * This does nothing and may be overwritten by the user.
  110516. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110517. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110518. * @param update the boolean update value actually passed to setParticles()
  110519. */
  110520. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110521. /**
  110522. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110523. * This will be passed three parameters.
  110524. * This does nothing and may be overwritten by the user.
  110525. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110526. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110527. * @param update the boolean update value actually passed to setParticles()
  110528. */
  110529. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110530. }
  110531. }
  110532. declare module BABYLON {
  110533. /**
  110534. * Represents one particle of a solid particle system.
  110535. */
  110536. export class SolidParticle {
  110537. /**
  110538. * particle global index
  110539. */
  110540. idx: number;
  110541. /**
  110542. * particle identifier
  110543. */
  110544. id: number;
  110545. /**
  110546. * The color of the particle
  110547. */
  110548. color: Nullable<Color4>;
  110549. /**
  110550. * The world space position of the particle.
  110551. */
  110552. position: Vector3;
  110553. /**
  110554. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110555. */
  110556. rotation: Vector3;
  110557. /**
  110558. * The world space rotation quaternion of the particle.
  110559. */
  110560. rotationQuaternion: Nullable<Quaternion>;
  110561. /**
  110562. * The scaling of the particle.
  110563. */
  110564. scaling: Vector3;
  110565. /**
  110566. * The uvs of the particle.
  110567. */
  110568. uvs: Vector4;
  110569. /**
  110570. * The current speed of the particle.
  110571. */
  110572. velocity: Vector3;
  110573. /**
  110574. * The pivot point in the particle local space.
  110575. */
  110576. pivot: Vector3;
  110577. /**
  110578. * Must the particle be translated from its pivot point in its local space ?
  110579. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110580. * Default : false
  110581. */
  110582. translateFromPivot: boolean;
  110583. /**
  110584. * Is the particle active or not ?
  110585. */
  110586. alive: boolean;
  110587. /**
  110588. * Is the particle visible or not ?
  110589. */
  110590. isVisible: boolean;
  110591. /**
  110592. * Index of this particle in the global "positions" array (Internal use)
  110593. * @hidden
  110594. */
  110595. _pos: number;
  110596. /**
  110597. * @hidden Index of this particle in the global "indices" array (Internal use)
  110598. */
  110599. _ind: number;
  110600. /**
  110601. * @hidden ModelShape of this particle (Internal use)
  110602. */
  110603. _model: ModelShape;
  110604. /**
  110605. * ModelShape id of this particle
  110606. */
  110607. shapeId: number;
  110608. /**
  110609. * Index of the particle in its shape id
  110610. */
  110611. idxInShape: number;
  110612. /**
  110613. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110614. */
  110615. _modelBoundingInfo: BoundingInfo;
  110616. /**
  110617. * @hidden Particle BoundingInfo object (Internal use)
  110618. */
  110619. _boundingInfo: BoundingInfo;
  110620. /**
  110621. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110622. */
  110623. _sps: SolidParticleSystem;
  110624. /**
  110625. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110626. */
  110627. _stillInvisible: boolean;
  110628. /**
  110629. * @hidden Last computed particle rotation matrix
  110630. */
  110631. _rotationMatrix: number[];
  110632. /**
  110633. * Parent particle Id, if any.
  110634. * Default null.
  110635. */
  110636. parentId: Nullable<number>;
  110637. /**
  110638. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110639. */
  110640. materialIndex: Nullable<number>;
  110641. /**
  110642. * Custom object or properties.
  110643. */
  110644. props: Nullable<any>;
  110645. /**
  110646. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110647. * The possible values are :
  110648. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110649. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110650. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110651. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110652. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110653. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110654. * */
  110655. cullingStrategy: number;
  110656. /**
  110657. * @hidden Internal global position in the SPS.
  110658. */
  110659. _globalPosition: Vector3;
  110660. /**
  110661. * Creates a Solid Particle object.
  110662. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110663. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110664. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110665. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110666. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110667. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110668. * @param shapeId (integer) is the model shape identifier in the SPS.
  110669. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110670. * @param sps defines the sps it is associated to
  110671. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110672. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110673. */
  110674. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110675. /**
  110676. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110677. * @param target the particle target
  110678. * @returns the current particle
  110679. */
  110680. copyToRef(target: SolidParticle): SolidParticle;
  110681. /**
  110682. * Legacy support, changed scale to scaling
  110683. */
  110684. get scale(): Vector3;
  110685. /**
  110686. * Legacy support, changed scale to scaling
  110687. */
  110688. set scale(scale: Vector3);
  110689. /**
  110690. * Legacy support, changed quaternion to rotationQuaternion
  110691. */
  110692. get quaternion(): Nullable<Quaternion>;
  110693. /**
  110694. * Legacy support, changed quaternion to rotationQuaternion
  110695. */
  110696. set quaternion(q: Nullable<Quaternion>);
  110697. /**
  110698. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110699. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110700. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110701. * @returns true if it intersects
  110702. */
  110703. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110704. /**
  110705. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110706. * A particle is in the frustum if its bounding box intersects the frustum
  110707. * @param frustumPlanes defines the frustum to test
  110708. * @returns true if the particle is in the frustum planes
  110709. */
  110710. isInFrustum(frustumPlanes: Plane[]): boolean;
  110711. /**
  110712. * get the rotation matrix of the particle
  110713. * @hidden
  110714. */
  110715. getRotationMatrix(m: Matrix): void;
  110716. }
  110717. /**
  110718. * Represents the shape of the model used by one particle of a solid particle system.
  110719. * SPS internal tool, don't use it manually.
  110720. */
  110721. export class ModelShape {
  110722. /**
  110723. * The shape id
  110724. * @hidden
  110725. */
  110726. shapeID: number;
  110727. /**
  110728. * flat array of model positions (internal use)
  110729. * @hidden
  110730. */
  110731. _shape: Vector3[];
  110732. /**
  110733. * flat array of model UVs (internal use)
  110734. * @hidden
  110735. */
  110736. _shapeUV: number[];
  110737. /**
  110738. * color array of the model
  110739. * @hidden
  110740. */
  110741. _shapeColors: number[];
  110742. /**
  110743. * indices array of the model
  110744. * @hidden
  110745. */
  110746. _indices: number[];
  110747. /**
  110748. * normals array of the model
  110749. * @hidden
  110750. */
  110751. _normals: number[];
  110752. /**
  110753. * length of the shape in the model indices array (internal use)
  110754. * @hidden
  110755. */
  110756. _indicesLength: number;
  110757. /**
  110758. * Custom position function (internal use)
  110759. * @hidden
  110760. */
  110761. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110762. /**
  110763. * Custom vertex function (internal use)
  110764. * @hidden
  110765. */
  110766. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110767. /**
  110768. * Model material (internal use)
  110769. * @hidden
  110770. */
  110771. _material: Nullable<Material>;
  110772. /**
  110773. * 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.
  110774. * SPS internal tool, don't use it manually.
  110775. * @hidden
  110776. */
  110777. 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>);
  110778. }
  110779. /**
  110780. * Represents a Depth Sorted Particle in the solid particle system.
  110781. * @hidden
  110782. */
  110783. export class DepthSortedParticle {
  110784. /**
  110785. * Particle index
  110786. */
  110787. idx: number;
  110788. /**
  110789. * Index of the particle in the "indices" array
  110790. */
  110791. ind: number;
  110792. /**
  110793. * Length of the particle shape in the "indices" array
  110794. */
  110795. indicesLength: number;
  110796. /**
  110797. * Squared distance from the particle to the camera
  110798. */
  110799. sqDistance: number;
  110800. /**
  110801. * Material index when used with MultiMaterials
  110802. */
  110803. materialIndex: number;
  110804. /**
  110805. * Creates a new sorted particle
  110806. * @param materialIndex
  110807. */
  110808. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110809. }
  110810. /**
  110811. * Represents a solid particle vertex
  110812. */
  110813. export class SolidParticleVertex {
  110814. /**
  110815. * Vertex position
  110816. */
  110817. position: Vector3;
  110818. /**
  110819. * Vertex color
  110820. */
  110821. color: Color4;
  110822. /**
  110823. * Vertex UV
  110824. */
  110825. uv: Vector2;
  110826. /**
  110827. * Creates a new solid particle vertex
  110828. */
  110829. constructor();
  110830. /** Vertex x coordinate */
  110831. get x(): number;
  110832. set x(val: number);
  110833. /** Vertex y coordinate */
  110834. get y(): number;
  110835. set y(val: number);
  110836. /** Vertex z coordinate */
  110837. get z(): number;
  110838. set z(val: number);
  110839. }
  110840. }
  110841. declare module BABYLON {
  110842. /**
  110843. * @hidden
  110844. */
  110845. export class _MeshCollisionData {
  110846. _checkCollisions: boolean;
  110847. _collisionMask: number;
  110848. _collisionGroup: number;
  110849. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110850. _collider: Nullable<Collider>;
  110851. _oldPositionForCollisions: Vector3;
  110852. _diffPositionForCollisions: Vector3;
  110853. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110854. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /** @hidden */
  110859. class _FacetDataStorage {
  110860. facetPositions: Vector3[];
  110861. facetNormals: Vector3[];
  110862. facetPartitioning: number[][];
  110863. facetNb: number;
  110864. partitioningSubdivisions: number;
  110865. partitioningBBoxRatio: number;
  110866. facetDataEnabled: boolean;
  110867. facetParameters: any;
  110868. bbSize: Vector3;
  110869. subDiv: {
  110870. max: number;
  110871. X: number;
  110872. Y: number;
  110873. Z: number;
  110874. };
  110875. facetDepthSort: boolean;
  110876. facetDepthSortEnabled: boolean;
  110877. depthSortedIndices: IndicesArray;
  110878. depthSortedFacets: {
  110879. ind: number;
  110880. sqDistance: number;
  110881. }[];
  110882. facetDepthSortFunction: (f1: {
  110883. ind: number;
  110884. sqDistance: number;
  110885. }, f2: {
  110886. ind: number;
  110887. sqDistance: number;
  110888. }) => number;
  110889. facetDepthSortFrom: Vector3;
  110890. facetDepthSortOrigin: Vector3;
  110891. invertedMatrix: Matrix;
  110892. }
  110893. /**
  110894. * @hidden
  110895. **/
  110896. class _InternalAbstractMeshDataInfo {
  110897. _hasVertexAlpha: boolean;
  110898. _useVertexColors: boolean;
  110899. _numBoneInfluencers: number;
  110900. _applyFog: boolean;
  110901. _receiveShadows: boolean;
  110902. _facetData: _FacetDataStorage;
  110903. _visibility: number;
  110904. _skeleton: Nullable<Skeleton>;
  110905. _layerMask: number;
  110906. _computeBonesUsingShaders: boolean;
  110907. _isActive: boolean;
  110908. _onlyForInstances: boolean;
  110909. _isActiveIntermediate: boolean;
  110910. _onlyForInstancesIntermediate: boolean;
  110911. _actAsRegularMesh: boolean;
  110912. }
  110913. /**
  110914. * Class used to store all common mesh properties
  110915. */
  110916. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110917. /** No occlusion */
  110918. static OCCLUSION_TYPE_NONE: number;
  110919. /** Occlusion set to optimisitic */
  110920. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110921. /** Occlusion set to strict */
  110922. static OCCLUSION_TYPE_STRICT: number;
  110923. /** Use an accurante occlusion algorithm */
  110924. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110925. /** Use a conservative occlusion algorithm */
  110926. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110927. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110928. * Test order :
  110929. * Is the bounding sphere outside the frustum ?
  110930. * If not, are the bounding box vertices outside the frustum ?
  110931. * It not, then the cullable object is in the frustum.
  110932. */
  110933. static readonly CULLINGSTRATEGY_STANDARD: number;
  110934. /** Culling strategy : Bounding Sphere Only.
  110935. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110936. * It's also less accurate than the standard because some not visible objects can still be selected.
  110937. * Test : is the bounding sphere outside the frustum ?
  110938. * If not, then the cullable object is in the frustum.
  110939. */
  110940. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110941. /** Culling strategy : Optimistic Inclusion.
  110942. * This in an inclusion test first, then the standard exclusion test.
  110943. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110944. * 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.
  110945. * Anyway, it's as accurate as the standard strategy.
  110946. * Test :
  110947. * Is the cullable object bounding sphere center in the frustum ?
  110948. * If not, apply the default culling strategy.
  110949. */
  110950. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110951. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110952. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110953. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110954. * 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.
  110955. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110956. * Test :
  110957. * Is the cullable object bounding sphere center in the frustum ?
  110958. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110959. */
  110960. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110961. /**
  110962. * No billboard
  110963. */
  110964. static get BILLBOARDMODE_NONE(): number;
  110965. /** Billboard on X axis */
  110966. static get BILLBOARDMODE_X(): number;
  110967. /** Billboard on Y axis */
  110968. static get BILLBOARDMODE_Y(): number;
  110969. /** Billboard on Z axis */
  110970. static get BILLBOARDMODE_Z(): number;
  110971. /** Billboard on all axes */
  110972. static get BILLBOARDMODE_ALL(): number;
  110973. /** Billboard on using position instead of orientation */
  110974. static get BILLBOARDMODE_USE_POSITION(): number;
  110975. /** @hidden */
  110976. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110977. /**
  110978. * The culling strategy to use to check whether the mesh must be rendered or not.
  110979. * This value can be changed at any time and will be used on the next render mesh selection.
  110980. * The possible values are :
  110981. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110982. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110983. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110984. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110985. * Please read each static variable documentation to get details about the culling process.
  110986. * */
  110987. cullingStrategy: number;
  110988. /**
  110989. * Gets the number of facets in the mesh
  110990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110991. */
  110992. get facetNb(): number;
  110993. /**
  110994. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110995. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110996. */
  110997. get partitioningSubdivisions(): number;
  110998. set partitioningSubdivisions(nb: number);
  110999. /**
  111000. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111001. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111002. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111003. */
  111004. get partitioningBBoxRatio(): number;
  111005. set partitioningBBoxRatio(ratio: number);
  111006. /**
  111007. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111008. * Works only for updatable meshes.
  111009. * Doesn't work with multi-materials
  111010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111011. */
  111012. get mustDepthSortFacets(): boolean;
  111013. set mustDepthSortFacets(sort: boolean);
  111014. /**
  111015. * The location (Vector3) where the facet depth sort must be computed from.
  111016. * By default, the active camera position.
  111017. * Used only when facet depth sort is enabled
  111018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111019. */
  111020. get facetDepthSortFrom(): Vector3;
  111021. set facetDepthSortFrom(location: Vector3);
  111022. /**
  111023. * gets a boolean indicating if facetData is enabled
  111024. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111025. */
  111026. get isFacetDataEnabled(): boolean;
  111027. /** @hidden */
  111028. _updateNonUniformScalingState(value: boolean): boolean;
  111029. /**
  111030. * An event triggered when this mesh collides with another one
  111031. */
  111032. onCollideObservable: Observable<AbstractMesh>;
  111033. /** Set a function to call when this mesh collides with another one */
  111034. set onCollide(callback: () => void);
  111035. /**
  111036. * An event triggered when the collision's position changes
  111037. */
  111038. onCollisionPositionChangeObservable: Observable<Vector3>;
  111039. /** Set a function to call when the collision's position changes */
  111040. set onCollisionPositionChange(callback: () => void);
  111041. /**
  111042. * An event triggered when material is changed
  111043. */
  111044. onMaterialChangedObservable: Observable<AbstractMesh>;
  111045. /**
  111046. * Gets or sets the orientation for POV movement & rotation
  111047. */
  111048. definedFacingForward: boolean;
  111049. /** @hidden */
  111050. _occlusionQuery: Nullable<WebGLQuery>;
  111051. /** @hidden */
  111052. _renderingGroup: Nullable<RenderingGroup>;
  111053. /**
  111054. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111055. */
  111056. get visibility(): number;
  111057. /**
  111058. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111059. */
  111060. set visibility(value: number);
  111061. /** Gets or sets the alpha index used to sort transparent meshes
  111062. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111063. */
  111064. alphaIndex: number;
  111065. /**
  111066. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111067. */
  111068. isVisible: boolean;
  111069. /**
  111070. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111071. */
  111072. isPickable: boolean;
  111073. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111074. showSubMeshesBoundingBox: boolean;
  111075. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111076. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111077. */
  111078. isBlocker: boolean;
  111079. /**
  111080. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111081. */
  111082. enablePointerMoveEvents: boolean;
  111083. /**
  111084. * Specifies the rendering group id for this mesh (0 by default)
  111085. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111086. */
  111087. renderingGroupId: number;
  111088. private _material;
  111089. /** Gets or sets current material */
  111090. get material(): Nullable<Material>;
  111091. set material(value: Nullable<Material>);
  111092. /**
  111093. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111094. * @see https://doc.babylonjs.com/babylon101/shadows
  111095. */
  111096. get receiveShadows(): boolean;
  111097. set receiveShadows(value: boolean);
  111098. /** Defines color to use when rendering outline */
  111099. outlineColor: Color3;
  111100. /** Define width to use when rendering outline */
  111101. outlineWidth: number;
  111102. /** Defines color to use when rendering overlay */
  111103. overlayColor: Color3;
  111104. /** Defines alpha to use when rendering overlay */
  111105. overlayAlpha: number;
  111106. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111107. get hasVertexAlpha(): boolean;
  111108. set hasVertexAlpha(value: boolean);
  111109. /** 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) */
  111110. get useVertexColors(): boolean;
  111111. set useVertexColors(value: boolean);
  111112. /**
  111113. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111114. */
  111115. get computeBonesUsingShaders(): boolean;
  111116. set computeBonesUsingShaders(value: boolean);
  111117. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111118. get numBoneInfluencers(): number;
  111119. set numBoneInfluencers(value: number);
  111120. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111121. get applyFog(): boolean;
  111122. set applyFog(value: boolean);
  111123. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111124. useOctreeForRenderingSelection: boolean;
  111125. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111126. useOctreeForPicking: boolean;
  111127. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111128. useOctreeForCollisions: boolean;
  111129. /**
  111130. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111131. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111132. */
  111133. get layerMask(): number;
  111134. set layerMask(value: number);
  111135. /**
  111136. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111137. */
  111138. alwaysSelectAsActiveMesh: boolean;
  111139. /**
  111140. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111141. */
  111142. doNotSyncBoundingInfo: boolean;
  111143. /**
  111144. * Gets or sets the current action manager
  111145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111146. */
  111147. actionManager: Nullable<AbstractActionManager>;
  111148. private _meshCollisionData;
  111149. /**
  111150. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111151. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111152. */
  111153. ellipsoid: Vector3;
  111154. /**
  111155. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  111156. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111157. */
  111158. ellipsoidOffset: Vector3;
  111159. /**
  111160. * Gets or sets a collision mask used to mask collisions (default is -1).
  111161. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111162. */
  111163. get collisionMask(): number;
  111164. set collisionMask(mask: number);
  111165. /**
  111166. * Gets or sets the current collision group mask (-1 by default).
  111167. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  111168. */
  111169. get collisionGroup(): number;
  111170. set collisionGroup(mask: number);
  111171. /**
  111172. * Gets or sets current surrounding meshes (null by default).
  111173. *
  111174. * By default collision detection is tested against every mesh in the scene.
  111175. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111176. * meshes will be tested for the collision.
  111177. *
  111178. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111179. */
  111180. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111181. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111182. /**
  111183. * Defines edge width used when edgesRenderer is enabled
  111184. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111185. */
  111186. edgesWidth: number;
  111187. /**
  111188. * Defines edge color used when edgesRenderer is enabled
  111189. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111190. */
  111191. edgesColor: Color4;
  111192. /** @hidden */
  111193. _edgesRenderer: Nullable<IEdgesRenderer>;
  111194. /** @hidden */
  111195. _masterMesh: Nullable<AbstractMesh>;
  111196. /** @hidden */
  111197. _boundingInfo: Nullable<BoundingInfo>;
  111198. /** @hidden */
  111199. _renderId: number;
  111200. /**
  111201. * Gets or sets the list of subMeshes
  111202. * @see https://doc.babylonjs.com/how_to/multi_materials
  111203. */
  111204. subMeshes: SubMesh[];
  111205. /** @hidden */
  111206. _intersectionsInProgress: AbstractMesh[];
  111207. /** @hidden */
  111208. _unIndexed: boolean;
  111209. /** @hidden */
  111210. _lightSources: Light[];
  111211. /** Gets the list of lights affecting that mesh */
  111212. get lightSources(): Light[];
  111213. /** @hidden */
  111214. get _positions(): Nullable<Vector3[]>;
  111215. /** @hidden */
  111216. _waitingData: {
  111217. lods: Nullable<any>;
  111218. actions: Nullable<any>;
  111219. freezeWorldMatrix: Nullable<boolean>;
  111220. };
  111221. /** @hidden */
  111222. _bonesTransformMatrices: Nullable<Float32Array>;
  111223. /** @hidden */
  111224. _transformMatrixTexture: Nullable<RawTexture>;
  111225. /**
  111226. * Gets or sets a skeleton to apply skining transformations
  111227. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111228. */
  111229. set skeleton(value: Nullable<Skeleton>);
  111230. get skeleton(): Nullable<Skeleton>;
  111231. /**
  111232. * An event triggered when the mesh is rebuilt.
  111233. */
  111234. onRebuildObservable: Observable<AbstractMesh>;
  111235. /**
  111236. * Creates a new AbstractMesh
  111237. * @param name defines the name of the mesh
  111238. * @param scene defines the hosting scene
  111239. */
  111240. constructor(name: string, scene?: Nullable<Scene>);
  111241. /**
  111242. * Returns the string "AbstractMesh"
  111243. * @returns "AbstractMesh"
  111244. */
  111245. getClassName(): string;
  111246. /**
  111247. * Gets a string representation of the current mesh
  111248. * @param fullDetails defines a boolean indicating if full details must be included
  111249. * @returns a string representation of the current mesh
  111250. */
  111251. toString(fullDetails?: boolean): string;
  111252. /**
  111253. * @hidden
  111254. */
  111255. protected _getEffectiveParent(): Nullable<Node>;
  111256. /** @hidden */
  111257. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111258. /** @hidden */
  111259. _rebuild(): void;
  111260. /** @hidden */
  111261. _resyncLightSources(): void;
  111262. /** @hidden */
  111263. _resyncLightSource(light: Light): void;
  111264. /** @hidden */
  111265. _unBindEffect(): void;
  111266. /** @hidden */
  111267. _removeLightSource(light: Light, dispose: boolean): void;
  111268. private _markSubMeshesAsDirty;
  111269. /** @hidden */
  111270. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111271. /** @hidden */
  111272. _markSubMeshesAsAttributesDirty(): void;
  111273. /** @hidden */
  111274. _markSubMeshesAsMiscDirty(): void;
  111275. /**
  111276. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111277. */
  111278. get scaling(): Vector3;
  111279. set scaling(newScaling: Vector3);
  111280. /**
  111281. * Returns true if the mesh is blocked. Implemented by child classes
  111282. */
  111283. get isBlocked(): boolean;
  111284. /**
  111285. * Returns the mesh itself by default. Implemented by child classes
  111286. * @param camera defines the camera to use to pick the right LOD level
  111287. * @returns the currentAbstractMesh
  111288. */
  111289. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111290. /**
  111291. * Returns 0 by default. Implemented by child classes
  111292. * @returns an integer
  111293. */
  111294. getTotalVertices(): number;
  111295. /**
  111296. * Returns a positive integer : the total number of indices in this mesh geometry.
  111297. * @returns the numner of indices or zero if the mesh has no geometry.
  111298. */
  111299. getTotalIndices(): number;
  111300. /**
  111301. * Returns null by default. Implemented by child classes
  111302. * @returns null
  111303. */
  111304. getIndices(): Nullable<IndicesArray>;
  111305. /**
  111306. * Returns the array of the requested vertex data kind. Implemented by child classes
  111307. * @param kind defines the vertex data kind to use
  111308. * @returns null
  111309. */
  111310. getVerticesData(kind: string): Nullable<FloatArray>;
  111311. /**
  111312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111314. * Note that a new underlying VertexBuffer object is created each call.
  111315. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111316. * @param kind defines vertex data kind:
  111317. * * VertexBuffer.PositionKind
  111318. * * VertexBuffer.UVKind
  111319. * * VertexBuffer.UV2Kind
  111320. * * VertexBuffer.UV3Kind
  111321. * * VertexBuffer.UV4Kind
  111322. * * VertexBuffer.UV5Kind
  111323. * * VertexBuffer.UV6Kind
  111324. * * VertexBuffer.ColorKind
  111325. * * VertexBuffer.MatricesIndicesKind
  111326. * * VertexBuffer.MatricesIndicesExtraKind
  111327. * * VertexBuffer.MatricesWeightsKind
  111328. * * VertexBuffer.MatricesWeightsExtraKind
  111329. * @param data defines the data source
  111330. * @param updatable defines if the data must be flagged as updatable (or static)
  111331. * @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
  111332. * @returns the current mesh
  111333. */
  111334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111335. /**
  111336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111337. * If the mesh has no geometry, it is simply returned as it is.
  111338. * @param kind defines vertex data kind:
  111339. * * VertexBuffer.PositionKind
  111340. * * VertexBuffer.UVKind
  111341. * * VertexBuffer.UV2Kind
  111342. * * VertexBuffer.UV3Kind
  111343. * * VertexBuffer.UV4Kind
  111344. * * VertexBuffer.UV5Kind
  111345. * * VertexBuffer.UV6Kind
  111346. * * VertexBuffer.ColorKind
  111347. * * VertexBuffer.MatricesIndicesKind
  111348. * * VertexBuffer.MatricesIndicesExtraKind
  111349. * * VertexBuffer.MatricesWeightsKind
  111350. * * VertexBuffer.MatricesWeightsExtraKind
  111351. * @param data defines the data source
  111352. * @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
  111353. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111354. * @returns the current mesh
  111355. */
  111356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111357. /**
  111358. * Sets the mesh indices,
  111359. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111360. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111361. * @param totalVertices Defines the total number of vertices
  111362. * @returns the current mesh
  111363. */
  111364. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111365. /**
  111366. * Gets a boolean indicating if specific vertex data is present
  111367. * @param kind defines the vertex data kind to use
  111368. * @returns true is data kind is present
  111369. */
  111370. isVerticesDataPresent(kind: string): boolean;
  111371. /**
  111372. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111373. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111374. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111375. * @returns a BoundingInfo
  111376. */
  111377. getBoundingInfo(): BoundingInfo;
  111378. /**
  111379. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111380. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111381. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111382. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111383. * @returns the current mesh
  111384. */
  111385. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111386. /**
  111387. * Overwrite the current bounding info
  111388. * @param boundingInfo defines the new bounding info
  111389. * @returns the current mesh
  111390. */
  111391. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111392. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111393. get useBones(): boolean;
  111394. /** @hidden */
  111395. _preActivate(): void;
  111396. /** @hidden */
  111397. _preActivateForIntermediateRendering(renderId: number): void;
  111398. /** @hidden */
  111399. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111400. /** @hidden */
  111401. _postActivate(): void;
  111402. /** @hidden */
  111403. _freeze(): void;
  111404. /** @hidden */
  111405. _unFreeze(): void;
  111406. /**
  111407. * Gets the current world matrix
  111408. * @returns a Matrix
  111409. */
  111410. getWorldMatrix(): Matrix;
  111411. /** @hidden */
  111412. _getWorldMatrixDeterminant(): number;
  111413. /**
  111414. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111415. */
  111416. get isAnInstance(): boolean;
  111417. /**
  111418. * Gets a boolean indicating if this mesh has instances
  111419. */
  111420. get hasInstances(): boolean;
  111421. /**
  111422. * Gets a boolean indicating if this mesh has thin instances
  111423. */
  111424. get hasThinInstances(): boolean;
  111425. /**
  111426. * Perform relative position change from the point of view of behind the front of the mesh.
  111427. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111428. * Supports definition of mesh facing forward or backward
  111429. * @param amountRight defines the distance on the right axis
  111430. * @param amountUp defines the distance on the up axis
  111431. * @param amountForward defines the distance on the forward axis
  111432. * @returns the current mesh
  111433. */
  111434. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111435. /**
  111436. * Calculate relative position change from the point of view of behind the front of the mesh.
  111437. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111438. * Supports definition of mesh facing forward or backward
  111439. * @param amountRight defines the distance on the right axis
  111440. * @param amountUp defines the distance on the up axis
  111441. * @param amountForward defines the distance on the forward axis
  111442. * @returns the new displacement vector
  111443. */
  111444. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111445. /**
  111446. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111447. * Supports definition of mesh facing forward or backward
  111448. * @param flipBack defines the flip
  111449. * @param twirlClockwise defines the twirl
  111450. * @param tiltRight defines the tilt
  111451. * @returns the current mesh
  111452. */
  111453. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111454. /**
  111455. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111456. * Supports definition of mesh facing forward or backward.
  111457. * @param flipBack defines the flip
  111458. * @param twirlClockwise defines the twirl
  111459. * @param tiltRight defines the tilt
  111460. * @returns the new rotation vector
  111461. */
  111462. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111463. /**
  111464. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111465. * This means the mesh underlying bounding box and sphere are recomputed.
  111466. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111467. * @returns the current mesh
  111468. */
  111469. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111470. /** @hidden */
  111471. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111472. /** @hidden */
  111473. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111474. /** @hidden */
  111475. _updateBoundingInfo(): AbstractMesh;
  111476. /** @hidden */
  111477. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111478. /** @hidden */
  111479. protected _afterComputeWorldMatrix(): void;
  111480. /** @hidden */
  111481. get _effectiveMesh(): AbstractMesh;
  111482. /**
  111483. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111484. * A mesh is in the frustum if its bounding box intersects the frustum
  111485. * @param frustumPlanes defines the frustum to test
  111486. * @returns true if the mesh is in the frustum planes
  111487. */
  111488. isInFrustum(frustumPlanes: Plane[]): boolean;
  111489. /**
  111490. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111491. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111492. * @param frustumPlanes defines the frustum to test
  111493. * @returns true if the mesh is completely in the frustum planes
  111494. */
  111495. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111496. /**
  111497. * True if the mesh intersects another mesh or a SolidParticle object
  111498. * @param mesh defines a target mesh or SolidParticle to test
  111499. * @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)
  111500. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111501. * @returns true if there is an intersection
  111502. */
  111503. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111504. /**
  111505. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111506. * @param point defines the point to test
  111507. * @returns true if there is an intersection
  111508. */
  111509. intersectsPoint(point: Vector3): boolean;
  111510. /**
  111511. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111512. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111513. */
  111514. get checkCollisions(): boolean;
  111515. set checkCollisions(collisionEnabled: boolean);
  111516. /**
  111517. * Gets Collider object used to compute collisions (not physics)
  111518. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111519. */
  111520. get collider(): Nullable<Collider>;
  111521. /**
  111522. * Move the mesh using collision engine
  111523. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111524. * @param displacement defines the requested displacement vector
  111525. * @returns the current mesh
  111526. */
  111527. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111528. private _onCollisionPositionChange;
  111529. /** @hidden */
  111530. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111531. /** @hidden */
  111532. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111533. /** @hidden */
  111534. _checkCollision(collider: Collider): AbstractMesh;
  111535. /** @hidden */
  111536. _generatePointsArray(): boolean;
  111537. /**
  111538. * Checks if the passed Ray intersects with the mesh
  111539. * @param ray defines the ray to use
  111540. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111542. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111543. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111544. * @returns the picking info
  111545. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111546. */
  111547. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111548. /**
  111549. * Clones the current mesh
  111550. * @param name defines the mesh name
  111551. * @param newParent defines the new mesh parent
  111552. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111553. * @returns the new mesh
  111554. */
  111555. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111556. /**
  111557. * Disposes all the submeshes of the current meshnp
  111558. * @returns the current mesh
  111559. */
  111560. releaseSubMeshes(): AbstractMesh;
  111561. /**
  111562. * Releases resources associated with this abstract mesh.
  111563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111565. */
  111566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111567. /**
  111568. * Adds the passed mesh as a child to the current mesh
  111569. * @param mesh defines the child mesh
  111570. * @returns the current mesh
  111571. */
  111572. addChild(mesh: AbstractMesh): AbstractMesh;
  111573. /**
  111574. * Removes the passed mesh from the current mesh children list
  111575. * @param mesh defines the child mesh
  111576. * @returns the current mesh
  111577. */
  111578. removeChild(mesh: AbstractMesh): AbstractMesh;
  111579. /** @hidden */
  111580. private _initFacetData;
  111581. /**
  111582. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111583. * This method can be called within the render loop.
  111584. * 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
  111585. * @returns the current mesh
  111586. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111587. */
  111588. updateFacetData(): AbstractMesh;
  111589. /**
  111590. * Returns the facetLocalNormals array.
  111591. * The normals are expressed in the mesh local spac
  111592. * @returns an array of Vector3
  111593. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111594. */
  111595. getFacetLocalNormals(): Vector3[];
  111596. /**
  111597. * Returns the facetLocalPositions array.
  111598. * The facet positions are expressed in the mesh local space
  111599. * @returns an array of Vector3
  111600. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111601. */
  111602. getFacetLocalPositions(): Vector3[];
  111603. /**
  111604. * Returns the facetLocalPartioning array
  111605. * @returns an array of array of numbers
  111606. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111607. */
  111608. getFacetLocalPartitioning(): number[][];
  111609. /**
  111610. * Returns the i-th facet position in the world system.
  111611. * This method allocates a new Vector3 per call
  111612. * @param i defines the facet index
  111613. * @returns a new Vector3
  111614. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111615. */
  111616. getFacetPosition(i: number): Vector3;
  111617. /**
  111618. * Sets the reference Vector3 with the i-th facet position in the world system
  111619. * @param i defines the facet index
  111620. * @param ref defines the target vector
  111621. * @returns the current mesh
  111622. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111623. */
  111624. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111625. /**
  111626. * Returns the i-th facet normal in the world system.
  111627. * This method allocates a new Vector3 per call
  111628. * @param i defines the facet index
  111629. * @returns a new Vector3
  111630. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111631. */
  111632. getFacetNormal(i: number): Vector3;
  111633. /**
  111634. * Sets the reference Vector3 with the i-th facet normal in the world system
  111635. * @param i defines the facet index
  111636. * @param ref defines the target vector
  111637. * @returns the current mesh
  111638. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111639. */
  111640. getFacetNormalToRef(i: number, ref: Vector3): this;
  111641. /**
  111642. * 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)
  111643. * @param x defines x coordinate
  111644. * @param y defines y coordinate
  111645. * @param z defines z coordinate
  111646. * @returns the array of facet indexes
  111647. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111648. */
  111649. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111650. /**
  111651. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111652. * @param projected sets as the (x,y,z) world projection on the facet
  111653. * @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
  111654. * @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
  111655. * @param x defines x coordinate
  111656. * @param y defines y coordinate
  111657. * @param z defines z coordinate
  111658. * @returns the face index if found (or null instead)
  111659. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111660. */
  111661. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111662. /**
  111663. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111664. * @param projected sets as the (x,y,z) local projection on the facet
  111665. * @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
  111666. * @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
  111667. * @param x defines x coordinate
  111668. * @param y defines y coordinate
  111669. * @param z defines z coordinate
  111670. * @returns the face index if found (or null instead)
  111671. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111672. */
  111673. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111674. /**
  111675. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111676. * @returns the parameters
  111677. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111678. */
  111679. getFacetDataParameters(): any;
  111680. /**
  111681. * Disables the feature FacetData and frees the related memory
  111682. * @returns the current mesh
  111683. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111684. */
  111685. disableFacetData(): AbstractMesh;
  111686. /**
  111687. * Updates the AbstractMesh indices array
  111688. * @param indices defines the data source
  111689. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111690. * @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)
  111691. * @returns the current mesh
  111692. */
  111693. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111694. /**
  111695. * Creates new normals data for the mesh
  111696. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111697. * @returns the current mesh
  111698. */
  111699. createNormals(updatable: boolean): AbstractMesh;
  111700. /**
  111701. * Align the mesh with a normal
  111702. * @param normal defines the normal to use
  111703. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111704. * @returns the current mesh
  111705. */
  111706. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111707. /** @hidden */
  111708. _checkOcclusionQuery(): boolean;
  111709. /**
  111710. * Disables the mesh edge rendering mode
  111711. * @returns the currentAbstractMesh
  111712. */
  111713. disableEdgesRendering(): AbstractMesh;
  111714. /**
  111715. * Enables the edge rendering mode on the mesh.
  111716. * This mode makes the mesh edges visible
  111717. * @param epsilon defines the maximal distance between two angles to detect a face
  111718. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111719. * @returns the currentAbstractMesh
  111720. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111721. */
  111722. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111723. /**
  111724. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111725. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111726. */
  111727. getConnectedParticleSystems(): IParticleSystem[];
  111728. }
  111729. }
  111730. declare module BABYLON {
  111731. /**
  111732. * Interface used to define ActionEvent
  111733. */
  111734. export interface IActionEvent {
  111735. /** The mesh or sprite that triggered the action */
  111736. source: any;
  111737. /** The X mouse cursor position at the time of the event */
  111738. pointerX: number;
  111739. /** The Y mouse cursor position at the time of the event */
  111740. pointerY: number;
  111741. /** The mesh that is currently pointed at (can be null) */
  111742. meshUnderPointer: Nullable<AbstractMesh>;
  111743. /** the original (browser) event that triggered the ActionEvent */
  111744. sourceEvent?: any;
  111745. /** additional data for the event */
  111746. additionalData?: any;
  111747. }
  111748. /**
  111749. * ActionEvent is the event being sent when an action is triggered.
  111750. */
  111751. export class ActionEvent implements IActionEvent {
  111752. /** The mesh or sprite that triggered the action */
  111753. source: any;
  111754. /** The X mouse cursor position at the time of the event */
  111755. pointerX: number;
  111756. /** The Y mouse cursor position at the time of the event */
  111757. pointerY: number;
  111758. /** The mesh that is currently pointed at (can be null) */
  111759. meshUnderPointer: Nullable<AbstractMesh>;
  111760. /** the original (browser) event that triggered the ActionEvent */
  111761. sourceEvent?: any;
  111762. /** additional data for the event */
  111763. additionalData?: any;
  111764. /**
  111765. * Creates a new ActionEvent
  111766. * @param source The mesh or sprite that triggered the action
  111767. * @param pointerX The X mouse cursor position at the time of the event
  111768. * @param pointerY The Y mouse cursor position at the time of the event
  111769. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111770. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111771. * @param additionalData additional data for the event
  111772. */
  111773. constructor(
  111774. /** The mesh or sprite that triggered the action */
  111775. source: any,
  111776. /** The X mouse cursor position at the time of the event */
  111777. pointerX: number,
  111778. /** The Y mouse cursor position at the time of the event */
  111779. pointerY: number,
  111780. /** The mesh that is currently pointed at (can be null) */
  111781. meshUnderPointer: Nullable<AbstractMesh>,
  111782. /** the original (browser) event that triggered the ActionEvent */
  111783. sourceEvent?: any,
  111784. /** additional data for the event */
  111785. additionalData?: any);
  111786. /**
  111787. * Helper function to auto-create an ActionEvent from a source mesh.
  111788. * @param source The source mesh that triggered the event
  111789. * @param evt The original (browser) event
  111790. * @param additionalData additional data for the event
  111791. * @returns the new ActionEvent
  111792. */
  111793. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111794. /**
  111795. * Helper function to auto-create an ActionEvent from a source sprite
  111796. * @param source The source sprite that triggered the event
  111797. * @param scene Scene associated with the sprite
  111798. * @param evt The original (browser) event
  111799. * @param additionalData additional data for the event
  111800. * @returns the new ActionEvent
  111801. */
  111802. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111803. /**
  111804. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111805. * @param scene the scene where the event occurred
  111806. * @param evt The original (browser) event
  111807. * @returns the new ActionEvent
  111808. */
  111809. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111810. /**
  111811. * Helper function to auto-create an ActionEvent from a primitive
  111812. * @param prim defines the target primitive
  111813. * @param pointerPos defines the pointer position
  111814. * @param evt The original (browser) event
  111815. * @param additionalData additional data for the event
  111816. * @returns the new ActionEvent
  111817. */
  111818. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111819. }
  111820. }
  111821. declare module BABYLON {
  111822. /**
  111823. * Abstract class used to decouple action Manager from scene and meshes.
  111824. * Do not instantiate.
  111825. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111826. */
  111827. export abstract class AbstractActionManager implements IDisposable {
  111828. /** Gets the list of active triggers */
  111829. static Triggers: {
  111830. [key: string]: number;
  111831. };
  111832. /** Gets the cursor to use when hovering items */
  111833. hoverCursor: string;
  111834. /** Gets the list of actions */
  111835. actions: IAction[];
  111836. /**
  111837. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111838. */
  111839. isRecursive: boolean;
  111840. /**
  111841. * Releases all associated resources
  111842. */
  111843. abstract dispose(): void;
  111844. /**
  111845. * Does this action manager has pointer triggers
  111846. */
  111847. abstract get hasPointerTriggers(): boolean;
  111848. /**
  111849. * Does this action manager has pick triggers
  111850. */
  111851. abstract get hasPickTriggers(): boolean;
  111852. /**
  111853. * Process a specific trigger
  111854. * @param trigger defines the trigger to process
  111855. * @param evt defines the event details to be processed
  111856. */
  111857. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111858. /**
  111859. * Does this action manager handles actions of any of the given triggers
  111860. * @param triggers defines the triggers to be tested
  111861. * @return a boolean indicating whether one (or more) of the triggers is handled
  111862. */
  111863. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111864. /**
  111865. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111866. * speed.
  111867. * @param triggerA defines the trigger to be tested
  111868. * @param triggerB defines the trigger to be tested
  111869. * @return a boolean indicating whether one (or more) of the triggers is handled
  111870. */
  111871. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111872. /**
  111873. * Does this action manager handles actions of a given trigger
  111874. * @param trigger defines the trigger to be tested
  111875. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111876. * @return whether the trigger is handled
  111877. */
  111878. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111879. /**
  111880. * Serialize this manager to a JSON object
  111881. * @param name defines the property name to store this manager
  111882. * @returns a JSON representation of this manager
  111883. */
  111884. abstract serialize(name: string): any;
  111885. /**
  111886. * Registers an action to this action manager
  111887. * @param action defines the action to be registered
  111888. * @return the action amended (prepared) after registration
  111889. */
  111890. abstract registerAction(action: IAction): Nullable<IAction>;
  111891. /**
  111892. * Unregisters an action to this action manager
  111893. * @param action defines the action to be unregistered
  111894. * @return a boolean indicating whether the action has been unregistered
  111895. */
  111896. abstract unregisterAction(action: IAction): Boolean;
  111897. /**
  111898. * Does exist one action manager with at least one trigger
  111899. **/
  111900. static get HasTriggers(): boolean;
  111901. /**
  111902. * Does exist one action manager with at least one pick trigger
  111903. **/
  111904. static get HasPickTriggers(): boolean;
  111905. /**
  111906. * Does exist one action manager that handles actions of a given trigger
  111907. * @param trigger defines the trigger to be tested
  111908. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111909. **/
  111910. static HasSpecificTrigger(trigger: number): boolean;
  111911. }
  111912. }
  111913. declare module BABYLON {
  111914. /**
  111915. * Defines how a node can be built from a string name.
  111916. */
  111917. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111918. /**
  111919. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111920. */
  111921. export class Node implements IBehaviorAware<Node> {
  111922. /** @hidden */
  111923. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111924. private static _NodeConstructors;
  111925. /**
  111926. * Add a new node constructor
  111927. * @param type defines the type name of the node to construct
  111928. * @param constructorFunc defines the constructor function
  111929. */
  111930. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111931. /**
  111932. * Returns a node constructor based on type name
  111933. * @param type defines the type name
  111934. * @param name defines the new node name
  111935. * @param scene defines the hosting scene
  111936. * @param options defines optional options to transmit to constructors
  111937. * @returns the new constructor or null
  111938. */
  111939. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111940. /**
  111941. * Gets or sets the name of the node
  111942. */
  111943. name: string;
  111944. /**
  111945. * Gets or sets the id of the node
  111946. */
  111947. id: string;
  111948. /**
  111949. * Gets or sets the unique id of the node
  111950. */
  111951. uniqueId: number;
  111952. /**
  111953. * Gets or sets a string used to store user defined state for the node
  111954. */
  111955. state: string;
  111956. /**
  111957. * Gets or sets an object used to store user defined information for the node
  111958. */
  111959. metadata: any;
  111960. /**
  111961. * For internal use only. Please do not use.
  111962. */
  111963. reservedDataStore: any;
  111964. /**
  111965. * List of inspectable custom properties (used by the Inspector)
  111966. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111967. */
  111968. inspectableCustomProperties: IInspectable[];
  111969. private _doNotSerialize;
  111970. /**
  111971. * Gets or sets a boolean used to define if the node must be serialized
  111972. */
  111973. get doNotSerialize(): boolean;
  111974. set doNotSerialize(value: boolean);
  111975. /** @hidden */
  111976. _isDisposed: boolean;
  111977. /**
  111978. * Gets a list of Animations associated with the node
  111979. */
  111980. animations: Animation[];
  111981. protected _ranges: {
  111982. [name: string]: Nullable<AnimationRange>;
  111983. };
  111984. /**
  111985. * Callback raised when the node is ready to be used
  111986. */
  111987. onReady: Nullable<(node: Node) => void>;
  111988. private _isEnabled;
  111989. private _isParentEnabled;
  111990. private _isReady;
  111991. /** @hidden */
  111992. _currentRenderId: number;
  111993. private _parentUpdateId;
  111994. /** @hidden */
  111995. _childUpdateId: number;
  111996. /** @hidden */
  111997. _waitingParentId: Nullable<string>;
  111998. /** @hidden */
  111999. _scene: Scene;
  112000. /** @hidden */
  112001. _cache: any;
  112002. private _parentNode;
  112003. private _children;
  112004. /** @hidden */
  112005. _worldMatrix: Matrix;
  112006. /** @hidden */
  112007. _worldMatrixDeterminant: number;
  112008. /** @hidden */
  112009. _worldMatrixDeterminantIsDirty: boolean;
  112010. /** @hidden */
  112011. private _sceneRootNodesIndex;
  112012. /**
  112013. * Gets a boolean indicating if the node has been disposed
  112014. * @returns true if the node was disposed
  112015. */
  112016. isDisposed(): boolean;
  112017. /**
  112018. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112019. * @see https://doc.babylonjs.com/how_to/parenting
  112020. */
  112021. set parent(parent: Nullable<Node>);
  112022. get parent(): Nullable<Node>;
  112023. /** @hidden */
  112024. _addToSceneRootNodes(): void;
  112025. /** @hidden */
  112026. _removeFromSceneRootNodes(): void;
  112027. private _animationPropertiesOverride;
  112028. /**
  112029. * Gets or sets the animation properties override
  112030. */
  112031. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112032. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112033. /**
  112034. * Gets a string idenfifying the name of the class
  112035. * @returns "Node" string
  112036. */
  112037. getClassName(): string;
  112038. /** @hidden */
  112039. readonly _isNode: boolean;
  112040. /**
  112041. * An event triggered when the mesh is disposed
  112042. */
  112043. onDisposeObservable: Observable<Node>;
  112044. private _onDisposeObserver;
  112045. /**
  112046. * Sets a callback that will be raised when the node will be disposed
  112047. */
  112048. set onDispose(callback: () => void);
  112049. /**
  112050. * Creates a new Node
  112051. * @param name the name and id to be given to this node
  112052. * @param scene the scene this node will be added to
  112053. */
  112054. constructor(name: string, scene?: Nullable<Scene>);
  112055. /**
  112056. * Gets the scene of the node
  112057. * @returns a scene
  112058. */
  112059. getScene(): Scene;
  112060. /**
  112061. * Gets the engine of the node
  112062. * @returns a Engine
  112063. */
  112064. getEngine(): Engine;
  112065. private _behaviors;
  112066. /**
  112067. * Attach a behavior to the node
  112068. * @see https://doc.babylonjs.com/features/behaviour
  112069. * @param behavior defines the behavior to attach
  112070. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112071. * @returns the current Node
  112072. */
  112073. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112074. /**
  112075. * Remove an attached behavior
  112076. * @see https://doc.babylonjs.com/features/behaviour
  112077. * @param behavior defines the behavior to attach
  112078. * @returns the current Node
  112079. */
  112080. removeBehavior(behavior: Behavior<Node>): Node;
  112081. /**
  112082. * Gets the list of attached behaviors
  112083. * @see https://doc.babylonjs.com/features/behaviour
  112084. */
  112085. get behaviors(): Behavior<Node>[];
  112086. /**
  112087. * Gets an attached behavior by name
  112088. * @param name defines the name of the behavior to look for
  112089. * @see https://doc.babylonjs.com/features/behaviour
  112090. * @returns null if behavior was not found else the requested behavior
  112091. */
  112092. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112093. /**
  112094. * Returns the latest update of the World matrix
  112095. * @returns a Matrix
  112096. */
  112097. getWorldMatrix(): Matrix;
  112098. /** @hidden */
  112099. _getWorldMatrixDeterminant(): number;
  112100. /**
  112101. * Returns directly the latest state of the mesh World matrix.
  112102. * A Matrix is returned.
  112103. */
  112104. get worldMatrixFromCache(): Matrix;
  112105. /** @hidden */
  112106. _initCache(): void;
  112107. /** @hidden */
  112108. updateCache(force?: boolean): void;
  112109. /** @hidden */
  112110. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112111. /** @hidden */
  112112. _updateCache(ignoreParentClass?: boolean): void;
  112113. /** @hidden */
  112114. _isSynchronized(): boolean;
  112115. /** @hidden */
  112116. _markSyncedWithParent(): void;
  112117. /** @hidden */
  112118. isSynchronizedWithParent(): boolean;
  112119. /** @hidden */
  112120. isSynchronized(): boolean;
  112121. /**
  112122. * Is this node ready to be used/rendered
  112123. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112124. * @return true if the node is ready
  112125. */
  112126. isReady(completeCheck?: boolean): boolean;
  112127. /**
  112128. * Is this node enabled?
  112129. * 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
  112130. * @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
  112131. * @return whether this node (and its parent) is enabled
  112132. */
  112133. isEnabled(checkAncestors?: boolean): boolean;
  112134. /** @hidden */
  112135. protected _syncParentEnabledState(): void;
  112136. /**
  112137. * Set the enabled state of this node
  112138. * @param value defines the new enabled state
  112139. */
  112140. setEnabled(value: boolean): void;
  112141. /**
  112142. * Is this node a descendant of the given node?
  112143. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112144. * @param ancestor defines the parent node to inspect
  112145. * @returns a boolean indicating if this node is a descendant of the given node
  112146. */
  112147. isDescendantOf(ancestor: Node): boolean;
  112148. /** @hidden */
  112149. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  112150. /**
  112151. * Will return all nodes that have this node as ascendant
  112152. * @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
  112153. * @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
  112154. * @return all children nodes of all types
  112155. */
  112156. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  112157. /**
  112158. * Get all child-meshes of this node
  112159. * @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)
  112160. * @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
  112161. * @returns an array of AbstractMesh
  112162. */
  112163. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  112164. /**
  112165. * Get all direct children of this node
  112166. * @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
  112167. * @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)
  112168. * @returns an array of Node
  112169. */
  112170. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  112171. /** @hidden */
  112172. _setReady(state: boolean): void;
  112173. /**
  112174. * Get an animation by name
  112175. * @param name defines the name of the animation to look for
  112176. * @returns null if not found else the requested animation
  112177. */
  112178. getAnimationByName(name: string): Nullable<Animation>;
  112179. /**
  112180. * Creates an animation range for this node
  112181. * @param name defines the name of the range
  112182. * @param from defines the starting key
  112183. * @param to defines the end key
  112184. */
  112185. createAnimationRange(name: string, from: number, to: number): void;
  112186. /**
  112187. * Delete a specific animation range
  112188. * @param name defines the name of the range to delete
  112189. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112190. */
  112191. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112192. /**
  112193. * Get an animation range by name
  112194. * @param name defines the name of the animation range to look for
  112195. * @returns null if not found else the requested animation range
  112196. */
  112197. getAnimationRange(name: string): Nullable<AnimationRange>;
  112198. /**
  112199. * Gets the list of all animation ranges defined on this node
  112200. * @returns an array
  112201. */
  112202. getAnimationRanges(): Nullable<AnimationRange>[];
  112203. /**
  112204. * Will start the animation sequence
  112205. * @param name defines the range frames for animation sequence
  112206. * @param loop defines if the animation should loop (false by default)
  112207. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112208. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112209. * @returns the object created for this animation. If range does not exist, it will return null
  112210. */
  112211. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112212. /**
  112213. * Serialize animation ranges into a JSON compatible object
  112214. * @returns serialization object
  112215. */
  112216. serializeAnimationRanges(): any;
  112217. /**
  112218. * Computes the world matrix of the node
  112219. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112220. * @returns the world matrix
  112221. */
  112222. computeWorldMatrix(force?: boolean): Matrix;
  112223. /**
  112224. * Releases resources associated with this node.
  112225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112227. */
  112228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112229. /**
  112230. * Parse animation range data from a serialization object and store them into a given node
  112231. * @param node defines where to store the animation ranges
  112232. * @param parsedNode defines the serialization object to read data from
  112233. * @param scene defines the hosting scene
  112234. */
  112235. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112236. /**
  112237. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112238. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112239. * @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
  112240. * @returns the new bounding vectors
  112241. */
  112242. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112243. min: Vector3;
  112244. max: Vector3;
  112245. };
  112246. }
  112247. }
  112248. declare module BABYLON {
  112249. /**
  112250. * @hidden
  112251. */
  112252. export class _IAnimationState {
  112253. key: number;
  112254. repeatCount: number;
  112255. workValue?: any;
  112256. loopMode?: number;
  112257. offsetValue?: any;
  112258. highLimitValue?: any;
  112259. }
  112260. /**
  112261. * Class used to store any kind of animation
  112262. */
  112263. export class Animation {
  112264. /**Name of the animation */
  112265. name: string;
  112266. /**Property to animate */
  112267. targetProperty: string;
  112268. /**The frames per second of the animation */
  112269. framePerSecond: number;
  112270. /**The data type of the animation */
  112271. dataType: number;
  112272. /**The loop mode of the animation */
  112273. loopMode?: number | undefined;
  112274. /**Specifies if blending should be enabled */
  112275. enableBlending?: boolean | undefined;
  112276. /**
  112277. * Use matrix interpolation instead of using direct key value when animating matrices
  112278. */
  112279. static AllowMatricesInterpolation: boolean;
  112280. /**
  112281. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112282. */
  112283. static AllowMatrixDecomposeForInterpolation: boolean;
  112284. /** Define the Url to load snippets */
  112285. static SnippetUrl: string;
  112286. /** Snippet ID if the animation was created from the snippet server */
  112287. snippetId: string;
  112288. /**
  112289. * Stores the key frames of the animation
  112290. */
  112291. private _keys;
  112292. /**
  112293. * Stores the easing function of the animation
  112294. */
  112295. private _easingFunction;
  112296. /**
  112297. * @hidden Internal use only
  112298. */
  112299. _runtimeAnimations: RuntimeAnimation[];
  112300. /**
  112301. * The set of event that will be linked to this animation
  112302. */
  112303. private _events;
  112304. /**
  112305. * Stores an array of target property paths
  112306. */
  112307. targetPropertyPath: string[];
  112308. /**
  112309. * Stores the blending speed of the animation
  112310. */
  112311. blendingSpeed: number;
  112312. /**
  112313. * Stores the animation ranges for the animation
  112314. */
  112315. private _ranges;
  112316. /**
  112317. * @hidden Internal use
  112318. */
  112319. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112320. /**
  112321. * Sets up an animation
  112322. * @param property The property to animate
  112323. * @param animationType The animation type to apply
  112324. * @param framePerSecond The frames per second of the animation
  112325. * @param easingFunction The easing function used in the animation
  112326. * @returns The created animation
  112327. */
  112328. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112329. /**
  112330. * Create and start an animation on a node
  112331. * @param name defines the name of the global animation that will be run on all nodes
  112332. * @param node defines the root node where the animation will take place
  112333. * @param targetProperty defines property to animate
  112334. * @param framePerSecond defines the number of frame per second yo use
  112335. * @param totalFrame defines the number of frames in total
  112336. * @param from defines the initial value
  112337. * @param to defines the final value
  112338. * @param loopMode defines which loop mode you want to use (off by default)
  112339. * @param easingFunction defines the easing function to use (linear by default)
  112340. * @param onAnimationEnd defines the callback to call when animation end
  112341. * @returns the animatable created for this animation
  112342. */
  112343. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112344. /**
  112345. * Create and start an animation on a node and its descendants
  112346. * @param name defines the name of the global animation that will be run on all nodes
  112347. * @param node defines the root node where the animation will take place
  112348. * @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
  112349. * @param targetProperty defines property to animate
  112350. * @param framePerSecond defines the number of frame per second to use
  112351. * @param totalFrame defines the number of frames in total
  112352. * @param from defines the initial value
  112353. * @param to defines the final value
  112354. * @param loopMode defines which loop mode you want to use (off by default)
  112355. * @param easingFunction defines the easing function to use (linear by default)
  112356. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112357. * @returns the list of animatables created for all nodes
  112358. * @example https://www.babylonjs-playground.com/#MH0VLI
  112359. */
  112360. 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[]>;
  112361. /**
  112362. * Creates a new animation, merges it with the existing animations and starts it
  112363. * @param name Name of the animation
  112364. * @param node Node which contains the scene that begins the animations
  112365. * @param targetProperty Specifies which property to animate
  112366. * @param framePerSecond The frames per second of the animation
  112367. * @param totalFrame The total number of frames
  112368. * @param from The frame at the beginning of the animation
  112369. * @param to The frame at the end of the animation
  112370. * @param loopMode Specifies the loop mode of the animation
  112371. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112372. * @param onAnimationEnd Callback to run once the animation is complete
  112373. * @returns Nullable animation
  112374. */
  112375. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112376. /**
  112377. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112378. * @param sourceAnimation defines the Animation containing keyframes to convert
  112379. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112380. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112381. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112382. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112383. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112384. */
  112385. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112386. /**
  112387. * Transition property of an host to the target Value
  112388. * @param property The property to transition
  112389. * @param targetValue The target Value of the property
  112390. * @param host The object where the property to animate belongs
  112391. * @param scene Scene used to run the animation
  112392. * @param frameRate Framerate (in frame/s) to use
  112393. * @param transition The transition type we want to use
  112394. * @param duration The duration of the animation, in milliseconds
  112395. * @param onAnimationEnd Callback trigger at the end of the animation
  112396. * @returns Nullable animation
  112397. */
  112398. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112399. /**
  112400. * Return the array of runtime animations currently using this animation
  112401. */
  112402. get runtimeAnimations(): RuntimeAnimation[];
  112403. /**
  112404. * Specifies if any of the runtime animations are currently running
  112405. */
  112406. get hasRunningRuntimeAnimations(): boolean;
  112407. /**
  112408. * Initializes the animation
  112409. * @param name Name of the animation
  112410. * @param targetProperty Property to animate
  112411. * @param framePerSecond The frames per second of the animation
  112412. * @param dataType The data type of the animation
  112413. * @param loopMode The loop mode of the animation
  112414. * @param enableBlending Specifies if blending should be enabled
  112415. */
  112416. constructor(
  112417. /**Name of the animation */
  112418. name: string,
  112419. /**Property to animate */
  112420. targetProperty: string,
  112421. /**The frames per second of the animation */
  112422. framePerSecond: number,
  112423. /**The data type of the animation */
  112424. dataType: number,
  112425. /**The loop mode of the animation */
  112426. loopMode?: number | undefined,
  112427. /**Specifies if blending should be enabled */
  112428. enableBlending?: boolean | undefined);
  112429. /**
  112430. * Converts the animation to a string
  112431. * @param fullDetails support for multiple levels of logging within scene loading
  112432. * @returns String form of the animation
  112433. */
  112434. toString(fullDetails?: boolean): string;
  112435. /**
  112436. * Add an event to this animation
  112437. * @param event Event to add
  112438. */
  112439. addEvent(event: AnimationEvent): void;
  112440. /**
  112441. * Remove all events found at the given frame
  112442. * @param frame The frame to remove events from
  112443. */
  112444. removeEvents(frame: number): void;
  112445. /**
  112446. * Retrieves all the events from the animation
  112447. * @returns Events from the animation
  112448. */
  112449. getEvents(): AnimationEvent[];
  112450. /**
  112451. * Creates an animation range
  112452. * @param name Name of the animation range
  112453. * @param from Starting frame of the animation range
  112454. * @param to Ending frame of the animation
  112455. */
  112456. createRange(name: string, from: number, to: number): void;
  112457. /**
  112458. * Deletes an animation range by name
  112459. * @param name Name of the animation range to delete
  112460. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112461. */
  112462. deleteRange(name: string, deleteFrames?: boolean): void;
  112463. /**
  112464. * Gets the animation range by name, or null if not defined
  112465. * @param name Name of the animation range
  112466. * @returns Nullable animation range
  112467. */
  112468. getRange(name: string): Nullable<AnimationRange>;
  112469. /**
  112470. * Gets the key frames from the animation
  112471. * @returns The key frames of the animation
  112472. */
  112473. getKeys(): Array<IAnimationKey>;
  112474. /**
  112475. * Gets the highest frame rate of the animation
  112476. * @returns Highest frame rate of the animation
  112477. */
  112478. getHighestFrame(): number;
  112479. /**
  112480. * Gets the easing function of the animation
  112481. * @returns Easing function of the animation
  112482. */
  112483. getEasingFunction(): IEasingFunction;
  112484. /**
  112485. * Sets the easing function of the animation
  112486. * @param easingFunction A custom mathematical formula for animation
  112487. */
  112488. setEasingFunction(easingFunction: EasingFunction): void;
  112489. /**
  112490. * Interpolates a scalar linearly
  112491. * @param startValue Start value of the animation curve
  112492. * @param endValue End value of the animation curve
  112493. * @param gradient Scalar amount to interpolate
  112494. * @returns Interpolated scalar value
  112495. */
  112496. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112497. /**
  112498. * Interpolates a scalar cubically
  112499. * @param startValue Start value of the animation curve
  112500. * @param outTangent End tangent of the animation
  112501. * @param endValue End value of the animation curve
  112502. * @param inTangent Start tangent of the animation curve
  112503. * @param gradient Scalar amount to interpolate
  112504. * @returns Interpolated scalar value
  112505. */
  112506. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112507. /**
  112508. * Interpolates a quaternion using a spherical linear interpolation
  112509. * @param startValue Start value of the animation curve
  112510. * @param endValue End value of the animation curve
  112511. * @param gradient Scalar amount to interpolate
  112512. * @returns Interpolated quaternion value
  112513. */
  112514. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112515. /**
  112516. * Interpolates a quaternion cubically
  112517. * @param startValue Start value of the animation curve
  112518. * @param outTangent End tangent of the animation curve
  112519. * @param endValue End value of the animation curve
  112520. * @param inTangent Start tangent of the animation curve
  112521. * @param gradient Scalar amount to interpolate
  112522. * @returns Interpolated quaternion value
  112523. */
  112524. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112525. /**
  112526. * Interpolates a Vector3 linearl
  112527. * @param startValue Start value of the animation curve
  112528. * @param endValue End value of the animation curve
  112529. * @param gradient Scalar amount to interpolate
  112530. * @returns Interpolated scalar value
  112531. */
  112532. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112533. /**
  112534. * Interpolates a Vector3 cubically
  112535. * @param startValue Start value of the animation curve
  112536. * @param outTangent End tangent of the animation
  112537. * @param endValue End value of the animation curve
  112538. * @param inTangent Start tangent of the animation curve
  112539. * @param gradient Scalar amount to interpolate
  112540. * @returns InterpolatedVector3 value
  112541. */
  112542. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112543. /**
  112544. * Interpolates a Vector2 linearly
  112545. * @param startValue Start value of the animation curve
  112546. * @param endValue End value of the animation curve
  112547. * @param gradient Scalar amount to interpolate
  112548. * @returns Interpolated Vector2 value
  112549. */
  112550. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112551. /**
  112552. * Interpolates a Vector2 cubically
  112553. * @param startValue Start value of the animation curve
  112554. * @param outTangent End tangent of the animation
  112555. * @param endValue End value of the animation curve
  112556. * @param inTangent Start tangent of the animation curve
  112557. * @param gradient Scalar amount to interpolate
  112558. * @returns Interpolated Vector2 value
  112559. */
  112560. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112561. /**
  112562. * Interpolates a size linearly
  112563. * @param startValue Start value of the animation curve
  112564. * @param endValue End value of the animation curve
  112565. * @param gradient Scalar amount to interpolate
  112566. * @returns Interpolated Size value
  112567. */
  112568. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112569. /**
  112570. * Interpolates a Color3 linearly
  112571. * @param startValue Start value of the animation curve
  112572. * @param endValue End value of the animation curve
  112573. * @param gradient Scalar amount to interpolate
  112574. * @returns Interpolated Color3 value
  112575. */
  112576. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112577. /**
  112578. * Interpolates a Color4 linearly
  112579. * @param startValue Start value of the animation curve
  112580. * @param endValue End value of the animation curve
  112581. * @param gradient Scalar amount to interpolate
  112582. * @returns Interpolated Color3 value
  112583. */
  112584. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112585. /**
  112586. * @hidden Internal use only
  112587. */
  112588. _getKeyValue(value: any): any;
  112589. /**
  112590. * @hidden Internal use only
  112591. */
  112592. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112593. /**
  112594. * Defines the function to use to interpolate matrices
  112595. * @param startValue defines the start matrix
  112596. * @param endValue defines the end matrix
  112597. * @param gradient defines the gradient between both matrices
  112598. * @param result defines an optional target matrix where to store the interpolation
  112599. * @returns the interpolated matrix
  112600. */
  112601. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112602. /**
  112603. * Makes a copy of the animation
  112604. * @returns Cloned animation
  112605. */
  112606. clone(): Animation;
  112607. /**
  112608. * Sets the key frames of the animation
  112609. * @param values The animation key frames to set
  112610. */
  112611. setKeys(values: Array<IAnimationKey>): void;
  112612. /**
  112613. * Serializes the animation to an object
  112614. * @returns Serialized object
  112615. */
  112616. serialize(): any;
  112617. /**
  112618. * Float animation type
  112619. */
  112620. static readonly ANIMATIONTYPE_FLOAT: number;
  112621. /**
  112622. * Vector3 animation type
  112623. */
  112624. static readonly ANIMATIONTYPE_VECTOR3: number;
  112625. /**
  112626. * Quaternion animation type
  112627. */
  112628. static readonly ANIMATIONTYPE_QUATERNION: number;
  112629. /**
  112630. * Matrix animation type
  112631. */
  112632. static readonly ANIMATIONTYPE_MATRIX: number;
  112633. /**
  112634. * Color3 animation type
  112635. */
  112636. static readonly ANIMATIONTYPE_COLOR3: number;
  112637. /**
  112638. * Color3 animation type
  112639. */
  112640. static readonly ANIMATIONTYPE_COLOR4: number;
  112641. /**
  112642. * Vector2 animation type
  112643. */
  112644. static readonly ANIMATIONTYPE_VECTOR2: number;
  112645. /**
  112646. * Size animation type
  112647. */
  112648. static readonly ANIMATIONTYPE_SIZE: number;
  112649. /**
  112650. * Relative Loop Mode
  112651. */
  112652. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112653. /**
  112654. * Cycle Loop Mode
  112655. */
  112656. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112657. /**
  112658. * Constant Loop Mode
  112659. */
  112660. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112661. /** @hidden */
  112662. static _UniversalLerp(left: any, right: any, amount: number): any;
  112663. /**
  112664. * Parses an animation object and creates an animation
  112665. * @param parsedAnimation Parsed animation object
  112666. * @returns Animation object
  112667. */
  112668. static Parse(parsedAnimation: any): Animation;
  112669. /**
  112670. * Appends the serialized animations from the source animations
  112671. * @param source Source containing the animations
  112672. * @param destination Target to store the animations
  112673. */
  112674. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112675. /**
  112676. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112677. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112678. * @param url defines the url to load from
  112679. * @returns a promise that will resolve to the new animation or an array of animations
  112680. */
  112681. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112682. /**
  112683. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112684. * @param snippetId defines the snippet to load
  112685. * @returns a promise that will resolve to the new animation or a new array of animations
  112686. */
  112687. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112688. }
  112689. }
  112690. declare module BABYLON {
  112691. /**
  112692. * Interface containing an array of animations
  112693. */
  112694. export interface IAnimatable {
  112695. /**
  112696. * Array of animations
  112697. */
  112698. animations: Nullable<Array<Animation>>;
  112699. }
  112700. }
  112701. declare module BABYLON {
  112702. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112703. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112704. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112705. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112706. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112707. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112708. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112709. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112710. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112711. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112712. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112713. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112714. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112715. /**
  112716. * Decorator used to define property that can be serialized as reference to a camera
  112717. * @param sourceName defines the name of the property to decorate
  112718. */
  112719. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112720. /**
  112721. * Class used to help serialization objects
  112722. */
  112723. export class SerializationHelper {
  112724. /** @hidden */
  112725. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112726. /** @hidden */
  112727. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112728. /** @hidden */
  112729. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112730. /** @hidden */
  112731. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112732. /**
  112733. * Appends the serialized animations from the source animations
  112734. * @param source Source containing the animations
  112735. * @param destination Target to store the animations
  112736. */
  112737. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112738. /**
  112739. * Static function used to serialized a specific entity
  112740. * @param entity defines the entity to serialize
  112741. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112742. * @returns a JSON compatible object representing the serialization of the entity
  112743. */
  112744. static Serialize<T>(entity: T, serializationObject?: any): any;
  112745. /**
  112746. * Creates a new entity from a serialization data object
  112747. * @param creationFunction defines a function used to instanciated the new entity
  112748. * @param source defines the source serialization data
  112749. * @param scene defines the hosting scene
  112750. * @param rootUrl defines the root url for resources
  112751. * @returns a new entity
  112752. */
  112753. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112754. /**
  112755. * Clones an object
  112756. * @param creationFunction defines the function used to instanciate the new object
  112757. * @param source defines the source object
  112758. * @returns the cloned object
  112759. */
  112760. static Clone<T>(creationFunction: () => T, source: T): T;
  112761. /**
  112762. * Instanciates a new object based on a source one (some data will be shared between both object)
  112763. * @param creationFunction defines the function used to instanciate the new object
  112764. * @param source defines the source object
  112765. * @returns the new object
  112766. */
  112767. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112768. }
  112769. }
  112770. declare module BABYLON {
  112771. /**
  112772. * Base class of all the textures in babylon.
  112773. * It groups all the common properties the materials, post process, lights... might need
  112774. * in order to make a correct use of the texture.
  112775. */
  112776. export class BaseTexture implements IAnimatable {
  112777. /**
  112778. * Default anisotropic filtering level for the application.
  112779. * It is set to 4 as a good tradeoff between perf and quality.
  112780. */
  112781. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112782. /**
  112783. * Gets or sets the unique id of the texture
  112784. */
  112785. uniqueId: number;
  112786. /**
  112787. * Define the name of the texture.
  112788. */
  112789. name: string;
  112790. /**
  112791. * Gets or sets an object used to store user defined information.
  112792. */
  112793. metadata: any;
  112794. /**
  112795. * For internal use only. Please do not use.
  112796. */
  112797. reservedDataStore: any;
  112798. private _hasAlpha;
  112799. /**
  112800. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112801. */
  112802. set hasAlpha(value: boolean);
  112803. get hasAlpha(): boolean;
  112804. /**
  112805. * Defines if the alpha value should be determined via the rgb values.
  112806. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112807. */
  112808. getAlphaFromRGB: boolean;
  112809. /**
  112810. * Intensity or strength of the texture.
  112811. * It is commonly used by materials to fine tune the intensity of the texture
  112812. */
  112813. level: number;
  112814. /**
  112815. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112816. * This is part of the texture as textures usually maps to one uv set.
  112817. */
  112818. coordinatesIndex: number;
  112819. private _coordinatesMode;
  112820. /**
  112821. * How a texture is mapped.
  112822. *
  112823. * | Value | Type | Description |
  112824. * | ----- | ----------------------------------- | ----------- |
  112825. * | 0 | EXPLICIT_MODE | |
  112826. * | 1 | SPHERICAL_MODE | |
  112827. * | 2 | PLANAR_MODE | |
  112828. * | 3 | CUBIC_MODE | |
  112829. * | 4 | PROJECTION_MODE | |
  112830. * | 5 | SKYBOX_MODE | |
  112831. * | 6 | INVCUBIC_MODE | |
  112832. * | 7 | EQUIRECTANGULAR_MODE | |
  112833. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112834. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112835. */
  112836. set coordinatesMode(value: number);
  112837. get coordinatesMode(): number;
  112838. /**
  112839. * | Value | Type | Description |
  112840. * | ----- | ------------------ | ----------- |
  112841. * | 0 | CLAMP_ADDRESSMODE | |
  112842. * | 1 | WRAP_ADDRESSMODE | |
  112843. * | 2 | MIRROR_ADDRESSMODE | |
  112844. */
  112845. wrapU: number;
  112846. /**
  112847. * | Value | Type | Description |
  112848. * | ----- | ------------------ | ----------- |
  112849. * | 0 | CLAMP_ADDRESSMODE | |
  112850. * | 1 | WRAP_ADDRESSMODE | |
  112851. * | 2 | MIRROR_ADDRESSMODE | |
  112852. */
  112853. wrapV: number;
  112854. /**
  112855. * | Value | Type | Description |
  112856. * | ----- | ------------------ | ----------- |
  112857. * | 0 | CLAMP_ADDRESSMODE | |
  112858. * | 1 | WRAP_ADDRESSMODE | |
  112859. * | 2 | MIRROR_ADDRESSMODE | |
  112860. */
  112861. wrapR: number;
  112862. /**
  112863. * With compliant hardware and browser (supporting anisotropic filtering)
  112864. * this defines the level of anisotropic filtering in the texture.
  112865. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112866. */
  112867. anisotropicFilteringLevel: number;
  112868. /**
  112869. * Define if the texture is a cube texture or if false a 2d texture.
  112870. */
  112871. get isCube(): boolean;
  112872. set isCube(value: boolean);
  112873. /**
  112874. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112875. */
  112876. get is3D(): boolean;
  112877. set is3D(value: boolean);
  112878. /**
  112879. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112880. */
  112881. get is2DArray(): boolean;
  112882. set is2DArray(value: boolean);
  112883. /**
  112884. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112885. * HDR texture are usually stored in linear space.
  112886. * This only impacts the PBR and Background materials
  112887. */
  112888. gammaSpace: boolean;
  112889. /**
  112890. * Gets or sets whether or not the texture contains RGBD data.
  112891. */
  112892. get isRGBD(): boolean;
  112893. set isRGBD(value: boolean);
  112894. /**
  112895. * Is Z inverted in the texture (useful in a cube texture).
  112896. */
  112897. invertZ: boolean;
  112898. /**
  112899. * Are mip maps generated for this texture or not.
  112900. */
  112901. get noMipmap(): boolean;
  112902. /**
  112903. * @hidden
  112904. */
  112905. lodLevelInAlpha: boolean;
  112906. /**
  112907. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112908. */
  112909. get lodGenerationOffset(): number;
  112910. set lodGenerationOffset(value: number);
  112911. /**
  112912. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112913. */
  112914. get lodGenerationScale(): number;
  112915. set lodGenerationScale(value: number);
  112916. /**
  112917. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112918. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112919. * average roughness values.
  112920. */
  112921. get linearSpecularLOD(): boolean;
  112922. set linearSpecularLOD(value: boolean);
  112923. /**
  112924. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112925. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112926. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112927. */
  112928. get irradianceTexture(): Nullable<BaseTexture>;
  112929. set irradianceTexture(value: Nullable<BaseTexture>);
  112930. /**
  112931. * Define if the texture is a render target.
  112932. */
  112933. isRenderTarget: boolean;
  112934. /**
  112935. * Define the unique id of the texture in the scene.
  112936. */
  112937. get uid(): string;
  112938. /** @hidden */
  112939. _prefiltered: boolean;
  112940. /**
  112941. * Return a string representation of the texture.
  112942. * @returns the texture as a string
  112943. */
  112944. toString(): string;
  112945. /**
  112946. * Get the class name of the texture.
  112947. * @returns "BaseTexture"
  112948. */
  112949. getClassName(): string;
  112950. /**
  112951. * Define the list of animation attached to the texture.
  112952. */
  112953. animations: Animation[];
  112954. /**
  112955. * An event triggered when the texture is disposed.
  112956. */
  112957. onDisposeObservable: Observable<BaseTexture>;
  112958. private _onDisposeObserver;
  112959. /**
  112960. * Callback triggered when the texture has been disposed.
  112961. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112962. */
  112963. set onDispose(callback: () => void);
  112964. /**
  112965. * Define the current state of the loading sequence when in delayed load mode.
  112966. */
  112967. delayLoadState: number;
  112968. protected _scene: Nullable<Scene>;
  112969. protected _engine: Nullable<ThinEngine>;
  112970. /** @hidden */
  112971. _texture: Nullable<InternalTexture>;
  112972. private _uid;
  112973. /**
  112974. * Define if the texture is preventinga material to render or not.
  112975. * If not and the texture is not ready, the engine will use a default black texture instead.
  112976. */
  112977. get isBlocking(): boolean;
  112978. /**
  112979. * Instantiates a new BaseTexture.
  112980. * Base class of all the textures in babylon.
  112981. * It groups all the common properties the materials, post process, lights... might need
  112982. * in order to make a correct use of the texture.
  112983. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112984. */
  112985. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112986. /**
  112987. * Get the scene the texture belongs to.
  112988. * @returns the scene or null if undefined
  112989. */
  112990. getScene(): Nullable<Scene>;
  112991. /** @hidden */
  112992. protected _getEngine(): Nullable<ThinEngine>;
  112993. /**
  112994. * Get the texture transform matrix used to offset tile the texture for istance.
  112995. * @returns the transformation matrix
  112996. */
  112997. getTextureMatrix(): Matrix;
  112998. /**
  112999. * Get the texture reflection matrix used to rotate/transform the reflection.
  113000. * @returns the reflection matrix
  113001. */
  113002. getReflectionTextureMatrix(): Matrix;
  113003. /**
  113004. * Get the underlying lower level texture from Babylon.
  113005. * @returns the insternal texture
  113006. */
  113007. getInternalTexture(): Nullable<InternalTexture>;
  113008. /**
  113009. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113010. * @returns true if ready or not blocking
  113011. */
  113012. isReadyOrNotBlocking(): boolean;
  113013. /**
  113014. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113015. * @returns true if fully ready
  113016. */
  113017. isReady(): boolean;
  113018. private _cachedSize;
  113019. /**
  113020. * Get the size of the texture.
  113021. * @returns the texture size.
  113022. */
  113023. getSize(): ISize;
  113024. /**
  113025. * Get the base size of the texture.
  113026. * It can be different from the size if the texture has been resized for POT for instance
  113027. * @returns the base size
  113028. */
  113029. getBaseSize(): ISize;
  113030. /**
  113031. * Update the sampling mode of the texture.
  113032. * Default is Trilinear mode.
  113033. *
  113034. * | Value | Type | Description |
  113035. * | ----- | ------------------ | ----------- |
  113036. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113037. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113038. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113039. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113040. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113041. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113042. * | 7 | NEAREST_LINEAR | |
  113043. * | 8 | NEAREST_NEAREST | |
  113044. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113045. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113046. * | 11 | LINEAR_LINEAR | |
  113047. * | 12 | LINEAR_NEAREST | |
  113048. *
  113049. * > _mag_: magnification filter (close to the viewer)
  113050. * > _min_: minification filter (far from the viewer)
  113051. * > _mip_: filter used between mip map levels
  113052. *@param samplingMode Define the new sampling mode of the texture
  113053. */
  113054. updateSamplingMode(samplingMode: number): void;
  113055. /**
  113056. * Scales the texture if is `canRescale()`
  113057. * @param ratio the resize factor we want to use to rescale
  113058. */
  113059. scale(ratio: number): void;
  113060. /**
  113061. * Get if the texture can rescale.
  113062. */
  113063. get canRescale(): boolean;
  113064. /** @hidden */
  113065. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113066. /** @hidden */
  113067. _rebuild(): void;
  113068. /**
  113069. * Triggers the load sequence in delayed load mode.
  113070. */
  113071. delayLoad(): void;
  113072. /**
  113073. * Clones the texture.
  113074. * @returns the cloned texture
  113075. */
  113076. clone(): Nullable<BaseTexture>;
  113077. /**
  113078. * Get the texture underlying type (INT, FLOAT...)
  113079. */
  113080. get textureType(): number;
  113081. /**
  113082. * Get the texture underlying format (RGB, RGBA...)
  113083. */
  113084. get textureFormat(): number;
  113085. /**
  113086. * Indicates that textures need to be re-calculated for all materials
  113087. */
  113088. protected _markAllSubMeshesAsTexturesDirty(): void;
  113089. /**
  113090. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113091. * This will returns an RGBA array buffer containing either in values (0-255) or
  113092. * float values (0-1) depending of the underlying buffer type.
  113093. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113094. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113095. * @param buffer defines a user defined buffer to fill with data (can be null)
  113096. * @returns The Array buffer containing the pixels data.
  113097. */
  113098. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113099. /**
  113100. * Release and destroy the underlying lower level texture aka internalTexture.
  113101. */
  113102. releaseInternalTexture(): void;
  113103. /** @hidden */
  113104. get _lodTextureHigh(): Nullable<BaseTexture>;
  113105. /** @hidden */
  113106. get _lodTextureMid(): Nullable<BaseTexture>;
  113107. /** @hidden */
  113108. get _lodTextureLow(): Nullable<BaseTexture>;
  113109. /**
  113110. * Dispose the texture and release its associated resources.
  113111. */
  113112. dispose(): void;
  113113. /**
  113114. * Serialize the texture into a JSON representation that can be parsed later on.
  113115. * @returns the JSON representation of the texture
  113116. */
  113117. serialize(): any;
  113118. /**
  113119. * Helper function to be called back once a list of texture contains only ready textures.
  113120. * @param textures Define the list of textures to wait for
  113121. * @param callback Define the callback triggered once the entire list will be ready
  113122. */
  113123. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113124. private static _isScene;
  113125. }
  113126. }
  113127. declare module BABYLON {
  113128. /**
  113129. * Options to be used when creating an effect.
  113130. */
  113131. export interface IEffectCreationOptions {
  113132. /**
  113133. * Atrributes that will be used in the shader.
  113134. */
  113135. attributes: string[];
  113136. /**
  113137. * Uniform varible names that will be set in the shader.
  113138. */
  113139. uniformsNames: string[];
  113140. /**
  113141. * Uniform buffer variable names that will be set in the shader.
  113142. */
  113143. uniformBuffersNames: string[];
  113144. /**
  113145. * Sampler texture variable names that will be set in the shader.
  113146. */
  113147. samplers: string[];
  113148. /**
  113149. * Define statements that will be set in the shader.
  113150. */
  113151. defines: any;
  113152. /**
  113153. * Possible fallbacks for this effect to improve performance when needed.
  113154. */
  113155. fallbacks: Nullable<IEffectFallbacks>;
  113156. /**
  113157. * Callback that will be called when the shader is compiled.
  113158. */
  113159. onCompiled: Nullable<(effect: Effect) => void>;
  113160. /**
  113161. * Callback that will be called if an error occurs during shader compilation.
  113162. */
  113163. onError: Nullable<(effect: Effect, errors: string) => void>;
  113164. /**
  113165. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113166. */
  113167. indexParameters?: any;
  113168. /**
  113169. * Max number of lights that can be used in the shader.
  113170. */
  113171. maxSimultaneousLights?: number;
  113172. /**
  113173. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  113174. */
  113175. transformFeedbackVaryings?: Nullable<string[]>;
  113176. /**
  113177. * 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
  113178. */
  113179. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113180. /**
  113181. * Is this effect rendering to several color attachments ?
  113182. */
  113183. multiTarget?: boolean;
  113184. }
  113185. /**
  113186. * Effect containing vertex and fragment shader that can be executed on an object.
  113187. */
  113188. export class Effect implements IDisposable {
  113189. /**
  113190. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113191. */
  113192. static ShadersRepository: string;
  113193. /**
  113194. * Enable logging of the shader code when a compilation error occurs
  113195. */
  113196. static LogShaderCodeOnCompilationError: boolean;
  113197. /**
  113198. * Name of the effect.
  113199. */
  113200. name: any;
  113201. /**
  113202. * String container all the define statements that should be set on the shader.
  113203. */
  113204. defines: string;
  113205. /**
  113206. * Callback that will be called when the shader is compiled.
  113207. */
  113208. onCompiled: Nullable<(effect: Effect) => void>;
  113209. /**
  113210. * Callback that will be called if an error occurs during shader compilation.
  113211. */
  113212. onError: Nullable<(effect: Effect, errors: string) => void>;
  113213. /**
  113214. * Callback that will be called when effect is bound.
  113215. */
  113216. onBind: Nullable<(effect: Effect) => void>;
  113217. /**
  113218. * Unique ID of the effect.
  113219. */
  113220. uniqueId: number;
  113221. /**
  113222. * Observable that will be called when the shader is compiled.
  113223. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113224. */
  113225. onCompileObservable: Observable<Effect>;
  113226. /**
  113227. * Observable that will be called if an error occurs during shader compilation.
  113228. */
  113229. onErrorObservable: Observable<Effect>;
  113230. /** @hidden */
  113231. _onBindObservable: Nullable<Observable<Effect>>;
  113232. /**
  113233. * @hidden
  113234. * Specifies if the effect was previously ready
  113235. */
  113236. _wasPreviouslyReady: boolean;
  113237. /**
  113238. * Observable that will be called when effect is bound.
  113239. */
  113240. get onBindObservable(): Observable<Effect>;
  113241. /** @hidden */
  113242. _bonesComputationForcedToCPU: boolean;
  113243. /** @hidden */
  113244. _multiTarget: boolean;
  113245. private static _uniqueIdSeed;
  113246. private _engine;
  113247. private _uniformBuffersNames;
  113248. private _uniformBuffersNamesList;
  113249. private _uniformsNames;
  113250. private _samplerList;
  113251. private _samplers;
  113252. private _isReady;
  113253. private _compilationError;
  113254. private _allFallbacksProcessed;
  113255. private _attributesNames;
  113256. private _attributes;
  113257. private _attributeLocationByName;
  113258. private _uniforms;
  113259. /**
  113260. * Key for the effect.
  113261. * @hidden
  113262. */
  113263. _key: string;
  113264. private _indexParameters;
  113265. private _fallbacks;
  113266. private _vertexSourceCode;
  113267. private _fragmentSourceCode;
  113268. private _vertexSourceCodeOverride;
  113269. private _fragmentSourceCodeOverride;
  113270. private _transformFeedbackVaryings;
  113271. /**
  113272. * Compiled shader to webGL program.
  113273. * @hidden
  113274. */
  113275. _pipelineContext: Nullable<IPipelineContext>;
  113276. private _valueCache;
  113277. private static _baseCache;
  113278. /**
  113279. * Instantiates an effect.
  113280. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113281. * @param baseName Name of the effect.
  113282. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113283. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113284. * @param samplers List of sampler variables that will be passed to the shader.
  113285. * @param engine Engine to be used to render the effect
  113286. * @param defines Define statements to be added to the shader.
  113287. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113288. * @param onCompiled Callback that will be called when the shader is compiled.
  113289. * @param onError Callback that will be called if an error occurs during shader compilation.
  113290. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113291. */
  113292. 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);
  113293. private _useFinalCode;
  113294. /**
  113295. * Unique key for this effect
  113296. */
  113297. get key(): string;
  113298. /**
  113299. * If the effect has been compiled and prepared.
  113300. * @returns if the effect is compiled and prepared.
  113301. */
  113302. isReady(): boolean;
  113303. private _isReadyInternal;
  113304. /**
  113305. * The engine the effect was initialized with.
  113306. * @returns the engine.
  113307. */
  113308. getEngine(): Engine;
  113309. /**
  113310. * The pipeline context for this effect
  113311. * @returns the associated pipeline context
  113312. */
  113313. getPipelineContext(): Nullable<IPipelineContext>;
  113314. /**
  113315. * The set of names of attribute variables for the shader.
  113316. * @returns An array of attribute names.
  113317. */
  113318. getAttributesNames(): string[];
  113319. /**
  113320. * Returns the attribute at the given index.
  113321. * @param index The index of the attribute.
  113322. * @returns The location of the attribute.
  113323. */
  113324. getAttributeLocation(index: number): number;
  113325. /**
  113326. * Returns the attribute based on the name of the variable.
  113327. * @param name of the attribute to look up.
  113328. * @returns the attribute location.
  113329. */
  113330. getAttributeLocationByName(name: string): number;
  113331. /**
  113332. * The number of attributes.
  113333. * @returns the numnber of attributes.
  113334. */
  113335. getAttributesCount(): number;
  113336. /**
  113337. * Gets the index of a uniform variable.
  113338. * @param uniformName of the uniform to look up.
  113339. * @returns the index.
  113340. */
  113341. getUniformIndex(uniformName: string): number;
  113342. /**
  113343. * Returns the attribute based on the name of the variable.
  113344. * @param uniformName of the uniform to look up.
  113345. * @returns the location of the uniform.
  113346. */
  113347. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113348. /**
  113349. * Returns an array of sampler variable names
  113350. * @returns The array of sampler variable names.
  113351. */
  113352. getSamplers(): string[];
  113353. /**
  113354. * Returns an array of uniform variable names
  113355. * @returns The array of uniform variable names.
  113356. */
  113357. getUniformNames(): string[];
  113358. /**
  113359. * Returns an array of uniform buffer variable names
  113360. * @returns The array of uniform buffer variable names.
  113361. */
  113362. getUniformBuffersNames(): string[];
  113363. /**
  113364. * Returns the index parameters used to create the effect
  113365. * @returns The index parameters object
  113366. */
  113367. getIndexParameters(): any;
  113368. /**
  113369. * The error from the last compilation.
  113370. * @returns the error string.
  113371. */
  113372. getCompilationError(): string;
  113373. /**
  113374. * Gets a boolean indicating that all fallbacks were used during compilation
  113375. * @returns true if all fallbacks were used
  113376. */
  113377. allFallbacksProcessed(): boolean;
  113378. /**
  113379. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113380. * @param func The callback to be used.
  113381. */
  113382. executeWhenCompiled(func: (effect: Effect) => void): void;
  113383. private _checkIsReady;
  113384. private _loadShader;
  113385. /**
  113386. * Gets the vertex shader source code of this effect
  113387. */
  113388. get vertexSourceCode(): string;
  113389. /**
  113390. * Gets the fragment shader source code of this effect
  113391. */
  113392. get fragmentSourceCode(): string;
  113393. /**
  113394. * Recompiles the webGL program
  113395. * @param vertexSourceCode The source code for the vertex shader.
  113396. * @param fragmentSourceCode The source code for the fragment shader.
  113397. * @param onCompiled Callback called when completed.
  113398. * @param onError Callback called on error.
  113399. * @hidden
  113400. */
  113401. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113402. /**
  113403. * Prepares the effect
  113404. * @hidden
  113405. */
  113406. _prepareEffect(): void;
  113407. private _getShaderCodeAndErrorLine;
  113408. private _processCompilationErrors;
  113409. /**
  113410. * Checks if the effect is supported. (Must be called after compilation)
  113411. */
  113412. get isSupported(): boolean;
  113413. /**
  113414. * Binds a texture to the engine to be used as output of the shader.
  113415. * @param channel Name of the output variable.
  113416. * @param texture Texture to bind.
  113417. * @hidden
  113418. */
  113419. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113420. /**
  113421. * Sets a texture on the engine to be used in the shader.
  113422. * @param channel Name of the sampler variable.
  113423. * @param texture Texture to set.
  113424. */
  113425. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113426. /**
  113427. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113428. * @param channel Name of the sampler variable.
  113429. * @param texture Texture to set.
  113430. */
  113431. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113432. /**
  113433. * Sets an array of textures on the engine to be used in the shader.
  113434. * @param channel Name of the variable.
  113435. * @param textures Textures to set.
  113436. */
  113437. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113438. /**
  113439. * 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)
  113440. * @param channel Name of the sampler variable.
  113441. * @param postProcess Post process to get the input texture from.
  113442. */
  113443. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113444. /**
  113445. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113446. * 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)
  113447. * @param channel Name of the sampler variable.
  113448. * @param postProcess Post process to get the output texture from.
  113449. */
  113450. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113451. /** @hidden */
  113452. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113453. /** @hidden */
  113454. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113455. /** @hidden */
  113456. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113457. /** @hidden */
  113458. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113459. /**
  113460. * Binds a buffer to a uniform.
  113461. * @param buffer Buffer to bind.
  113462. * @param name Name of the uniform variable to bind to.
  113463. */
  113464. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113465. /**
  113466. * Binds block to a uniform.
  113467. * @param blockName Name of the block to bind.
  113468. * @param index Index to bind.
  113469. */
  113470. bindUniformBlock(blockName: string, index: number): void;
  113471. /**
  113472. * Sets an interger value on a uniform variable.
  113473. * @param uniformName Name of the variable.
  113474. * @param value Value to be set.
  113475. * @returns this effect.
  113476. */
  113477. setInt(uniformName: string, value: number): Effect;
  113478. /**
  113479. * Sets an int array on a uniform variable.
  113480. * @param uniformName Name of the variable.
  113481. * @param array array to be set.
  113482. * @returns this effect.
  113483. */
  113484. setIntArray(uniformName: string, array: Int32Array): Effect;
  113485. /**
  113486. * 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)
  113487. * @param uniformName Name of the variable.
  113488. * @param array array to be set.
  113489. * @returns this effect.
  113490. */
  113491. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113492. /**
  113493. * 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)
  113494. * @param uniformName Name of the variable.
  113495. * @param array array to be set.
  113496. * @returns this effect.
  113497. */
  113498. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113499. /**
  113500. * 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)
  113501. * @param uniformName Name of the variable.
  113502. * @param array array to be set.
  113503. * @returns this effect.
  113504. */
  113505. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113506. /**
  113507. * Sets an float array on a uniform variable.
  113508. * @param uniformName Name of the variable.
  113509. * @param array array to be set.
  113510. * @returns this effect.
  113511. */
  113512. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113513. /**
  113514. * 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)
  113515. * @param uniformName Name of the variable.
  113516. * @param array array to be set.
  113517. * @returns this effect.
  113518. */
  113519. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113520. /**
  113521. * 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)
  113522. * @param uniformName Name of the variable.
  113523. * @param array array to be set.
  113524. * @returns this effect.
  113525. */
  113526. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113527. /**
  113528. * 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)
  113529. * @param uniformName Name of the variable.
  113530. * @param array array to be set.
  113531. * @returns this effect.
  113532. */
  113533. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113534. /**
  113535. * Sets an array on a uniform variable.
  113536. * @param uniformName Name of the variable.
  113537. * @param array array to be set.
  113538. * @returns this effect.
  113539. */
  113540. setArray(uniformName: string, array: number[]): Effect;
  113541. /**
  113542. * 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)
  113543. * @param uniformName Name of the variable.
  113544. * @param array array to be set.
  113545. * @returns this effect.
  113546. */
  113547. setArray2(uniformName: string, array: number[]): Effect;
  113548. /**
  113549. * 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)
  113550. * @param uniformName Name of the variable.
  113551. * @param array array to be set.
  113552. * @returns this effect.
  113553. */
  113554. setArray3(uniformName: string, array: number[]): Effect;
  113555. /**
  113556. * 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)
  113557. * @param uniformName Name of the variable.
  113558. * @param array array to be set.
  113559. * @returns this effect.
  113560. */
  113561. setArray4(uniformName: string, array: number[]): Effect;
  113562. /**
  113563. * Sets matrices on a uniform variable.
  113564. * @param uniformName Name of the variable.
  113565. * @param matrices matrices to be set.
  113566. * @returns this effect.
  113567. */
  113568. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113569. /**
  113570. * Sets matrix on a uniform variable.
  113571. * @param uniformName Name of the variable.
  113572. * @param matrix matrix to be set.
  113573. * @returns this effect.
  113574. */
  113575. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113576. /**
  113577. * 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)
  113578. * @param uniformName Name of the variable.
  113579. * @param matrix matrix to be set.
  113580. * @returns this effect.
  113581. */
  113582. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113583. /**
  113584. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113585. * @param uniformName Name of the variable.
  113586. * @param matrix matrix to be set.
  113587. * @returns this effect.
  113588. */
  113589. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113590. /**
  113591. * Sets a float on a uniform variable.
  113592. * @param uniformName Name of the variable.
  113593. * @param value value to be set.
  113594. * @returns this effect.
  113595. */
  113596. setFloat(uniformName: string, value: number): Effect;
  113597. /**
  113598. * Sets a boolean on a uniform variable.
  113599. * @param uniformName Name of the variable.
  113600. * @param bool value to be set.
  113601. * @returns this effect.
  113602. */
  113603. setBool(uniformName: string, bool: boolean): Effect;
  113604. /**
  113605. * Sets a Vector2 on a uniform variable.
  113606. * @param uniformName Name of the variable.
  113607. * @param vector2 vector2 to be set.
  113608. * @returns this effect.
  113609. */
  113610. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113611. /**
  113612. * Sets a float2 on a uniform variable.
  113613. * @param uniformName Name of the variable.
  113614. * @param x First float in float2.
  113615. * @param y Second float in float2.
  113616. * @returns this effect.
  113617. */
  113618. setFloat2(uniformName: string, x: number, y: number): Effect;
  113619. /**
  113620. * Sets a Vector3 on a uniform variable.
  113621. * @param uniformName Name of the variable.
  113622. * @param vector3 Value to be set.
  113623. * @returns this effect.
  113624. */
  113625. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113626. /**
  113627. * Sets a float3 on a uniform variable.
  113628. * @param uniformName Name of the variable.
  113629. * @param x First float in float3.
  113630. * @param y Second float in float3.
  113631. * @param z Third float in float3.
  113632. * @returns this effect.
  113633. */
  113634. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113635. /**
  113636. * Sets a Vector4 on a uniform variable.
  113637. * @param uniformName Name of the variable.
  113638. * @param vector4 Value to be set.
  113639. * @returns this effect.
  113640. */
  113641. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113642. /**
  113643. * Sets a float4 on a uniform variable.
  113644. * @param uniformName Name of the variable.
  113645. * @param x First float in float4.
  113646. * @param y Second float in float4.
  113647. * @param z Third float in float4.
  113648. * @param w Fourth float in float4.
  113649. * @returns this effect.
  113650. */
  113651. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113652. /**
  113653. * Sets a Color3 on a uniform variable.
  113654. * @param uniformName Name of the variable.
  113655. * @param color3 Value to be set.
  113656. * @returns this effect.
  113657. */
  113658. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113659. /**
  113660. * Sets a Color4 on a uniform variable.
  113661. * @param uniformName Name of the variable.
  113662. * @param color3 Value to be set.
  113663. * @param alpha Alpha value to be set.
  113664. * @returns this effect.
  113665. */
  113666. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113667. /**
  113668. * Sets a Color4 on a uniform variable
  113669. * @param uniformName defines the name of the variable
  113670. * @param color4 defines the value to be set
  113671. * @returns this effect.
  113672. */
  113673. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113674. /** Release all associated resources */
  113675. dispose(): void;
  113676. /**
  113677. * This function will add a new shader to the shader store
  113678. * @param name the name of the shader
  113679. * @param pixelShader optional pixel shader content
  113680. * @param vertexShader optional vertex shader content
  113681. */
  113682. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113683. /**
  113684. * Store of each shader (The can be looked up using effect.key)
  113685. */
  113686. static ShadersStore: {
  113687. [key: string]: string;
  113688. };
  113689. /**
  113690. * Store of each included file for a shader (The can be looked up using effect.key)
  113691. */
  113692. static IncludesShadersStore: {
  113693. [key: string]: string;
  113694. };
  113695. /**
  113696. * Resets the cache of effects.
  113697. */
  113698. static ResetCache(): void;
  113699. }
  113700. }
  113701. declare module BABYLON {
  113702. /**
  113703. * Interface used to describe the capabilities of the engine relatively to the current browser
  113704. */
  113705. export interface EngineCapabilities {
  113706. /** Maximum textures units per fragment shader */
  113707. maxTexturesImageUnits: number;
  113708. /** Maximum texture units per vertex shader */
  113709. maxVertexTextureImageUnits: number;
  113710. /** Maximum textures units in the entire pipeline */
  113711. maxCombinedTexturesImageUnits: number;
  113712. /** Maximum texture size */
  113713. maxTextureSize: number;
  113714. /** Maximum texture samples */
  113715. maxSamples?: number;
  113716. /** Maximum cube texture size */
  113717. maxCubemapTextureSize: number;
  113718. /** Maximum render texture size */
  113719. maxRenderTextureSize: number;
  113720. /** Maximum number of vertex attributes */
  113721. maxVertexAttribs: number;
  113722. /** Maximum number of varyings */
  113723. maxVaryingVectors: number;
  113724. /** Maximum number of uniforms per vertex shader */
  113725. maxVertexUniformVectors: number;
  113726. /** Maximum number of uniforms per fragment shader */
  113727. maxFragmentUniformVectors: number;
  113728. /** Defines if standard derivates (dx/dy) are supported */
  113729. standardDerivatives: boolean;
  113730. /** Defines if s3tc texture compression is supported */
  113731. s3tc?: WEBGL_compressed_texture_s3tc;
  113732. /** Defines if pvrtc texture compression is supported */
  113733. pvrtc: any;
  113734. /** Defines if etc1 texture compression is supported */
  113735. etc1: any;
  113736. /** Defines if etc2 texture compression is supported */
  113737. etc2: any;
  113738. /** Defines if astc texture compression is supported */
  113739. astc: any;
  113740. /** Defines if float textures are supported */
  113741. textureFloat: boolean;
  113742. /** Defines if vertex array objects are supported */
  113743. vertexArrayObject: boolean;
  113744. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113745. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113746. /** Gets the maximum level of anisotropy supported */
  113747. maxAnisotropy: number;
  113748. /** Defines if instancing is supported */
  113749. instancedArrays: boolean;
  113750. /** Defines if 32 bits indices are supported */
  113751. uintIndices: boolean;
  113752. /** Defines if high precision shaders are supported */
  113753. highPrecisionShaderSupported: boolean;
  113754. /** Defines if depth reading in the fragment shader is supported */
  113755. fragmentDepthSupported: boolean;
  113756. /** Defines if float texture linear filtering is supported*/
  113757. textureFloatLinearFiltering: boolean;
  113758. /** Defines if rendering to float textures is supported */
  113759. textureFloatRender: boolean;
  113760. /** Defines if half float textures are supported*/
  113761. textureHalfFloat: boolean;
  113762. /** Defines if half float texture linear filtering is supported*/
  113763. textureHalfFloatLinearFiltering: boolean;
  113764. /** Defines if rendering to half float textures is supported */
  113765. textureHalfFloatRender: boolean;
  113766. /** Defines if textureLOD shader command is supported */
  113767. textureLOD: boolean;
  113768. /** Defines if draw buffers extension is supported */
  113769. drawBuffersExtension: boolean;
  113770. /** Defines if depth textures are supported */
  113771. depthTextureExtension: boolean;
  113772. /** Defines if float color buffer are supported */
  113773. colorBufferFloat: boolean;
  113774. /** Gets disjoint timer query extension (null if not supported) */
  113775. timerQuery?: EXT_disjoint_timer_query;
  113776. /** Defines if timestamp can be used with timer query */
  113777. canUseTimestampForTimerQuery: boolean;
  113778. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113779. multiview?: any;
  113780. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113781. oculusMultiview?: any;
  113782. /** Function used to let the system compiles shaders in background */
  113783. parallelShaderCompile?: {
  113784. COMPLETION_STATUS_KHR: number;
  113785. };
  113786. /** Max number of texture samples for MSAA */
  113787. maxMSAASamples: number;
  113788. /** Defines if the blend min max extension is supported */
  113789. blendMinMax: boolean;
  113790. }
  113791. }
  113792. declare module BABYLON {
  113793. /**
  113794. * @hidden
  113795. **/
  113796. export class DepthCullingState {
  113797. private _isDepthTestDirty;
  113798. private _isDepthMaskDirty;
  113799. private _isDepthFuncDirty;
  113800. private _isCullFaceDirty;
  113801. private _isCullDirty;
  113802. private _isZOffsetDirty;
  113803. private _isFrontFaceDirty;
  113804. private _depthTest;
  113805. private _depthMask;
  113806. private _depthFunc;
  113807. private _cull;
  113808. private _cullFace;
  113809. private _zOffset;
  113810. private _frontFace;
  113811. /**
  113812. * Initializes the state.
  113813. */
  113814. constructor();
  113815. get isDirty(): boolean;
  113816. get zOffset(): number;
  113817. set zOffset(value: number);
  113818. get cullFace(): Nullable<number>;
  113819. set cullFace(value: Nullable<number>);
  113820. get cull(): Nullable<boolean>;
  113821. set cull(value: Nullable<boolean>);
  113822. get depthFunc(): Nullable<number>;
  113823. set depthFunc(value: Nullable<number>);
  113824. get depthMask(): boolean;
  113825. set depthMask(value: boolean);
  113826. get depthTest(): boolean;
  113827. set depthTest(value: boolean);
  113828. get frontFace(): Nullable<number>;
  113829. set frontFace(value: Nullable<number>);
  113830. reset(): void;
  113831. apply(gl: WebGLRenderingContext): void;
  113832. }
  113833. }
  113834. declare module BABYLON {
  113835. /**
  113836. * @hidden
  113837. **/
  113838. export class StencilState {
  113839. /** 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 */
  113840. static readonly ALWAYS: number;
  113841. /** Passed to stencilOperation to specify that stencil value must be kept */
  113842. static readonly KEEP: number;
  113843. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113844. static readonly REPLACE: number;
  113845. private _isStencilTestDirty;
  113846. private _isStencilMaskDirty;
  113847. private _isStencilFuncDirty;
  113848. private _isStencilOpDirty;
  113849. private _stencilTest;
  113850. private _stencilMask;
  113851. private _stencilFunc;
  113852. private _stencilFuncRef;
  113853. private _stencilFuncMask;
  113854. private _stencilOpStencilFail;
  113855. private _stencilOpDepthFail;
  113856. private _stencilOpStencilDepthPass;
  113857. get isDirty(): boolean;
  113858. get stencilFunc(): number;
  113859. set stencilFunc(value: number);
  113860. get stencilFuncRef(): number;
  113861. set stencilFuncRef(value: number);
  113862. get stencilFuncMask(): number;
  113863. set stencilFuncMask(value: number);
  113864. get stencilOpStencilFail(): number;
  113865. set stencilOpStencilFail(value: number);
  113866. get stencilOpDepthFail(): number;
  113867. set stencilOpDepthFail(value: number);
  113868. get stencilOpStencilDepthPass(): number;
  113869. set stencilOpStencilDepthPass(value: number);
  113870. get stencilMask(): number;
  113871. set stencilMask(value: number);
  113872. get stencilTest(): boolean;
  113873. set stencilTest(value: boolean);
  113874. constructor();
  113875. reset(): void;
  113876. apply(gl: WebGLRenderingContext): void;
  113877. }
  113878. }
  113879. declare module BABYLON {
  113880. /**
  113881. * @hidden
  113882. **/
  113883. export class AlphaState {
  113884. private _isAlphaBlendDirty;
  113885. private _isBlendFunctionParametersDirty;
  113886. private _isBlendEquationParametersDirty;
  113887. private _isBlendConstantsDirty;
  113888. private _alphaBlend;
  113889. private _blendFunctionParameters;
  113890. private _blendEquationParameters;
  113891. private _blendConstants;
  113892. /**
  113893. * Initializes the state.
  113894. */
  113895. constructor();
  113896. get isDirty(): boolean;
  113897. get alphaBlend(): boolean;
  113898. set alphaBlend(value: boolean);
  113899. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113900. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113901. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113902. reset(): void;
  113903. apply(gl: WebGLRenderingContext): void;
  113904. }
  113905. }
  113906. declare module BABYLON {
  113907. /** @hidden */
  113908. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113909. attributeProcessor(attribute: string): string;
  113910. varyingProcessor(varying: string, isFragment: boolean): string;
  113911. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113912. }
  113913. }
  113914. declare module BABYLON {
  113915. /**
  113916. * Interface for attribute information associated with buffer instanciation
  113917. */
  113918. export interface InstancingAttributeInfo {
  113919. /**
  113920. * Name of the GLSL attribute
  113921. * if attribute index is not specified, this is used to retrieve the index from the effect
  113922. */
  113923. attributeName: string;
  113924. /**
  113925. * Index/offset of the attribute in the vertex shader
  113926. * if not specified, this will be computes from the name.
  113927. */
  113928. index?: number;
  113929. /**
  113930. * size of the attribute, 1, 2, 3 or 4
  113931. */
  113932. attributeSize: number;
  113933. /**
  113934. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113935. */
  113936. offset: number;
  113937. /**
  113938. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113939. * default to 1
  113940. */
  113941. divisor?: number;
  113942. /**
  113943. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113944. * default is FLOAT
  113945. */
  113946. attributeType?: number;
  113947. /**
  113948. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113949. */
  113950. normalized?: boolean;
  113951. }
  113952. }
  113953. declare module BABYLON {
  113954. interface ThinEngine {
  113955. /**
  113956. * Update a video texture
  113957. * @param texture defines the texture to update
  113958. * @param video defines the video element to use
  113959. * @param invertY defines if data must be stored with Y axis inverted
  113960. */
  113961. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113962. }
  113963. }
  113964. declare module BABYLON {
  113965. interface ThinEngine {
  113966. /**
  113967. * Creates a dynamic texture
  113968. * @param width defines the width of the texture
  113969. * @param height defines the height of the texture
  113970. * @param generateMipMaps defines if the engine should generate the mip levels
  113971. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113972. * @returns the dynamic texture inside an InternalTexture
  113973. */
  113974. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113975. /**
  113976. * Update the content of a dynamic texture
  113977. * @param texture defines the texture to update
  113978. * @param canvas defines the canvas containing the source
  113979. * @param invertY defines if data must be stored with Y axis inverted
  113980. * @param premulAlpha defines if alpha is stored as premultiplied
  113981. * @param format defines the format of the data
  113982. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113983. */
  113984. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113985. }
  113986. }
  113987. declare module BABYLON {
  113988. /**
  113989. * Settings for finer control over video usage
  113990. */
  113991. export interface VideoTextureSettings {
  113992. /**
  113993. * Applies `autoplay` to video, if specified
  113994. */
  113995. autoPlay?: boolean;
  113996. /**
  113997. * Applies `loop` to video, if specified
  113998. */
  113999. loop?: boolean;
  114000. /**
  114001. * Automatically updates internal texture from video at every frame in the render loop
  114002. */
  114003. autoUpdateTexture: boolean;
  114004. /**
  114005. * Image src displayed during the video loading or until the user interacts with the video.
  114006. */
  114007. poster?: string;
  114008. }
  114009. /**
  114010. * If you want to display a video in your scene, this is the special texture for that.
  114011. * This special texture works similar to other textures, with the exception of a few parameters.
  114012. * @see https://doc.babylonjs.com/how_to/video_texture
  114013. */
  114014. export class VideoTexture extends Texture {
  114015. /**
  114016. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114017. */
  114018. readonly autoUpdateTexture: boolean;
  114019. /**
  114020. * The video instance used by the texture internally
  114021. */
  114022. readonly video: HTMLVideoElement;
  114023. private _onUserActionRequestedObservable;
  114024. /**
  114025. * Event triggerd when a dom action is required by the user to play the video.
  114026. * This happens due to recent changes in browser policies preventing video to auto start.
  114027. */
  114028. get onUserActionRequestedObservable(): Observable<Texture>;
  114029. private _generateMipMaps;
  114030. private _stillImageCaptured;
  114031. private _displayingPosterTexture;
  114032. private _settings;
  114033. private _createInternalTextureOnEvent;
  114034. private _frameId;
  114035. private _currentSrc;
  114036. /**
  114037. * Creates a video texture.
  114038. * If you want to display a video in your scene, this is the special texture for that.
  114039. * This special texture works similar to other textures, with the exception of a few parameters.
  114040. * @see https://doc.babylonjs.com/how_to/video_texture
  114041. * @param name optional name, will detect from video source, if not defined
  114042. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114043. * @param scene is obviously the current scene.
  114044. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114045. * @param invertY is false by default but can be used to invert video on Y axis
  114046. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114047. * @param settings allows finer control over video usage
  114048. */
  114049. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114050. private _getName;
  114051. private _getVideo;
  114052. private _createInternalTexture;
  114053. private reset;
  114054. /**
  114055. * @hidden Internal method to initiate `update`.
  114056. */
  114057. _rebuild(): void;
  114058. /**
  114059. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114060. */
  114061. update(): void;
  114062. /**
  114063. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114064. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114065. */
  114066. updateTexture(isVisible: boolean): void;
  114067. protected _updateInternalTexture: () => void;
  114068. /**
  114069. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114070. * @param url New url.
  114071. */
  114072. updateURL(url: string): void;
  114073. /**
  114074. * Clones the texture.
  114075. * @returns the cloned texture
  114076. */
  114077. clone(): VideoTexture;
  114078. /**
  114079. * Dispose the texture and release its associated resources.
  114080. */
  114081. dispose(): void;
  114082. /**
  114083. * Creates a video texture straight from a stream.
  114084. * @param scene Define the scene the texture should be created in
  114085. * @param stream Define the stream the texture should be created from
  114086. * @returns The created video texture as a promise
  114087. */
  114088. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114089. /**
  114090. * Creates a video texture straight from your WebCam video feed.
  114091. * @param scene Define the scene the texture should be created in
  114092. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114093. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114094. * @returns The created video texture as a promise
  114095. */
  114096. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114097. minWidth: number;
  114098. maxWidth: number;
  114099. minHeight: number;
  114100. maxHeight: number;
  114101. deviceId: string;
  114102. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114103. /**
  114104. * Creates a video texture straight from your WebCam video feed.
  114105. * @param scene Define the scene the texture should be created in
  114106. * @param onReady Define a callback to triggered once the texture will be ready
  114107. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114108. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114109. */
  114110. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114111. minWidth: number;
  114112. maxWidth: number;
  114113. minHeight: number;
  114114. maxHeight: number;
  114115. deviceId: string;
  114116. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114117. }
  114118. }
  114119. declare module BABYLON {
  114120. /**
  114121. * Defines the interface used by objects working like Scene
  114122. * @hidden
  114123. */
  114124. export interface ISceneLike {
  114125. _addPendingData(data: any): void;
  114126. _removePendingData(data: any): void;
  114127. offlineProvider: IOfflineProvider;
  114128. }
  114129. /** Interface defining initialization parameters for Engine class */
  114130. export interface EngineOptions extends WebGLContextAttributes {
  114131. /**
  114132. * Defines if the engine should no exceed a specified device ratio
  114133. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  114134. */
  114135. limitDeviceRatio?: number;
  114136. /**
  114137. * Defines if webvr should be enabled automatically
  114138. * @see https://doc.babylonjs.com/how_to/webvr_camera
  114139. */
  114140. autoEnableWebVR?: boolean;
  114141. /**
  114142. * Defines if webgl2 should be turned off even if supported
  114143. * @see https://doc.babylonjs.com/features/webgl2
  114144. */
  114145. disableWebGL2Support?: boolean;
  114146. /**
  114147. * Defines if webaudio should be initialized as well
  114148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114149. */
  114150. audioEngine?: boolean;
  114151. /**
  114152. * Defines if animations should run using a deterministic lock step
  114153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114154. */
  114155. deterministicLockstep?: boolean;
  114156. /** Defines the maximum steps to use with deterministic lock step mode */
  114157. lockstepMaxSteps?: number;
  114158. /** Defines the seconds between each deterministic lock step */
  114159. timeStep?: number;
  114160. /**
  114161. * Defines that engine should ignore context lost events
  114162. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  114163. */
  114164. doNotHandleContextLost?: boolean;
  114165. /**
  114166. * Defines that engine should ignore modifying touch action attribute and style
  114167. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  114168. */
  114169. doNotHandleTouchAction?: boolean;
  114170. /**
  114171. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  114172. */
  114173. useHighPrecisionFloats?: boolean;
  114174. /**
  114175. * Make the canvas XR Compatible for XR sessions
  114176. */
  114177. xrCompatible?: boolean;
  114178. /**
  114179. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114180. */
  114181. useHighPrecisionMatrix?: boolean;
  114182. }
  114183. /**
  114184. * The base engine class (root of all engines)
  114185. */
  114186. export class ThinEngine {
  114187. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114188. static ExceptionList: ({
  114189. key: string;
  114190. capture: string;
  114191. captureConstraint: number;
  114192. targets: string[];
  114193. } | {
  114194. key: string;
  114195. capture: null;
  114196. captureConstraint: null;
  114197. targets: string[];
  114198. })[];
  114199. /** @hidden */
  114200. static _TextureLoaders: IInternalTextureLoader[];
  114201. /**
  114202. * Returns the current npm package of the sdk
  114203. */
  114204. static get NpmPackage(): string;
  114205. /**
  114206. * Returns the current version of the framework
  114207. */
  114208. static get Version(): string;
  114209. /**
  114210. * Returns a string describing the current engine
  114211. */
  114212. get description(): string;
  114213. /**
  114214. * Gets or sets the epsilon value used by collision engine
  114215. */
  114216. static CollisionsEpsilon: number;
  114217. /**
  114218. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114219. */
  114220. static get ShadersRepository(): string;
  114221. static set ShadersRepository(value: string);
  114222. /** @hidden */
  114223. _shaderProcessor: IShaderProcessor;
  114224. /**
  114225. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114226. */
  114227. forcePOTTextures: boolean;
  114228. /**
  114229. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114230. */
  114231. isFullscreen: boolean;
  114232. /**
  114233. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114234. */
  114235. cullBackFaces: boolean;
  114236. /**
  114237. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114238. */
  114239. renderEvenInBackground: boolean;
  114240. /**
  114241. * Gets or sets a boolean indicating that cache can be kept between frames
  114242. */
  114243. preventCacheWipeBetweenFrames: boolean;
  114244. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114245. validateShaderPrograms: boolean;
  114246. /**
  114247. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114248. * This can provide greater z depth for distant objects.
  114249. */
  114250. useReverseDepthBuffer: boolean;
  114251. /**
  114252. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114253. */
  114254. disableUniformBuffers: boolean;
  114255. /** @hidden */
  114256. _uniformBuffers: UniformBuffer[];
  114257. /**
  114258. * Gets a boolean indicating that the engine supports uniform buffers
  114259. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114260. */
  114261. get supportsUniformBuffers(): boolean;
  114262. /** @hidden */
  114263. _gl: WebGLRenderingContext;
  114264. /** @hidden */
  114265. _webGLVersion: number;
  114266. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114267. protected _windowIsBackground: boolean;
  114268. protected _creationOptions: EngineOptions;
  114269. protected _highPrecisionShadersAllowed: boolean;
  114270. /** @hidden */
  114271. get _shouldUseHighPrecisionShader(): boolean;
  114272. /**
  114273. * Gets a boolean indicating that only power of 2 textures are supported
  114274. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114275. */
  114276. get needPOTTextures(): boolean;
  114277. /** @hidden */
  114278. _badOS: boolean;
  114279. /** @hidden */
  114280. _badDesktopOS: boolean;
  114281. private _hardwareScalingLevel;
  114282. /** @hidden */
  114283. _caps: EngineCapabilities;
  114284. private _isStencilEnable;
  114285. private _glVersion;
  114286. private _glRenderer;
  114287. private _glVendor;
  114288. /** @hidden */
  114289. _videoTextureSupported: boolean;
  114290. protected _renderingQueueLaunched: boolean;
  114291. protected _activeRenderLoops: (() => void)[];
  114292. /**
  114293. * Observable signaled when a context lost event is raised
  114294. */
  114295. onContextLostObservable: Observable<ThinEngine>;
  114296. /**
  114297. * Observable signaled when a context restored event is raised
  114298. */
  114299. onContextRestoredObservable: Observable<ThinEngine>;
  114300. private _onContextLost;
  114301. private _onContextRestored;
  114302. protected _contextWasLost: boolean;
  114303. /** @hidden */
  114304. _doNotHandleContextLost: boolean;
  114305. /**
  114306. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114307. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114308. */
  114309. get doNotHandleContextLost(): boolean;
  114310. set doNotHandleContextLost(value: boolean);
  114311. /**
  114312. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114313. */
  114314. disableVertexArrayObjects: boolean;
  114315. /** @hidden */
  114316. protected _colorWrite: boolean;
  114317. /** @hidden */
  114318. protected _colorWriteChanged: boolean;
  114319. /** @hidden */
  114320. protected _depthCullingState: DepthCullingState;
  114321. /** @hidden */
  114322. protected _stencilState: StencilState;
  114323. /** @hidden */
  114324. _alphaState: AlphaState;
  114325. /** @hidden */
  114326. _alphaMode: number;
  114327. /** @hidden */
  114328. _alphaEquation: number;
  114329. /** @hidden */
  114330. _internalTexturesCache: InternalTexture[];
  114331. /** @hidden */
  114332. protected _activeChannel: number;
  114333. private _currentTextureChannel;
  114334. /** @hidden */
  114335. protected _boundTexturesCache: {
  114336. [key: string]: Nullable<InternalTexture>;
  114337. };
  114338. /** @hidden */
  114339. protected _currentEffect: Nullable<Effect>;
  114340. /** @hidden */
  114341. protected _currentProgram: Nullable<WebGLProgram>;
  114342. private _compiledEffects;
  114343. private _vertexAttribArraysEnabled;
  114344. /** @hidden */
  114345. protected _cachedViewport: Nullable<IViewportLike>;
  114346. private _cachedVertexArrayObject;
  114347. /** @hidden */
  114348. protected _cachedVertexBuffers: any;
  114349. /** @hidden */
  114350. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114351. /** @hidden */
  114352. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114353. /** @hidden */
  114354. _currentRenderTarget: Nullable<InternalTexture>;
  114355. private _uintIndicesCurrentlySet;
  114356. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114357. /** @hidden */
  114358. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114359. /** @hidden */
  114360. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114361. private _currentBufferPointers;
  114362. private _currentInstanceLocations;
  114363. private _currentInstanceBuffers;
  114364. private _textureUnits;
  114365. /** @hidden */
  114366. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114367. /** @hidden */
  114368. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114369. /** @hidden */
  114370. _boundRenderFunction: any;
  114371. private _vaoRecordInProgress;
  114372. private _mustWipeVertexAttributes;
  114373. private _emptyTexture;
  114374. private _emptyCubeTexture;
  114375. private _emptyTexture3D;
  114376. private _emptyTexture2DArray;
  114377. /** @hidden */
  114378. _frameHandler: number;
  114379. private _nextFreeTextureSlots;
  114380. private _maxSimultaneousTextures;
  114381. private _activeRequests;
  114382. /** @hidden */
  114383. _transformTextureUrl: Nullable<(url: string) => string>;
  114384. protected get _supportsHardwareTextureRescaling(): boolean;
  114385. private _framebufferDimensionsObject;
  114386. /**
  114387. * sets the object from which width and height will be taken from when getting render width and height
  114388. * Will fallback to the gl object
  114389. * @param dimensions the framebuffer width and height that will be used.
  114390. */
  114391. set framebufferDimensionsObject(dimensions: Nullable<{
  114392. framebufferWidth: number;
  114393. framebufferHeight: number;
  114394. }>);
  114395. /**
  114396. * Gets the current viewport
  114397. */
  114398. get currentViewport(): Nullable<IViewportLike>;
  114399. /**
  114400. * Gets the default empty texture
  114401. */
  114402. get emptyTexture(): InternalTexture;
  114403. /**
  114404. * Gets the default empty 3D texture
  114405. */
  114406. get emptyTexture3D(): InternalTexture;
  114407. /**
  114408. * Gets the default empty 2D array texture
  114409. */
  114410. get emptyTexture2DArray(): InternalTexture;
  114411. /**
  114412. * Gets the default empty cube texture
  114413. */
  114414. get emptyCubeTexture(): InternalTexture;
  114415. /**
  114416. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114417. */
  114418. readonly premultipliedAlpha: boolean;
  114419. /**
  114420. * Observable event triggered before each texture is initialized
  114421. */
  114422. onBeforeTextureInitObservable: Observable<Texture>;
  114423. /**
  114424. * Creates a new engine
  114425. * @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
  114426. * @param antialias defines enable antialiasing (default: false)
  114427. * @param options defines further options to be sent to the getContext() function
  114428. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114429. */
  114430. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114431. private _rebuildInternalTextures;
  114432. private _rebuildEffects;
  114433. /**
  114434. * Gets a boolean indicating if all created effects are ready
  114435. * @returns true if all effects are ready
  114436. */
  114437. areAllEffectsReady(): boolean;
  114438. protected _rebuildBuffers(): void;
  114439. protected _initGLContext(): void;
  114440. /**
  114441. * Gets version of the current webGL context
  114442. */
  114443. get webGLVersion(): number;
  114444. /**
  114445. * Gets a string idenfifying the name of the class
  114446. * @returns "Engine" string
  114447. */
  114448. getClassName(): string;
  114449. /**
  114450. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114451. */
  114452. get isStencilEnable(): boolean;
  114453. /** @hidden */
  114454. _prepareWorkingCanvas(): void;
  114455. /**
  114456. * Reset the texture cache to empty state
  114457. */
  114458. resetTextureCache(): void;
  114459. /**
  114460. * Gets an object containing information about the current webGL context
  114461. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114462. */
  114463. getGlInfo(): {
  114464. vendor: string;
  114465. renderer: string;
  114466. version: string;
  114467. };
  114468. /**
  114469. * Defines the hardware scaling level.
  114470. * By default the hardware scaling level is computed from the window device ratio.
  114471. * 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.
  114472. * @param level defines the level to use
  114473. */
  114474. setHardwareScalingLevel(level: number): void;
  114475. /**
  114476. * Gets the current hardware scaling level.
  114477. * By default the hardware scaling level is computed from the window device ratio.
  114478. * 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.
  114479. * @returns a number indicating the current hardware scaling level
  114480. */
  114481. getHardwareScalingLevel(): number;
  114482. /**
  114483. * Gets the list of loaded textures
  114484. * @returns an array containing all loaded textures
  114485. */
  114486. getLoadedTexturesCache(): InternalTexture[];
  114487. /**
  114488. * Gets the object containing all engine capabilities
  114489. * @returns the EngineCapabilities object
  114490. */
  114491. getCaps(): EngineCapabilities;
  114492. /**
  114493. * stop executing a render loop function and remove it from the execution array
  114494. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114495. */
  114496. stopRenderLoop(renderFunction?: () => void): void;
  114497. /** @hidden */
  114498. _renderLoop(): void;
  114499. /**
  114500. * Gets the HTML canvas attached with the current webGL context
  114501. * @returns a HTML canvas
  114502. */
  114503. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114504. /**
  114505. * Gets host window
  114506. * @returns the host window object
  114507. */
  114508. getHostWindow(): Nullable<Window>;
  114509. /**
  114510. * Gets the current render width
  114511. * @param useScreen defines if screen size must be used (or the current render target if any)
  114512. * @returns a number defining the current render width
  114513. */
  114514. getRenderWidth(useScreen?: boolean): number;
  114515. /**
  114516. * Gets the current render height
  114517. * @param useScreen defines if screen size must be used (or the current render target if any)
  114518. * @returns a number defining the current render height
  114519. */
  114520. getRenderHeight(useScreen?: boolean): number;
  114521. /**
  114522. * Can be used to override the current requestAnimationFrame requester.
  114523. * @hidden
  114524. */
  114525. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114526. /**
  114527. * Register and execute a render loop. The engine can have more than one render function
  114528. * @param renderFunction defines the function to continuously execute
  114529. */
  114530. runRenderLoop(renderFunction: () => void): void;
  114531. /**
  114532. * Clear the current render buffer or the current render target (if any is set up)
  114533. * @param color defines the color to use
  114534. * @param backBuffer defines if the back buffer must be cleared
  114535. * @param depth defines if the depth buffer must be cleared
  114536. * @param stencil defines if the stencil buffer must be cleared
  114537. */
  114538. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114539. private _viewportCached;
  114540. /** @hidden */
  114541. _viewport(x: number, y: number, width: number, height: number): void;
  114542. /**
  114543. * Set the WebGL's viewport
  114544. * @param viewport defines the viewport element to be used
  114545. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114546. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114547. */
  114548. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114549. /**
  114550. * Begin a new frame
  114551. */
  114552. beginFrame(): void;
  114553. /**
  114554. * Enf the current frame
  114555. */
  114556. endFrame(): void;
  114557. /**
  114558. * Resize the view according to the canvas' size
  114559. */
  114560. resize(): void;
  114561. /**
  114562. * Force a specific size of the canvas
  114563. * @param width defines the new canvas' width
  114564. * @param height defines the new canvas' height
  114565. * @returns true if the size was changed
  114566. */
  114567. setSize(width: number, height: number): boolean;
  114568. /**
  114569. * Binds the frame buffer to the specified texture.
  114570. * @param texture The texture to render to or null for the default canvas
  114571. * @param faceIndex The face of the texture to render to in case of cube texture
  114572. * @param requiredWidth The width of the target to render to
  114573. * @param requiredHeight The height of the target to render to
  114574. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114575. * @param lodLevel defines the lod level to bind to the frame buffer
  114576. * @param layer defines the 2d array index to bind to frame buffer to
  114577. */
  114578. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114579. /** @hidden */
  114580. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114581. /**
  114582. * Unbind the current render target texture from the webGL context
  114583. * @param texture defines the render target texture to unbind
  114584. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114585. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114586. */
  114587. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114588. /**
  114589. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114590. */
  114591. flushFramebuffer(): void;
  114592. /**
  114593. * Unbind the current render target and bind the default framebuffer
  114594. */
  114595. restoreDefaultFramebuffer(): void;
  114596. /** @hidden */
  114597. protected _resetVertexBufferBinding(): void;
  114598. /**
  114599. * Creates a vertex buffer
  114600. * @param data the data for the vertex buffer
  114601. * @returns the new WebGL static buffer
  114602. */
  114603. createVertexBuffer(data: DataArray): DataBuffer;
  114604. private _createVertexBuffer;
  114605. /**
  114606. * Creates a dynamic vertex buffer
  114607. * @param data the data for the dynamic vertex buffer
  114608. * @returns the new WebGL dynamic buffer
  114609. */
  114610. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114611. protected _resetIndexBufferBinding(): void;
  114612. /**
  114613. * Creates a new index buffer
  114614. * @param indices defines the content of the index buffer
  114615. * @param updatable defines if the index buffer must be updatable
  114616. * @returns a new webGL buffer
  114617. */
  114618. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114619. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114620. /**
  114621. * Bind a webGL buffer to the webGL context
  114622. * @param buffer defines the buffer to bind
  114623. */
  114624. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114625. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114626. private bindBuffer;
  114627. /**
  114628. * update the bound buffer with the given data
  114629. * @param data defines the data to update
  114630. */
  114631. updateArrayBuffer(data: Float32Array): void;
  114632. private _vertexAttribPointer;
  114633. /** @hidden */
  114634. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114635. private _bindVertexBuffersAttributes;
  114636. /**
  114637. * Records a vertex array object
  114638. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114639. * @param vertexBuffers defines the list of vertex buffers to store
  114640. * @param indexBuffer defines the index buffer to store
  114641. * @param effect defines the effect to store
  114642. * @returns the new vertex array object
  114643. */
  114644. recordVertexArrayObject(vertexBuffers: {
  114645. [key: string]: VertexBuffer;
  114646. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114647. /**
  114648. * Bind a specific vertex array object
  114649. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114650. * @param vertexArrayObject defines the vertex array object to bind
  114651. * @param indexBuffer defines the index buffer to bind
  114652. */
  114653. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114654. /**
  114655. * Bind webGl buffers directly to the webGL context
  114656. * @param vertexBuffer defines the vertex buffer to bind
  114657. * @param indexBuffer defines the index buffer to bind
  114658. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114659. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114660. * @param effect defines the effect associated with the vertex buffer
  114661. */
  114662. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114663. private _unbindVertexArrayObject;
  114664. /**
  114665. * Bind a list of vertex buffers to the webGL context
  114666. * @param vertexBuffers defines the list of vertex buffers to bind
  114667. * @param indexBuffer defines the index buffer to bind
  114668. * @param effect defines the effect associated with the vertex buffers
  114669. */
  114670. bindBuffers(vertexBuffers: {
  114671. [key: string]: Nullable<VertexBuffer>;
  114672. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114673. /**
  114674. * Unbind all instance attributes
  114675. */
  114676. unbindInstanceAttributes(): void;
  114677. /**
  114678. * Release and free the memory of a vertex array object
  114679. * @param vao defines the vertex array object to delete
  114680. */
  114681. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114682. /** @hidden */
  114683. _releaseBuffer(buffer: DataBuffer): boolean;
  114684. protected _deleteBuffer(buffer: DataBuffer): void;
  114685. /**
  114686. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114687. * @param instancesBuffer defines the webGL buffer to update and bind
  114688. * @param data defines the data to store in the buffer
  114689. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114690. */
  114691. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114692. /**
  114693. * Bind the content of a webGL buffer used with instantiation
  114694. * @param instancesBuffer defines the webGL buffer to bind
  114695. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114696. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114697. */
  114698. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114699. /**
  114700. * Disable the instance attribute corresponding to the name in parameter
  114701. * @param name defines the name of the attribute to disable
  114702. */
  114703. disableInstanceAttributeByName(name: string): void;
  114704. /**
  114705. * Disable the instance attribute corresponding to the location in parameter
  114706. * @param attributeLocation defines the attribute location of the attribute to disable
  114707. */
  114708. disableInstanceAttribute(attributeLocation: number): void;
  114709. /**
  114710. * Disable the attribute corresponding to the location in parameter
  114711. * @param attributeLocation defines the attribute location of the attribute to disable
  114712. */
  114713. disableAttributeByIndex(attributeLocation: number): void;
  114714. /**
  114715. * Send a draw order
  114716. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114717. * @param indexStart defines the starting index
  114718. * @param indexCount defines the number of index to draw
  114719. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114720. */
  114721. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114722. /**
  114723. * Draw a list of points
  114724. * @param verticesStart defines the index of first vertex to draw
  114725. * @param verticesCount defines the count of vertices to draw
  114726. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114727. */
  114728. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114729. /**
  114730. * Draw a list of unindexed primitives
  114731. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114732. * @param verticesStart defines the index of first vertex to draw
  114733. * @param verticesCount defines the count of vertices to draw
  114734. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114735. */
  114736. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114737. /**
  114738. * Draw a list of indexed primitives
  114739. * @param fillMode defines the primitive to use
  114740. * @param indexStart defines the starting index
  114741. * @param indexCount defines the number of index to draw
  114742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114743. */
  114744. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114745. /**
  114746. * Draw a list of unindexed primitives
  114747. * @param fillMode defines the primitive to use
  114748. * @param verticesStart defines the index of first vertex to draw
  114749. * @param verticesCount defines the count of vertices to draw
  114750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114751. */
  114752. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114753. private _drawMode;
  114754. /** @hidden */
  114755. protected _reportDrawCall(): void;
  114756. /** @hidden */
  114757. _releaseEffect(effect: Effect): void;
  114758. /** @hidden */
  114759. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114760. /**
  114761. * Create a new effect (used to store vertex/fragment shaders)
  114762. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114763. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114764. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114765. * @param samplers defines an array of string used to represent textures
  114766. * @param defines defines the string containing the defines to use to compile the shaders
  114767. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114768. * @param onCompiled defines a function to call when the effect creation is successful
  114769. * @param onError defines a function to call when the effect creation has failed
  114770. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114771. * @returns the new Effect
  114772. */
  114773. 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;
  114774. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114775. private _compileShader;
  114776. private _compileRawShader;
  114777. /** @hidden */
  114778. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114779. /**
  114780. * Directly creates a webGL program
  114781. * @param pipelineContext defines the pipeline context to attach to
  114782. * @param vertexCode defines the vertex shader code to use
  114783. * @param fragmentCode defines the fragment shader code to use
  114784. * @param context defines the webGL context to use (if not set, the current one will be used)
  114785. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114786. * @returns the new webGL program
  114787. */
  114788. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114789. /**
  114790. * Creates a webGL program
  114791. * @param pipelineContext defines the pipeline context to attach to
  114792. * @param vertexCode defines the vertex shader code to use
  114793. * @param fragmentCode defines the fragment shader code to use
  114794. * @param defines defines the string containing the defines to use to compile the shaders
  114795. * @param context defines the webGL context to use (if not set, the current one will be used)
  114796. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114797. * @returns the new webGL program
  114798. */
  114799. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114800. /**
  114801. * Creates a new pipeline context
  114802. * @returns the new pipeline
  114803. */
  114804. createPipelineContext(): IPipelineContext;
  114805. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114806. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114807. /** @hidden */
  114808. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114809. /** @hidden */
  114810. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114811. /** @hidden */
  114812. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114813. /**
  114814. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114815. * @param pipelineContext defines the pipeline context to use
  114816. * @param uniformsNames defines the list of uniform names
  114817. * @returns an array of webGL uniform locations
  114818. */
  114819. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114820. /**
  114821. * Gets the lsit of active attributes for a given webGL program
  114822. * @param pipelineContext defines the pipeline context to use
  114823. * @param attributesNames defines the list of attribute names to get
  114824. * @returns an array of indices indicating the offset of each attribute
  114825. */
  114826. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114827. /**
  114828. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114829. * @param effect defines the effect to activate
  114830. */
  114831. enableEffect(effect: Nullable<Effect>): void;
  114832. /**
  114833. * Set the value of an uniform to a number (int)
  114834. * @param uniform defines the webGL uniform location where to store the value
  114835. * @param value defines the int number to store
  114836. */
  114837. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114838. /**
  114839. * Set the value of an uniform to an array of int32
  114840. * @param uniform defines the webGL uniform location where to store the value
  114841. * @param array defines the array of int32 to store
  114842. */
  114843. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114844. /**
  114845. * Set the value of an uniform to an array of int32 (stored as vec2)
  114846. * @param uniform defines the webGL uniform location where to store the value
  114847. * @param array defines the array of int32 to store
  114848. */
  114849. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114850. /**
  114851. * Set the value of an uniform to an array of int32 (stored as vec3)
  114852. * @param uniform defines the webGL uniform location where to store the value
  114853. * @param array defines the array of int32 to store
  114854. */
  114855. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114856. /**
  114857. * Set the value of an uniform to an array of int32 (stored as vec4)
  114858. * @param uniform defines the webGL uniform location where to store the value
  114859. * @param array defines the array of int32 to store
  114860. */
  114861. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114862. /**
  114863. * Set the value of an uniform to an array of number
  114864. * @param uniform defines the webGL uniform location where to store the value
  114865. * @param array defines the array of number to store
  114866. */
  114867. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114868. /**
  114869. * Set the value of an uniform to an array of number (stored as vec2)
  114870. * @param uniform defines the webGL uniform location where to store the value
  114871. * @param array defines the array of number to store
  114872. */
  114873. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114874. /**
  114875. * Set the value of an uniform to an array of number (stored as vec3)
  114876. * @param uniform defines the webGL uniform location where to store the value
  114877. * @param array defines the array of number to store
  114878. */
  114879. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114880. /**
  114881. * Set the value of an uniform to an array of number (stored as vec4)
  114882. * @param uniform defines the webGL uniform location where to store the value
  114883. * @param array defines the array of number to store
  114884. */
  114885. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114886. /**
  114887. * Set the value of an uniform to an array of float32 (stored as matrices)
  114888. * @param uniform defines the webGL uniform location where to store the value
  114889. * @param matrices defines the array of float32 to store
  114890. */
  114891. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114892. /**
  114893. * Set the value of an uniform to a matrix (3x3)
  114894. * @param uniform defines the webGL uniform location where to store the value
  114895. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114896. */
  114897. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114898. /**
  114899. * Set the value of an uniform to a matrix (2x2)
  114900. * @param uniform defines the webGL uniform location where to store the value
  114901. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114902. */
  114903. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114904. /**
  114905. * Set the value of an uniform to a number (float)
  114906. * @param uniform defines the webGL uniform location where to store the value
  114907. * @param value defines the float number to store
  114908. */
  114909. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114910. /**
  114911. * Set the value of an uniform to a vec2
  114912. * @param uniform defines the webGL uniform location where to store the value
  114913. * @param x defines the 1st component of the value
  114914. * @param y defines the 2nd component of the value
  114915. */
  114916. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114917. /**
  114918. * Set the value of an uniform to a vec3
  114919. * @param uniform defines the webGL uniform location where to store the value
  114920. * @param x defines the 1st component of the value
  114921. * @param y defines the 2nd component of the value
  114922. * @param z defines the 3rd component of the value
  114923. */
  114924. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114925. /**
  114926. * Set the value of an uniform to a vec4
  114927. * @param uniform defines the webGL uniform location where to store the value
  114928. * @param x defines the 1st component of the value
  114929. * @param y defines the 2nd component of the value
  114930. * @param z defines the 3rd component of the value
  114931. * @param w defines the 4th component of the value
  114932. */
  114933. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114934. /**
  114935. * Apply all cached states (depth, culling, stencil and alpha)
  114936. */
  114937. applyStates(): void;
  114938. /**
  114939. * Enable or disable color writing
  114940. * @param enable defines the state to set
  114941. */
  114942. setColorWrite(enable: boolean): void;
  114943. /**
  114944. * Gets a boolean indicating if color writing is enabled
  114945. * @returns the current color writing state
  114946. */
  114947. getColorWrite(): boolean;
  114948. /**
  114949. * Gets the depth culling state manager
  114950. */
  114951. get depthCullingState(): DepthCullingState;
  114952. /**
  114953. * Gets the alpha state manager
  114954. */
  114955. get alphaState(): AlphaState;
  114956. /**
  114957. * Gets the stencil state manager
  114958. */
  114959. get stencilState(): StencilState;
  114960. /**
  114961. * Clears the list of texture accessible through engine.
  114962. * This can help preventing texture load conflict due to name collision.
  114963. */
  114964. clearInternalTexturesCache(): void;
  114965. /**
  114966. * Force the entire cache to be cleared
  114967. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114968. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114969. */
  114970. wipeCaches(bruteForce?: boolean): void;
  114971. /** @hidden */
  114972. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114973. min: number;
  114974. mag: number;
  114975. };
  114976. /** @hidden */
  114977. _createTexture(): WebGLTexture;
  114978. /**
  114979. * Usually called from Texture.ts.
  114980. * Passed information to create a WebGLTexture
  114981. * @param url defines a value which contains one of the following:
  114982. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114983. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114984. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114985. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114986. * @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)
  114987. * @param scene needed for loading to the correct scene
  114988. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114989. * @param onLoad optional callback to be called upon successful completion
  114990. * @param onError optional callback to be called upon failure
  114991. * @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
  114992. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114993. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114994. * @param forcedExtension defines the extension to use to pick the right loader
  114995. * @param mimeType defines an optional mime type
  114996. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114997. */
  114998. 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;
  114999. /**
  115000. * Loads an image as an HTMLImageElement.
  115001. * @param input url string, ArrayBuffer, or Blob to load
  115002. * @param onLoad callback called when the image successfully loads
  115003. * @param onError callback called when the image fails to load
  115004. * @param offlineProvider offline provider for caching
  115005. * @param mimeType optional mime type
  115006. * @returns the HTMLImageElement of the loaded image
  115007. * @hidden
  115008. */
  115009. 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>;
  115010. /**
  115011. * @hidden
  115012. */
  115013. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115014. private _unpackFlipYCached;
  115015. /**
  115016. * In case you are sharing the context with other applications, it might
  115017. * be interested to not cache the unpack flip y state to ensure a consistent
  115018. * value would be set.
  115019. */
  115020. enableUnpackFlipYCached: boolean;
  115021. /** @hidden */
  115022. _unpackFlipY(value: boolean): void;
  115023. /** @hidden */
  115024. _getUnpackAlignement(): number;
  115025. private _getTextureTarget;
  115026. /**
  115027. * Update the sampling mode of a given texture
  115028. * @param samplingMode defines the required sampling mode
  115029. * @param texture defines the texture to update
  115030. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115031. */
  115032. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115033. /**
  115034. * Update the sampling mode of a given texture
  115035. * @param texture defines the texture to update
  115036. * @param wrapU defines the texture wrap mode of the u coordinates
  115037. * @param wrapV defines the texture wrap mode of the v coordinates
  115038. * @param wrapR defines the texture wrap mode of the r coordinates
  115039. */
  115040. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115041. /** @hidden */
  115042. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115043. width: number;
  115044. height: number;
  115045. layers?: number;
  115046. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115047. /** @hidden */
  115048. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115049. /** @hidden */
  115050. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115051. /**
  115052. * Update a portion of an internal texture
  115053. * @param texture defines the texture to update
  115054. * @param imageData defines the data to store into the texture
  115055. * @param xOffset defines the x coordinates of the update rectangle
  115056. * @param yOffset defines the y coordinates of the update rectangle
  115057. * @param width defines the width of the update rectangle
  115058. * @param height defines the height of the update rectangle
  115059. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115060. * @param lod defines the lod level to update (0 by default)
  115061. */
  115062. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115063. /** @hidden */
  115064. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115065. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115066. private _prepareWebGLTexture;
  115067. /** @hidden */
  115068. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115069. private _getDepthStencilBuffer;
  115070. /** @hidden */
  115071. _releaseFramebufferObjects(texture: InternalTexture): void;
  115072. /** @hidden */
  115073. _releaseTexture(texture: InternalTexture): void;
  115074. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115075. protected _setProgram(program: WebGLProgram): void;
  115076. protected _boundUniforms: {
  115077. [key: number]: WebGLUniformLocation;
  115078. };
  115079. /**
  115080. * Binds an effect to the webGL context
  115081. * @param effect defines the effect to bind
  115082. */
  115083. bindSamplers(effect: Effect): void;
  115084. private _activateCurrentTexture;
  115085. /** @hidden */
  115086. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115087. /** @hidden */
  115088. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115089. /**
  115090. * Unbind all textures from the webGL context
  115091. */
  115092. unbindAllTextures(): void;
  115093. /**
  115094. * Sets a texture to the according uniform.
  115095. * @param channel The texture channel
  115096. * @param uniform The uniform to set
  115097. * @param texture The texture to apply
  115098. */
  115099. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115100. private _bindSamplerUniformToChannel;
  115101. private _getTextureWrapMode;
  115102. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115103. /**
  115104. * Sets an array of texture to the webGL context
  115105. * @param channel defines the channel where the texture array must be set
  115106. * @param uniform defines the associated uniform location
  115107. * @param textures defines the array of textures to bind
  115108. */
  115109. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115110. /** @hidden */
  115111. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115112. private _setTextureParameterFloat;
  115113. private _setTextureParameterInteger;
  115114. /**
  115115. * Unbind all vertex attributes from the webGL context
  115116. */
  115117. unbindAllAttributes(): void;
  115118. /**
  115119. * 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
  115120. */
  115121. releaseEffects(): void;
  115122. /**
  115123. * Dispose and release all associated resources
  115124. */
  115125. dispose(): void;
  115126. /**
  115127. * Attach a new callback raised when context lost event is fired
  115128. * @param callback defines the callback to call
  115129. */
  115130. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115131. /**
  115132. * Attach a new callback raised when context restored event is fired
  115133. * @param callback defines the callback to call
  115134. */
  115135. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  115136. /**
  115137. * Get the current error code of the webGL context
  115138. * @returns the error code
  115139. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  115140. */
  115141. getError(): number;
  115142. private _canRenderToFloatFramebuffer;
  115143. private _canRenderToHalfFloatFramebuffer;
  115144. private _canRenderToFramebuffer;
  115145. /** @hidden */
  115146. _getWebGLTextureType(type: number): number;
  115147. /** @hidden */
  115148. _getInternalFormat(format: number): number;
  115149. /** @hidden */
  115150. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  115151. /** @hidden */
  115152. _getRGBAMultiSampleBufferFormat(type: number): number;
  115153. /** @hidden */
  115154. _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;
  115155. /**
  115156. * Loads a file from a url
  115157. * @param url url to load
  115158. * @param onSuccess callback called when the file successfully loads
  115159. * @param onProgress callback called while file is loading (if the server supports this mode)
  115160. * @param offlineProvider defines the offline provider for caching
  115161. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115162. * @param onError callback called when the file fails to load
  115163. * @returns a file request object
  115164. * @hidden
  115165. */
  115166. 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;
  115167. /**
  115168. * Reads pixels from the current frame buffer. Please note that this function can be slow
  115169. * @param x defines the x coordinate of the rectangle where pixels must be read
  115170. * @param y defines the y coordinate of the rectangle where pixels must be read
  115171. * @param width defines the width of the rectangle where pixels must be read
  115172. * @param height defines the height of the rectangle where pixels must be read
  115173. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  115174. * @returns a Uint8Array containing RGBA colors
  115175. */
  115176. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115177. private static _isSupported;
  115178. /**
  115179. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115180. * @returns true if the engine can be created
  115181. * @ignorenaming
  115182. */
  115183. static isSupported(): boolean;
  115184. /**
  115185. * Find the next highest power of two.
  115186. * @param x Number to start search from.
  115187. * @return Next highest power of two.
  115188. */
  115189. static CeilingPOT(x: number): number;
  115190. /**
  115191. * Find the next lowest power of two.
  115192. * @param x Number to start search from.
  115193. * @return Next lowest power of two.
  115194. */
  115195. static FloorPOT(x: number): number;
  115196. /**
  115197. * Find the nearest power of two.
  115198. * @param x Number to start search from.
  115199. * @return Next nearest power of two.
  115200. */
  115201. static NearestPOT(x: number): number;
  115202. /**
  115203. * Get the closest exponent of two
  115204. * @param value defines the value to approximate
  115205. * @param max defines the maximum value to return
  115206. * @param mode defines how to define the closest value
  115207. * @returns closest exponent of two of the given value
  115208. */
  115209. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115210. /**
  115211. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115212. * @param func - the function to be called
  115213. * @param requester - the object that will request the next frame. Falls back to window.
  115214. * @returns frame number
  115215. */
  115216. static QueueNewFrame(func: () => void, requester?: any): number;
  115217. /**
  115218. * Gets host document
  115219. * @returns the host document object
  115220. */
  115221. getHostDocument(): Nullable<Document>;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /**
  115226. * Class representing spherical harmonics coefficients to the 3rd degree
  115227. */
  115228. export class SphericalHarmonics {
  115229. /**
  115230. * Defines whether or not the harmonics have been prescaled for rendering.
  115231. */
  115232. preScaled: boolean;
  115233. /**
  115234. * The l0,0 coefficients of the spherical harmonics
  115235. */
  115236. l00: Vector3;
  115237. /**
  115238. * The l1,-1 coefficients of the spherical harmonics
  115239. */
  115240. l1_1: Vector3;
  115241. /**
  115242. * The l1,0 coefficients of the spherical harmonics
  115243. */
  115244. l10: Vector3;
  115245. /**
  115246. * The l1,1 coefficients of the spherical harmonics
  115247. */
  115248. l11: Vector3;
  115249. /**
  115250. * The l2,-2 coefficients of the spherical harmonics
  115251. */
  115252. l2_2: Vector3;
  115253. /**
  115254. * The l2,-1 coefficients of the spherical harmonics
  115255. */
  115256. l2_1: Vector3;
  115257. /**
  115258. * The l2,0 coefficients of the spherical harmonics
  115259. */
  115260. l20: Vector3;
  115261. /**
  115262. * The l2,1 coefficients of the spherical harmonics
  115263. */
  115264. l21: Vector3;
  115265. /**
  115266. * The l2,2 coefficients of the spherical harmonics
  115267. */
  115268. l22: Vector3;
  115269. /**
  115270. * Adds a light to the spherical harmonics
  115271. * @param direction the direction of the light
  115272. * @param color the color of the light
  115273. * @param deltaSolidAngle the delta solid angle of the light
  115274. */
  115275. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115276. /**
  115277. * Scales the spherical harmonics by the given amount
  115278. * @param scale the amount to scale
  115279. */
  115280. scaleInPlace(scale: number): void;
  115281. /**
  115282. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115283. *
  115284. * ```
  115285. * E_lm = A_l * L_lm
  115286. * ```
  115287. *
  115288. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115289. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115290. * the scaling factors are given in equation 9.
  115291. */
  115292. convertIncidentRadianceToIrradiance(): void;
  115293. /**
  115294. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115295. *
  115296. * ```
  115297. * L = (1/pi) * E * rho
  115298. * ```
  115299. *
  115300. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115301. */
  115302. convertIrradianceToLambertianRadiance(): void;
  115303. /**
  115304. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115305. * required operations at run time.
  115306. *
  115307. * This is simply done by scaling back the SH with Ylm constants parameter.
  115308. * The trigonometric part being applied by the shader at run time.
  115309. */
  115310. preScaleForRendering(): void;
  115311. /**
  115312. * Constructs a spherical harmonics from an array.
  115313. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115314. * @returns the spherical harmonics
  115315. */
  115316. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115317. /**
  115318. * Gets the spherical harmonics from polynomial
  115319. * @param polynomial the spherical polynomial
  115320. * @returns the spherical harmonics
  115321. */
  115322. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115323. }
  115324. /**
  115325. * Class representing spherical polynomial coefficients to the 3rd degree
  115326. */
  115327. export class SphericalPolynomial {
  115328. private _harmonics;
  115329. /**
  115330. * The spherical harmonics used to create the polynomials.
  115331. */
  115332. get preScaledHarmonics(): SphericalHarmonics;
  115333. /**
  115334. * The x coefficients of the spherical polynomial
  115335. */
  115336. x: Vector3;
  115337. /**
  115338. * The y coefficients of the spherical polynomial
  115339. */
  115340. y: Vector3;
  115341. /**
  115342. * The z coefficients of the spherical polynomial
  115343. */
  115344. z: Vector3;
  115345. /**
  115346. * The xx coefficients of the spherical polynomial
  115347. */
  115348. xx: Vector3;
  115349. /**
  115350. * The yy coefficients of the spherical polynomial
  115351. */
  115352. yy: Vector3;
  115353. /**
  115354. * The zz coefficients of the spherical polynomial
  115355. */
  115356. zz: Vector3;
  115357. /**
  115358. * The xy coefficients of the spherical polynomial
  115359. */
  115360. xy: Vector3;
  115361. /**
  115362. * The yz coefficients of the spherical polynomial
  115363. */
  115364. yz: Vector3;
  115365. /**
  115366. * The zx coefficients of the spherical polynomial
  115367. */
  115368. zx: Vector3;
  115369. /**
  115370. * Adds an ambient color to the spherical polynomial
  115371. * @param color the color to add
  115372. */
  115373. addAmbient(color: Color3): void;
  115374. /**
  115375. * Scales the spherical polynomial by the given amount
  115376. * @param scale the amount to scale
  115377. */
  115378. scaleInPlace(scale: number): void;
  115379. /**
  115380. * Gets the spherical polynomial from harmonics
  115381. * @param harmonics the spherical harmonics
  115382. * @returns the spherical polynomial
  115383. */
  115384. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115385. /**
  115386. * Constructs a spherical polynomial from an array.
  115387. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115388. * @returns the spherical polynomial
  115389. */
  115390. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115391. }
  115392. }
  115393. declare module BABYLON {
  115394. /**
  115395. * Defines the source of the internal texture
  115396. */
  115397. export enum InternalTextureSource {
  115398. /**
  115399. * The source of the texture data is unknown
  115400. */
  115401. Unknown = 0,
  115402. /**
  115403. * Texture data comes from an URL
  115404. */
  115405. Url = 1,
  115406. /**
  115407. * Texture data is only used for temporary storage
  115408. */
  115409. Temp = 2,
  115410. /**
  115411. * Texture data comes from raw data (ArrayBuffer)
  115412. */
  115413. Raw = 3,
  115414. /**
  115415. * Texture content is dynamic (video or dynamic texture)
  115416. */
  115417. Dynamic = 4,
  115418. /**
  115419. * Texture content is generated by rendering to it
  115420. */
  115421. RenderTarget = 5,
  115422. /**
  115423. * Texture content is part of a multi render target process
  115424. */
  115425. MultiRenderTarget = 6,
  115426. /**
  115427. * Texture data comes from a cube data file
  115428. */
  115429. Cube = 7,
  115430. /**
  115431. * Texture data comes from a raw cube data
  115432. */
  115433. CubeRaw = 8,
  115434. /**
  115435. * Texture data come from a prefiltered cube data file
  115436. */
  115437. CubePrefiltered = 9,
  115438. /**
  115439. * Texture content is raw 3D data
  115440. */
  115441. Raw3D = 10,
  115442. /**
  115443. * Texture content is raw 2D array data
  115444. */
  115445. Raw2DArray = 11,
  115446. /**
  115447. * Texture content is a depth texture
  115448. */
  115449. Depth = 12,
  115450. /**
  115451. * Texture data comes from a raw cube data encoded with RGBD
  115452. */
  115453. CubeRawRGBD = 13
  115454. }
  115455. /**
  115456. * Class used to store data associated with WebGL texture data for the engine
  115457. * This class should not be used directly
  115458. */
  115459. export class InternalTexture {
  115460. /** @hidden */
  115461. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115462. /**
  115463. * Defines if the texture is ready
  115464. */
  115465. isReady: boolean;
  115466. /**
  115467. * Defines if the texture is a cube texture
  115468. */
  115469. isCube: boolean;
  115470. /**
  115471. * Defines if the texture contains 3D data
  115472. */
  115473. is3D: boolean;
  115474. /**
  115475. * Defines if the texture contains 2D array data
  115476. */
  115477. is2DArray: boolean;
  115478. /**
  115479. * Defines if the texture contains multiview data
  115480. */
  115481. isMultiview: boolean;
  115482. /**
  115483. * Gets the URL used to load this texture
  115484. */
  115485. url: string;
  115486. /**
  115487. * Gets the sampling mode of the texture
  115488. */
  115489. samplingMode: number;
  115490. /**
  115491. * Gets a boolean indicating if the texture needs mipmaps generation
  115492. */
  115493. generateMipMaps: boolean;
  115494. /**
  115495. * Gets the number of samples used by the texture (WebGL2+ only)
  115496. */
  115497. samples: number;
  115498. /**
  115499. * Gets the type of the texture (int, float...)
  115500. */
  115501. type: number;
  115502. /**
  115503. * Gets the format of the texture (RGB, RGBA...)
  115504. */
  115505. format: number;
  115506. /**
  115507. * Observable called when the texture is loaded
  115508. */
  115509. onLoadedObservable: Observable<InternalTexture>;
  115510. /**
  115511. * Gets the width of the texture
  115512. */
  115513. width: number;
  115514. /**
  115515. * Gets the height of the texture
  115516. */
  115517. height: number;
  115518. /**
  115519. * Gets the depth of the texture
  115520. */
  115521. depth: number;
  115522. /**
  115523. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115524. */
  115525. baseWidth: number;
  115526. /**
  115527. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115528. */
  115529. baseHeight: number;
  115530. /**
  115531. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115532. */
  115533. baseDepth: number;
  115534. /**
  115535. * Gets a boolean indicating if the texture is inverted on Y axis
  115536. */
  115537. invertY: boolean;
  115538. /** @hidden */
  115539. _invertVScale: boolean;
  115540. /** @hidden */
  115541. _associatedChannel: number;
  115542. /** @hidden */
  115543. _source: InternalTextureSource;
  115544. /** @hidden */
  115545. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115546. /** @hidden */
  115547. _bufferView: Nullable<ArrayBufferView>;
  115548. /** @hidden */
  115549. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115550. /** @hidden */
  115551. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115552. /** @hidden */
  115553. _size: number;
  115554. /** @hidden */
  115555. _extension: string;
  115556. /** @hidden */
  115557. _files: Nullable<string[]>;
  115558. /** @hidden */
  115559. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115560. /** @hidden */
  115561. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115562. /** @hidden */
  115563. _framebuffer: Nullable<WebGLFramebuffer>;
  115564. /** @hidden */
  115565. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115566. /** @hidden */
  115567. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115568. /** @hidden */
  115569. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115570. /** @hidden */
  115571. _attachments: Nullable<number[]>;
  115572. /** @hidden */
  115573. _textureArray: Nullable<InternalTexture[]>;
  115574. /** @hidden */
  115575. _cachedCoordinatesMode: Nullable<number>;
  115576. /** @hidden */
  115577. _cachedWrapU: Nullable<number>;
  115578. /** @hidden */
  115579. _cachedWrapV: Nullable<number>;
  115580. /** @hidden */
  115581. _cachedWrapR: Nullable<number>;
  115582. /** @hidden */
  115583. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115584. /** @hidden */
  115585. _isDisabled: boolean;
  115586. /** @hidden */
  115587. _compression: Nullable<string>;
  115588. /** @hidden */
  115589. _generateStencilBuffer: boolean;
  115590. /** @hidden */
  115591. _generateDepthBuffer: boolean;
  115592. /** @hidden */
  115593. _comparisonFunction: number;
  115594. /** @hidden */
  115595. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115596. /** @hidden */
  115597. _lodGenerationScale: number;
  115598. /** @hidden */
  115599. _lodGenerationOffset: number;
  115600. /** @hidden */
  115601. _depthStencilTexture: Nullable<InternalTexture>;
  115602. /** @hidden */
  115603. _colorTextureArray: Nullable<WebGLTexture>;
  115604. /** @hidden */
  115605. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115606. /** @hidden */
  115607. _lodTextureHigh: Nullable<BaseTexture>;
  115608. /** @hidden */
  115609. _lodTextureMid: Nullable<BaseTexture>;
  115610. /** @hidden */
  115611. _lodTextureLow: Nullable<BaseTexture>;
  115612. /** @hidden */
  115613. _isRGBD: boolean;
  115614. /** @hidden */
  115615. _linearSpecularLOD: boolean;
  115616. /** @hidden */
  115617. _irradianceTexture: Nullable<BaseTexture>;
  115618. /** @hidden */
  115619. _webGLTexture: Nullable<WebGLTexture>;
  115620. /** @hidden */
  115621. _references: number;
  115622. private _engine;
  115623. /**
  115624. * Gets the Engine the texture belongs to.
  115625. * @returns The babylon engine
  115626. */
  115627. getEngine(): ThinEngine;
  115628. /**
  115629. * Gets the data source type of the texture
  115630. */
  115631. get source(): InternalTextureSource;
  115632. /**
  115633. * Creates a new InternalTexture
  115634. * @param engine defines the engine to use
  115635. * @param source defines the type of data that will be used
  115636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115637. */
  115638. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115639. /**
  115640. * Increments the number of references (ie. the number of Texture that point to it)
  115641. */
  115642. incrementReferences(): void;
  115643. /**
  115644. * Change the size of the texture (not the size of the content)
  115645. * @param width defines the new width
  115646. * @param height defines the new height
  115647. * @param depth defines the new depth (1 by default)
  115648. */
  115649. updateSize(width: int, height: int, depth?: int): void;
  115650. /** @hidden */
  115651. _rebuild(): void;
  115652. /** @hidden */
  115653. _swapAndDie(target: InternalTexture): void;
  115654. /**
  115655. * Dispose the current allocated resources
  115656. */
  115657. dispose(): void;
  115658. }
  115659. }
  115660. declare module BABYLON {
  115661. /**
  115662. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115664. */
  115665. export class Analyser {
  115666. /**
  115667. * Gets or sets the smoothing
  115668. * @ignorenaming
  115669. */
  115670. SMOOTHING: number;
  115671. /**
  115672. * Gets or sets the FFT table size
  115673. * @ignorenaming
  115674. */
  115675. FFT_SIZE: number;
  115676. /**
  115677. * Gets or sets the bar graph amplitude
  115678. * @ignorenaming
  115679. */
  115680. BARGRAPHAMPLITUDE: number;
  115681. /**
  115682. * Gets or sets the position of the debug canvas
  115683. * @ignorenaming
  115684. */
  115685. DEBUGCANVASPOS: {
  115686. x: number;
  115687. y: number;
  115688. };
  115689. /**
  115690. * Gets or sets the debug canvas size
  115691. * @ignorenaming
  115692. */
  115693. DEBUGCANVASSIZE: {
  115694. width: number;
  115695. height: number;
  115696. };
  115697. private _byteFreqs;
  115698. private _byteTime;
  115699. private _floatFreqs;
  115700. private _webAudioAnalyser;
  115701. private _debugCanvas;
  115702. private _debugCanvasContext;
  115703. private _scene;
  115704. private _registerFunc;
  115705. private _audioEngine;
  115706. /**
  115707. * Creates a new analyser
  115708. * @param scene defines hosting scene
  115709. */
  115710. constructor(scene: Scene);
  115711. /**
  115712. * Get the number of data values you will have to play with for the visualization
  115713. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115714. * @returns a number
  115715. */
  115716. getFrequencyBinCount(): number;
  115717. /**
  115718. * Gets the current frequency data as a byte array
  115719. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115720. * @returns a Uint8Array
  115721. */
  115722. getByteFrequencyData(): Uint8Array;
  115723. /**
  115724. * Gets the current waveform as a byte array
  115725. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115726. * @returns a Uint8Array
  115727. */
  115728. getByteTimeDomainData(): Uint8Array;
  115729. /**
  115730. * Gets the current frequency data as a float array
  115731. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115732. * @returns a Float32Array
  115733. */
  115734. getFloatFrequencyData(): Float32Array;
  115735. /**
  115736. * Renders the debug canvas
  115737. */
  115738. drawDebugCanvas(): void;
  115739. /**
  115740. * Stops rendering the debug canvas and removes it
  115741. */
  115742. stopDebugCanvas(): void;
  115743. /**
  115744. * Connects two audio nodes
  115745. * @param inputAudioNode defines first node to connect
  115746. * @param outputAudioNode defines second node to connect
  115747. */
  115748. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115749. /**
  115750. * Releases all associated resources
  115751. */
  115752. dispose(): void;
  115753. }
  115754. }
  115755. declare module BABYLON {
  115756. /**
  115757. * This represents an audio engine and it is responsible
  115758. * to play, synchronize and analyse sounds throughout the application.
  115759. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115760. */
  115761. export interface IAudioEngine extends IDisposable {
  115762. /**
  115763. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115764. */
  115765. readonly canUseWebAudio: boolean;
  115766. /**
  115767. * Gets the current AudioContext if available.
  115768. */
  115769. readonly audioContext: Nullable<AudioContext>;
  115770. /**
  115771. * The master gain node defines the global audio volume of your audio engine.
  115772. */
  115773. readonly masterGain: GainNode;
  115774. /**
  115775. * Gets whether or not mp3 are supported by your browser.
  115776. */
  115777. readonly isMP3supported: boolean;
  115778. /**
  115779. * Gets whether or not ogg are supported by your browser.
  115780. */
  115781. readonly isOGGsupported: boolean;
  115782. /**
  115783. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115784. * @ignoreNaming
  115785. */
  115786. WarnedWebAudioUnsupported: boolean;
  115787. /**
  115788. * Defines if the audio engine relies on a custom unlocked button.
  115789. * In this case, the embedded button will not be displayed.
  115790. */
  115791. useCustomUnlockedButton: boolean;
  115792. /**
  115793. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115794. */
  115795. readonly unlocked: boolean;
  115796. /**
  115797. * Event raised when audio has been unlocked on the browser.
  115798. */
  115799. onAudioUnlockedObservable: Observable<AudioEngine>;
  115800. /**
  115801. * Event raised when audio has been locked on the browser.
  115802. */
  115803. onAudioLockedObservable: Observable<AudioEngine>;
  115804. /**
  115805. * Flags the audio engine in Locked state.
  115806. * This happens due to new browser policies preventing audio to autoplay.
  115807. */
  115808. lock(): void;
  115809. /**
  115810. * Unlocks the audio engine once a user action has been done on the dom.
  115811. * This is helpful to resume play once browser policies have been satisfied.
  115812. */
  115813. unlock(): void;
  115814. /**
  115815. * Gets the global volume sets on the master gain.
  115816. * @returns the global volume if set or -1 otherwise
  115817. */
  115818. getGlobalVolume(): number;
  115819. /**
  115820. * Sets the global volume of your experience (sets on the master gain).
  115821. * @param newVolume Defines the new global volume of the application
  115822. */
  115823. setGlobalVolume(newVolume: number): void;
  115824. /**
  115825. * Connect the audio engine to an audio analyser allowing some amazing
  115826. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115827. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115828. * @param analyser The analyser to connect to the engine
  115829. */
  115830. connectToAnalyser(analyser: Analyser): void;
  115831. }
  115832. /**
  115833. * This represents the default audio engine used in babylon.
  115834. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115836. */
  115837. export class AudioEngine implements IAudioEngine {
  115838. private _audioContext;
  115839. private _audioContextInitialized;
  115840. private _muteButton;
  115841. private _hostElement;
  115842. /**
  115843. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115844. */
  115845. canUseWebAudio: boolean;
  115846. /**
  115847. * The master gain node defines the global audio volume of your audio engine.
  115848. */
  115849. masterGain: GainNode;
  115850. /**
  115851. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115852. * @ignoreNaming
  115853. */
  115854. WarnedWebAudioUnsupported: boolean;
  115855. /**
  115856. * Gets whether or not mp3 are supported by your browser.
  115857. */
  115858. isMP3supported: boolean;
  115859. /**
  115860. * Gets whether or not ogg are supported by your browser.
  115861. */
  115862. isOGGsupported: boolean;
  115863. /**
  115864. * Gets whether audio has been unlocked on the device.
  115865. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115866. * a user interaction has happened.
  115867. */
  115868. unlocked: boolean;
  115869. /**
  115870. * Defines if the audio engine relies on a custom unlocked button.
  115871. * In this case, the embedded button will not be displayed.
  115872. */
  115873. useCustomUnlockedButton: boolean;
  115874. /**
  115875. * Event raised when audio has been unlocked on the browser.
  115876. */
  115877. onAudioUnlockedObservable: Observable<AudioEngine>;
  115878. /**
  115879. * Event raised when audio has been locked on the browser.
  115880. */
  115881. onAudioLockedObservable: Observable<AudioEngine>;
  115882. /**
  115883. * Gets the current AudioContext if available.
  115884. */
  115885. get audioContext(): Nullable<AudioContext>;
  115886. private _connectedAnalyser;
  115887. /**
  115888. * Instantiates a new audio engine.
  115889. *
  115890. * There should be only one per page as some browsers restrict the number
  115891. * of audio contexts you can create.
  115892. * @param hostElement defines the host element where to display the mute icon if necessary
  115893. */
  115894. constructor(hostElement?: Nullable<HTMLElement>);
  115895. /**
  115896. * Flags the audio engine in Locked state.
  115897. * This happens due to new browser policies preventing audio to autoplay.
  115898. */
  115899. lock(): void;
  115900. /**
  115901. * Unlocks the audio engine once a user action has been done on the dom.
  115902. * This is helpful to resume play once browser policies have been satisfied.
  115903. */
  115904. unlock(): void;
  115905. private _resumeAudioContext;
  115906. private _initializeAudioContext;
  115907. private _tryToRun;
  115908. private _triggerRunningState;
  115909. private _triggerSuspendedState;
  115910. private _displayMuteButton;
  115911. private _moveButtonToTopLeft;
  115912. private _onResize;
  115913. private _hideMuteButton;
  115914. /**
  115915. * Destroy and release the resources associated with the audio ccontext.
  115916. */
  115917. dispose(): void;
  115918. /**
  115919. * Gets the global volume sets on the master gain.
  115920. * @returns the global volume if set or -1 otherwise
  115921. */
  115922. getGlobalVolume(): number;
  115923. /**
  115924. * Sets the global volume of your experience (sets on the master gain).
  115925. * @param newVolume Defines the new global volume of the application
  115926. */
  115927. setGlobalVolume(newVolume: number): void;
  115928. /**
  115929. * Connect the audio engine to an audio analyser allowing some amazing
  115930. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115931. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115932. * @param analyser The analyser to connect to the engine
  115933. */
  115934. connectToAnalyser(analyser: Analyser): void;
  115935. }
  115936. }
  115937. declare module BABYLON {
  115938. /**
  115939. * Interface used to present a loading screen while loading a scene
  115940. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115941. */
  115942. export interface ILoadingScreen {
  115943. /**
  115944. * Function called to display the loading screen
  115945. */
  115946. displayLoadingUI: () => void;
  115947. /**
  115948. * Function called to hide the loading screen
  115949. */
  115950. hideLoadingUI: () => void;
  115951. /**
  115952. * Gets or sets the color to use for the background
  115953. */
  115954. loadingUIBackgroundColor: string;
  115955. /**
  115956. * Gets or sets the text to display while loading
  115957. */
  115958. loadingUIText: string;
  115959. }
  115960. /**
  115961. * Class used for the default loading screen
  115962. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115963. */
  115964. export class DefaultLoadingScreen implements ILoadingScreen {
  115965. private _renderingCanvas;
  115966. private _loadingText;
  115967. private _loadingDivBackgroundColor;
  115968. private _loadingDiv;
  115969. private _loadingTextDiv;
  115970. /** Gets or sets the logo url to use for the default loading screen */
  115971. static DefaultLogoUrl: string;
  115972. /** Gets or sets the spinner url to use for the default loading screen */
  115973. static DefaultSpinnerUrl: string;
  115974. /**
  115975. * Creates a new default loading screen
  115976. * @param _renderingCanvas defines the canvas used to render the scene
  115977. * @param _loadingText defines the default text to display
  115978. * @param _loadingDivBackgroundColor defines the default background color
  115979. */
  115980. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115981. /**
  115982. * Function called to display the loading screen
  115983. */
  115984. displayLoadingUI(): void;
  115985. /**
  115986. * Function called to hide the loading screen
  115987. */
  115988. hideLoadingUI(): void;
  115989. /**
  115990. * Gets or sets the text to display while loading
  115991. */
  115992. set loadingUIText(text: string);
  115993. get loadingUIText(): string;
  115994. /**
  115995. * Gets or sets the color to use for the background
  115996. */
  115997. get loadingUIBackgroundColor(): string;
  115998. set loadingUIBackgroundColor(color: string);
  115999. private _resizeLoadingUI;
  116000. }
  116001. }
  116002. declare module BABYLON {
  116003. /**
  116004. * Interface for any object that can request an animation frame
  116005. */
  116006. export interface ICustomAnimationFrameRequester {
  116007. /**
  116008. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116009. */
  116010. renderFunction?: Function;
  116011. /**
  116012. * Called to request the next frame to render to
  116013. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116014. */
  116015. requestAnimationFrame: Function;
  116016. /**
  116017. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116018. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116019. */
  116020. requestID?: number;
  116021. }
  116022. }
  116023. declare module BABYLON {
  116024. /**
  116025. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116026. */
  116027. export class PerformanceMonitor {
  116028. private _enabled;
  116029. private _rollingFrameTime;
  116030. private _lastFrameTimeMs;
  116031. /**
  116032. * constructor
  116033. * @param frameSampleSize The number of samples required to saturate the sliding window
  116034. */
  116035. constructor(frameSampleSize?: number);
  116036. /**
  116037. * Samples current frame
  116038. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116039. */
  116040. sampleFrame(timeMs?: number): void;
  116041. /**
  116042. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116043. */
  116044. get averageFrameTime(): number;
  116045. /**
  116046. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116047. */
  116048. get averageFrameTimeVariance(): number;
  116049. /**
  116050. * Returns the frame time of the most recent frame
  116051. */
  116052. get instantaneousFrameTime(): number;
  116053. /**
  116054. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116055. */
  116056. get averageFPS(): number;
  116057. /**
  116058. * Returns the average framerate in frames per second using the most recent frame time
  116059. */
  116060. get instantaneousFPS(): number;
  116061. /**
  116062. * Returns true if enough samples have been taken to completely fill the sliding window
  116063. */
  116064. get isSaturated(): boolean;
  116065. /**
  116066. * Enables contributions to the sliding window sample set
  116067. */
  116068. enable(): void;
  116069. /**
  116070. * Disables contributions to the sliding window sample set
  116071. * Samples will not be interpolated over the disabled period
  116072. */
  116073. disable(): void;
  116074. /**
  116075. * Returns true if sampling is enabled
  116076. */
  116077. get isEnabled(): boolean;
  116078. /**
  116079. * Resets performance monitor
  116080. */
  116081. reset(): void;
  116082. }
  116083. /**
  116084. * RollingAverage
  116085. *
  116086. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116087. */
  116088. export class RollingAverage {
  116089. /**
  116090. * Current average
  116091. */
  116092. average: number;
  116093. /**
  116094. * Current variance
  116095. */
  116096. variance: number;
  116097. protected _samples: Array<number>;
  116098. protected _sampleCount: number;
  116099. protected _pos: number;
  116100. protected _m2: number;
  116101. /**
  116102. * constructor
  116103. * @param length The number of samples required to saturate the sliding window
  116104. */
  116105. constructor(length: number);
  116106. /**
  116107. * Adds a sample to the sample set
  116108. * @param v The sample value
  116109. */
  116110. add(v: number): void;
  116111. /**
  116112. * Returns previously added values or null if outside of history or outside the sliding window domain
  116113. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116114. * @return Value previously recorded with add() or null if outside of range
  116115. */
  116116. history(i: number): number;
  116117. /**
  116118. * Returns true if enough samples have been taken to completely fill the sliding window
  116119. * @return true if sample-set saturated
  116120. */
  116121. isSaturated(): boolean;
  116122. /**
  116123. * Resets the rolling average (equivalent to 0 samples taken so far)
  116124. */
  116125. reset(): void;
  116126. /**
  116127. * Wraps a value around the sample range boundaries
  116128. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  116129. * @return Wrapped position in sample range
  116130. */
  116131. protected _wrapPosition(i: number): number;
  116132. }
  116133. }
  116134. declare module BABYLON {
  116135. /**
  116136. * This class is used to track a performance counter which is number based.
  116137. * The user has access to many properties which give statistics of different nature.
  116138. *
  116139. * The implementer can track two kinds of Performance Counter: time and count.
  116140. * 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.
  116141. * 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.
  116142. */
  116143. export class PerfCounter {
  116144. /**
  116145. * Gets or sets a global boolean to turn on and off all the counters
  116146. */
  116147. static Enabled: boolean;
  116148. /**
  116149. * Returns the smallest value ever
  116150. */
  116151. get min(): number;
  116152. /**
  116153. * Returns the biggest value ever
  116154. */
  116155. get max(): number;
  116156. /**
  116157. * Returns the average value since the performance counter is running
  116158. */
  116159. get average(): number;
  116160. /**
  116161. * Returns the average value of the last second the counter was monitored
  116162. */
  116163. get lastSecAverage(): number;
  116164. /**
  116165. * Returns the current value
  116166. */
  116167. get current(): number;
  116168. /**
  116169. * Gets the accumulated total
  116170. */
  116171. get total(): number;
  116172. /**
  116173. * Gets the total value count
  116174. */
  116175. get count(): number;
  116176. /**
  116177. * Creates a new counter
  116178. */
  116179. constructor();
  116180. /**
  116181. * Call this method to start monitoring a new frame.
  116182. * 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.
  116183. */
  116184. fetchNewFrame(): void;
  116185. /**
  116186. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116187. * @param newCount the count value to add to the monitored count
  116188. * @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.
  116189. */
  116190. addCount(newCount: number, fetchResult: boolean): void;
  116191. /**
  116192. * Start monitoring this performance counter
  116193. */
  116194. beginMonitoring(): void;
  116195. /**
  116196. * Compute the time lapsed since the previous beginMonitoring() call.
  116197. * @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
  116198. */
  116199. endMonitoring(newFrame?: boolean): void;
  116200. private _fetchResult;
  116201. private _startMonitoringTime;
  116202. private _min;
  116203. private _max;
  116204. private _average;
  116205. private _current;
  116206. private _totalValueCount;
  116207. private _totalAccumulated;
  116208. private _lastSecAverage;
  116209. private _lastSecAccumulated;
  116210. private _lastSecTime;
  116211. private _lastSecValueCount;
  116212. }
  116213. }
  116214. declare module BABYLON {
  116215. interface ThinEngine {
  116216. /**
  116217. * Sets alpha constants used by some alpha blending modes
  116218. * @param r defines the red component
  116219. * @param g defines the green component
  116220. * @param b defines the blue component
  116221. * @param a defines the alpha component
  116222. */
  116223. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  116224. /**
  116225. * Sets the current alpha mode
  116226. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116227. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116228. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116229. */
  116230. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116231. /**
  116232. * Gets the current alpha mode
  116233. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116234. * @returns the current alpha mode
  116235. */
  116236. getAlphaMode(): number;
  116237. /**
  116238. * Sets the current alpha equation
  116239. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  116240. */
  116241. setAlphaEquation(equation: number): void;
  116242. /**
  116243. * Gets the current alpha equation.
  116244. * @returns the current alpha equation
  116245. */
  116246. getAlphaEquation(): number;
  116247. }
  116248. }
  116249. declare module BABYLON {
  116250. interface ThinEngine {
  116251. /** @hidden */
  116252. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116253. }
  116254. }
  116255. declare module BABYLON {
  116256. /**
  116257. * Defines the interface used by display changed events
  116258. */
  116259. export interface IDisplayChangedEventArgs {
  116260. /** Gets the vrDisplay object (if any) */
  116261. vrDisplay: Nullable<any>;
  116262. /** Gets a boolean indicating if webVR is supported */
  116263. vrSupported: boolean;
  116264. }
  116265. /**
  116266. * Defines the interface used by objects containing a viewport (like a camera)
  116267. */
  116268. interface IViewportOwnerLike {
  116269. /**
  116270. * Gets or sets the viewport
  116271. */
  116272. viewport: IViewportLike;
  116273. }
  116274. /**
  116275. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116276. */
  116277. export class Engine extends ThinEngine {
  116278. /** Defines that alpha blending is disabled */
  116279. static readonly ALPHA_DISABLE: number;
  116280. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116281. static readonly ALPHA_ADD: number;
  116282. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116283. static readonly ALPHA_COMBINE: number;
  116284. /** Defines that alpha blending to DEST - SRC * DEST */
  116285. static readonly ALPHA_SUBTRACT: number;
  116286. /** Defines that alpha blending to SRC * DEST */
  116287. static readonly ALPHA_MULTIPLY: number;
  116288. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116289. static readonly ALPHA_MAXIMIZED: number;
  116290. /** Defines that alpha blending to SRC + DEST */
  116291. static readonly ALPHA_ONEONE: number;
  116292. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116293. static readonly ALPHA_PREMULTIPLIED: number;
  116294. /**
  116295. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116296. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116297. */
  116298. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116299. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116300. static readonly ALPHA_INTERPOLATE: number;
  116301. /**
  116302. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116303. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116304. */
  116305. static readonly ALPHA_SCREENMODE: number;
  116306. /** Defines that the ressource is not delayed*/
  116307. static readonly DELAYLOADSTATE_NONE: number;
  116308. /** Defines that the ressource was successfully delay loaded */
  116309. static readonly DELAYLOADSTATE_LOADED: number;
  116310. /** Defines that the ressource is currently delay loading */
  116311. static readonly DELAYLOADSTATE_LOADING: number;
  116312. /** Defines that the ressource is delayed and has not started loading */
  116313. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116314. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116315. static readonly NEVER: number;
  116316. /** 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 */
  116317. static readonly ALWAYS: number;
  116318. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116319. static readonly LESS: number;
  116320. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116321. static readonly EQUAL: number;
  116322. /** 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 */
  116323. static readonly LEQUAL: number;
  116324. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116325. static readonly GREATER: number;
  116326. /** 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 */
  116327. static readonly GEQUAL: number;
  116328. /** 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 */
  116329. static readonly NOTEQUAL: number;
  116330. /** Passed to stencilOperation to specify that stencil value must be kept */
  116331. static readonly KEEP: number;
  116332. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116333. static readonly REPLACE: number;
  116334. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116335. static readonly INCR: number;
  116336. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116337. static readonly DECR: number;
  116338. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116339. static readonly INVERT: number;
  116340. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116341. static readonly INCR_WRAP: number;
  116342. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116343. static readonly DECR_WRAP: number;
  116344. /** Texture is not repeating outside of 0..1 UVs */
  116345. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116346. /** Texture is repeating outside of 0..1 UVs */
  116347. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116348. /** Texture is repeating and mirrored */
  116349. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116350. /** ALPHA */
  116351. static readonly TEXTUREFORMAT_ALPHA: number;
  116352. /** LUMINANCE */
  116353. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116354. /** LUMINANCE_ALPHA */
  116355. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116356. /** RGB */
  116357. static readonly TEXTUREFORMAT_RGB: number;
  116358. /** RGBA */
  116359. static readonly TEXTUREFORMAT_RGBA: number;
  116360. /** RED */
  116361. static readonly TEXTUREFORMAT_RED: number;
  116362. /** RED (2nd reference) */
  116363. static readonly TEXTUREFORMAT_R: number;
  116364. /** RG */
  116365. static readonly TEXTUREFORMAT_RG: number;
  116366. /** RED_INTEGER */
  116367. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116368. /** RED_INTEGER (2nd reference) */
  116369. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116370. /** RG_INTEGER */
  116371. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116372. /** RGB_INTEGER */
  116373. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116374. /** RGBA_INTEGER */
  116375. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116376. /** UNSIGNED_BYTE */
  116377. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116378. /** UNSIGNED_BYTE (2nd reference) */
  116379. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116380. /** FLOAT */
  116381. static readonly TEXTURETYPE_FLOAT: number;
  116382. /** HALF_FLOAT */
  116383. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116384. /** BYTE */
  116385. static readonly TEXTURETYPE_BYTE: number;
  116386. /** SHORT */
  116387. static readonly TEXTURETYPE_SHORT: number;
  116388. /** UNSIGNED_SHORT */
  116389. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116390. /** INT */
  116391. static readonly TEXTURETYPE_INT: number;
  116392. /** UNSIGNED_INT */
  116393. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116394. /** UNSIGNED_SHORT_4_4_4_4 */
  116395. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116396. /** UNSIGNED_SHORT_5_5_5_1 */
  116397. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116398. /** UNSIGNED_SHORT_5_6_5 */
  116399. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116400. /** UNSIGNED_INT_2_10_10_10_REV */
  116401. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116402. /** UNSIGNED_INT_24_8 */
  116403. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116404. /** UNSIGNED_INT_10F_11F_11F_REV */
  116405. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116406. /** UNSIGNED_INT_5_9_9_9_REV */
  116407. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116408. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116409. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116410. /** nearest is mag = nearest and min = nearest and mip = linear */
  116411. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116412. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116413. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116414. /** Trilinear is mag = linear and min = linear and mip = linear */
  116415. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116416. /** nearest is mag = nearest and min = nearest and mip = linear */
  116417. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116418. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116419. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116420. /** Trilinear is mag = linear and min = linear and mip = linear */
  116421. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116422. /** mag = nearest and min = nearest and mip = nearest */
  116423. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116424. /** mag = nearest and min = linear and mip = nearest */
  116425. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116426. /** mag = nearest and min = linear and mip = linear */
  116427. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116428. /** mag = nearest and min = linear and mip = none */
  116429. static readonly TEXTURE_NEAREST_LINEAR: number;
  116430. /** mag = nearest and min = nearest and mip = none */
  116431. static readonly TEXTURE_NEAREST_NEAREST: number;
  116432. /** mag = linear and min = nearest and mip = nearest */
  116433. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116434. /** mag = linear and min = nearest and mip = linear */
  116435. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116436. /** mag = linear and min = linear and mip = none */
  116437. static readonly TEXTURE_LINEAR_LINEAR: number;
  116438. /** mag = linear and min = nearest and mip = none */
  116439. static readonly TEXTURE_LINEAR_NEAREST: number;
  116440. /** Explicit coordinates mode */
  116441. static readonly TEXTURE_EXPLICIT_MODE: number;
  116442. /** Spherical coordinates mode */
  116443. static readonly TEXTURE_SPHERICAL_MODE: number;
  116444. /** Planar coordinates mode */
  116445. static readonly TEXTURE_PLANAR_MODE: number;
  116446. /** Cubic coordinates mode */
  116447. static readonly TEXTURE_CUBIC_MODE: number;
  116448. /** Projection coordinates mode */
  116449. static readonly TEXTURE_PROJECTION_MODE: number;
  116450. /** Skybox coordinates mode */
  116451. static readonly TEXTURE_SKYBOX_MODE: number;
  116452. /** Inverse Cubic coordinates mode */
  116453. static readonly TEXTURE_INVCUBIC_MODE: number;
  116454. /** Equirectangular coordinates mode */
  116455. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116456. /** Equirectangular Fixed coordinates mode */
  116457. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116458. /** Equirectangular Fixed Mirrored coordinates mode */
  116459. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116460. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116461. static readonly SCALEMODE_FLOOR: number;
  116462. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116463. static readonly SCALEMODE_NEAREST: number;
  116464. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116465. static readonly SCALEMODE_CEILING: number;
  116466. /**
  116467. * Returns the current npm package of the sdk
  116468. */
  116469. static get NpmPackage(): string;
  116470. /**
  116471. * Returns the current version of the framework
  116472. */
  116473. static get Version(): string;
  116474. /** Gets the list of created engines */
  116475. static get Instances(): Engine[];
  116476. /**
  116477. * Gets the latest created engine
  116478. */
  116479. static get LastCreatedEngine(): Nullable<Engine>;
  116480. /**
  116481. * Gets the latest created scene
  116482. */
  116483. static get LastCreatedScene(): Nullable<Scene>;
  116484. /**
  116485. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116486. * @param flag defines which part of the materials must be marked as dirty
  116487. * @param predicate defines a predicate used to filter which materials should be affected
  116488. */
  116489. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116490. /**
  116491. * Method called to create the default loading screen.
  116492. * This can be overriden in your own app.
  116493. * @param canvas The rendering canvas element
  116494. * @returns The loading screen
  116495. */
  116496. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116497. /**
  116498. * Method called to create the default rescale post process on each engine.
  116499. */
  116500. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116501. /**
  116502. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116503. **/
  116504. enableOfflineSupport: boolean;
  116505. /**
  116506. * 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)
  116507. **/
  116508. disableManifestCheck: boolean;
  116509. /**
  116510. * Gets the list of created scenes
  116511. */
  116512. scenes: Scene[];
  116513. /**
  116514. * Event raised when a new scene is created
  116515. */
  116516. onNewSceneAddedObservable: Observable<Scene>;
  116517. /**
  116518. * Gets the list of created postprocesses
  116519. */
  116520. postProcesses: PostProcess[];
  116521. /**
  116522. * Gets a boolean indicating if the pointer is currently locked
  116523. */
  116524. isPointerLock: boolean;
  116525. /**
  116526. * Observable event triggered each time the rendering canvas is resized
  116527. */
  116528. onResizeObservable: Observable<Engine>;
  116529. /**
  116530. * Observable event triggered each time the canvas loses focus
  116531. */
  116532. onCanvasBlurObservable: Observable<Engine>;
  116533. /**
  116534. * Observable event triggered each time the canvas gains focus
  116535. */
  116536. onCanvasFocusObservable: Observable<Engine>;
  116537. /**
  116538. * Observable event triggered each time the canvas receives pointerout event
  116539. */
  116540. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116541. /**
  116542. * Observable raised when the engine begins a new frame
  116543. */
  116544. onBeginFrameObservable: Observable<Engine>;
  116545. /**
  116546. * If set, will be used to request the next animation frame for the render loop
  116547. */
  116548. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116549. /**
  116550. * Observable raised when the engine ends the current frame
  116551. */
  116552. onEndFrameObservable: Observable<Engine>;
  116553. /**
  116554. * Observable raised when the engine is about to compile a shader
  116555. */
  116556. onBeforeShaderCompilationObservable: Observable<Engine>;
  116557. /**
  116558. * Observable raised when the engine has jsut compiled a shader
  116559. */
  116560. onAfterShaderCompilationObservable: Observable<Engine>;
  116561. /**
  116562. * Gets the audio engine
  116563. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116564. * @ignorenaming
  116565. */
  116566. static audioEngine: IAudioEngine;
  116567. /**
  116568. * Default AudioEngine factory responsible of creating the Audio Engine.
  116569. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116570. */
  116571. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116572. /**
  116573. * Default offline support factory responsible of creating a tool used to store data locally.
  116574. * By default, this will create a Database object if the workload has been embedded.
  116575. */
  116576. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116577. private _loadingScreen;
  116578. private _pointerLockRequested;
  116579. private _rescalePostProcess;
  116580. private _deterministicLockstep;
  116581. private _lockstepMaxSteps;
  116582. private _timeStep;
  116583. protected get _supportsHardwareTextureRescaling(): boolean;
  116584. private _fps;
  116585. private _deltaTime;
  116586. /** @hidden */
  116587. _drawCalls: PerfCounter;
  116588. /** 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 */
  116589. canvasTabIndex: number;
  116590. /**
  116591. * Turn this value on if you want to pause FPS computation when in background
  116592. */
  116593. disablePerformanceMonitorInBackground: boolean;
  116594. private _performanceMonitor;
  116595. /**
  116596. * Gets the performance monitor attached to this engine
  116597. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116598. */
  116599. get performanceMonitor(): PerformanceMonitor;
  116600. private _onFocus;
  116601. private _onBlur;
  116602. private _onCanvasPointerOut;
  116603. private _onCanvasBlur;
  116604. private _onCanvasFocus;
  116605. private _onFullscreenChange;
  116606. private _onPointerLockChange;
  116607. /**
  116608. * Gets the HTML element used to attach event listeners
  116609. * @returns a HTML element
  116610. */
  116611. getInputElement(): Nullable<HTMLElement>;
  116612. /**
  116613. * Creates a new engine
  116614. * @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
  116615. * @param antialias defines enable antialiasing (default: false)
  116616. * @param options defines further options to be sent to the getContext() function
  116617. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116618. */
  116619. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116620. /**
  116621. * Gets current aspect ratio
  116622. * @param viewportOwner defines the camera to use to get the aspect ratio
  116623. * @param useScreen defines if screen size must be used (or the current render target if any)
  116624. * @returns a number defining the aspect ratio
  116625. */
  116626. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116627. /**
  116628. * Gets current screen aspect ratio
  116629. * @returns a number defining the aspect ratio
  116630. */
  116631. getScreenAspectRatio(): number;
  116632. /**
  116633. * Gets the client rect of the HTML canvas attached with the current webGL context
  116634. * @returns a client rectanglee
  116635. */
  116636. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116637. /**
  116638. * Gets the client rect of the HTML element used for events
  116639. * @returns a client rectanglee
  116640. */
  116641. getInputElementClientRect(): Nullable<ClientRect>;
  116642. /**
  116643. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116644. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116645. * @returns true if engine is in deterministic lock step mode
  116646. */
  116647. isDeterministicLockStep(): boolean;
  116648. /**
  116649. * Gets the max steps when engine is running in deterministic lock step
  116650. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116651. * @returns the max steps
  116652. */
  116653. getLockstepMaxSteps(): number;
  116654. /**
  116655. * Returns the time in ms between steps when using deterministic lock step.
  116656. * @returns time step in (ms)
  116657. */
  116658. getTimeStep(): number;
  116659. /**
  116660. * Force the mipmap generation for the given render target texture
  116661. * @param texture defines the render target texture to use
  116662. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116663. */
  116664. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116665. /** States */
  116666. /**
  116667. * Set various states to the webGL context
  116668. * @param culling defines backface culling state
  116669. * @param zOffset defines the value to apply to zOffset (0 by default)
  116670. * @param force defines if states must be applied even if cache is up to date
  116671. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116672. */
  116673. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116674. /**
  116675. * Set the z offset to apply to current rendering
  116676. * @param value defines the offset to apply
  116677. */
  116678. setZOffset(value: number): void;
  116679. /**
  116680. * Gets the current value of the zOffset
  116681. * @returns the current zOffset state
  116682. */
  116683. getZOffset(): number;
  116684. /**
  116685. * Enable or disable depth buffering
  116686. * @param enable defines the state to set
  116687. */
  116688. setDepthBuffer(enable: boolean): void;
  116689. /**
  116690. * Gets a boolean indicating if depth writing is enabled
  116691. * @returns the current depth writing state
  116692. */
  116693. getDepthWrite(): boolean;
  116694. /**
  116695. * Enable or disable depth writing
  116696. * @param enable defines the state to set
  116697. */
  116698. setDepthWrite(enable: boolean): void;
  116699. /**
  116700. * Gets a boolean indicating if stencil buffer is enabled
  116701. * @returns the current stencil buffer state
  116702. */
  116703. getStencilBuffer(): boolean;
  116704. /**
  116705. * Enable or disable the stencil buffer
  116706. * @param enable defines if the stencil buffer must be enabled or disabled
  116707. */
  116708. setStencilBuffer(enable: boolean): void;
  116709. /**
  116710. * Gets the current stencil mask
  116711. * @returns a number defining the new stencil mask to use
  116712. */
  116713. getStencilMask(): number;
  116714. /**
  116715. * Sets the current stencil mask
  116716. * @param mask defines the new stencil mask to use
  116717. */
  116718. setStencilMask(mask: number): void;
  116719. /**
  116720. * Gets the current stencil function
  116721. * @returns a number defining the stencil function to use
  116722. */
  116723. getStencilFunction(): number;
  116724. /**
  116725. * Gets the current stencil reference value
  116726. * @returns a number defining the stencil reference value to use
  116727. */
  116728. getStencilFunctionReference(): number;
  116729. /**
  116730. * Gets the current stencil mask
  116731. * @returns a number defining the stencil mask to use
  116732. */
  116733. getStencilFunctionMask(): number;
  116734. /**
  116735. * Sets the current stencil function
  116736. * @param stencilFunc defines the new stencil function to use
  116737. */
  116738. setStencilFunction(stencilFunc: number): void;
  116739. /**
  116740. * Sets the current stencil reference
  116741. * @param reference defines the new stencil reference to use
  116742. */
  116743. setStencilFunctionReference(reference: number): void;
  116744. /**
  116745. * Sets the current stencil mask
  116746. * @param mask defines the new stencil mask to use
  116747. */
  116748. setStencilFunctionMask(mask: number): void;
  116749. /**
  116750. * Gets the current stencil operation when stencil fails
  116751. * @returns a number defining stencil operation to use when stencil fails
  116752. */
  116753. getStencilOperationFail(): number;
  116754. /**
  116755. * Gets the current stencil operation when depth fails
  116756. * @returns a number defining stencil operation to use when depth fails
  116757. */
  116758. getStencilOperationDepthFail(): number;
  116759. /**
  116760. * Gets the current stencil operation when stencil passes
  116761. * @returns a number defining stencil operation to use when stencil passes
  116762. */
  116763. getStencilOperationPass(): number;
  116764. /**
  116765. * Sets the stencil operation to use when stencil fails
  116766. * @param operation defines the stencil operation to use when stencil fails
  116767. */
  116768. setStencilOperationFail(operation: number): void;
  116769. /**
  116770. * Sets the stencil operation to use when depth fails
  116771. * @param operation defines the stencil operation to use when depth fails
  116772. */
  116773. setStencilOperationDepthFail(operation: number): void;
  116774. /**
  116775. * Sets the stencil operation to use when stencil passes
  116776. * @param operation defines the stencil operation to use when stencil passes
  116777. */
  116778. setStencilOperationPass(operation: number): void;
  116779. /**
  116780. * Sets a boolean indicating if the dithering state is enabled or disabled
  116781. * @param value defines the dithering state
  116782. */
  116783. setDitheringState(value: boolean): void;
  116784. /**
  116785. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116786. * @param value defines the rasterizer state
  116787. */
  116788. setRasterizerState(value: boolean): void;
  116789. /**
  116790. * Gets the current depth function
  116791. * @returns a number defining the depth function
  116792. */
  116793. getDepthFunction(): Nullable<number>;
  116794. /**
  116795. * Sets the current depth function
  116796. * @param depthFunc defines the function to use
  116797. */
  116798. setDepthFunction(depthFunc: number): void;
  116799. /**
  116800. * Sets the current depth function to GREATER
  116801. */
  116802. setDepthFunctionToGreater(): void;
  116803. /**
  116804. * Sets the current depth function to GEQUAL
  116805. */
  116806. setDepthFunctionToGreaterOrEqual(): void;
  116807. /**
  116808. * Sets the current depth function to LESS
  116809. */
  116810. setDepthFunctionToLess(): void;
  116811. /**
  116812. * Sets the current depth function to LEQUAL
  116813. */
  116814. setDepthFunctionToLessOrEqual(): void;
  116815. private _cachedStencilBuffer;
  116816. private _cachedStencilFunction;
  116817. private _cachedStencilMask;
  116818. private _cachedStencilOperationPass;
  116819. private _cachedStencilOperationFail;
  116820. private _cachedStencilOperationDepthFail;
  116821. private _cachedStencilReference;
  116822. /**
  116823. * Caches the the state of the stencil buffer
  116824. */
  116825. cacheStencilState(): void;
  116826. /**
  116827. * Restores the state of the stencil buffer
  116828. */
  116829. restoreStencilState(): void;
  116830. /**
  116831. * Directly set the WebGL Viewport
  116832. * @param x defines the x coordinate of the viewport (in screen space)
  116833. * @param y defines the y coordinate of the viewport (in screen space)
  116834. * @param width defines the width of the viewport (in screen space)
  116835. * @param height defines the height of the viewport (in screen space)
  116836. * @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
  116837. */
  116838. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116839. /**
  116840. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116841. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116842. * @param y defines the y-coordinate of the corner of the clear rectangle
  116843. * @param width defines the width of the clear rectangle
  116844. * @param height defines the height of the clear rectangle
  116845. * @param clearColor defines the clear color
  116846. */
  116847. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116848. /**
  116849. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116850. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116851. * @param y defines the y-coordinate of the corner of the clear rectangle
  116852. * @param width defines the width of the clear rectangle
  116853. * @param height defines the height of the clear rectangle
  116854. */
  116855. enableScissor(x: number, y: number, width: number, height: number): void;
  116856. /**
  116857. * Disable previously set scissor test rectangle
  116858. */
  116859. disableScissor(): void;
  116860. protected _reportDrawCall(): void;
  116861. /**
  116862. * Initializes a webVR display and starts listening to display change events
  116863. * The onVRDisplayChangedObservable will be notified upon these changes
  116864. * @returns The onVRDisplayChangedObservable
  116865. */
  116866. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116867. /** @hidden */
  116868. _prepareVRComponent(): void;
  116869. /** @hidden */
  116870. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116871. /** @hidden */
  116872. _submitVRFrame(): void;
  116873. /**
  116874. * Call this function to leave webVR mode
  116875. * Will do nothing if webVR is not supported or if there is no webVR device
  116876. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116877. */
  116878. disableVR(): void;
  116879. /**
  116880. * Gets a boolean indicating that the system is in VR mode and is presenting
  116881. * @returns true if VR mode is engaged
  116882. */
  116883. isVRPresenting(): boolean;
  116884. /** @hidden */
  116885. _requestVRFrame(): void;
  116886. /** @hidden */
  116887. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116888. /**
  116889. * Gets the source code of the vertex shader associated with a specific webGL program
  116890. * @param program defines the program to use
  116891. * @returns a string containing the source code of the vertex shader associated with the program
  116892. */
  116893. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116894. /**
  116895. * Gets the source code of the fragment shader associated with a specific webGL program
  116896. * @param program defines the program to use
  116897. * @returns a string containing the source code of the fragment shader associated with the program
  116898. */
  116899. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116900. /**
  116901. * Sets a depth stencil texture from a render target to the according uniform.
  116902. * @param channel The texture channel
  116903. * @param uniform The uniform to set
  116904. * @param texture The render target texture containing the depth stencil texture to apply
  116905. */
  116906. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116907. /**
  116908. * Sets a texture to the webGL context from a postprocess
  116909. * @param channel defines the channel to use
  116910. * @param postProcess defines the source postprocess
  116911. */
  116912. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116913. /**
  116914. * Binds the output of the passed in post process to the texture channel specified
  116915. * @param channel The channel the texture should be bound to
  116916. * @param postProcess The post process which's output should be bound
  116917. */
  116918. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116919. protected _rebuildBuffers(): void;
  116920. /** @hidden */
  116921. _renderFrame(): void;
  116922. _renderLoop(): void;
  116923. /** @hidden */
  116924. _renderViews(): boolean;
  116925. /**
  116926. * Toggle full screen mode
  116927. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116928. */
  116929. switchFullscreen(requestPointerLock: boolean): void;
  116930. /**
  116931. * Enters full screen mode
  116932. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116933. */
  116934. enterFullscreen(requestPointerLock: boolean): void;
  116935. /**
  116936. * Exits full screen mode
  116937. */
  116938. exitFullscreen(): void;
  116939. /**
  116940. * Enters Pointerlock mode
  116941. */
  116942. enterPointerlock(): void;
  116943. /**
  116944. * Exits Pointerlock mode
  116945. */
  116946. exitPointerlock(): void;
  116947. /**
  116948. * Begin a new frame
  116949. */
  116950. beginFrame(): void;
  116951. /**
  116952. * Enf the current frame
  116953. */
  116954. endFrame(): void;
  116955. resize(): void;
  116956. /**
  116957. * Force a specific size of the canvas
  116958. * @param width defines the new canvas' width
  116959. * @param height defines the new canvas' height
  116960. * @returns true if the size was changed
  116961. */
  116962. setSize(width: number, height: number): boolean;
  116963. /**
  116964. * Updates a dynamic vertex buffer.
  116965. * @param vertexBuffer the vertex buffer to update
  116966. * @param data the data used to update the vertex buffer
  116967. * @param byteOffset the byte offset of the data
  116968. * @param byteLength the byte length of the data
  116969. */
  116970. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116971. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116972. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116973. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116974. _releaseTexture(texture: InternalTexture): void;
  116975. /**
  116976. * @hidden
  116977. * Rescales a texture
  116978. * @param source input texutre
  116979. * @param destination destination texture
  116980. * @param scene scene to use to render the resize
  116981. * @param internalFormat format to use when resizing
  116982. * @param onComplete callback to be called when resize has completed
  116983. */
  116984. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116985. /**
  116986. * Gets the current framerate
  116987. * @returns a number representing the framerate
  116988. */
  116989. getFps(): number;
  116990. /**
  116991. * Gets the time spent between current and previous frame
  116992. * @returns a number representing the delta time in ms
  116993. */
  116994. getDeltaTime(): number;
  116995. private _measureFps;
  116996. /** @hidden */
  116997. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116998. /**
  116999. * Update a dynamic index buffer
  117000. * @param indexBuffer defines the target index buffer
  117001. * @param indices defines the data to update
  117002. * @param offset defines the offset in the target index buffer where update should start
  117003. */
  117004. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117005. /**
  117006. * Updates the sample count of a render target texture
  117007. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117008. * @param texture defines the texture to update
  117009. * @param samples defines the sample count to set
  117010. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117011. */
  117012. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117013. /**
  117014. * Updates a depth texture Comparison Mode and Function.
  117015. * If the comparison Function is equal to 0, the mode will be set to none.
  117016. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117017. * @param texture The texture to set the comparison function for
  117018. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117019. */
  117020. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117021. /**
  117022. * Creates a webGL buffer to use with instanciation
  117023. * @param capacity defines the size of the buffer
  117024. * @returns the webGL buffer
  117025. */
  117026. createInstancesBuffer(capacity: number): DataBuffer;
  117027. /**
  117028. * Delete a webGL buffer used with instanciation
  117029. * @param buffer defines the webGL buffer to delete
  117030. */
  117031. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117032. private _clientWaitAsync;
  117033. /** @hidden */
  117034. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117035. dispose(): void;
  117036. private _disableTouchAction;
  117037. /**
  117038. * Display the loading screen
  117039. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117040. */
  117041. displayLoadingUI(): void;
  117042. /**
  117043. * Hide the loading screen
  117044. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117045. */
  117046. hideLoadingUI(): void;
  117047. /**
  117048. * Gets the current loading screen object
  117049. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117050. */
  117051. get loadingScreen(): ILoadingScreen;
  117052. /**
  117053. * Sets the current loading screen object
  117054. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117055. */
  117056. set loadingScreen(loadingScreen: ILoadingScreen);
  117057. /**
  117058. * Sets the current loading screen text
  117059. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117060. */
  117061. set loadingUIText(text: string);
  117062. /**
  117063. * Sets the current loading screen background color
  117064. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117065. */
  117066. set loadingUIBackgroundColor(color: string);
  117067. /** Pointerlock and fullscreen */
  117068. /**
  117069. * Ask the browser to promote the current element to pointerlock mode
  117070. * @param element defines the DOM element to promote
  117071. */
  117072. static _RequestPointerlock(element: HTMLElement): void;
  117073. /**
  117074. * Asks the browser to exit pointerlock mode
  117075. */
  117076. static _ExitPointerlock(): void;
  117077. /**
  117078. * Ask the browser to promote the current element to fullscreen rendering mode
  117079. * @param element defines the DOM element to promote
  117080. */
  117081. static _RequestFullscreen(element: HTMLElement): void;
  117082. /**
  117083. * Asks the browser to exit fullscreen mode
  117084. */
  117085. static _ExitFullscreen(): void;
  117086. }
  117087. }
  117088. declare module BABYLON {
  117089. /**
  117090. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117091. * during the life time of the application.
  117092. */
  117093. export class EngineStore {
  117094. /** Gets the list of created engines */
  117095. static Instances: Engine[];
  117096. /** @hidden */
  117097. static _LastCreatedScene: Nullable<Scene>;
  117098. /**
  117099. * Gets the latest created engine
  117100. */
  117101. static get LastCreatedEngine(): Nullable<Engine>;
  117102. /**
  117103. * Gets the latest created scene
  117104. */
  117105. static get LastCreatedScene(): Nullable<Scene>;
  117106. /**
  117107. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117108. * @ignorenaming
  117109. */
  117110. static UseFallbackTexture: boolean;
  117111. /**
  117112. * Texture content used if a texture cannot loaded
  117113. * @ignorenaming
  117114. */
  117115. static FallbackTexture: string;
  117116. }
  117117. }
  117118. declare module BABYLON {
  117119. /**
  117120. * Helper class that provides a small promise polyfill
  117121. */
  117122. export class PromisePolyfill {
  117123. /**
  117124. * Static function used to check if the polyfill is required
  117125. * If this is the case then the function will inject the polyfill to window.Promise
  117126. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117127. */
  117128. static Apply(force?: boolean): void;
  117129. }
  117130. }
  117131. declare module BABYLON {
  117132. /**
  117133. * Interface for screenshot methods with describe argument called `size` as object with options
  117134. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117135. */
  117136. export interface IScreenshotSize {
  117137. /**
  117138. * number in pixels for canvas height
  117139. */
  117140. height?: number;
  117141. /**
  117142. * multiplier allowing render at a higher or lower resolution
  117143. * If value is defined then height and width will be ignored and taken from camera
  117144. */
  117145. precision?: number;
  117146. /**
  117147. * number in pixels for canvas width
  117148. */
  117149. width?: number;
  117150. }
  117151. }
  117152. declare module BABYLON {
  117153. interface IColor4Like {
  117154. r: float;
  117155. g: float;
  117156. b: float;
  117157. a: float;
  117158. }
  117159. /**
  117160. * Class containing a set of static utilities functions
  117161. */
  117162. export class Tools {
  117163. /**
  117164. * Gets or sets the base URL to use to load assets
  117165. */
  117166. static get BaseUrl(): string;
  117167. static set BaseUrl(value: string);
  117168. /**
  117169. * Enable/Disable Custom HTTP Request Headers globally.
  117170. * default = false
  117171. * @see CustomRequestHeaders
  117172. */
  117173. static UseCustomRequestHeaders: boolean;
  117174. /**
  117175. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117176. * i.e. when loading files, where the server/service expects an Authorization header
  117177. */
  117178. static CustomRequestHeaders: {
  117179. [key: string]: string;
  117180. };
  117181. /**
  117182. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117183. */
  117184. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117185. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117186. /**
  117187. * Default behaviour for cors in the application.
  117188. * It can be a string if the expected behavior is identical in the entire app.
  117189. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117190. */
  117191. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117192. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117193. /**
  117194. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117195. * @ignorenaming
  117196. */
  117197. static get UseFallbackTexture(): boolean;
  117198. static set UseFallbackTexture(value: boolean);
  117199. /**
  117200. * Use this object to register external classes like custom textures or material
  117201. * to allow the laoders to instantiate them
  117202. */
  117203. static get RegisteredExternalClasses(): {
  117204. [key: string]: Object;
  117205. };
  117206. static set RegisteredExternalClasses(classes: {
  117207. [key: string]: Object;
  117208. });
  117209. /**
  117210. * Texture content used if a texture cannot loaded
  117211. * @ignorenaming
  117212. */
  117213. static get fallbackTexture(): string;
  117214. static set fallbackTexture(value: string);
  117215. /**
  117216. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117217. * @param u defines the coordinate on X axis
  117218. * @param v defines the coordinate on Y axis
  117219. * @param width defines the width of the source data
  117220. * @param height defines the height of the source data
  117221. * @param pixels defines the source byte array
  117222. * @param color defines the output color
  117223. */
  117224. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117225. /**
  117226. * Interpolates between a and b via alpha
  117227. * @param a The lower value (returned when alpha = 0)
  117228. * @param b The upper value (returned when alpha = 1)
  117229. * @param alpha The interpolation-factor
  117230. * @return The mixed value
  117231. */
  117232. static Mix(a: number, b: number, alpha: number): number;
  117233. /**
  117234. * Tries to instantiate a new object from a given class name
  117235. * @param className defines the class name to instantiate
  117236. * @returns the new object or null if the system was not able to do the instantiation
  117237. */
  117238. static Instantiate(className: string): any;
  117239. /**
  117240. * Provides a slice function that will work even on IE
  117241. * @param data defines the array to slice
  117242. * @param start defines the start of the data (optional)
  117243. * @param end defines the end of the data (optional)
  117244. * @returns the new sliced array
  117245. */
  117246. static Slice<T>(data: T, start?: number, end?: number): T;
  117247. /**
  117248. * Polyfill for setImmediate
  117249. * @param action defines the action to execute after the current execution block
  117250. */
  117251. static SetImmediate(action: () => void): void;
  117252. /**
  117253. * Function indicating if a number is an exponent of 2
  117254. * @param value defines the value to test
  117255. * @returns true if the value is an exponent of 2
  117256. */
  117257. static IsExponentOfTwo(value: number): boolean;
  117258. private static _tmpFloatArray;
  117259. /**
  117260. * Returns the nearest 32-bit single precision float representation of a Number
  117261. * @param value A Number. If the parameter is of a different type, it will get converted
  117262. * to a number or to NaN if it cannot be converted
  117263. * @returns number
  117264. */
  117265. static FloatRound(value: number): number;
  117266. /**
  117267. * Extracts the filename from a path
  117268. * @param path defines the path to use
  117269. * @returns the filename
  117270. */
  117271. static GetFilename(path: string): string;
  117272. /**
  117273. * Extracts the "folder" part of a path (everything before the filename).
  117274. * @param uri The URI to extract the info from
  117275. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117276. * @returns The "folder" part of the path
  117277. */
  117278. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117279. /**
  117280. * Extracts text content from a DOM element hierarchy
  117281. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117282. */
  117283. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117284. /**
  117285. * Convert an angle in radians to degrees
  117286. * @param angle defines the angle to convert
  117287. * @returns the angle in degrees
  117288. */
  117289. static ToDegrees(angle: number): number;
  117290. /**
  117291. * Convert an angle in degrees to radians
  117292. * @param angle defines the angle to convert
  117293. * @returns the angle in radians
  117294. */
  117295. static ToRadians(angle: number): number;
  117296. /**
  117297. * Returns an array if obj is not an array
  117298. * @param obj defines the object to evaluate as an array
  117299. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117300. * @returns either obj directly if obj is an array or a new array containing obj
  117301. */
  117302. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117303. /**
  117304. * Gets the pointer prefix to use
  117305. * @param engine defines the engine we are finding the prefix for
  117306. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117307. */
  117308. static GetPointerPrefix(engine: Engine): string;
  117309. /**
  117310. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117311. * @param url define the url we are trying
  117312. * @param element define the dom element where to configure the cors policy
  117313. */
  117314. static SetCorsBehavior(url: string | string[], element: {
  117315. crossOrigin: string | null;
  117316. }): void;
  117317. /**
  117318. * Removes unwanted characters from an url
  117319. * @param url defines the url to clean
  117320. * @returns the cleaned url
  117321. */
  117322. static CleanUrl(url: string): string;
  117323. /**
  117324. * Gets or sets a function used to pre-process url before using them to load assets
  117325. */
  117326. static get PreprocessUrl(): (url: string) => string;
  117327. static set PreprocessUrl(processor: (url: string) => string);
  117328. /**
  117329. * Loads an image as an HTMLImageElement.
  117330. * @param input url string, ArrayBuffer, or Blob to load
  117331. * @param onLoad callback called when the image successfully loads
  117332. * @param onError callback called when the image fails to load
  117333. * @param offlineProvider offline provider for caching
  117334. * @param mimeType optional mime type
  117335. * @returns the HTMLImageElement of the loaded image
  117336. */
  117337. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117338. /**
  117339. * Loads a file from a url
  117340. * @param url url string, ArrayBuffer, or Blob to load
  117341. * @param onSuccess callback called when the file successfully loads
  117342. * @param onProgress callback called while file is loading (if the server supports this mode)
  117343. * @param offlineProvider defines the offline provider for caching
  117344. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117345. * @param onError callback called when the file fails to load
  117346. * @returns a file request object
  117347. */
  117348. 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;
  117349. /**
  117350. * Loads a file from a url
  117351. * @param url the file url to load
  117352. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117353. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117354. */
  117355. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117356. /**
  117357. * Load a script (identified by an url). When the url returns, the
  117358. * content of this file is added into a new script element, attached to the DOM (body element)
  117359. * @param scriptUrl defines the url of the script to laod
  117360. * @param onSuccess defines the callback called when the script is loaded
  117361. * @param onError defines the callback to call if an error occurs
  117362. * @param scriptId defines the id of the script element
  117363. */
  117364. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117365. /**
  117366. * Load an asynchronous script (identified by an url). When the url returns, the
  117367. * content of this file is added into a new script element, attached to the DOM (body element)
  117368. * @param scriptUrl defines the url of the script to laod
  117369. * @param scriptId defines the id of the script element
  117370. * @returns a promise request object
  117371. */
  117372. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117373. /**
  117374. * Loads a file from a blob
  117375. * @param fileToLoad defines the blob to use
  117376. * @param callback defines the callback to call when data is loaded
  117377. * @param progressCallback defines the callback to call during loading process
  117378. * @returns a file request object
  117379. */
  117380. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117381. /**
  117382. * Reads a file from a File object
  117383. * @param file defines the file to load
  117384. * @param onSuccess defines the callback to call when data is loaded
  117385. * @param onProgress defines the callback to call during loading process
  117386. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117387. * @param onError defines the callback to call when an error occurs
  117388. * @returns a file request object
  117389. */
  117390. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117391. /**
  117392. * Creates a data url from a given string content
  117393. * @param content defines the content to convert
  117394. * @returns the new data url link
  117395. */
  117396. static FileAsURL(content: string): string;
  117397. /**
  117398. * Format the given number to a specific decimal format
  117399. * @param value defines the number to format
  117400. * @param decimals defines the number of decimals to use
  117401. * @returns the formatted string
  117402. */
  117403. static Format(value: number, decimals?: number): string;
  117404. /**
  117405. * Tries to copy an object by duplicating every property
  117406. * @param source defines the source object
  117407. * @param destination defines the target object
  117408. * @param doNotCopyList defines a list of properties to avoid
  117409. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117410. */
  117411. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117412. /**
  117413. * Gets a boolean indicating if the given object has no own property
  117414. * @param obj defines the object to test
  117415. * @returns true if object has no own property
  117416. */
  117417. static IsEmpty(obj: any): boolean;
  117418. /**
  117419. * Function used to register events at window level
  117420. * @param windowElement defines the Window object to use
  117421. * @param events defines the events to register
  117422. */
  117423. static RegisterTopRootEvents(windowElement: Window, events: {
  117424. name: string;
  117425. handler: Nullable<(e: FocusEvent) => any>;
  117426. }[]): void;
  117427. /**
  117428. * Function used to unregister events from window level
  117429. * @param windowElement defines the Window object to use
  117430. * @param events defines the events to unregister
  117431. */
  117432. static UnregisterTopRootEvents(windowElement: Window, events: {
  117433. name: string;
  117434. handler: Nullable<(e: FocusEvent) => any>;
  117435. }[]): void;
  117436. /**
  117437. * @ignore
  117438. */
  117439. static _ScreenshotCanvas: HTMLCanvasElement;
  117440. /**
  117441. * Dumps the current bound framebuffer
  117442. * @param width defines the rendering width
  117443. * @param height defines the rendering height
  117444. * @param engine defines the hosting engine
  117445. * @param successCallback defines the callback triggered once the data are available
  117446. * @param mimeType defines the mime type of the result
  117447. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117448. */
  117449. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117450. /**
  117451. * Converts the canvas data to blob.
  117452. * This acts as a polyfill for browsers not supporting the to blob function.
  117453. * @param canvas Defines the canvas to extract the data from
  117454. * @param successCallback Defines the callback triggered once the data are available
  117455. * @param mimeType Defines the mime type of the result
  117456. */
  117457. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117458. /**
  117459. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117460. * @param successCallback defines the callback triggered once the data are available
  117461. * @param mimeType defines the mime type of the result
  117462. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117463. */
  117464. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117465. /**
  117466. * Downloads a blob in the browser
  117467. * @param blob defines the blob to download
  117468. * @param fileName defines the name of the downloaded file
  117469. */
  117470. static Download(blob: Blob, fileName: string): void;
  117471. /**
  117472. * Captures a screenshot of the current rendering
  117473. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117474. * @param engine defines the rendering engine
  117475. * @param camera defines the source camera
  117476. * @param size This parameter can be set to a single number or to an object with the
  117477. * following (optional) properties: precision, width, height. If a single number is passed,
  117478. * it will be used for both width and height. If an object is passed, the screenshot size
  117479. * will be derived from the parameters. The precision property is a multiplier allowing
  117480. * rendering at a higher or lower resolution
  117481. * @param successCallback defines the callback receives a single parameter which contains the
  117482. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117483. * src parameter of an <img> to display it
  117484. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117485. * Check your browser for supported MIME types
  117486. */
  117487. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117488. /**
  117489. * Captures a screenshot of the current rendering
  117490. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117491. * @param engine defines the rendering engine
  117492. * @param camera defines the source camera
  117493. * @param size This parameter can be set to a single number or to an object with the
  117494. * following (optional) properties: precision, width, height. If a single number is passed,
  117495. * it will be used for both width and height. If an object is passed, the screenshot size
  117496. * will be derived from the parameters. The precision property is a multiplier allowing
  117497. * rendering at a higher or lower resolution
  117498. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117499. * Check your browser for supported MIME types
  117500. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117501. * to the src parameter of an <img> to display it
  117502. */
  117503. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117504. /**
  117505. * Generates an image screenshot from the specified camera.
  117506. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117507. * @param engine The engine to use for rendering
  117508. * @param camera The camera to use for rendering
  117509. * @param size This parameter can be set to a single number or to an object with the
  117510. * following (optional) properties: precision, width, height. If a single number is passed,
  117511. * it will be used for both width and height. If an object is passed, the screenshot size
  117512. * will be derived from the parameters. The precision property is a multiplier allowing
  117513. * rendering at a higher or lower resolution
  117514. * @param successCallback The callback receives a single parameter which contains the
  117515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117516. * src parameter of an <img> to display it
  117517. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117518. * Check your browser for supported MIME types
  117519. * @param samples Texture samples (default: 1)
  117520. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117521. * @param fileName A name for for the downloaded file.
  117522. */
  117523. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117524. /**
  117525. * Generates an image screenshot from the specified camera.
  117526. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117527. * @param engine The engine to use for rendering
  117528. * @param camera The camera to use for rendering
  117529. * @param size This parameter can be set to a single number or to an object with the
  117530. * following (optional) properties: precision, width, height. If a single number is passed,
  117531. * it will be used for both width and height. If an object is passed, the screenshot size
  117532. * will be derived from the parameters. The precision property is a multiplier allowing
  117533. * rendering at a higher or lower resolution
  117534. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117535. * Check your browser for supported MIME types
  117536. * @param samples Texture samples (default: 1)
  117537. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117538. * @param fileName A name for for the downloaded file.
  117539. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117540. * to the src parameter of an <img> to display it
  117541. */
  117542. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117543. /**
  117544. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117545. * Be aware Math.random() could cause collisions, but:
  117546. * "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"
  117547. * @returns a pseudo random id
  117548. */
  117549. static RandomId(): string;
  117550. /**
  117551. * Test if the given uri is a base64 string
  117552. * @param uri The uri to test
  117553. * @return True if the uri is a base64 string or false otherwise
  117554. */
  117555. static IsBase64(uri: string): boolean;
  117556. /**
  117557. * Decode the given base64 uri.
  117558. * @param uri The uri to decode
  117559. * @return The decoded base64 data.
  117560. */
  117561. static DecodeBase64(uri: string): ArrayBuffer;
  117562. /**
  117563. * Gets the absolute url.
  117564. * @param url the input url
  117565. * @return the absolute url
  117566. */
  117567. static GetAbsoluteUrl(url: string): string;
  117568. /**
  117569. * No log
  117570. */
  117571. static readonly NoneLogLevel: number;
  117572. /**
  117573. * Only message logs
  117574. */
  117575. static readonly MessageLogLevel: number;
  117576. /**
  117577. * Only warning logs
  117578. */
  117579. static readonly WarningLogLevel: number;
  117580. /**
  117581. * Only error logs
  117582. */
  117583. static readonly ErrorLogLevel: number;
  117584. /**
  117585. * All logs
  117586. */
  117587. static readonly AllLogLevel: number;
  117588. /**
  117589. * Gets a value indicating the number of loading errors
  117590. * @ignorenaming
  117591. */
  117592. static get errorsCount(): number;
  117593. /**
  117594. * Callback called when a new log is added
  117595. */
  117596. static OnNewCacheEntry: (entry: string) => void;
  117597. /**
  117598. * Log a message to the console
  117599. * @param message defines the message to log
  117600. */
  117601. static Log(message: string): void;
  117602. /**
  117603. * Write a warning message to the console
  117604. * @param message defines the message to log
  117605. */
  117606. static Warn(message: string): void;
  117607. /**
  117608. * Write an error message to the console
  117609. * @param message defines the message to log
  117610. */
  117611. static Error(message: string): void;
  117612. /**
  117613. * Gets current log cache (list of logs)
  117614. */
  117615. static get LogCache(): string;
  117616. /**
  117617. * Clears the log cache
  117618. */
  117619. static ClearLogCache(): void;
  117620. /**
  117621. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117622. */
  117623. static set LogLevels(level: number);
  117624. /**
  117625. * Checks if the window object exists
  117626. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117627. */
  117628. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117629. /**
  117630. * No performance log
  117631. */
  117632. static readonly PerformanceNoneLogLevel: number;
  117633. /**
  117634. * Use user marks to log performance
  117635. */
  117636. static readonly PerformanceUserMarkLogLevel: number;
  117637. /**
  117638. * Log performance to the console
  117639. */
  117640. static readonly PerformanceConsoleLogLevel: number;
  117641. private static _performance;
  117642. /**
  117643. * Sets the current performance log level
  117644. */
  117645. static set PerformanceLogLevel(level: number);
  117646. private static _StartPerformanceCounterDisabled;
  117647. private static _EndPerformanceCounterDisabled;
  117648. private static _StartUserMark;
  117649. private static _EndUserMark;
  117650. private static _StartPerformanceConsole;
  117651. private static _EndPerformanceConsole;
  117652. /**
  117653. * Starts a performance counter
  117654. */
  117655. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117656. /**
  117657. * Ends a specific performance coutner
  117658. */
  117659. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117660. /**
  117661. * Gets either window.performance.now() if supported or Date.now() else
  117662. */
  117663. static get Now(): number;
  117664. /**
  117665. * This method will return the name of the class used to create the instance of the given object.
  117666. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117667. * @param object the object to get the class name from
  117668. * @param isType defines if the object is actually a type
  117669. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117670. */
  117671. static GetClassName(object: any, isType?: boolean): string;
  117672. /**
  117673. * Gets the first element of an array satisfying a given predicate
  117674. * @param array defines the array to browse
  117675. * @param predicate defines the predicate to use
  117676. * @returns null if not found or the element
  117677. */
  117678. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117679. /**
  117680. * This method will return the name of the full name of the class, including its owning module (if any).
  117681. * 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).
  117682. * @param object the object to get the class name from
  117683. * @param isType defines if the object is actually a type
  117684. * @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.
  117685. * @ignorenaming
  117686. */
  117687. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117688. /**
  117689. * Returns a promise that resolves after the given amount of time.
  117690. * @param delay Number of milliseconds to delay
  117691. * @returns Promise that resolves after the given amount of time
  117692. */
  117693. static DelayAsync(delay: number): Promise<void>;
  117694. /**
  117695. * Utility function to detect if the current user agent is Safari
  117696. * @returns whether or not the current user agent is safari
  117697. */
  117698. static IsSafari(): boolean;
  117699. }
  117700. /**
  117701. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117702. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117703. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117704. * @param name The name of the class, case should be preserved
  117705. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117706. */
  117707. export function className(name: string, module?: string): (target: Object) => void;
  117708. /**
  117709. * An implementation of a loop for asynchronous functions.
  117710. */
  117711. export class AsyncLoop {
  117712. /**
  117713. * Defines the number of iterations for the loop
  117714. */
  117715. iterations: number;
  117716. /**
  117717. * Defines the current index of the loop.
  117718. */
  117719. index: number;
  117720. private _done;
  117721. private _fn;
  117722. private _successCallback;
  117723. /**
  117724. * Constructor.
  117725. * @param iterations the number of iterations.
  117726. * @param func the function to run each iteration
  117727. * @param successCallback the callback that will be called upon succesful execution
  117728. * @param offset starting offset.
  117729. */
  117730. constructor(
  117731. /**
  117732. * Defines the number of iterations for the loop
  117733. */
  117734. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117735. /**
  117736. * Execute the next iteration. Must be called after the last iteration was finished.
  117737. */
  117738. executeNext(): void;
  117739. /**
  117740. * Break the loop and run the success callback.
  117741. */
  117742. breakLoop(): void;
  117743. /**
  117744. * Create and run an async loop.
  117745. * @param iterations the number of iterations.
  117746. * @param fn the function to run each iteration
  117747. * @param successCallback the callback that will be called upon succesful execution
  117748. * @param offset starting offset.
  117749. * @returns the created async loop object
  117750. */
  117751. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117752. /**
  117753. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117754. * @param iterations total number of iterations
  117755. * @param syncedIterations number of synchronous iterations in each async iteration.
  117756. * @param fn the function to call each iteration.
  117757. * @param callback a success call back that will be called when iterating stops.
  117758. * @param breakFunction a break condition (optional)
  117759. * @param timeout timeout settings for the setTimeout function. default - 0.
  117760. * @returns the created async loop object
  117761. */
  117762. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117763. }
  117764. }
  117765. declare module BABYLON {
  117766. /**
  117767. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117768. * The underlying implementation relies on an associative array to ensure the best performances.
  117769. * The value can be anything including 'null' but except 'undefined'
  117770. */
  117771. export class StringDictionary<T> {
  117772. /**
  117773. * This will clear this dictionary and copy the content from the 'source' one.
  117774. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117775. * @param source the dictionary to take the content from and copy to this dictionary
  117776. */
  117777. copyFrom(source: StringDictionary<T>): void;
  117778. /**
  117779. * Get a value based from its key
  117780. * @param key the given key to get the matching value from
  117781. * @return the value if found, otherwise undefined is returned
  117782. */
  117783. get(key: string): T | undefined;
  117784. /**
  117785. * Get a value from its key or add it if it doesn't exist.
  117786. * This method will ensure you that a given key/data will be present in the dictionary.
  117787. * @param key the given key to get the matching value from
  117788. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117789. * The factory will only be invoked if there's no data for the given key.
  117790. * @return the value corresponding to the key.
  117791. */
  117792. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117793. /**
  117794. * Get a value from its key if present in the dictionary otherwise add it
  117795. * @param key the key to get the value from
  117796. * @param val if there's no such key/value pair in the dictionary add it with this value
  117797. * @return the value corresponding to the key
  117798. */
  117799. getOrAdd(key: string, val: T): T;
  117800. /**
  117801. * Check if there's a given key in the dictionary
  117802. * @param key the key to check for
  117803. * @return true if the key is present, false otherwise
  117804. */
  117805. contains(key: string): boolean;
  117806. /**
  117807. * Add a new key and its corresponding value
  117808. * @param key the key to add
  117809. * @param value the value corresponding to the key
  117810. * @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
  117811. */
  117812. add(key: string, value: T): boolean;
  117813. /**
  117814. * Update a specific value associated to a key
  117815. * @param key defines the key to use
  117816. * @param value defines the value to store
  117817. * @returns true if the value was updated (or false if the key was not found)
  117818. */
  117819. set(key: string, value: T): boolean;
  117820. /**
  117821. * Get the element of the given key and remove it from the dictionary
  117822. * @param key defines the key to search
  117823. * @returns the value associated with the key or null if not found
  117824. */
  117825. getAndRemove(key: string): Nullable<T>;
  117826. /**
  117827. * Remove a key/value from the dictionary.
  117828. * @param key the key to remove
  117829. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117830. */
  117831. remove(key: string): boolean;
  117832. /**
  117833. * Clear the whole content of the dictionary
  117834. */
  117835. clear(): void;
  117836. /**
  117837. * Gets the current count
  117838. */
  117839. get count(): number;
  117840. /**
  117841. * Execute a callback on each key/val of the dictionary.
  117842. * Note that you can remove any element in this dictionary in the callback implementation
  117843. * @param callback the callback to execute on a given key/value pair
  117844. */
  117845. forEach(callback: (key: string, val: T) => void): void;
  117846. /**
  117847. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117848. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117849. * Note that you can remove any element in this dictionary in the callback implementation
  117850. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117851. * @returns the first item
  117852. */
  117853. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117854. private _count;
  117855. private _data;
  117856. }
  117857. }
  117858. declare module BABYLON {
  117859. /** @hidden */
  117860. export interface ICollisionCoordinator {
  117861. createCollider(): Collider;
  117862. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117863. init(scene: Scene): void;
  117864. }
  117865. /** @hidden */
  117866. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117867. private _scene;
  117868. private _scaledPosition;
  117869. private _scaledVelocity;
  117870. private _finalPosition;
  117871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117872. createCollider(): Collider;
  117873. init(scene: Scene): void;
  117874. private _collideWithWorld;
  117875. }
  117876. }
  117877. declare module BABYLON {
  117878. /**
  117879. * Class used to manage all inputs for the scene.
  117880. */
  117881. export class InputManager {
  117882. /** The distance in pixel that you have to move to prevent some events */
  117883. static DragMovementThreshold: number;
  117884. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117885. static LongPressDelay: number;
  117886. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117887. static DoubleClickDelay: number;
  117888. /** If you need to check double click without raising a single click at first click, enable this flag */
  117889. static ExclusiveDoubleClickMode: boolean;
  117890. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  117891. private _alreadyAttached;
  117892. private _wheelEventName;
  117893. private _onPointerMove;
  117894. private _onPointerDown;
  117895. private _onPointerUp;
  117896. private _initClickEvent;
  117897. private _initActionManager;
  117898. private _delayedSimpleClick;
  117899. private _delayedSimpleClickTimeout;
  117900. private _previousDelayedSimpleClickTimeout;
  117901. private _meshPickProceed;
  117902. private _previousButtonPressed;
  117903. private _currentPickResult;
  117904. private _previousPickResult;
  117905. private _totalPointersPressed;
  117906. private _doubleClickOccured;
  117907. private _pointerOverMesh;
  117908. private _pickedDownMesh;
  117909. private _pickedUpMesh;
  117910. private _pointerX;
  117911. private _pointerY;
  117912. private _unTranslatedPointerX;
  117913. private _unTranslatedPointerY;
  117914. private _startingPointerPosition;
  117915. private _previousStartingPointerPosition;
  117916. private _startingPointerTime;
  117917. private _previousStartingPointerTime;
  117918. private _pointerCaptures;
  117919. private _onKeyDown;
  117920. private _onKeyUp;
  117921. private _onCanvasFocusObserver;
  117922. private _onCanvasBlurObserver;
  117923. private _scene;
  117924. /**
  117925. * Creates a new InputManager
  117926. * @param scene defines the hosting scene
  117927. */
  117928. constructor(scene: Scene);
  117929. /**
  117930. * Gets the mesh that is currently under the pointer
  117931. */
  117932. get meshUnderPointer(): Nullable<AbstractMesh>;
  117933. /**
  117934. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117935. */
  117936. get unTranslatedPointer(): Vector2;
  117937. /**
  117938. * Gets or sets the current on-screen X position of the pointer
  117939. */
  117940. get pointerX(): number;
  117941. set pointerX(value: number);
  117942. /**
  117943. * Gets or sets the current on-screen Y position of the pointer
  117944. */
  117945. get pointerY(): number;
  117946. set pointerY(value: number);
  117947. private _updatePointerPosition;
  117948. private _processPointerMove;
  117949. private _setRayOnPointerInfo;
  117950. private _checkPrePointerObservable;
  117951. /**
  117952. * Use this method to simulate a pointer move on a mesh
  117953. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117954. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117955. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117956. */
  117957. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117958. /**
  117959. * Use this method to simulate a pointer down on a mesh
  117960. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117961. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117962. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117963. */
  117964. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117965. private _processPointerDown;
  117966. /** @hidden */
  117967. _isPointerSwiping(): boolean;
  117968. /**
  117969. * Use this method to simulate a pointer up on a mesh
  117970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117973. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117974. */
  117975. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117976. private _processPointerUp;
  117977. /**
  117978. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117979. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117980. * @returns true if the pointer was captured
  117981. */
  117982. isPointerCaptured(pointerId?: number): boolean;
  117983. /**
  117984. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117985. * @param attachUp defines if you want to attach events to pointerup
  117986. * @param attachDown defines if you want to attach events to pointerdown
  117987. * @param attachMove defines if you want to attach events to pointermove
  117988. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117989. */
  117990. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117991. /**
  117992. * Detaches all event handlers
  117993. */
  117994. detachControl(): void;
  117995. /**
  117996. * Force the value of meshUnderPointer
  117997. * @param mesh defines the mesh to use
  117998. */
  117999. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118000. /**
  118001. * Gets the mesh under the pointer
  118002. * @returns a Mesh or null if no mesh is under the pointer
  118003. */
  118004. getPointerOverMesh(): Nullable<AbstractMesh>;
  118005. }
  118006. }
  118007. declare module BABYLON {
  118008. /**
  118009. * This class defines the direct association between an animation and a target
  118010. */
  118011. export class TargetedAnimation {
  118012. /**
  118013. * Animation to perform
  118014. */
  118015. animation: Animation;
  118016. /**
  118017. * Target to animate
  118018. */
  118019. target: any;
  118020. /**
  118021. * Returns the string "TargetedAnimation"
  118022. * @returns "TargetedAnimation"
  118023. */
  118024. getClassName(): string;
  118025. /**
  118026. * Serialize the object
  118027. * @returns the JSON object representing the current entity
  118028. */
  118029. serialize(): any;
  118030. }
  118031. /**
  118032. * Use this class to create coordinated animations on multiple targets
  118033. */
  118034. export class AnimationGroup implements IDisposable {
  118035. /** The name of the animation group */
  118036. name: string;
  118037. private _scene;
  118038. private _targetedAnimations;
  118039. private _animatables;
  118040. private _from;
  118041. private _to;
  118042. private _isStarted;
  118043. private _isPaused;
  118044. private _speedRatio;
  118045. private _loopAnimation;
  118046. private _isAdditive;
  118047. /**
  118048. * Gets or sets the unique id of the node
  118049. */
  118050. uniqueId: number;
  118051. /**
  118052. * This observable will notify when one animation have ended
  118053. */
  118054. onAnimationEndObservable: Observable<TargetedAnimation>;
  118055. /**
  118056. * Observer raised when one animation loops
  118057. */
  118058. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118059. /**
  118060. * Observer raised when all animations have looped
  118061. */
  118062. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118063. /**
  118064. * This observable will notify when all animations have ended.
  118065. */
  118066. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118067. /**
  118068. * This observable will notify when all animations have paused.
  118069. */
  118070. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118071. /**
  118072. * This observable will notify when all animations are playing.
  118073. */
  118074. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118075. /**
  118076. * Gets the first frame
  118077. */
  118078. get from(): number;
  118079. /**
  118080. * Gets the last frame
  118081. */
  118082. get to(): number;
  118083. /**
  118084. * Define if the animations are started
  118085. */
  118086. get isStarted(): boolean;
  118087. /**
  118088. * Gets a value indicating that the current group is playing
  118089. */
  118090. get isPlaying(): boolean;
  118091. /**
  118092. * Gets or sets the speed ratio to use for all animations
  118093. */
  118094. get speedRatio(): number;
  118095. /**
  118096. * Gets or sets the speed ratio to use for all animations
  118097. */
  118098. set speedRatio(value: number);
  118099. /**
  118100. * Gets or sets if all animations should loop or not
  118101. */
  118102. get loopAnimation(): boolean;
  118103. set loopAnimation(value: boolean);
  118104. /**
  118105. * Gets or sets if all animations should be evaluated additively
  118106. */
  118107. get isAdditive(): boolean;
  118108. set isAdditive(value: boolean);
  118109. /**
  118110. * Gets the targeted animations for this animation group
  118111. */
  118112. get targetedAnimations(): Array<TargetedAnimation>;
  118113. /**
  118114. * returning the list of animatables controlled by this animation group.
  118115. */
  118116. get animatables(): Array<Animatable>;
  118117. /**
  118118. * Gets the list of target animations
  118119. */
  118120. get children(): TargetedAnimation[];
  118121. /**
  118122. * Instantiates a new Animation Group.
  118123. * This helps managing several animations at once.
  118124. * @see https://doc.babylonjs.com/how_to/group
  118125. * @param name Defines the name of the group
  118126. * @param scene Defines the scene the group belongs to
  118127. */
  118128. constructor(
  118129. /** The name of the animation group */
  118130. name: string, scene?: Nullable<Scene>);
  118131. /**
  118132. * Add an animation (with its target) in the group
  118133. * @param animation defines the animation we want to add
  118134. * @param target defines the target of the animation
  118135. * @returns the TargetedAnimation object
  118136. */
  118137. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118138. /**
  118139. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118140. * It can add constant keys at begin or end
  118141. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118142. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118143. * @returns the animation group
  118144. */
  118145. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118146. private _animationLoopCount;
  118147. private _animationLoopFlags;
  118148. private _processLoop;
  118149. /**
  118150. * Start all animations on given targets
  118151. * @param loop defines if animations must loop
  118152. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118153. * @param from defines the from key (optional)
  118154. * @param to defines the to key (optional)
  118155. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118156. * @returns the current animation group
  118157. */
  118158. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118159. /**
  118160. * Pause all animations
  118161. * @returns the animation group
  118162. */
  118163. pause(): AnimationGroup;
  118164. /**
  118165. * Play all animations to initial state
  118166. * This function will start() the animations if they were not started or will restart() them if they were paused
  118167. * @param loop defines if animations must loop
  118168. * @returns the animation group
  118169. */
  118170. play(loop?: boolean): AnimationGroup;
  118171. /**
  118172. * Reset all animations to initial state
  118173. * @returns the animation group
  118174. */
  118175. reset(): AnimationGroup;
  118176. /**
  118177. * Restart animations from key 0
  118178. * @returns the animation group
  118179. */
  118180. restart(): AnimationGroup;
  118181. /**
  118182. * Stop all animations
  118183. * @returns the animation group
  118184. */
  118185. stop(): AnimationGroup;
  118186. /**
  118187. * Set animation weight for all animatables
  118188. * @param weight defines the weight to use
  118189. * @return the animationGroup
  118190. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118191. */
  118192. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118193. /**
  118194. * Synchronize and normalize all animatables with a source animatable
  118195. * @param root defines the root animatable to synchronize with
  118196. * @return the animationGroup
  118197. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118198. */
  118199. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118200. /**
  118201. * Goes to a specific frame in this animation group
  118202. * @param frame the frame number to go to
  118203. * @return the animationGroup
  118204. */
  118205. goToFrame(frame: number): AnimationGroup;
  118206. /**
  118207. * Dispose all associated resources
  118208. */
  118209. dispose(): void;
  118210. private _checkAnimationGroupEnded;
  118211. /**
  118212. * Clone the current animation group and returns a copy
  118213. * @param newName defines the name of the new group
  118214. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118215. * @returns the new aniamtion group
  118216. */
  118217. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118218. /**
  118219. * Serializes the animationGroup to an object
  118220. * @returns Serialized object
  118221. */
  118222. serialize(): any;
  118223. /**
  118224. * Returns a new AnimationGroup object parsed from the source provided.
  118225. * @param parsedAnimationGroup defines the source
  118226. * @param scene defines the scene that will receive the animationGroup
  118227. * @returns a new AnimationGroup
  118228. */
  118229. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118230. /**
  118231. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118232. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118233. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118234. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118235. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118236. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118237. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118238. */
  118239. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118240. /**
  118241. * Returns the string "AnimationGroup"
  118242. * @returns "AnimationGroup"
  118243. */
  118244. getClassName(): string;
  118245. /**
  118246. * Creates a detailled string about the object
  118247. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118248. * @returns a string representing the object
  118249. */
  118250. toString(fullDetails?: boolean): string;
  118251. }
  118252. }
  118253. declare module BABYLON {
  118254. /**
  118255. * Define an interface for all classes that will hold resources
  118256. */
  118257. export interface IDisposable {
  118258. /**
  118259. * Releases all held resources
  118260. */
  118261. dispose(): void;
  118262. }
  118263. /** Interface defining initialization parameters for Scene class */
  118264. export interface SceneOptions {
  118265. /**
  118266. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118267. * It will improve performance when the number of geometries becomes important.
  118268. */
  118269. useGeometryUniqueIdsMap?: boolean;
  118270. /**
  118271. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118272. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118273. */
  118274. useMaterialMeshMap?: boolean;
  118275. /**
  118276. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118277. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118278. */
  118279. useClonedMeshMap?: boolean;
  118280. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118281. virtual?: boolean;
  118282. }
  118283. /**
  118284. * Represents a scene to be rendered by the engine.
  118285. * @see https://doc.babylonjs.com/features/scene
  118286. */
  118287. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  118288. /** The fog is deactivated */
  118289. static readonly FOGMODE_NONE: number;
  118290. /** The fog density is following an exponential function */
  118291. static readonly FOGMODE_EXP: number;
  118292. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118293. static readonly FOGMODE_EXP2: number;
  118294. /** The fog density is following a linear function. */
  118295. static readonly FOGMODE_LINEAR: number;
  118296. /**
  118297. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118298. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118299. */
  118300. static MinDeltaTime: number;
  118301. /**
  118302. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118303. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118304. */
  118305. static MaxDeltaTime: number;
  118306. /**
  118307. * Factory used to create the default material.
  118308. * @param name The name of the material to create
  118309. * @param scene The scene to create the material for
  118310. * @returns The default material
  118311. */
  118312. static DefaultMaterialFactory(scene: Scene): Material;
  118313. /**
  118314. * Factory used to create the a collision coordinator.
  118315. * @returns The collision coordinator
  118316. */
  118317. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118318. /** @hidden */
  118319. _inputManager: InputManager;
  118320. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118321. cameraToUseForPointers: Nullable<Camera>;
  118322. /** @hidden */
  118323. readonly _isScene: boolean;
  118324. /** @hidden */
  118325. _blockEntityCollection: boolean;
  118326. /**
  118327. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118328. */
  118329. autoClear: boolean;
  118330. /**
  118331. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118332. */
  118333. autoClearDepthAndStencil: boolean;
  118334. /**
  118335. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118336. */
  118337. clearColor: Color4;
  118338. /**
  118339. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118340. */
  118341. ambientColor: Color3;
  118342. /**
  118343. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118344. * It should only be one of the following (if not the default embedded one):
  118345. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118346. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118347. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118348. * The material properties need to be setup according to the type of texture in use.
  118349. */
  118350. environmentBRDFTexture: BaseTexture;
  118351. /** @hidden */
  118352. protected _environmentTexture: Nullable<BaseTexture>;
  118353. /**
  118354. * Texture used in all pbr material as the reflection texture.
  118355. * As in the majority of the scene they are the same (exception for multi room and so on),
  118356. * this is easier to reference from here than from all the materials.
  118357. */
  118358. get environmentTexture(): Nullable<BaseTexture>;
  118359. /**
  118360. * Texture used in all pbr material as the reflection texture.
  118361. * As in the majority of the scene they are the same (exception for multi room and so on),
  118362. * this is easier to set here than in all the materials.
  118363. */
  118364. set environmentTexture(value: Nullable<BaseTexture>);
  118365. /** @hidden */
  118366. protected _environmentIntensity: number;
  118367. /**
  118368. * Intensity of the environment in all pbr material.
  118369. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118370. * As in the majority of the scene they are the same (exception for multi room and so on),
  118371. * this is easier to reference from here than from all the materials.
  118372. */
  118373. get environmentIntensity(): number;
  118374. /**
  118375. * Intensity of the environment in all pbr material.
  118376. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118377. * As in the majority of the scene they are the same (exception for multi room and so on),
  118378. * this is easier to set here than in all the materials.
  118379. */
  118380. set environmentIntensity(value: number);
  118381. /** @hidden */
  118382. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118383. /**
  118384. * Default image processing configuration used either in the rendering
  118385. * Forward main pass or through the imageProcessingPostProcess if present.
  118386. * As in the majority of the scene they are the same (exception for multi camera),
  118387. * this is easier to reference from here than from all the materials and post process.
  118388. *
  118389. * No setter as we it is a shared configuration, you can set the values instead.
  118390. */
  118391. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118392. private _forceWireframe;
  118393. /**
  118394. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118395. */
  118396. set forceWireframe(value: boolean);
  118397. get forceWireframe(): boolean;
  118398. private _skipFrustumClipping;
  118399. /**
  118400. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118401. */
  118402. set skipFrustumClipping(value: boolean);
  118403. get skipFrustumClipping(): boolean;
  118404. private _forcePointsCloud;
  118405. /**
  118406. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118407. */
  118408. set forcePointsCloud(value: boolean);
  118409. get forcePointsCloud(): boolean;
  118410. /**
  118411. * Gets or sets the active clipplane 1
  118412. */
  118413. clipPlane: Nullable<Plane>;
  118414. /**
  118415. * Gets or sets the active clipplane 2
  118416. */
  118417. clipPlane2: Nullable<Plane>;
  118418. /**
  118419. * Gets or sets the active clipplane 3
  118420. */
  118421. clipPlane3: Nullable<Plane>;
  118422. /**
  118423. * Gets or sets the active clipplane 4
  118424. */
  118425. clipPlane4: Nullable<Plane>;
  118426. /**
  118427. * Gets or sets the active clipplane 5
  118428. */
  118429. clipPlane5: Nullable<Plane>;
  118430. /**
  118431. * Gets or sets the active clipplane 6
  118432. */
  118433. clipPlane6: Nullable<Plane>;
  118434. /**
  118435. * Gets or sets a boolean indicating if animations are enabled
  118436. */
  118437. animationsEnabled: boolean;
  118438. private _animationPropertiesOverride;
  118439. /**
  118440. * Gets or sets the animation properties override
  118441. */
  118442. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118443. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118444. /**
  118445. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118446. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118447. */
  118448. useConstantAnimationDeltaTime: boolean;
  118449. /**
  118450. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118451. * Please note that it requires to run a ray cast through the scene on every frame
  118452. */
  118453. constantlyUpdateMeshUnderPointer: boolean;
  118454. /**
  118455. * Defines the HTML cursor to use when hovering over interactive elements
  118456. */
  118457. hoverCursor: string;
  118458. /**
  118459. * Defines the HTML default cursor to use (empty by default)
  118460. */
  118461. defaultCursor: string;
  118462. /**
  118463. * Defines whether cursors are handled by the scene.
  118464. */
  118465. doNotHandleCursors: boolean;
  118466. /**
  118467. * This is used to call preventDefault() on pointer down
  118468. * in order to block unwanted artifacts like system double clicks
  118469. */
  118470. preventDefaultOnPointerDown: boolean;
  118471. /**
  118472. * This is used to call preventDefault() on pointer up
  118473. * in order to block unwanted artifacts like system double clicks
  118474. */
  118475. preventDefaultOnPointerUp: boolean;
  118476. /**
  118477. * Gets or sets user defined metadata
  118478. */
  118479. metadata: any;
  118480. /**
  118481. * For internal use only. Please do not use.
  118482. */
  118483. reservedDataStore: any;
  118484. /**
  118485. * Gets the name of the plugin used to load this scene (null by default)
  118486. */
  118487. loadingPluginName: string;
  118488. /**
  118489. * Use this array to add regular expressions used to disable offline support for specific urls
  118490. */
  118491. disableOfflineSupportExceptionRules: RegExp[];
  118492. /**
  118493. * An event triggered when the scene is disposed.
  118494. */
  118495. onDisposeObservable: Observable<Scene>;
  118496. private _onDisposeObserver;
  118497. /** Sets a function to be executed when this scene is disposed. */
  118498. set onDispose(callback: () => void);
  118499. /**
  118500. * An event triggered before rendering the scene (right after animations and physics)
  118501. */
  118502. onBeforeRenderObservable: Observable<Scene>;
  118503. private _onBeforeRenderObserver;
  118504. /** Sets a function to be executed before rendering this scene */
  118505. set beforeRender(callback: Nullable<() => void>);
  118506. /**
  118507. * An event triggered after rendering the scene
  118508. */
  118509. onAfterRenderObservable: Observable<Scene>;
  118510. /**
  118511. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118512. */
  118513. onAfterRenderCameraObservable: Observable<Camera>;
  118514. private _onAfterRenderObserver;
  118515. /** Sets a function to be executed after rendering this scene */
  118516. set afterRender(callback: Nullable<() => void>);
  118517. /**
  118518. * An event triggered before animating the scene
  118519. */
  118520. onBeforeAnimationsObservable: Observable<Scene>;
  118521. /**
  118522. * An event triggered after animations processing
  118523. */
  118524. onAfterAnimationsObservable: Observable<Scene>;
  118525. /**
  118526. * An event triggered before draw calls are ready to be sent
  118527. */
  118528. onBeforeDrawPhaseObservable: Observable<Scene>;
  118529. /**
  118530. * An event triggered after draw calls have been sent
  118531. */
  118532. onAfterDrawPhaseObservable: Observable<Scene>;
  118533. /**
  118534. * An event triggered when the scene is ready
  118535. */
  118536. onReadyObservable: Observable<Scene>;
  118537. /**
  118538. * An event triggered before rendering a camera
  118539. */
  118540. onBeforeCameraRenderObservable: Observable<Camera>;
  118541. private _onBeforeCameraRenderObserver;
  118542. /** Sets a function to be executed before rendering a camera*/
  118543. set beforeCameraRender(callback: () => void);
  118544. /**
  118545. * An event triggered after rendering a camera
  118546. */
  118547. onAfterCameraRenderObservable: Observable<Camera>;
  118548. private _onAfterCameraRenderObserver;
  118549. /** Sets a function to be executed after rendering a camera*/
  118550. set afterCameraRender(callback: () => void);
  118551. /**
  118552. * An event triggered when active meshes evaluation is about to start
  118553. */
  118554. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118555. /**
  118556. * An event triggered when active meshes evaluation is done
  118557. */
  118558. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118559. /**
  118560. * An event triggered when particles rendering is about to start
  118561. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118562. */
  118563. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118564. /**
  118565. * An event triggered when particles rendering is done
  118566. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118567. */
  118568. onAfterParticlesRenderingObservable: Observable<Scene>;
  118569. /**
  118570. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118571. */
  118572. onDataLoadedObservable: Observable<Scene>;
  118573. /**
  118574. * An event triggered when a camera is created
  118575. */
  118576. onNewCameraAddedObservable: Observable<Camera>;
  118577. /**
  118578. * An event triggered when a camera is removed
  118579. */
  118580. onCameraRemovedObservable: Observable<Camera>;
  118581. /**
  118582. * An event triggered when a light is created
  118583. */
  118584. onNewLightAddedObservable: Observable<Light>;
  118585. /**
  118586. * An event triggered when a light is removed
  118587. */
  118588. onLightRemovedObservable: Observable<Light>;
  118589. /**
  118590. * An event triggered when a geometry is created
  118591. */
  118592. onNewGeometryAddedObservable: Observable<Geometry>;
  118593. /**
  118594. * An event triggered when a geometry is removed
  118595. */
  118596. onGeometryRemovedObservable: Observable<Geometry>;
  118597. /**
  118598. * An event triggered when a transform node is created
  118599. */
  118600. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118601. /**
  118602. * An event triggered when a transform node is removed
  118603. */
  118604. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118605. /**
  118606. * An event triggered when a mesh is created
  118607. */
  118608. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118609. /**
  118610. * An event triggered when a mesh is removed
  118611. */
  118612. onMeshRemovedObservable: Observable<AbstractMesh>;
  118613. /**
  118614. * An event triggered when a skeleton is created
  118615. */
  118616. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118617. /**
  118618. * An event triggered when a skeleton is removed
  118619. */
  118620. onSkeletonRemovedObservable: Observable<Skeleton>;
  118621. /**
  118622. * An event triggered when a material is created
  118623. */
  118624. onNewMaterialAddedObservable: Observable<Material>;
  118625. /**
  118626. * An event triggered when a material is removed
  118627. */
  118628. onMaterialRemovedObservable: Observable<Material>;
  118629. /**
  118630. * An event triggered when a texture is created
  118631. */
  118632. onNewTextureAddedObservable: Observable<BaseTexture>;
  118633. /**
  118634. * An event triggered when a texture is removed
  118635. */
  118636. onTextureRemovedObservable: Observable<BaseTexture>;
  118637. /**
  118638. * An event triggered when render targets are about to be rendered
  118639. * Can happen multiple times per frame.
  118640. */
  118641. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118642. /**
  118643. * An event triggered when render targets were rendered.
  118644. * Can happen multiple times per frame.
  118645. */
  118646. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118647. /**
  118648. * An event triggered before calculating deterministic simulation step
  118649. */
  118650. onBeforeStepObservable: Observable<Scene>;
  118651. /**
  118652. * An event triggered after calculating deterministic simulation step
  118653. */
  118654. onAfterStepObservable: Observable<Scene>;
  118655. /**
  118656. * An event triggered when the activeCamera property is updated
  118657. */
  118658. onActiveCameraChanged: Observable<Scene>;
  118659. /**
  118660. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118661. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118662. * 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)
  118663. */
  118664. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118665. /**
  118666. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118667. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118668. * 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)
  118669. */
  118670. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118671. /**
  118672. * This Observable will when a mesh has been imported into the scene.
  118673. */
  118674. onMeshImportedObservable: Observable<AbstractMesh>;
  118675. /**
  118676. * This Observable will when an animation file has been imported into the scene.
  118677. */
  118678. onAnimationFileImportedObservable: Observable<Scene>;
  118679. /**
  118680. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118681. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118682. */
  118683. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118684. /** @hidden */
  118685. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118686. /**
  118687. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118688. */
  118689. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118690. /**
  118691. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118692. */
  118693. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118694. /**
  118695. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118696. */
  118697. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118698. /** Callback called when a pointer move is detected */
  118699. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118700. /** Callback called when a pointer down is detected */
  118701. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118702. /** Callback called when a pointer up is detected */
  118703. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118704. /** Callback called when a pointer pick is detected */
  118705. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118706. /**
  118707. * 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).
  118708. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118709. */
  118710. onPrePointerObservable: Observable<PointerInfoPre>;
  118711. /**
  118712. * Observable event triggered each time an input event is received from the rendering canvas
  118713. */
  118714. onPointerObservable: Observable<PointerInfo>;
  118715. /**
  118716. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118717. */
  118718. get unTranslatedPointer(): Vector2;
  118719. /**
  118720. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118721. */
  118722. static get DragMovementThreshold(): number;
  118723. static set DragMovementThreshold(value: number);
  118724. /**
  118725. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118726. */
  118727. static get LongPressDelay(): number;
  118728. static set LongPressDelay(value: number);
  118729. /**
  118730. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118731. */
  118732. static get DoubleClickDelay(): number;
  118733. static set DoubleClickDelay(value: number);
  118734. /** If you need to check double click without raising a single click at first click, enable this flag */
  118735. static get ExclusiveDoubleClickMode(): boolean;
  118736. static set ExclusiveDoubleClickMode(value: boolean);
  118737. /** @hidden */
  118738. _mirroredCameraPosition: Nullable<Vector3>;
  118739. /**
  118740. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118741. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118742. */
  118743. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118744. /**
  118745. * Observable event triggered each time an keyboard event is received from the hosting window
  118746. */
  118747. onKeyboardObservable: Observable<KeyboardInfo>;
  118748. private _useRightHandedSystem;
  118749. /**
  118750. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118751. */
  118752. set useRightHandedSystem(value: boolean);
  118753. get useRightHandedSystem(): boolean;
  118754. private _timeAccumulator;
  118755. private _currentStepId;
  118756. private _currentInternalStep;
  118757. /**
  118758. * Sets the step Id used by deterministic lock step
  118759. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118760. * @param newStepId defines the step Id
  118761. */
  118762. setStepId(newStepId: number): void;
  118763. /**
  118764. * Gets the step Id used by deterministic lock step
  118765. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118766. * @returns the step Id
  118767. */
  118768. getStepId(): number;
  118769. /**
  118770. * Gets the internal step used by deterministic lock step
  118771. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118772. * @returns the internal step
  118773. */
  118774. getInternalStep(): number;
  118775. private _fogEnabled;
  118776. /**
  118777. * Gets or sets a boolean indicating if fog is enabled on this scene
  118778. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118779. * (Default is true)
  118780. */
  118781. set fogEnabled(value: boolean);
  118782. get fogEnabled(): boolean;
  118783. private _fogMode;
  118784. /**
  118785. * Gets or sets the fog mode to use
  118786. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118787. * | mode | value |
  118788. * | --- | --- |
  118789. * | FOGMODE_NONE | 0 |
  118790. * | FOGMODE_EXP | 1 |
  118791. * | FOGMODE_EXP2 | 2 |
  118792. * | FOGMODE_LINEAR | 3 |
  118793. */
  118794. set fogMode(value: number);
  118795. get fogMode(): number;
  118796. /**
  118797. * Gets or sets the fog color to use
  118798. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118799. * (Default is Color3(0.2, 0.2, 0.3))
  118800. */
  118801. fogColor: Color3;
  118802. /**
  118803. * Gets or sets the fog density to use
  118804. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118805. * (Default is 0.1)
  118806. */
  118807. fogDensity: number;
  118808. /**
  118809. * Gets or sets the fog start distance to use
  118810. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118811. * (Default is 0)
  118812. */
  118813. fogStart: number;
  118814. /**
  118815. * Gets or sets the fog end distance to use
  118816. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118817. * (Default is 1000)
  118818. */
  118819. fogEnd: number;
  118820. /**
  118821. * Flag indicating that the frame buffer binding is handled by another component
  118822. */
  118823. prePass: boolean;
  118824. private _shadowsEnabled;
  118825. /**
  118826. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118827. */
  118828. set shadowsEnabled(value: boolean);
  118829. get shadowsEnabled(): boolean;
  118830. private _lightsEnabled;
  118831. /**
  118832. * Gets or sets a boolean indicating if lights are enabled on this scene
  118833. */
  118834. set lightsEnabled(value: boolean);
  118835. get lightsEnabled(): boolean;
  118836. /** All of the active cameras added to this scene. */
  118837. activeCameras: Camera[];
  118838. /** @hidden */
  118839. _activeCamera: Nullable<Camera>;
  118840. /** Gets or sets the current active camera */
  118841. get activeCamera(): Nullable<Camera>;
  118842. set activeCamera(value: Nullable<Camera>);
  118843. private _defaultMaterial;
  118844. /** The default material used on meshes when no material is affected */
  118845. get defaultMaterial(): Material;
  118846. /** The default material used on meshes when no material is affected */
  118847. set defaultMaterial(value: Material);
  118848. private _texturesEnabled;
  118849. /**
  118850. * Gets or sets a boolean indicating if textures are enabled on this scene
  118851. */
  118852. set texturesEnabled(value: boolean);
  118853. get texturesEnabled(): boolean;
  118854. /**
  118855. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118856. */
  118857. physicsEnabled: boolean;
  118858. /**
  118859. * Gets or sets a boolean indicating if particles are enabled on this scene
  118860. */
  118861. particlesEnabled: boolean;
  118862. /**
  118863. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118864. */
  118865. spritesEnabled: boolean;
  118866. private _skeletonsEnabled;
  118867. /**
  118868. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118869. */
  118870. set skeletonsEnabled(value: boolean);
  118871. get skeletonsEnabled(): boolean;
  118872. /**
  118873. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118874. */
  118875. lensFlaresEnabled: boolean;
  118876. /**
  118877. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118878. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118879. */
  118880. collisionsEnabled: boolean;
  118881. private _collisionCoordinator;
  118882. /** @hidden */
  118883. get collisionCoordinator(): ICollisionCoordinator;
  118884. /**
  118885. * Defines the gravity applied to this scene (used only for collisions)
  118886. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118887. */
  118888. gravity: Vector3;
  118889. /**
  118890. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118891. */
  118892. postProcessesEnabled: boolean;
  118893. /**
  118894. * The list of postprocesses added to the scene
  118895. */
  118896. postProcesses: PostProcess[];
  118897. /**
  118898. * Gets the current postprocess manager
  118899. */
  118900. postProcessManager: PostProcessManager;
  118901. /**
  118902. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118903. */
  118904. renderTargetsEnabled: boolean;
  118905. /**
  118906. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118907. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118908. */
  118909. dumpNextRenderTargets: boolean;
  118910. /**
  118911. * The list of user defined render targets added to the scene
  118912. */
  118913. customRenderTargets: RenderTargetTexture[];
  118914. /**
  118915. * Defines if texture loading must be delayed
  118916. * If true, textures will only be loaded when they need to be rendered
  118917. */
  118918. useDelayedTextureLoading: boolean;
  118919. /**
  118920. * Gets the list of meshes imported to the scene through SceneLoader
  118921. */
  118922. importedMeshesFiles: String[];
  118923. /**
  118924. * Gets or sets a boolean indicating if probes are enabled on this scene
  118925. */
  118926. probesEnabled: boolean;
  118927. /**
  118928. * Gets or sets the current offline provider to use to store scene data
  118929. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118930. */
  118931. offlineProvider: IOfflineProvider;
  118932. /**
  118933. * Gets or sets the action manager associated with the scene
  118934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118935. */
  118936. actionManager: AbstractActionManager;
  118937. private _meshesForIntersections;
  118938. /**
  118939. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118940. */
  118941. proceduralTexturesEnabled: boolean;
  118942. private _engine;
  118943. private _totalVertices;
  118944. /** @hidden */
  118945. _activeIndices: PerfCounter;
  118946. /** @hidden */
  118947. _activeParticles: PerfCounter;
  118948. /** @hidden */
  118949. _activeBones: PerfCounter;
  118950. private _animationRatio;
  118951. /** @hidden */
  118952. _animationTimeLast: number;
  118953. /** @hidden */
  118954. _animationTime: number;
  118955. /**
  118956. * Gets or sets a general scale for animation speed
  118957. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118958. */
  118959. animationTimeScale: number;
  118960. /** @hidden */
  118961. _cachedMaterial: Nullable<Material>;
  118962. /** @hidden */
  118963. _cachedEffect: Nullable<Effect>;
  118964. /** @hidden */
  118965. _cachedVisibility: Nullable<number>;
  118966. private _renderId;
  118967. private _frameId;
  118968. private _executeWhenReadyTimeoutId;
  118969. private _intermediateRendering;
  118970. private _viewUpdateFlag;
  118971. private _projectionUpdateFlag;
  118972. /** @hidden */
  118973. _toBeDisposed: Nullable<IDisposable>[];
  118974. private _activeRequests;
  118975. /** @hidden */
  118976. _pendingData: any[];
  118977. private _isDisposed;
  118978. /**
  118979. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118980. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118981. */
  118982. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118983. private _activeMeshes;
  118984. private _processedMaterials;
  118985. private _renderTargets;
  118986. /** @hidden */
  118987. _activeParticleSystems: SmartArray<IParticleSystem>;
  118988. private _activeSkeletons;
  118989. private _softwareSkinnedMeshes;
  118990. private _renderingManager;
  118991. /** @hidden */
  118992. _activeAnimatables: Animatable[];
  118993. private _transformMatrix;
  118994. private _sceneUbo;
  118995. /** @hidden */
  118996. _viewMatrix: Matrix;
  118997. private _projectionMatrix;
  118998. /** @hidden */
  118999. _forcedViewPosition: Nullable<Vector3>;
  119000. /** @hidden */
  119001. _frustumPlanes: Plane[];
  119002. /**
  119003. * Gets the list of frustum planes (built from the active camera)
  119004. */
  119005. get frustumPlanes(): Plane[];
  119006. /**
  119007. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119008. * This is useful if there are more lights that the maximum simulteanous authorized
  119009. */
  119010. requireLightSorting: boolean;
  119011. /** @hidden */
  119012. readonly useMaterialMeshMap: boolean;
  119013. /** @hidden */
  119014. readonly useClonedMeshMap: boolean;
  119015. private _externalData;
  119016. private _uid;
  119017. /**
  119018. * @hidden
  119019. * Backing store of defined scene components.
  119020. */
  119021. _components: ISceneComponent[];
  119022. /**
  119023. * @hidden
  119024. * Backing store of defined scene components.
  119025. */
  119026. _serializableComponents: ISceneSerializableComponent[];
  119027. /**
  119028. * List of components to register on the next registration step.
  119029. */
  119030. private _transientComponents;
  119031. /**
  119032. * Registers the transient components if needed.
  119033. */
  119034. private _registerTransientComponents;
  119035. /**
  119036. * @hidden
  119037. * Add a component to the scene.
  119038. * Note that the ccomponent could be registered on th next frame if this is called after
  119039. * the register component stage.
  119040. * @param component Defines the component to add to the scene
  119041. */
  119042. _addComponent(component: ISceneComponent): void;
  119043. /**
  119044. * @hidden
  119045. * Gets a component from the scene.
  119046. * @param name defines the name of the component to retrieve
  119047. * @returns the component or null if not present
  119048. */
  119049. _getComponent(name: string): Nullable<ISceneComponent>;
  119050. /**
  119051. * @hidden
  119052. * Defines the actions happening before camera updates.
  119053. */
  119054. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119055. /**
  119056. * @hidden
  119057. * Defines the actions happening before clear the canvas.
  119058. */
  119059. _beforeClearStage: Stage<SimpleStageAction>;
  119060. /**
  119061. * @hidden
  119062. * Defines the actions when collecting render targets for the frame.
  119063. */
  119064. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119065. /**
  119066. * @hidden
  119067. * Defines the actions happening for one camera in the frame.
  119068. */
  119069. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119070. /**
  119071. * @hidden
  119072. * Defines the actions happening during the per mesh ready checks.
  119073. */
  119074. _isReadyForMeshStage: Stage<MeshStageAction>;
  119075. /**
  119076. * @hidden
  119077. * Defines the actions happening before evaluate active mesh checks.
  119078. */
  119079. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119080. /**
  119081. * @hidden
  119082. * Defines the actions happening during the evaluate sub mesh checks.
  119083. */
  119084. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119085. /**
  119086. * @hidden
  119087. * Defines the actions happening during the active mesh stage.
  119088. */
  119089. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119090. /**
  119091. * @hidden
  119092. * Defines the actions happening during the per camera render target step.
  119093. */
  119094. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119095. /**
  119096. * @hidden
  119097. * Defines the actions happening just before the active camera is drawing.
  119098. */
  119099. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119100. /**
  119101. * @hidden
  119102. * Defines the actions happening just before a render target is drawing.
  119103. */
  119104. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119105. /**
  119106. * @hidden
  119107. * Defines the actions happening just before a rendering group is drawing.
  119108. */
  119109. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119110. /**
  119111. * @hidden
  119112. * Defines the actions happening just before a mesh is drawing.
  119113. */
  119114. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119115. /**
  119116. * @hidden
  119117. * Defines the actions happening just after a mesh has been drawn.
  119118. */
  119119. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119120. /**
  119121. * @hidden
  119122. * Defines the actions happening just after a rendering group has been drawn.
  119123. */
  119124. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119125. /**
  119126. * @hidden
  119127. * Defines the actions happening just after the active camera has been drawn.
  119128. */
  119129. _afterCameraDrawStage: Stage<CameraStageAction>;
  119130. /**
  119131. * @hidden
  119132. * Defines the actions happening just after a render target has been drawn.
  119133. */
  119134. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119135. /**
  119136. * @hidden
  119137. * Defines the actions happening just after rendering all cameras and computing intersections.
  119138. */
  119139. _afterRenderStage: Stage<SimpleStageAction>;
  119140. /**
  119141. * @hidden
  119142. * Defines the actions happening when a pointer move event happens.
  119143. */
  119144. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119145. /**
  119146. * @hidden
  119147. * Defines the actions happening when a pointer down event happens.
  119148. */
  119149. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119150. /**
  119151. * @hidden
  119152. * Defines the actions happening when a pointer up event happens.
  119153. */
  119154. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119155. /**
  119156. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119157. */
  119158. private geometriesByUniqueId;
  119159. /**
  119160. * Creates a new Scene
  119161. * @param engine defines the engine to use to render this scene
  119162. * @param options defines the scene options
  119163. */
  119164. constructor(engine: Engine, options?: SceneOptions);
  119165. /**
  119166. * Gets a string idenfifying the name of the class
  119167. * @returns "Scene" string
  119168. */
  119169. getClassName(): string;
  119170. private _defaultMeshCandidates;
  119171. /**
  119172. * @hidden
  119173. */
  119174. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119175. private _defaultSubMeshCandidates;
  119176. /**
  119177. * @hidden
  119178. */
  119179. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119180. /**
  119181. * Sets the default candidate providers for the scene.
  119182. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119183. * and getCollidingSubMeshCandidates to their default function
  119184. */
  119185. setDefaultCandidateProviders(): void;
  119186. /**
  119187. * Gets the mesh that is currently under the pointer
  119188. */
  119189. get meshUnderPointer(): Nullable<AbstractMesh>;
  119190. /**
  119191. * Gets or sets the current on-screen X position of the pointer
  119192. */
  119193. get pointerX(): number;
  119194. set pointerX(value: number);
  119195. /**
  119196. * Gets or sets the current on-screen Y position of the pointer
  119197. */
  119198. get pointerY(): number;
  119199. set pointerY(value: number);
  119200. /**
  119201. * Gets the cached material (ie. the latest rendered one)
  119202. * @returns the cached material
  119203. */
  119204. getCachedMaterial(): Nullable<Material>;
  119205. /**
  119206. * Gets the cached effect (ie. the latest rendered one)
  119207. * @returns the cached effect
  119208. */
  119209. getCachedEffect(): Nullable<Effect>;
  119210. /**
  119211. * Gets the cached visibility state (ie. the latest rendered one)
  119212. * @returns the cached visibility state
  119213. */
  119214. getCachedVisibility(): Nullable<number>;
  119215. /**
  119216. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119217. * @param material defines the current material
  119218. * @param effect defines the current effect
  119219. * @param visibility defines the current visibility state
  119220. * @returns true if one parameter is not cached
  119221. */
  119222. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119223. /**
  119224. * Gets the engine associated with the scene
  119225. * @returns an Engine
  119226. */
  119227. getEngine(): Engine;
  119228. /**
  119229. * Gets the total number of vertices rendered per frame
  119230. * @returns the total number of vertices rendered per frame
  119231. */
  119232. getTotalVertices(): number;
  119233. /**
  119234. * Gets the performance counter for total vertices
  119235. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119236. */
  119237. get totalVerticesPerfCounter(): PerfCounter;
  119238. /**
  119239. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119240. * @returns the total number of active indices rendered per frame
  119241. */
  119242. getActiveIndices(): number;
  119243. /**
  119244. * Gets the performance counter for active indices
  119245. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119246. */
  119247. get totalActiveIndicesPerfCounter(): PerfCounter;
  119248. /**
  119249. * Gets the total number of active particles rendered per frame
  119250. * @returns the total number of active particles rendered per frame
  119251. */
  119252. getActiveParticles(): number;
  119253. /**
  119254. * Gets the performance counter for active particles
  119255. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119256. */
  119257. get activeParticlesPerfCounter(): PerfCounter;
  119258. /**
  119259. * Gets the total number of active bones rendered per frame
  119260. * @returns the total number of active bones rendered per frame
  119261. */
  119262. getActiveBones(): number;
  119263. /**
  119264. * Gets the performance counter for active bones
  119265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119266. */
  119267. get activeBonesPerfCounter(): PerfCounter;
  119268. /**
  119269. * Gets the array of active meshes
  119270. * @returns an array of AbstractMesh
  119271. */
  119272. getActiveMeshes(): SmartArray<AbstractMesh>;
  119273. /**
  119274. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119275. * @returns a number
  119276. */
  119277. getAnimationRatio(): number;
  119278. /**
  119279. * Gets an unique Id for the current render phase
  119280. * @returns a number
  119281. */
  119282. getRenderId(): number;
  119283. /**
  119284. * Gets an unique Id for the current frame
  119285. * @returns a number
  119286. */
  119287. getFrameId(): number;
  119288. /** Call this function if you want to manually increment the render Id*/
  119289. incrementRenderId(): void;
  119290. private _createUbo;
  119291. /**
  119292. * Use this method to simulate a pointer move on a mesh
  119293. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119294. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119295. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119296. * @returns the current scene
  119297. */
  119298. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119299. /**
  119300. * Use this method to simulate a pointer down on a mesh
  119301. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119302. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119303. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119304. * @returns the current scene
  119305. */
  119306. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119307. /**
  119308. * Use this method to simulate a pointer up on a mesh
  119309. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119310. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119311. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119312. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119313. * @returns the current scene
  119314. */
  119315. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119316. /**
  119317. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119318. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119319. * @returns true if the pointer was captured
  119320. */
  119321. isPointerCaptured(pointerId?: number): boolean;
  119322. /**
  119323. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119324. * @param attachUp defines if you want to attach events to pointerup
  119325. * @param attachDown defines if you want to attach events to pointerdown
  119326. * @param attachMove defines if you want to attach events to pointermove
  119327. */
  119328. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119329. /** Detaches all event handlers*/
  119330. detachControl(): void;
  119331. /**
  119332. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119333. * Delay loaded resources are not taking in account
  119334. * @return true if all required resources are ready
  119335. */
  119336. isReady(): boolean;
  119337. /** Resets all cached information relative to material (including effect and visibility) */
  119338. resetCachedMaterial(): void;
  119339. /**
  119340. * Registers a function to be called before every frame render
  119341. * @param func defines the function to register
  119342. */
  119343. registerBeforeRender(func: () => void): void;
  119344. /**
  119345. * Unregisters a function called before every frame render
  119346. * @param func defines the function to unregister
  119347. */
  119348. unregisterBeforeRender(func: () => void): void;
  119349. /**
  119350. * Registers a function to be called after every frame render
  119351. * @param func defines the function to register
  119352. */
  119353. registerAfterRender(func: () => void): void;
  119354. /**
  119355. * Unregisters a function called after every frame render
  119356. * @param func defines the function to unregister
  119357. */
  119358. unregisterAfterRender(func: () => void): void;
  119359. private _executeOnceBeforeRender;
  119360. /**
  119361. * The provided function will run before render once and will be disposed afterwards.
  119362. * A timeout delay can be provided so that the function will be executed in N ms.
  119363. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119364. * @param func The function to be executed.
  119365. * @param timeout optional delay in ms
  119366. */
  119367. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119368. /** @hidden */
  119369. _addPendingData(data: any): void;
  119370. /** @hidden */
  119371. _removePendingData(data: any): void;
  119372. /**
  119373. * Returns the number of items waiting to be loaded
  119374. * @returns the number of items waiting to be loaded
  119375. */
  119376. getWaitingItemsCount(): number;
  119377. /**
  119378. * Returns a boolean indicating if the scene is still loading data
  119379. */
  119380. get isLoading(): boolean;
  119381. /**
  119382. * Registers a function to be executed when the scene is ready
  119383. * @param {Function} func - the function to be executed
  119384. */
  119385. executeWhenReady(func: () => void): void;
  119386. /**
  119387. * Returns a promise that resolves when the scene is ready
  119388. * @returns A promise that resolves when the scene is ready
  119389. */
  119390. whenReadyAsync(): Promise<void>;
  119391. /** @hidden */
  119392. _checkIsReady(): void;
  119393. /**
  119394. * Gets all animatable attached to the scene
  119395. */
  119396. get animatables(): Animatable[];
  119397. /**
  119398. * Resets the last animation time frame.
  119399. * Useful to override when animations start running when loading a scene for the first time.
  119400. */
  119401. resetLastAnimationTimeFrame(): void;
  119402. /**
  119403. * Gets the current view matrix
  119404. * @returns a Matrix
  119405. */
  119406. getViewMatrix(): Matrix;
  119407. /**
  119408. * Gets the current projection matrix
  119409. * @returns a Matrix
  119410. */
  119411. getProjectionMatrix(): Matrix;
  119412. /**
  119413. * Gets the current transform matrix
  119414. * @returns a Matrix made of View * Projection
  119415. */
  119416. getTransformMatrix(): Matrix;
  119417. /**
  119418. * Sets the current transform matrix
  119419. * @param viewL defines the View matrix to use
  119420. * @param projectionL defines the Projection matrix to use
  119421. * @param viewR defines the right View matrix to use (if provided)
  119422. * @param projectionR defines the right Projection matrix to use (if provided)
  119423. */
  119424. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119425. /**
  119426. * Gets the uniform buffer used to store scene data
  119427. * @returns a UniformBuffer
  119428. */
  119429. getSceneUniformBuffer(): UniformBuffer;
  119430. /**
  119431. * Gets an unique (relatively to the current scene) Id
  119432. * @returns an unique number for the scene
  119433. */
  119434. getUniqueId(): number;
  119435. /**
  119436. * Add a mesh to the list of scene's meshes
  119437. * @param newMesh defines the mesh to add
  119438. * @param recursive if all child meshes should also be added to the scene
  119439. */
  119440. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119441. /**
  119442. * Remove a mesh for the list of scene's meshes
  119443. * @param toRemove defines the mesh to remove
  119444. * @param recursive if all child meshes should also be removed from the scene
  119445. * @returns the index where the mesh was in the mesh list
  119446. */
  119447. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119448. /**
  119449. * Add a transform node to the list of scene's transform nodes
  119450. * @param newTransformNode defines the transform node to add
  119451. */
  119452. addTransformNode(newTransformNode: TransformNode): void;
  119453. /**
  119454. * Remove a transform node for the list of scene's transform nodes
  119455. * @param toRemove defines the transform node to remove
  119456. * @returns the index where the transform node was in the transform node list
  119457. */
  119458. removeTransformNode(toRemove: TransformNode): number;
  119459. /**
  119460. * Remove a skeleton for the list of scene's skeletons
  119461. * @param toRemove defines the skeleton to remove
  119462. * @returns the index where the skeleton was in the skeleton list
  119463. */
  119464. removeSkeleton(toRemove: Skeleton): number;
  119465. /**
  119466. * Remove a morph target for the list of scene's morph targets
  119467. * @param toRemove defines the morph target to remove
  119468. * @returns the index where the morph target was in the morph target list
  119469. */
  119470. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119471. /**
  119472. * Remove a light for the list of scene's lights
  119473. * @param toRemove defines the light to remove
  119474. * @returns the index where the light was in the light list
  119475. */
  119476. removeLight(toRemove: Light): number;
  119477. /**
  119478. * Remove a camera for the list of scene's cameras
  119479. * @param toRemove defines the camera to remove
  119480. * @returns the index where the camera was in the camera list
  119481. */
  119482. removeCamera(toRemove: Camera): number;
  119483. /**
  119484. * Remove a particle system for the list of scene's particle systems
  119485. * @param toRemove defines the particle system to remove
  119486. * @returns the index where the particle system was in the particle system list
  119487. */
  119488. removeParticleSystem(toRemove: IParticleSystem): number;
  119489. /**
  119490. * Remove a animation for the list of scene's animations
  119491. * @param toRemove defines the animation to remove
  119492. * @returns the index where the animation was in the animation list
  119493. */
  119494. removeAnimation(toRemove: Animation): number;
  119495. /**
  119496. * Will stop the animation of the given target
  119497. * @param target - the target
  119498. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119499. * @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)
  119500. */
  119501. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119502. /**
  119503. * Removes the given animation group from this scene.
  119504. * @param toRemove The animation group to remove
  119505. * @returns The index of the removed animation group
  119506. */
  119507. removeAnimationGroup(toRemove: AnimationGroup): number;
  119508. /**
  119509. * Removes the given multi-material from this scene.
  119510. * @param toRemove The multi-material to remove
  119511. * @returns The index of the removed multi-material
  119512. */
  119513. removeMultiMaterial(toRemove: MultiMaterial): number;
  119514. /**
  119515. * Removes the given material from this scene.
  119516. * @param toRemove The material to remove
  119517. * @returns The index of the removed material
  119518. */
  119519. removeMaterial(toRemove: Material): number;
  119520. /**
  119521. * Removes the given action manager from this scene.
  119522. * @param toRemove The action manager to remove
  119523. * @returns The index of the removed action manager
  119524. */
  119525. removeActionManager(toRemove: AbstractActionManager): number;
  119526. /**
  119527. * Removes the given texture from this scene.
  119528. * @param toRemove The texture to remove
  119529. * @returns The index of the removed texture
  119530. */
  119531. removeTexture(toRemove: BaseTexture): number;
  119532. /**
  119533. * Adds the given light to this scene
  119534. * @param newLight The light to add
  119535. */
  119536. addLight(newLight: Light): void;
  119537. /**
  119538. * Sorts the list list based on light priorities
  119539. */
  119540. sortLightsByPriority(): void;
  119541. /**
  119542. * Adds the given camera to this scene
  119543. * @param newCamera The camera to add
  119544. */
  119545. addCamera(newCamera: Camera): void;
  119546. /**
  119547. * Adds the given skeleton to this scene
  119548. * @param newSkeleton The skeleton to add
  119549. */
  119550. addSkeleton(newSkeleton: Skeleton): void;
  119551. /**
  119552. * Adds the given particle system to this scene
  119553. * @param newParticleSystem The particle system to add
  119554. */
  119555. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119556. /**
  119557. * Adds the given animation to this scene
  119558. * @param newAnimation The animation to add
  119559. */
  119560. addAnimation(newAnimation: Animation): void;
  119561. /**
  119562. * Adds the given animation group to this scene.
  119563. * @param newAnimationGroup The animation group to add
  119564. */
  119565. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119566. /**
  119567. * Adds the given multi-material to this scene
  119568. * @param newMultiMaterial The multi-material to add
  119569. */
  119570. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119571. /**
  119572. * Adds the given material to this scene
  119573. * @param newMaterial The material to add
  119574. */
  119575. addMaterial(newMaterial: Material): void;
  119576. /**
  119577. * Adds the given morph target to this scene
  119578. * @param newMorphTargetManager The morph target to add
  119579. */
  119580. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119581. /**
  119582. * Adds the given geometry to this scene
  119583. * @param newGeometry The geometry to add
  119584. */
  119585. addGeometry(newGeometry: Geometry): void;
  119586. /**
  119587. * Adds the given action manager to this scene
  119588. * @param newActionManager The action manager to add
  119589. */
  119590. addActionManager(newActionManager: AbstractActionManager): void;
  119591. /**
  119592. * Adds the given texture to this scene.
  119593. * @param newTexture The texture to add
  119594. */
  119595. addTexture(newTexture: BaseTexture): void;
  119596. /**
  119597. * Switch active camera
  119598. * @param newCamera defines the new active camera
  119599. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119600. */
  119601. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119602. /**
  119603. * sets the active camera of the scene using its ID
  119604. * @param id defines the camera's ID
  119605. * @return the new active camera or null if none found.
  119606. */
  119607. setActiveCameraByID(id: string): Nullable<Camera>;
  119608. /**
  119609. * sets the active camera of the scene using its name
  119610. * @param name defines the camera's name
  119611. * @returns the new active camera or null if none found.
  119612. */
  119613. setActiveCameraByName(name: string): Nullable<Camera>;
  119614. /**
  119615. * get an animation group using its name
  119616. * @param name defines the material's name
  119617. * @return the animation group or null if none found.
  119618. */
  119619. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119620. /**
  119621. * Get a material using its unique id
  119622. * @param uniqueId defines the material's unique id
  119623. * @return the material or null if none found.
  119624. */
  119625. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119626. /**
  119627. * get a material using its id
  119628. * @param id defines the material's ID
  119629. * @return the material or null if none found.
  119630. */
  119631. getMaterialByID(id: string): Nullable<Material>;
  119632. /**
  119633. * Gets a the last added material using a given id
  119634. * @param id defines the material's ID
  119635. * @return the last material with the given id or null if none found.
  119636. */
  119637. getLastMaterialByID(id: string): Nullable<Material>;
  119638. /**
  119639. * Gets a material using its name
  119640. * @param name defines the material's name
  119641. * @return the material or null if none found.
  119642. */
  119643. getMaterialByName(name: string): Nullable<Material>;
  119644. /**
  119645. * Get a texture using its unique id
  119646. * @param uniqueId defines the texture's unique id
  119647. * @return the texture or null if none found.
  119648. */
  119649. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119650. /**
  119651. * Gets a camera using its id
  119652. * @param id defines the id to look for
  119653. * @returns the camera or null if not found
  119654. */
  119655. getCameraByID(id: string): Nullable<Camera>;
  119656. /**
  119657. * Gets a camera using its unique id
  119658. * @param uniqueId defines the unique id to look for
  119659. * @returns the camera or null if not found
  119660. */
  119661. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119662. /**
  119663. * Gets a camera using its name
  119664. * @param name defines the camera's name
  119665. * @return the camera or null if none found.
  119666. */
  119667. getCameraByName(name: string): Nullable<Camera>;
  119668. /**
  119669. * Gets a bone using its id
  119670. * @param id defines the bone's id
  119671. * @return the bone or null if not found
  119672. */
  119673. getBoneByID(id: string): Nullable<Bone>;
  119674. /**
  119675. * Gets a bone using its id
  119676. * @param name defines the bone's name
  119677. * @return the bone or null if not found
  119678. */
  119679. getBoneByName(name: string): Nullable<Bone>;
  119680. /**
  119681. * Gets a light node using its name
  119682. * @param name defines the the light's name
  119683. * @return the light or null if none found.
  119684. */
  119685. getLightByName(name: string): Nullable<Light>;
  119686. /**
  119687. * Gets a light node using its id
  119688. * @param id defines the light's id
  119689. * @return the light or null if none found.
  119690. */
  119691. getLightByID(id: string): Nullable<Light>;
  119692. /**
  119693. * Gets a light node using its scene-generated unique ID
  119694. * @param uniqueId defines the light's unique id
  119695. * @return the light or null if none found.
  119696. */
  119697. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119698. /**
  119699. * Gets a particle system by id
  119700. * @param id defines the particle system id
  119701. * @return the corresponding system or null if none found
  119702. */
  119703. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119704. /**
  119705. * Gets a geometry using its ID
  119706. * @param id defines the geometry's id
  119707. * @return the geometry or null if none found.
  119708. */
  119709. getGeometryByID(id: string): Nullable<Geometry>;
  119710. private _getGeometryByUniqueID;
  119711. /**
  119712. * Add a new geometry to this scene
  119713. * @param geometry defines the geometry to be added to the scene.
  119714. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119715. * @return a boolean defining if the geometry was added or not
  119716. */
  119717. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119718. /**
  119719. * Removes an existing geometry
  119720. * @param geometry defines the geometry to be removed from the scene
  119721. * @return a boolean defining if the geometry was removed or not
  119722. */
  119723. removeGeometry(geometry: Geometry): boolean;
  119724. /**
  119725. * Gets the list of geometries attached to the scene
  119726. * @returns an array of Geometry
  119727. */
  119728. getGeometries(): Geometry[];
  119729. /**
  119730. * Gets the first added mesh found of a given ID
  119731. * @param id defines the id to search for
  119732. * @return the mesh found or null if not found at all
  119733. */
  119734. getMeshByID(id: string): Nullable<AbstractMesh>;
  119735. /**
  119736. * Gets a list of meshes using their id
  119737. * @param id defines the id to search for
  119738. * @returns a list of meshes
  119739. */
  119740. getMeshesByID(id: string): Array<AbstractMesh>;
  119741. /**
  119742. * Gets the first added transform node found of a given ID
  119743. * @param id defines the id to search for
  119744. * @return the found transform node or null if not found at all.
  119745. */
  119746. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119747. /**
  119748. * Gets a transform node with its auto-generated unique id
  119749. * @param uniqueId efines the unique id to search for
  119750. * @return the found transform node or null if not found at all.
  119751. */
  119752. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119753. /**
  119754. * Gets a list of transform nodes using their id
  119755. * @param id defines the id to search for
  119756. * @returns a list of transform nodes
  119757. */
  119758. getTransformNodesByID(id: string): Array<TransformNode>;
  119759. /**
  119760. * Gets a mesh with its auto-generated unique id
  119761. * @param uniqueId defines the unique id to search for
  119762. * @return the found mesh or null if not found at all.
  119763. */
  119764. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119765. /**
  119766. * Gets a the last added mesh using a given id
  119767. * @param id defines the id to search for
  119768. * @return the found mesh or null if not found at all.
  119769. */
  119770. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119771. /**
  119772. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119773. * @param id defines the id to search for
  119774. * @return the found node or null if not found at all
  119775. */
  119776. getLastEntryByID(id: string): Nullable<Node>;
  119777. /**
  119778. * Gets a node (Mesh, Camera, Light) using a given id
  119779. * @param id defines the id to search for
  119780. * @return the found node or null if not found at all
  119781. */
  119782. getNodeByID(id: string): Nullable<Node>;
  119783. /**
  119784. * Gets a node (Mesh, Camera, Light) using a given name
  119785. * @param name defines the name to search for
  119786. * @return the found node or null if not found at all.
  119787. */
  119788. getNodeByName(name: string): Nullable<Node>;
  119789. /**
  119790. * Gets a mesh using a given name
  119791. * @param name defines the name to search for
  119792. * @return the found mesh or null if not found at all.
  119793. */
  119794. getMeshByName(name: string): Nullable<AbstractMesh>;
  119795. /**
  119796. * Gets a transform node using a given name
  119797. * @param name defines the name to search for
  119798. * @return the found transform node or null if not found at all.
  119799. */
  119800. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119801. /**
  119802. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119803. * @param id defines the id to search for
  119804. * @return the found skeleton or null if not found at all.
  119805. */
  119806. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119807. /**
  119808. * Gets a skeleton using a given auto generated unique id
  119809. * @param uniqueId defines the unique id to search for
  119810. * @return the found skeleton or null if not found at all.
  119811. */
  119812. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119813. /**
  119814. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119815. * @param id defines the id to search for
  119816. * @return the found skeleton or null if not found at all.
  119817. */
  119818. getSkeletonById(id: string): Nullable<Skeleton>;
  119819. /**
  119820. * Gets a skeleton using a given name
  119821. * @param name defines the name to search for
  119822. * @return the found skeleton or null if not found at all.
  119823. */
  119824. getSkeletonByName(name: string): Nullable<Skeleton>;
  119825. /**
  119826. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119827. * @param id defines the id to search for
  119828. * @return the found morph target manager or null if not found at all.
  119829. */
  119830. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119831. /**
  119832. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119833. * @param id defines the id to search for
  119834. * @return the found morph target or null if not found at all.
  119835. */
  119836. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119837. /**
  119838. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119839. * @param name defines the name to search for
  119840. * @return the found morph target or null if not found at all.
  119841. */
  119842. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119843. /**
  119844. * Gets a boolean indicating if the given mesh is active
  119845. * @param mesh defines the mesh to look for
  119846. * @returns true if the mesh is in the active list
  119847. */
  119848. isActiveMesh(mesh: AbstractMesh): boolean;
  119849. /**
  119850. * Return a unique id as a string which can serve as an identifier for the scene
  119851. */
  119852. get uid(): string;
  119853. /**
  119854. * Add an externaly attached data from its key.
  119855. * This method call will fail and return false, if such key already exists.
  119856. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119857. * @param key the unique key that identifies the data
  119858. * @param data the data object to associate to the key for this Engine instance
  119859. * @return true if no such key were already present and the data was added successfully, false otherwise
  119860. */
  119861. addExternalData<T>(key: string, data: T): boolean;
  119862. /**
  119863. * Get an externaly attached data from its key
  119864. * @param key the unique key that identifies the data
  119865. * @return the associated data, if present (can be null), or undefined if not present
  119866. */
  119867. getExternalData<T>(key: string): Nullable<T>;
  119868. /**
  119869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119870. * @param key the unique key that identifies the data
  119871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119872. * @return the associated data, can be null if the factory returned null.
  119873. */
  119874. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119875. /**
  119876. * Remove an externaly attached data from the Engine instance
  119877. * @param key the unique key that identifies the data
  119878. * @return true if the data was successfully removed, false if it doesn't exist
  119879. */
  119880. removeExternalData(key: string): boolean;
  119881. private _evaluateSubMesh;
  119882. /**
  119883. * Clear the processed materials smart array preventing retention point in material dispose.
  119884. */
  119885. freeProcessedMaterials(): void;
  119886. private _preventFreeActiveMeshesAndRenderingGroups;
  119887. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119888. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119889. * when disposing several meshes in a row or a hierarchy of meshes.
  119890. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119891. */
  119892. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119893. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119894. /**
  119895. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119896. */
  119897. freeActiveMeshes(): void;
  119898. /**
  119899. * Clear the info related to rendering groups preventing retention points during dispose.
  119900. */
  119901. freeRenderingGroups(): void;
  119902. /** @hidden */
  119903. _isInIntermediateRendering(): boolean;
  119904. /**
  119905. * Lambda returning the list of potentially active meshes.
  119906. */
  119907. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119908. /**
  119909. * Lambda returning the list of potentially active sub meshes.
  119910. */
  119911. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119912. /**
  119913. * Lambda returning the list of potentially intersecting sub meshes.
  119914. */
  119915. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119916. /**
  119917. * Lambda returning the list of potentially colliding sub meshes.
  119918. */
  119919. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119920. private _activeMeshesFrozen;
  119921. private _skipEvaluateActiveMeshesCompletely;
  119922. /**
  119923. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119924. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119925. * @returns the current scene
  119926. */
  119927. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119928. /**
  119929. * Use this function to restart evaluating active meshes on every frame
  119930. * @returns the current scene
  119931. */
  119932. unfreezeActiveMeshes(): Scene;
  119933. private _evaluateActiveMeshes;
  119934. private _activeMesh;
  119935. /**
  119936. * Update the transform matrix to update from the current active camera
  119937. * @param force defines a boolean used to force the update even if cache is up to date
  119938. */
  119939. updateTransformMatrix(force?: boolean): void;
  119940. private _bindFrameBuffer;
  119941. /** @hidden */
  119942. _allowPostProcessClearColor: boolean;
  119943. /** @hidden */
  119944. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119945. private _processSubCameras;
  119946. private _checkIntersections;
  119947. /** @hidden */
  119948. _advancePhysicsEngineStep(step: number): void;
  119949. /**
  119950. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119951. */
  119952. getDeterministicFrameTime: () => number;
  119953. /** @hidden */
  119954. _animate(): void;
  119955. /** Execute all animations (for a frame) */
  119956. animate(): void;
  119957. /**
  119958. * Render the scene
  119959. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119960. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119961. */
  119962. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119963. /**
  119964. * Freeze all materials
  119965. * A frozen material will not be updatable but should be faster to render
  119966. */
  119967. freezeMaterials(): void;
  119968. /**
  119969. * Unfreeze all materials
  119970. * A frozen material will not be updatable but should be faster to render
  119971. */
  119972. unfreezeMaterials(): void;
  119973. /**
  119974. * Releases all held ressources
  119975. */
  119976. dispose(): void;
  119977. /**
  119978. * Gets if the scene is already disposed
  119979. */
  119980. get isDisposed(): boolean;
  119981. /**
  119982. * Call this function to reduce memory footprint of the scene.
  119983. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119984. */
  119985. clearCachedVertexData(): void;
  119986. /**
  119987. * This function will remove the local cached buffer data from texture.
  119988. * It will save memory but will prevent the texture from being rebuilt
  119989. */
  119990. cleanCachedTextureBuffer(): void;
  119991. /**
  119992. * Get the world extend vectors with an optional filter
  119993. *
  119994. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119995. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119996. */
  119997. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119998. min: Vector3;
  119999. max: Vector3;
  120000. };
  120001. /**
  120002. * Creates a ray that can be used to pick in the scene
  120003. * @param x defines the x coordinate of the origin (on-screen)
  120004. * @param y defines the y coordinate of the origin (on-screen)
  120005. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120006. * @param camera defines the camera to use for the picking
  120007. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120008. * @returns a Ray
  120009. */
  120010. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120011. /**
  120012. * Creates a ray that can be used to pick in the scene
  120013. * @param x defines the x coordinate of the origin (on-screen)
  120014. * @param y defines the y coordinate of the origin (on-screen)
  120015. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120016. * @param result defines the ray where to store the picking ray
  120017. * @param camera defines the camera to use for the picking
  120018. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120019. * @returns the current scene
  120020. */
  120021. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120022. /**
  120023. * Creates a ray that can be used to pick in the scene
  120024. * @param x defines the x coordinate of the origin (on-screen)
  120025. * @param y defines the y coordinate of the origin (on-screen)
  120026. * @param camera defines the camera to use for the picking
  120027. * @returns a Ray
  120028. */
  120029. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120030. /**
  120031. * Creates a ray that can be used to pick in the scene
  120032. * @param x defines the x coordinate of the origin (on-screen)
  120033. * @param y defines the y coordinate of the origin (on-screen)
  120034. * @param result defines the ray where to store the picking ray
  120035. * @param camera defines the camera to use for the picking
  120036. * @returns the current scene
  120037. */
  120038. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120039. /** Launch a ray to try to pick a mesh in the scene
  120040. * @param x position on screen
  120041. * @param y position on screen
  120042. * @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
  120043. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120044. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120045. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120046. * @returns a PickingInfo
  120047. */
  120048. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120049. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120050. * @param x position on screen
  120051. * @param y position on screen
  120052. * @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
  120053. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120054. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120055. * @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)
  120056. */
  120057. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120058. /** Use the given ray to pick a mesh in the scene
  120059. * @param ray The ray to use to pick meshes
  120060. * @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
  120061. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120062. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120063. * @returns a PickingInfo
  120064. */
  120065. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120066. /**
  120067. * Launch a ray to try to pick a mesh in the scene
  120068. * @param x X position on screen
  120069. * @param y Y position on screen
  120070. * @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
  120071. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120072. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120073. * @returns an array of PickingInfo
  120074. */
  120075. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120076. /**
  120077. * Launch a ray to try to pick a mesh in the scene
  120078. * @param ray Ray to use
  120079. * @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
  120080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120081. * @returns an array of PickingInfo
  120082. */
  120083. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120084. /**
  120085. * Force the value of meshUnderPointer
  120086. * @param mesh defines the mesh to use
  120087. */
  120088. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  120089. /**
  120090. * Gets the mesh under the pointer
  120091. * @returns a Mesh or null if no mesh is under the pointer
  120092. */
  120093. getPointerOverMesh(): Nullable<AbstractMesh>;
  120094. /** @hidden */
  120095. _rebuildGeometries(): void;
  120096. /** @hidden */
  120097. _rebuildTextures(): void;
  120098. private _getByTags;
  120099. /**
  120100. * Get a list of meshes by tags
  120101. * @param tagsQuery defines the tags query to use
  120102. * @param forEach defines a predicate used to filter results
  120103. * @returns an array of Mesh
  120104. */
  120105. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120106. /**
  120107. * Get a list of cameras by tags
  120108. * @param tagsQuery defines the tags query to use
  120109. * @param forEach defines a predicate used to filter results
  120110. * @returns an array of Camera
  120111. */
  120112. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120113. /**
  120114. * Get a list of lights by tags
  120115. * @param tagsQuery defines the tags query to use
  120116. * @param forEach defines a predicate used to filter results
  120117. * @returns an array of Light
  120118. */
  120119. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120120. /**
  120121. * Get a list of materials by tags
  120122. * @param tagsQuery defines the tags query to use
  120123. * @param forEach defines a predicate used to filter results
  120124. * @returns an array of Material
  120125. */
  120126. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120127. /**
  120128. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120129. * This allowed control for front to back rendering or reversly depending of the special needs.
  120130. *
  120131. * @param renderingGroupId The rendering group id corresponding to its index
  120132. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120133. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120134. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120135. */
  120136. 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;
  120137. /**
  120138. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120139. *
  120140. * @param renderingGroupId The rendering group id corresponding to its index
  120141. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120142. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120143. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120144. */
  120145. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120146. /**
  120147. * Gets the current auto clear configuration for one rendering group of the rendering
  120148. * manager.
  120149. * @param index the rendering group index to get the information for
  120150. * @returns The auto clear setup for the requested rendering group
  120151. */
  120152. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120153. private _blockMaterialDirtyMechanism;
  120154. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120155. get blockMaterialDirtyMechanism(): boolean;
  120156. set blockMaterialDirtyMechanism(value: boolean);
  120157. /**
  120158. * Will flag all materials as dirty to trigger new shader compilation
  120159. * @param flag defines the flag used to specify which material part must be marked as dirty
  120160. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  120161. */
  120162. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  120163. /** @hidden */
  120164. _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;
  120165. /** @hidden */
  120166. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120167. /** @hidden */
  120168. _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;
  120169. /** @hidden */
  120170. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  120171. /** @hidden */
  120172. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  120173. /** @hidden */
  120174. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  120175. }
  120176. }
  120177. declare module BABYLON {
  120178. /**
  120179. * Set of assets to keep when moving a scene into an asset container.
  120180. */
  120181. export class KeepAssets extends AbstractScene {
  120182. }
  120183. /**
  120184. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120185. */
  120186. export class InstantiatedEntries {
  120187. /**
  120188. * List of new root nodes (eg. nodes with no parent)
  120189. */
  120190. rootNodes: TransformNode[];
  120191. /**
  120192. * List of new skeletons
  120193. */
  120194. skeletons: Skeleton[];
  120195. /**
  120196. * List of new animation groups
  120197. */
  120198. animationGroups: AnimationGroup[];
  120199. }
  120200. /**
  120201. * Container with a set of assets that can be added or removed from a scene.
  120202. */
  120203. export class AssetContainer extends AbstractScene {
  120204. private _wasAddedToScene;
  120205. /**
  120206. * The scene the AssetContainer belongs to.
  120207. */
  120208. scene: Scene;
  120209. /**
  120210. * Instantiates an AssetContainer.
  120211. * @param scene The scene the AssetContainer belongs to.
  120212. */
  120213. constructor(scene: Scene);
  120214. /**
  120215. * Instantiate or clone all meshes and add the new ones to the scene.
  120216. * Skeletons and animation groups will all be cloned
  120217. * @param nameFunction defines an optional function used to get new names for clones
  120218. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120219. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120220. */
  120221. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120222. /**
  120223. * Adds all the assets from the container to the scene.
  120224. */
  120225. addAllToScene(): void;
  120226. /**
  120227. * Removes all the assets in the container from the scene
  120228. */
  120229. removeAllFromScene(): void;
  120230. /**
  120231. * Disposes all the assets in the container
  120232. */
  120233. dispose(): void;
  120234. private _moveAssets;
  120235. /**
  120236. * Removes all the assets contained in the scene and adds them to the container.
  120237. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120238. */
  120239. moveAllFromScene(keepAssets?: KeepAssets): void;
  120240. /**
  120241. * 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.
  120242. * @returns the root mesh
  120243. */
  120244. createRootMesh(): Mesh;
  120245. /**
  120246. * Merge animations (direct and animation groups) from this asset container into a scene
  120247. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120248. * @param animatables set of animatables to retarget to a node from the scene
  120249. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120250. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120251. */
  120252. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120253. }
  120254. }
  120255. declare module BABYLON {
  120256. /**
  120257. * Defines how the parser contract is defined.
  120258. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120259. */
  120260. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120261. /**
  120262. * Defines how the individual parser contract is defined.
  120263. * These parser can parse an individual asset
  120264. */
  120265. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120266. /**
  120267. * Base class of the scene acting as a container for the different elements composing a scene.
  120268. * This class is dynamically extended by the different components of the scene increasing
  120269. * flexibility and reducing coupling
  120270. */
  120271. export abstract class AbstractScene {
  120272. /**
  120273. * Stores the list of available parsers in the application.
  120274. */
  120275. private static _BabylonFileParsers;
  120276. /**
  120277. * Stores the list of available individual parsers in the application.
  120278. */
  120279. private static _IndividualBabylonFileParsers;
  120280. /**
  120281. * Adds a parser in the list of available ones
  120282. * @param name Defines the name of the parser
  120283. * @param parser Defines the parser to add
  120284. */
  120285. static AddParser(name: string, parser: BabylonFileParser): void;
  120286. /**
  120287. * Gets a general parser from the list of avaialble ones
  120288. * @param name Defines the name of the parser
  120289. * @returns the requested parser or null
  120290. */
  120291. static GetParser(name: string): Nullable<BabylonFileParser>;
  120292. /**
  120293. * Adds n individual parser in the list of available ones
  120294. * @param name Defines the name of the parser
  120295. * @param parser Defines the parser to add
  120296. */
  120297. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120298. /**
  120299. * Gets an individual parser from the list of avaialble ones
  120300. * @param name Defines the name of the parser
  120301. * @returns the requested parser or null
  120302. */
  120303. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120304. /**
  120305. * Parser json data and populate both a scene and its associated container object
  120306. * @param jsonData Defines the data to parse
  120307. * @param scene Defines the scene to parse the data for
  120308. * @param container Defines the container attached to the parsing sequence
  120309. * @param rootUrl Defines the root url of the data
  120310. */
  120311. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120312. /**
  120313. * Gets the list of root nodes (ie. nodes with no parent)
  120314. */
  120315. rootNodes: Node[];
  120316. /** All of the cameras added to this scene
  120317. * @see https://doc.babylonjs.com/babylon101/cameras
  120318. */
  120319. cameras: Camera[];
  120320. /**
  120321. * All of the lights added to this scene
  120322. * @see https://doc.babylonjs.com/babylon101/lights
  120323. */
  120324. lights: Light[];
  120325. /**
  120326. * All of the (abstract) meshes added to this scene
  120327. */
  120328. meshes: AbstractMesh[];
  120329. /**
  120330. * The list of skeletons added to the scene
  120331. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120332. */
  120333. skeletons: Skeleton[];
  120334. /**
  120335. * All of the particle systems added to this scene
  120336. * @see https://doc.babylonjs.com/babylon101/particles
  120337. */
  120338. particleSystems: IParticleSystem[];
  120339. /**
  120340. * Gets a list of Animations associated with the scene
  120341. */
  120342. animations: Animation[];
  120343. /**
  120344. * All of the animation groups added to this scene
  120345. * @see https://doc.babylonjs.com/how_to/group
  120346. */
  120347. animationGroups: AnimationGroup[];
  120348. /**
  120349. * All of the multi-materials added to this scene
  120350. * @see https://doc.babylonjs.com/how_to/multi_materials
  120351. */
  120352. multiMaterials: MultiMaterial[];
  120353. /**
  120354. * All of the materials added to this scene
  120355. * In the context of a Scene, it is not supposed to be modified manually.
  120356. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120357. * Note also that the order of the Material within the array is not significant and might change.
  120358. * @see https://doc.babylonjs.com/babylon101/materials
  120359. */
  120360. materials: Material[];
  120361. /**
  120362. * The list of morph target managers added to the scene
  120363. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120364. */
  120365. morphTargetManagers: MorphTargetManager[];
  120366. /**
  120367. * The list of geometries used in the scene.
  120368. */
  120369. geometries: Geometry[];
  120370. /**
  120371. * All of the tranform nodes added to this scene
  120372. * In the context of a Scene, it is not supposed to be modified manually.
  120373. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120374. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120375. * @see https://doc.babylonjs.com/how_to/transformnode
  120376. */
  120377. transformNodes: TransformNode[];
  120378. /**
  120379. * ActionManagers available on the scene.
  120380. */
  120381. actionManagers: AbstractActionManager[];
  120382. /**
  120383. * Textures to keep.
  120384. */
  120385. textures: BaseTexture[];
  120386. /**
  120387. * Environment texture for the scene
  120388. */
  120389. environmentTexture: Nullable<BaseTexture>;
  120390. /**
  120391. * @returns all meshes, lights, cameras, transformNodes and bones
  120392. */
  120393. getNodes(): Array<Node>;
  120394. }
  120395. }
  120396. declare module BABYLON {
  120397. /**
  120398. * Interface used to define options for Sound class
  120399. */
  120400. export interface ISoundOptions {
  120401. /**
  120402. * Does the sound autoplay once loaded.
  120403. */
  120404. autoplay?: boolean;
  120405. /**
  120406. * Does the sound loop after it finishes playing once.
  120407. */
  120408. loop?: boolean;
  120409. /**
  120410. * Sound's volume
  120411. */
  120412. volume?: number;
  120413. /**
  120414. * Is it a spatial sound?
  120415. */
  120416. spatialSound?: boolean;
  120417. /**
  120418. * Maximum distance to hear that sound
  120419. */
  120420. maxDistance?: number;
  120421. /**
  120422. * Uses user defined attenuation function
  120423. */
  120424. useCustomAttenuation?: boolean;
  120425. /**
  120426. * Define the roll off factor of spatial sounds.
  120427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120428. */
  120429. rolloffFactor?: number;
  120430. /**
  120431. * Define the reference distance the sound should be heard perfectly.
  120432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120433. */
  120434. refDistance?: number;
  120435. /**
  120436. * Define the distance attenuation model the sound will follow.
  120437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120438. */
  120439. distanceModel?: string;
  120440. /**
  120441. * Defines the playback speed (1 by default)
  120442. */
  120443. playbackRate?: number;
  120444. /**
  120445. * Defines if the sound is from a streaming source
  120446. */
  120447. streaming?: boolean;
  120448. /**
  120449. * Defines an optional length (in seconds) inside the sound file
  120450. */
  120451. length?: number;
  120452. /**
  120453. * Defines an optional offset (in seconds) inside the sound file
  120454. */
  120455. offset?: number;
  120456. /**
  120457. * If true, URLs will not be required to state the audio file codec to use.
  120458. */
  120459. skipCodecCheck?: boolean;
  120460. }
  120461. /**
  120462. * Defines a sound that can be played in the application.
  120463. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120465. */
  120466. export class Sound {
  120467. /**
  120468. * The name of the sound in the scene.
  120469. */
  120470. name: string;
  120471. /**
  120472. * Does the sound autoplay once loaded.
  120473. */
  120474. autoplay: boolean;
  120475. /**
  120476. * Does the sound loop after it finishes playing once.
  120477. */
  120478. loop: boolean;
  120479. /**
  120480. * Does the sound use a custom attenuation curve to simulate the falloff
  120481. * happening when the source gets further away from the camera.
  120482. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120483. */
  120484. useCustomAttenuation: boolean;
  120485. /**
  120486. * The sound track id this sound belongs to.
  120487. */
  120488. soundTrackId: number;
  120489. /**
  120490. * Is this sound currently played.
  120491. */
  120492. isPlaying: boolean;
  120493. /**
  120494. * Is this sound currently paused.
  120495. */
  120496. isPaused: boolean;
  120497. /**
  120498. * Does this sound enables spatial sound.
  120499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120500. */
  120501. spatialSound: boolean;
  120502. /**
  120503. * Define the reference distance the sound should be heard perfectly.
  120504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120505. */
  120506. refDistance: number;
  120507. /**
  120508. * Define the roll off factor of spatial sounds.
  120509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120510. */
  120511. rolloffFactor: number;
  120512. /**
  120513. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120515. */
  120516. maxDistance: number;
  120517. /**
  120518. * Define the distance attenuation model the sound will follow.
  120519. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120520. */
  120521. distanceModel: string;
  120522. /**
  120523. * @hidden
  120524. * Back Compat
  120525. **/
  120526. onended: () => any;
  120527. /**
  120528. * Gets or sets an object used to store user defined information for the sound.
  120529. */
  120530. metadata: any;
  120531. /**
  120532. * Observable event when the current playing sound finishes.
  120533. */
  120534. onEndedObservable: Observable<Sound>;
  120535. private _panningModel;
  120536. private _playbackRate;
  120537. private _streaming;
  120538. private _startTime;
  120539. private _startOffset;
  120540. private _position;
  120541. /** @hidden */
  120542. _positionInEmitterSpace: boolean;
  120543. private _localDirection;
  120544. private _volume;
  120545. private _isReadyToPlay;
  120546. private _isDirectional;
  120547. private _readyToPlayCallback;
  120548. private _audioBuffer;
  120549. private _soundSource;
  120550. private _streamingSource;
  120551. private _soundPanner;
  120552. private _soundGain;
  120553. private _inputAudioNode;
  120554. private _outputAudioNode;
  120555. private _coneInnerAngle;
  120556. private _coneOuterAngle;
  120557. private _coneOuterGain;
  120558. private _scene;
  120559. private _connectedTransformNode;
  120560. private _customAttenuationFunction;
  120561. private _registerFunc;
  120562. private _isOutputConnected;
  120563. private _htmlAudioElement;
  120564. private _urlType;
  120565. private _length?;
  120566. private _offset?;
  120567. /** @hidden */
  120568. static _SceneComponentInitialization: (scene: Scene) => void;
  120569. /**
  120570. * Create a sound and attach it to a scene
  120571. * @param name Name of your sound
  120572. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120573. * @param scene defines the scene the sound belongs to
  120574. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120575. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120576. */
  120577. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120578. /**
  120579. * Release the sound and its associated resources
  120580. */
  120581. dispose(): void;
  120582. /**
  120583. * Gets if the sounds is ready to be played or not.
  120584. * @returns true if ready, otherwise false
  120585. */
  120586. isReady(): boolean;
  120587. private _soundLoaded;
  120588. /**
  120589. * Sets the data of the sound from an audiobuffer
  120590. * @param audioBuffer The audioBuffer containing the data
  120591. */
  120592. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120593. /**
  120594. * Updates the current sounds options such as maxdistance, loop...
  120595. * @param options A JSON object containing values named as the object properties
  120596. */
  120597. updateOptions(options: ISoundOptions): void;
  120598. private _createSpatialParameters;
  120599. private _updateSpatialParameters;
  120600. /**
  120601. * Switch the panning model to HRTF:
  120602. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120603. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120604. */
  120605. switchPanningModelToHRTF(): void;
  120606. /**
  120607. * Switch the panning model to Equal Power:
  120608. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120609. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120610. */
  120611. switchPanningModelToEqualPower(): void;
  120612. private _switchPanningModel;
  120613. /**
  120614. * Connect this sound to a sound track audio node like gain...
  120615. * @param soundTrackAudioNode the sound track audio node to connect to
  120616. */
  120617. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120618. /**
  120619. * Transform this sound into a directional source
  120620. * @param coneInnerAngle Size of the inner cone in degree
  120621. * @param coneOuterAngle Size of the outer cone in degree
  120622. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120623. */
  120624. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120625. /**
  120626. * Gets or sets the inner angle for the directional cone.
  120627. */
  120628. get directionalConeInnerAngle(): number;
  120629. /**
  120630. * Gets or sets the inner angle for the directional cone.
  120631. */
  120632. set directionalConeInnerAngle(value: number);
  120633. /**
  120634. * Gets or sets the outer angle for the directional cone.
  120635. */
  120636. get directionalConeOuterAngle(): number;
  120637. /**
  120638. * Gets or sets the outer angle for the directional cone.
  120639. */
  120640. set directionalConeOuterAngle(value: number);
  120641. /**
  120642. * Sets the position of the emitter if spatial sound is enabled
  120643. * @param newPosition Defines the new posisiton
  120644. */
  120645. setPosition(newPosition: Vector3): void;
  120646. /**
  120647. * Sets the local direction of the emitter if spatial sound is enabled
  120648. * @param newLocalDirection Defines the new local direction
  120649. */
  120650. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120651. private _updateDirection;
  120652. /** @hidden */
  120653. updateDistanceFromListener(): void;
  120654. /**
  120655. * Sets a new custom attenuation function for the sound.
  120656. * @param callback Defines the function used for the attenuation
  120657. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120658. */
  120659. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120660. /**
  120661. * Play the sound
  120662. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120663. * @param offset (optional) Start the sound at a specific time in seconds
  120664. * @param length (optional) Sound duration (in seconds)
  120665. */
  120666. play(time?: number, offset?: number, length?: number): void;
  120667. private _onended;
  120668. /**
  120669. * Stop the sound
  120670. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120671. */
  120672. stop(time?: number): void;
  120673. /**
  120674. * Put the sound in pause
  120675. */
  120676. pause(): void;
  120677. /**
  120678. * Sets a dedicated volume for this sounds
  120679. * @param newVolume Define the new volume of the sound
  120680. * @param time Define time for gradual change to new volume
  120681. */
  120682. setVolume(newVolume: number, time?: number): void;
  120683. /**
  120684. * Set the sound play back rate
  120685. * @param newPlaybackRate Define the playback rate the sound should be played at
  120686. */
  120687. setPlaybackRate(newPlaybackRate: number): void;
  120688. /**
  120689. * Gets the volume of the sound.
  120690. * @returns the volume of the sound
  120691. */
  120692. getVolume(): number;
  120693. /**
  120694. * Attach the sound to a dedicated mesh
  120695. * @param transformNode The transform node to connect the sound with
  120696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120697. */
  120698. attachToMesh(transformNode: TransformNode): void;
  120699. /**
  120700. * Detach the sound from the previously attached mesh
  120701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120702. */
  120703. detachFromMesh(): void;
  120704. private _onRegisterAfterWorldMatrixUpdate;
  120705. /**
  120706. * Clone the current sound in the scene.
  120707. * @returns the new sound clone
  120708. */
  120709. clone(): Nullable<Sound>;
  120710. /**
  120711. * Gets the current underlying audio buffer containing the data
  120712. * @returns the audio buffer
  120713. */
  120714. getAudioBuffer(): Nullable<AudioBuffer>;
  120715. /**
  120716. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120717. * @returns the source node
  120718. */
  120719. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120720. /**
  120721. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120722. * @returns the gain node
  120723. */
  120724. getSoundGain(): Nullable<GainNode>;
  120725. /**
  120726. * Serializes the Sound in a JSON representation
  120727. * @returns the JSON representation of the sound
  120728. */
  120729. serialize(): any;
  120730. /**
  120731. * Parse a JSON representation of a sound to innstantiate in a given scene
  120732. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120733. * @param scene Define the scene the new parsed sound should be created in
  120734. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120735. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120736. * @returns the newly parsed sound
  120737. */
  120738. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120739. }
  120740. }
  120741. declare module BABYLON {
  120742. /**
  120743. * This defines an action helpful to play a defined sound on a triggered action.
  120744. */
  120745. export class PlaySoundAction extends Action {
  120746. private _sound;
  120747. /**
  120748. * Instantiate the action
  120749. * @param triggerOptions defines the trigger options
  120750. * @param sound defines the sound to play
  120751. * @param condition defines the trigger related conditions
  120752. */
  120753. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120754. /** @hidden */
  120755. _prepare(): void;
  120756. /**
  120757. * Execute the action and play the sound.
  120758. */
  120759. execute(): void;
  120760. /**
  120761. * Serializes the actions and its related information.
  120762. * @param parent defines the object to serialize in
  120763. * @returns the serialized object
  120764. */
  120765. serialize(parent: any): any;
  120766. }
  120767. /**
  120768. * This defines an action helpful to stop a defined sound on a triggered action.
  120769. */
  120770. export class StopSoundAction extends Action {
  120771. private _sound;
  120772. /**
  120773. * Instantiate the action
  120774. * @param triggerOptions defines the trigger options
  120775. * @param sound defines the sound to stop
  120776. * @param condition defines the trigger related conditions
  120777. */
  120778. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120779. /** @hidden */
  120780. _prepare(): void;
  120781. /**
  120782. * Execute the action and stop the sound.
  120783. */
  120784. execute(): void;
  120785. /**
  120786. * Serializes the actions and its related information.
  120787. * @param parent defines the object to serialize in
  120788. * @returns the serialized object
  120789. */
  120790. serialize(parent: any): any;
  120791. }
  120792. }
  120793. declare module BABYLON {
  120794. /**
  120795. * This defines an action responsible to change the value of a property
  120796. * by interpolating between its current value and the newly set one once triggered.
  120797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120798. */
  120799. export class InterpolateValueAction extends Action {
  120800. /**
  120801. * Defines the path of the property where the value should be interpolated
  120802. */
  120803. propertyPath: string;
  120804. /**
  120805. * Defines the target value at the end of the interpolation.
  120806. */
  120807. value: any;
  120808. /**
  120809. * Defines the time it will take for the property to interpolate to the value.
  120810. */
  120811. duration: number;
  120812. /**
  120813. * Defines if the other scene animations should be stopped when the action has been triggered
  120814. */
  120815. stopOtherAnimations?: boolean;
  120816. /**
  120817. * Defines a callback raised once the interpolation animation has been done.
  120818. */
  120819. onInterpolationDone?: () => void;
  120820. /**
  120821. * Observable triggered once the interpolation animation has been done.
  120822. */
  120823. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120824. private _target;
  120825. private _effectiveTarget;
  120826. private _property;
  120827. /**
  120828. * Instantiate the action
  120829. * @param triggerOptions defines the trigger options
  120830. * @param target defines the object containing the value to interpolate
  120831. * @param propertyPath defines the path to the property in the target object
  120832. * @param value defines the target value at the end of the interpolation
  120833. * @param duration deines the time it will take for the property to interpolate to the value.
  120834. * @param condition defines the trigger related conditions
  120835. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120836. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120837. */
  120838. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120839. /** @hidden */
  120840. _prepare(): void;
  120841. /**
  120842. * Execute the action starts the value interpolation.
  120843. */
  120844. execute(): void;
  120845. /**
  120846. * Serializes the actions and its related information.
  120847. * @param parent defines the object to serialize in
  120848. * @returns the serialized object
  120849. */
  120850. serialize(parent: any): any;
  120851. }
  120852. }
  120853. declare module BABYLON {
  120854. /**
  120855. * Options allowed during the creation of a sound track.
  120856. */
  120857. export interface ISoundTrackOptions {
  120858. /**
  120859. * The volume the sound track should take during creation
  120860. */
  120861. volume?: number;
  120862. /**
  120863. * Define if the sound track is the main sound track of the scene
  120864. */
  120865. mainTrack?: boolean;
  120866. }
  120867. /**
  120868. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120869. * It will be also used in a future release to apply effects on a specific track.
  120870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120871. */
  120872. export class SoundTrack {
  120873. /**
  120874. * The unique identifier of the sound track in the scene.
  120875. */
  120876. id: number;
  120877. /**
  120878. * The list of sounds included in the sound track.
  120879. */
  120880. soundCollection: Array<Sound>;
  120881. private _outputAudioNode;
  120882. private _scene;
  120883. private _connectedAnalyser;
  120884. private _options;
  120885. private _isInitialized;
  120886. /**
  120887. * Creates a new sound track.
  120888. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120889. * @param scene Define the scene the sound track belongs to
  120890. * @param options
  120891. */
  120892. constructor(scene: Scene, options?: ISoundTrackOptions);
  120893. private _initializeSoundTrackAudioGraph;
  120894. /**
  120895. * Release the sound track and its associated resources
  120896. */
  120897. dispose(): void;
  120898. /**
  120899. * Adds a sound to this sound track
  120900. * @param sound define the cound to add
  120901. * @ignoreNaming
  120902. */
  120903. AddSound(sound: Sound): void;
  120904. /**
  120905. * Removes a sound to this sound track
  120906. * @param sound define the cound to remove
  120907. * @ignoreNaming
  120908. */
  120909. RemoveSound(sound: Sound): void;
  120910. /**
  120911. * Set a global volume for the full sound track.
  120912. * @param newVolume Define the new volume of the sound track
  120913. */
  120914. setVolume(newVolume: number): void;
  120915. /**
  120916. * Switch the panning model to HRTF:
  120917. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120918. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120919. */
  120920. switchPanningModelToHRTF(): void;
  120921. /**
  120922. * Switch the panning model to Equal Power:
  120923. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120925. */
  120926. switchPanningModelToEqualPower(): void;
  120927. /**
  120928. * Connect the sound track to an audio analyser allowing some amazing
  120929. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120930. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120931. * @param analyser The analyser to connect to the engine
  120932. */
  120933. connectToAnalyser(analyser: Analyser): void;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. interface AbstractScene {
  120938. /**
  120939. * The list of sounds used in the scene.
  120940. */
  120941. sounds: Nullable<Array<Sound>>;
  120942. }
  120943. interface Scene {
  120944. /**
  120945. * @hidden
  120946. * Backing field
  120947. */
  120948. _mainSoundTrack: SoundTrack;
  120949. /**
  120950. * The main sound track played by the scene.
  120951. * It cotains your primary collection of sounds.
  120952. */
  120953. mainSoundTrack: SoundTrack;
  120954. /**
  120955. * The list of sound tracks added to the scene
  120956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120957. */
  120958. soundTracks: Nullable<Array<SoundTrack>>;
  120959. /**
  120960. * Gets a sound using a given name
  120961. * @param name defines the name to search for
  120962. * @return the found sound or null if not found at all.
  120963. */
  120964. getSoundByName(name: string): Nullable<Sound>;
  120965. /**
  120966. * Gets or sets if audio support is enabled
  120967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120968. */
  120969. audioEnabled: boolean;
  120970. /**
  120971. * Gets or sets if audio will be output to headphones
  120972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120973. */
  120974. headphone: boolean;
  120975. /**
  120976. * Gets or sets custom audio listener position provider
  120977. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120978. */
  120979. audioListenerPositionProvider: Nullable<() => Vector3>;
  120980. /**
  120981. * Gets or sets a refresh rate when using 3D audio positioning
  120982. */
  120983. audioPositioningRefreshRate: number;
  120984. }
  120985. /**
  120986. * Defines the sound scene component responsible to manage any sounds
  120987. * in a given scene.
  120988. */
  120989. export class AudioSceneComponent implements ISceneSerializableComponent {
  120990. /**
  120991. * The component name helpfull to identify the component in the list of scene components.
  120992. */
  120993. readonly name: string;
  120994. /**
  120995. * The scene the component belongs to.
  120996. */
  120997. scene: Scene;
  120998. private _audioEnabled;
  120999. /**
  121000. * Gets whether audio is enabled or not.
  121001. * Please use related enable/disable method to switch state.
  121002. */
  121003. get audioEnabled(): boolean;
  121004. private _headphone;
  121005. /**
  121006. * Gets whether audio is outputing to headphone or not.
  121007. * Please use the according Switch methods to change output.
  121008. */
  121009. get headphone(): boolean;
  121010. /**
  121011. * Gets or sets a refresh rate when using 3D audio positioning
  121012. */
  121013. audioPositioningRefreshRate: number;
  121014. private _audioListenerPositionProvider;
  121015. /**
  121016. * Gets the current audio listener position provider
  121017. */
  121018. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121019. /**
  121020. * Sets a custom listener position for all sounds in the scene
  121021. * By default, this is the position of the first active camera
  121022. */
  121023. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121024. /**
  121025. * Creates a new instance of the component for the given scene
  121026. * @param scene Defines the scene to register the component in
  121027. */
  121028. constructor(scene: Scene);
  121029. /**
  121030. * Registers the component in a given scene
  121031. */
  121032. register(): void;
  121033. /**
  121034. * Rebuilds the elements related to this component in case of
  121035. * context lost for instance.
  121036. */
  121037. rebuild(): void;
  121038. /**
  121039. * Serializes the component data to the specified json object
  121040. * @param serializationObject The object to serialize to
  121041. */
  121042. serialize(serializationObject: any): void;
  121043. /**
  121044. * Adds all the elements from the container to the scene
  121045. * @param container the container holding the elements
  121046. */
  121047. addFromContainer(container: AbstractScene): void;
  121048. /**
  121049. * Removes all the elements in the container from the scene
  121050. * @param container contains the elements to remove
  121051. * @param dispose if the removed element should be disposed (default: false)
  121052. */
  121053. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121054. /**
  121055. * Disposes the component and the associated ressources.
  121056. */
  121057. dispose(): void;
  121058. /**
  121059. * Disables audio in the associated scene.
  121060. */
  121061. disableAudio(): void;
  121062. /**
  121063. * Enables audio in the associated scene.
  121064. */
  121065. enableAudio(): void;
  121066. /**
  121067. * Switch audio to headphone output.
  121068. */
  121069. switchAudioModeForHeadphones(): void;
  121070. /**
  121071. * Switch audio to normal speakers.
  121072. */
  121073. switchAudioModeForNormalSpeakers(): void;
  121074. private _cachedCameraDirection;
  121075. private _cachedCameraPosition;
  121076. private _lastCheck;
  121077. private _afterRender;
  121078. }
  121079. }
  121080. declare module BABYLON {
  121081. /**
  121082. * Wraps one or more Sound objects and selects one with random weight for playback.
  121083. */
  121084. export class WeightedSound {
  121085. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121086. loop: boolean;
  121087. private _coneInnerAngle;
  121088. private _coneOuterAngle;
  121089. private _volume;
  121090. /** A Sound is currently playing. */
  121091. isPlaying: boolean;
  121092. /** A Sound is currently paused. */
  121093. isPaused: boolean;
  121094. private _sounds;
  121095. private _weights;
  121096. private _currentIndex?;
  121097. /**
  121098. * Creates a new WeightedSound from the list of sounds given.
  121099. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121100. * @param sounds Array of Sounds that will be selected from.
  121101. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121102. */
  121103. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121104. /**
  121105. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121106. */
  121107. get directionalConeInnerAngle(): number;
  121108. /**
  121109. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121110. */
  121111. set directionalConeInnerAngle(value: number);
  121112. /**
  121113. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121114. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121115. */
  121116. get directionalConeOuterAngle(): number;
  121117. /**
  121118. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121119. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121120. */
  121121. set directionalConeOuterAngle(value: number);
  121122. /**
  121123. * Playback volume.
  121124. */
  121125. get volume(): number;
  121126. /**
  121127. * Playback volume.
  121128. */
  121129. set volume(value: number);
  121130. private _onended;
  121131. /**
  121132. * Suspend playback
  121133. */
  121134. pause(): void;
  121135. /**
  121136. * Stop playback
  121137. */
  121138. stop(): void;
  121139. /**
  121140. * Start playback.
  121141. * @param startOffset Position the clip head at a specific time in seconds.
  121142. */
  121143. play(startOffset?: number): void;
  121144. }
  121145. }
  121146. declare module BABYLON {
  121147. /**
  121148. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  121149. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121150. */
  121151. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  121152. /**
  121153. * Gets the name of the behavior.
  121154. */
  121155. get name(): string;
  121156. /**
  121157. * The easing function used by animations
  121158. */
  121159. static EasingFunction: BackEase;
  121160. /**
  121161. * The easing mode used by animations
  121162. */
  121163. static EasingMode: number;
  121164. /**
  121165. * The duration of the animation, in milliseconds
  121166. */
  121167. transitionDuration: number;
  121168. /**
  121169. * Length of the distance animated by the transition when lower radius is reached
  121170. */
  121171. lowerRadiusTransitionRange: number;
  121172. /**
  121173. * Length of the distance animated by the transition when upper radius is reached
  121174. */
  121175. upperRadiusTransitionRange: number;
  121176. private _autoTransitionRange;
  121177. /**
  121178. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121179. */
  121180. get autoTransitionRange(): boolean;
  121181. /**
  121182. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121183. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121184. */
  121185. set autoTransitionRange(value: boolean);
  121186. private _attachedCamera;
  121187. private _onAfterCheckInputsObserver;
  121188. private _onMeshTargetChangedObserver;
  121189. /**
  121190. * Initializes the behavior.
  121191. */
  121192. init(): void;
  121193. /**
  121194. * Attaches the behavior to its arc rotate camera.
  121195. * @param camera Defines the camera to attach the behavior to
  121196. */
  121197. attach(camera: ArcRotateCamera): void;
  121198. /**
  121199. * Detaches the behavior from its current arc rotate camera.
  121200. */
  121201. detach(): void;
  121202. private _radiusIsAnimating;
  121203. private _radiusBounceTransition;
  121204. private _animatables;
  121205. private _cachedWheelPrecision;
  121206. /**
  121207. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121208. * @param radiusLimit The limit to check against.
  121209. * @return Bool to indicate if at limit.
  121210. */
  121211. private _isRadiusAtLimit;
  121212. /**
  121213. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121214. * @param radiusDelta The delta by which to animate to. Can be negative.
  121215. */
  121216. private _applyBoundRadiusAnimation;
  121217. /**
  121218. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121219. */
  121220. protected _clearAnimationLocks(): void;
  121221. /**
  121222. * Stops and removes all animations that have been applied to the camera
  121223. */
  121224. stopAllAnimations(): void;
  121225. }
  121226. }
  121227. declare module BABYLON {
  121228. /**
  121229. * 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.
  121230. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121231. */
  121232. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121233. /**
  121234. * Gets the name of the behavior.
  121235. */
  121236. get name(): string;
  121237. private _mode;
  121238. private _radiusScale;
  121239. private _positionScale;
  121240. private _defaultElevation;
  121241. private _elevationReturnTime;
  121242. private _elevationReturnWaitTime;
  121243. private _zoomStopsAnimation;
  121244. private _framingTime;
  121245. /**
  121246. * The easing function used by animations
  121247. */
  121248. static EasingFunction: ExponentialEase;
  121249. /**
  121250. * The easing mode used by animations
  121251. */
  121252. static EasingMode: number;
  121253. /**
  121254. * Sets the current mode used by the behavior
  121255. */
  121256. set mode(mode: number);
  121257. /**
  121258. * Gets current mode used by the behavior.
  121259. */
  121260. get mode(): number;
  121261. /**
  121262. * Sets the scale applied to the radius (1 by default)
  121263. */
  121264. set radiusScale(radius: number);
  121265. /**
  121266. * Gets the scale applied to the radius
  121267. */
  121268. get radiusScale(): number;
  121269. /**
  121270. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121271. */
  121272. set positionScale(scale: number);
  121273. /**
  121274. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121275. */
  121276. get positionScale(): number;
  121277. /**
  121278. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121279. * behaviour is triggered, in radians.
  121280. */
  121281. set defaultElevation(elevation: number);
  121282. /**
  121283. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121284. * behaviour is triggered, in radians.
  121285. */
  121286. get defaultElevation(): number;
  121287. /**
  121288. * Sets the time (in milliseconds) taken to return to the default beta position.
  121289. * Negative value indicates camera should not return to default.
  121290. */
  121291. set elevationReturnTime(speed: number);
  121292. /**
  121293. * Gets the time (in milliseconds) taken to return to the default beta position.
  121294. * Negative value indicates camera should not return to default.
  121295. */
  121296. get elevationReturnTime(): number;
  121297. /**
  121298. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121299. */
  121300. set elevationReturnWaitTime(time: number);
  121301. /**
  121302. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121303. */
  121304. get elevationReturnWaitTime(): number;
  121305. /**
  121306. * Sets the flag that indicates if user zooming should stop animation.
  121307. */
  121308. set zoomStopsAnimation(flag: boolean);
  121309. /**
  121310. * Gets the flag that indicates if user zooming should stop animation.
  121311. */
  121312. get zoomStopsAnimation(): boolean;
  121313. /**
  121314. * Sets the transition time when framing the mesh, in milliseconds
  121315. */
  121316. set framingTime(time: number);
  121317. /**
  121318. * Gets the transition time when framing the mesh, in milliseconds
  121319. */
  121320. get framingTime(): number;
  121321. /**
  121322. * Define if the behavior should automatically change the configured
  121323. * camera limits and sensibilities.
  121324. */
  121325. autoCorrectCameraLimitsAndSensibility: boolean;
  121326. private _onPrePointerObservableObserver;
  121327. private _onAfterCheckInputsObserver;
  121328. private _onMeshTargetChangedObserver;
  121329. private _attachedCamera;
  121330. private _isPointerDown;
  121331. private _lastInteractionTime;
  121332. /**
  121333. * Initializes the behavior.
  121334. */
  121335. init(): void;
  121336. /**
  121337. * Attaches the behavior to its arc rotate camera.
  121338. * @param camera Defines the camera to attach the behavior to
  121339. */
  121340. attach(camera: ArcRotateCamera): void;
  121341. /**
  121342. * Detaches the behavior from its current arc rotate camera.
  121343. */
  121344. detach(): void;
  121345. private _animatables;
  121346. private _betaIsAnimating;
  121347. private _betaTransition;
  121348. private _radiusTransition;
  121349. private _vectorTransition;
  121350. /**
  121351. * Targets the given mesh and updates zoom level accordingly.
  121352. * @param mesh The mesh to target.
  121353. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121354. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121355. */
  121356. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121357. /**
  121358. * Targets the given mesh with its children and updates zoom level accordingly.
  121359. * @param mesh The mesh to target.
  121360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121362. */
  121363. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121364. /**
  121365. * Targets the given meshes with their children and updates zoom level accordingly.
  121366. * @param meshes The mesh to target.
  121367. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121368. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121369. */
  121370. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121371. /**
  121372. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121373. * @param minimumWorld Determines the smaller position of the bounding box extend
  121374. * @param maximumWorld Determines the bigger position of the bounding box extend
  121375. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121376. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121377. */
  121378. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121379. /**
  121380. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121381. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121382. * frustum width.
  121383. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121384. * to fully enclose the mesh in the viewing frustum.
  121385. */
  121386. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121387. /**
  121388. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121389. * is automatically returned to its default position (expected to be above ground plane).
  121390. */
  121391. private _maintainCameraAboveGround;
  121392. /**
  121393. * Returns the frustum slope based on the canvas ratio and camera FOV
  121394. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121395. */
  121396. private _getFrustumSlope;
  121397. /**
  121398. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121399. */
  121400. private _clearAnimationLocks;
  121401. /**
  121402. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121403. */
  121404. private _applyUserInteraction;
  121405. /**
  121406. * Stops and removes all animations that have been applied to the camera
  121407. */
  121408. stopAllAnimations(): void;
  121409. /**
  121410. * Gets a value indicating if the user is moving the camera
  121411. */
  121412. get isUserIsMoving(): boolean;
  121413. /**
  121414. * The camera can move all the way towards the mesh.
  121415. */
  121416. static IgnoreBoundsSizeMode: number;
  121417. /**
  121418. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121419. */
  121420. static FitFrustumSidesMode: number;
  121421. }
  121422. }
  121423. declare module BABYLON {
  121424. /**
  121425. * Base class for Camera Pointer Inputs.
  121426. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121427. * for example usage.
  121428. */
  121429. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121430. /**
  121431. * Defines the camera the input is attached to.
  121432. */
  121433. abstract camera: Camera;
  121434. /**
  121435. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121436. */
  121437. protected _altKey: boolean;
  121438. protected _ctrlKey: boolean;
  121439. protected _metaKey: boolean;
  121440. protected _shiftKey: boolean;
  121441. /**
  121442. * Which mouse buttons were pressed at time of last mouse event.
  121443. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121444. */
  121445. protected _buttonsPressed: number;
  121446. /**
  121447. * Defines the buttons associated with the input to handle camera move.
  121448. */
  121449. buttons: number[];
  121450. /**
  121451. * Attach the input controls to a specific dom element to get the input from.
  121452. * @param element Defines the element the controls should be listened from
  121453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121454. */
  121455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121456. /**
  121457. * Detach the current controls from the specified dom element.
  121458. * @param element Defines the element to stop listening the inputs from
  121459. */
  121460. detachControl(element: Nullable<HTMLElement>): void;
  121461. /**
  121462. * Gets the class name of the current input.
  121463. * @returns the class name
  121464. */
  121465. getClassName(): string;
  121466. /**
  121467. * Get the friendly name associated with the input class.
  121468. * @returns the input friendly name
  121469. */
  121470. getSimpleName(): string;
  121471. /**
  121472. * Called on pointer POINTERDOUBLETAP event.
  121473. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121474. */
  121475. protected onDoubleTap(type: string): void;
  121476. /**
  121477. * Called on pointer POINTERMOVE event if only a single touch is active.
  121478. * Override this method to provide functionality.
  121479. */
  121480. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121481. /**
  121482. * Called on pointer POINTERMOVE event if multiple touches are active.
  121483. * Override this method to provide functionality.
  121484. */
  121485. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121486. /**
  121487. * Called on JS contextmenu event.
  121488. * Override this method to provide functionality.
  121489. */
  121490. protected onContextMenu(evt: PointerEvent): void;
  121491. /**
  121492. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121493. * press.
  121494. * Override this method to provide functionality.
  121495. */
  121496. protected onButtonDown(evt: PointerEvent): void;
  121497. /**
  121498. * Called each time a new POINTERUP event occurs. Ie, for each button
  121499. * release.
  121500. * Override this method to provide functionality.
  121501. */
  121502. protected onButtonUp(evt: PointerEvent): void;
  121503. /**
  121504. * Called when window becomes inactive.
  121505. * Override this method to provide functionality.
  121506. */
  121507. protected onLostFocus(): void;
  121508. private _pointerInput;
  121509. private _observer;
  121510. private _onLostFocus;
  121511. private pointA;
  121512. private pointB;
  121513. }
  121514. }
  121515. declare module BABYLON {
  121516. /**
  121517. * Manage the pointers inputs to control an arc rotate camera.
  121518. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121519. */
  121520. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121521. /**
  121522. * Defines the camera the input is attached to.
  121523. */
  121524. camera: ArcRotateCamera;
  121525. /**
  121526. * Gets the class name of the current input.
  121527. * @returns the class name
  121528. */
  121529. getClassName(): string;
  121530. /**
  121531. * Defines the buttons associated with the input to handle camera move.
  121532. */
  121533. buttons: number[];
  121534. /**
  121535. * Defines the pointer angular sensibility along the X axis or how fast is
  121536. * the camera rotating.
  121537. */
  121538. angularSensibilityX: number;
  121539. /**
  121540. * Defines the pointer angular sensibility along the Y axis or how fast is
  121541. * the camera rotating.
  121542. */
  121543. angularSensibilityY: number;
  121544. /**
  121545. * Defines the pointer pinch precision or how fast is the camera zooming.
  121546. */
  121547. pinchPrecision: number;
  121548. /**
  121549. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121550. * from 0.
  121551. * It defines the percentage of current camera.radius to use as delta when
  121552. * pinch zoom is used.
  121553. */
  121554. pinchDeltaPercentage: number;
  121555. /**
  121556. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121557. * that any object in the plane at the camera's target point will scale
  121558. * perfectly with finger motion.
  121559. * Overrides pinchDeltaPercentage and pinchPrecision.
  121560. */
  121561. useNaturalPinchZoom: boolean;
  121562. /**
  121563. * Defines the pointer panning sensibility or how fast is the camera moving.
  121564. */
  121565. panningSensibility: number;
  121566. /**
  121567. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121568. */
  121569. multiTouchPanning: boolean;
  121570. /**
  121571. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121572. * zoom (pinch) through multitouch.
  121573. */
  121574. multiTouchPanAndZoom: boolean;
  121575. /**
  121576. * Revers pinch action direction.
  121577. */
  121578. pinchInwards: boolean;
  121579. private _isPanClick;
  121580. private _twoFingerActivityCount;
  121581. private _isPinching;
  121582. /**
  121583. * Called on pointer POINTERMOVE event if only a single touch is active.
  121584. */
  121585. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121586. /**
  121587. * Called on pointer POINTERDOUBLETAP event.
  121588. */
  121589. protected onDoubleTap(type: string): void;
  121590. /**
  121591. * Called on pointer POINTERMOVE event if multiple touches are active.
  121592. */
  121593. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121594. /**
  121595. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121596. * press.
  121597. */
  121598. protected onButtonDown(evt: PointerEvent): void;
  121599. /**
  121600. * Called each time a new POINTERUP event occurs. Ie, for each button
  121601. * release.
  121602. */
  121603. protected onButtonUp(evt: PointerEvent): void;
  121604. /**
  121605. * Called when window becomes inactive.
  121606. */
  121607. protected onLostFocus(): void;
  121608. }
  121609. }
  121610. declare module BABYLON {
  121611. /**
  121612. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121614. */
  121615. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121616. /**
  121617. * Defines the camera the input is attached to.
  121618. */
  121619. camera: ArcRotateCamera;
  121620. /**
  121621. * Defines the list of key codes associated with the up action (increase alpha)
  121622. */
  121623. keysUp: number[];
  121624. /**
  121625. * Defines the list of key codes associated with the down action (decrease alpha)
  121626. */
  121627. keysDown: number[];
  121628. /**
  121629. * Defines the list of key codes associated with the left action (increase beta)
  121630. */
  121631. keysLeft: number[];
  121632. /**
  121633. * Defines the list of key codes associated with the right action (decrease beta)
  121634. */
  121635. keysRight: number[];
  121636. /**
  121637. * Defines the list of key codes associated with the reset action.
  121638. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121639. */
  121640. keysReset: number[];
  121641. /**
  121642. * Defines the panning sensibility of the inputs.
  121643. * (How fast is the camera panning)
  121644. */
  121645. panningSensibility: number;
  121646. /**
  121647. * Defines the zooming sensibility of the inputs.
  121648. * (How fast is the camera zooming)
  121649. */
  121650. zoomingSensibility: number;
  121651. /**
  121652. * Defines whether maintaining the alt key down switch the movement mode from
  121653. * orientation to zoom.
  121654. */
  121655. useAltToZoom: boolean;
  121656. /**
  121657. * Rotation speed of the camera
  121658. */
  121659. angularSpeed: number;
  121660. private _keys;
  121661. private _ctrlPressed;
  121662. private _altPressed;
  121663. private _onCanvasBlurObserver;
  121664. private _onKeyboardObserver;
  121665. private _engine;
  121666. private _scene;
  121667. /**
  121668. * Attach the input controls to a specific dom element to get the input from.
  121669. * @param element Defines the element the controls should be listened from
  121670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121671. */
  121672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121673. /**
  121674. * Detach the current controls from the specified dom element.
  121675. * @param element Defines the element to stop listening the inputs from
  121676. */
  121677. detachControl(element: Nullable<HTMLElement>): void;
  121678. /**
  121679. * Update the current camera state depending on the inputs that have been used this frame.
  121680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121681. */
  121682. checkInputs(): void;
  121683. /**
  121684. * Gets the class name of the current intput.
  121685. * @returns the class name
  121686. */
  121687. getClassName(): string;
  121688. /**
  121689. * Get the friendly name associated with the input class.
  121690. * @returns the input friendly name
  121691. */
  121692. getSimpleName(): string;
  121693. }
  121694. }
  121695. declare module BABYLON {
  121696. /**
  121697. * Manage the mouse wheel inputs to control an arc rotate camera.
  121698. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121699. */
  121700. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121701. /**
  121702. * Defines the camera the input is attached to.
  121703. */
  121704. camera: ArcRotateCamera;
  121705. /**
  121706. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121707. */
  121708. wheelPrecision: number;
  121709. /**
  121710. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121711. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121712. */
  121713. wheelDeltaPercentage: number;
  121714. private _wheel;
  121715. private _observer;
  121716. private computeDeltaFromMouseWheelLegacyEvent;
  121717. /**
  121718. * Attach the input controls to a specific dom element to get the input from.
  121719. * @param element Defines the element the controls should be listened from
  121720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121721. */
  121722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121723. /**
  121724. * Detach the current controls from the specified dom element.
  121725. * @param element Defines the element to stop listening the inputs from
  121726. */
  121727. detachControl(element: Nullable<HTMLElement>): void;
  121728. /**
  121729. * Gets the class name of the current intput.
  121730. * @returns the class name
  121731. */
  121732. getClassName(): string;
  121733. /**
  121734. * Get the friendly name associated with the input class.
  121735. * @returns the input friendly name
  121736. */
  121737. getSimpleName(): string;
  121738. }
  121739. }
  121740. declare module BABYLON {
  121741. /**
  121742. * Default Inputs manager for the ArcRotateCamera.
  121743. * It groups all the default supported inputs for ease of use.
  121744. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121745. */
  121746. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121747. /**
  121748. * Instantiates a new ArcRotateCameraInputsManager.
  121749. * @param camera Defines the camera the inputs belong to
  121750. */
  121751. constructor(camera: ArcRotateCamera);
  121752. /**
  121753. * Add mouse wheel input support to the input manager.
  121754. * @returns the current input manager
  121755. */
  121756. addMouseWheel(): ArcRotateCameraInputsManager;
  121757. /**
  121758. * Add pointers input support to the input manager.
  121759. * @returns the current input manager
  121760. */
  121761. addPointers(): ArcRotateCameraInputsManager;
  121762. /**
  121763. * Add keyboard input support to the input manager.
  121764. * @returns the current input manager
  121765. */
  121766. addKeyboard(): ArcRotateCameraInputsManager;
  121767. }
  121768. }
  121769. declare module BABYLON {
  121770. /**
  121771. * This represents an orbital type of camera.
  121772. *
  121773. * 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.
  121774. * 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.
  121775. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121776. */
  121777. export class ArcRotateCamera extends TargetCamera {
  121778. /**
  121779. * Defines the rotation angle of the camera along the longitudinal axis.
  121780. */
  121781. alpha: number;
  121782. /**
  121783. * Defines the rotation angle of the camera along the latitudinal axis.
  121784. */
  121785. beta: number;
  121786. /**
  121787. * Defines the radius of the camera from it s target point.
  121788. */
  121789. radius: number;
  121790. protected _target: Vector3;
  121791. protected _targetHost: Nullable<AbstractMesh>;
  121792. /**
  121793. * Defines the target point of the camera.
  121794. * The camera looks towards it form the radius distance.
  121795. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  121796. */
  121797. get target(): Vector3;
  121798. set target(value: Vector3);
  121799. /**
  121800. * Define the current local position of the camera in the scene
  121801. */
  121802. get position(): Vector3;
  121803. set position(newPosition: Vector3);
  121804. protected _upVector: Vector3;
  121805. protected _upToYMatrix: Matrix;
  121806. protected _YToUpMatrix: Matrix;
  121807. /**
  121808. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121809. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121810. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121811. */
  121812. set upVector(vec: Vector3);
  121813. get upVector(): Vector3;
  121814. /**
  121815. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121816. */
  121817. setMatUp(): void;
  121818. /**
  121819. * Current inertia value on the longitudinal axis.
  121820. * The bigger this number the longer it will take for the camera to stop.
  121821. */
  121822. inertialAlphaOffset: number;
  121823. /**
  121824. * Current inertia value on the latitudinal axis.
  121825. * The bigger this number the longer it will take for the camera to stop.
  121826. */
  121827. inertialBetaOffset: number;
  121828. /**
  121829. * Current inertia value on the radius axis.
  121830. * The bigger this number the longer it will take for the camera to stop.
  121831. */
  121832. inertialRadiusOffset: number;
  121833. /**
  121834. * Minimum allowed angle on the longitudinal axis.
  121835. * This can help limiting how the Camera is able to move in the scene.
  121836. */
  121837. lowerAlphaLimit: Nullable<number>;
  121838. /**
  121839. * Maximum allowed angle on the longitudinal axis.
  121840. * This can help limiting how the Camera is able to move in the scene.
  121841. */
  121842. upperAlphaLimit: Nullable<number>;
  121843. /**
  121844. * Minimum allowed angle on the latitudinal axis.
  121845. * This can help limiting how the Camera is able to move in the scene.
  121846. */
  121847. lowerBetaLimit: number;
  121848. /**
  121849. * Maximum allowed angle on the latitudinal axis.
  121850. * This can help limiting how the Camera is able to move in the scene.
  121851. */
  121852. upperBetaLimit: number;
  121853. /**
  121854. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121855. * This can help limiting how the Camera is able to move in the scene.
  121856. */
  121857. lowerRadiusLimit: Nullable<number>;
  121858. /**
  121859. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121860. * This can help limiting how the Camera is able to move in the scene.
  121861. */
  121862. upperRadiusLimit: Nullable<number>;
  121863. /**
  121864. * Defines the current inertia value used during panning of the camera along the X axis.
  121865. */
  121866. inertialPanningX: number;
  121867. /**
  121868. * Defines the current inertia value used during panning of the camera along the Y axis.
  121869. */
  121870. inertialPanningY: number;
  121871. /**
  121872. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121873. * Basically if your fingers moves away from more than this distance you will be considered
  121874. * in pinch mode.
  121875. */
  121876. pinchToPanMaxDistance: number;
  121877. /**
  121878. * Defines the maximum distance the camera can pan.
  121879. * This could help keeping the cammera always in your scene.
  121880. */
  121881. panningDistanceLimit: Nullable<number>;
  121882. /**
  121883. * Defines the target of the camera before paning.
  121884. */
  121885. panningOriginTarget: Vector3;
  121886. /**
  121887. * Defines the value of the inertia used during panning.
  121888. * 0 would mean stop inertia and one would mean no decelleration at all.
  121889. */
  121890. panningInertia: number;
  121891. /**
  121892. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121893. */
  121894. get angularSensibilityX(): number;
  121895. set angularSensibilityX(value: number);
  121896. /**
  121897. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121898. */
  121899. get angularSensibilityY(): number;
  121900. set angularSensibilityY(value: number);
  121901. /**
  121902. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121903. */
  121904. get pinchPrecision(): number;
  121905. set pinchPrecision(value: number);
  121906. /**
  121907. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121908. * It will be used instead of pinchDeltaPrecision if different from 0.
  121909. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121910. */
  121911. get pinchDeltaPercentage(): number;
  121912. set pinchDeltaPercentage(value: number);
  121913. /**
  121914. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121915. * and pinch delta percentage.
  121916. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121917. * that any object in the plane at the camera's target point will scale
  121918. * perfectly with finger motion.
  121919. */
  121920. get useNaturalPinchZoom(): boolean;
  121921. set useNaturalPinchZoom(value: boolean);
  121922. /**
  121923. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121924. */
  121925. get panningSensibility(): number;
  121926. set panningSensibility(value: number);
  121927. /**
  121928. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121929. */
  121930. get keysUp(): number[];
  121931. set keysUp(value: number[]);
  121932. /**
  121933. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121934. */
  121935. get keysDown(): number[];
  121936. set keysDown(value: number[]);
  121937. /**
  121938. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121939. */
  121940. get keysLeft(): number[];
  121941. set keysLeft(value: number[]);
  121942. /**
  121943. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121944. */
  121945. get keysRight(): number[];
  121946. set keysRight(value: number[]);
  121947. /**
  121948. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121949. */
  121950. get wheelPrecision(): number;
  121951. set wheelPrecision(value: number);
  121952. /**
  121953. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121954. * It will be used instead of pinchDeltaPrecision if different from 0.
  121955. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121956. */
  121957. get wheelDeltaPercentage(): number;
  121958. set wheelDeltaPercentage(value: number);
  121959. /**
  121960. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121961. */
  121962. zoomOnFactor: number;
  121963. /**
  121964. * Defines a screen offset for the camera position.
  121965. */
  121966. targetScreenOffset: Vector2;
  121967. /**
  121968. * Allows the camera to be completely reversed.
  121969. * If false the camera can not arrive upside down.
  121970. */
  121971. allowUpsideDown: boolean;
  121972. /**
  121973. * Define if double tap/click is used to restore the previously saved state of the camera.
  121974. */
  121975. useInputToRestoreState: boolean;
  121976. /** @hidden */
  121977. _viewMatrix: Matrix;
  121978. /** @hidden */
  121979. _useCtrlForPanning: boolean;
  121980. /** @hidden */
  121981. _panningMouseButton: number;
  121982. /**
  121983. * Defines the input associated to the camera.
  121984. */
  121985. inputs: ArcRotateCameraInputsManager;
  121986. /** @hidden */
  121987. _reset: () => void;
  121988. /**
  121989. * Defines the allowed panning axis.
  121990. */
  121991. panningAxis: Vector3;
  121992. protected _localDirection: Vector3;
  121993. protected _transformedDirection: Vector3;
  121994. private _bouncingBehavior;
  121995. /**
  121996. * Gets the bouncing behavior of the camera if it has been enabled.
  121997. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121998. */
  121999. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122000. /**
  122001. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122002. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122003. */
  122004. get useBouncingBehavior(): boolean;
  122005. set useBouncingBehavior(value: boolean);
  122006. private _framingBehavior;
  122007. /**
  122008. * Gets the framing behavior of the camera if it has been enabled.
  122009. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122010. */
  122011. get framingBehavior(): Nullable<FramingBehavior>;
  122012. /**
  122013. * Defines if the framing behavior of the camera is enabled on the camera.
  122014. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122015. */
  122016. get useFramingBehavior(): boolean;
  122017. set useFramingBehavior(value: boolean);
  122018. private _autoRotationBehavior;
  122019. /**
  122020. * Gets the auto rotation behavior of the camera if it has been enabled.
  122021. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122022. */
  122023. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122024. /**
  122025. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122026. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122027. */
  122028. get useAutoRotationBehavior(): boolean;
  122029. set useAutoRotationBehavior(value: boolean);
  122030. /**
  122031. * Observable triggered when the mesh target has been changed on the camera.
  122032. */
  122033. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122034. /**
  122035. * Event raised when the camera is colliding with a mesh.
  122036. */
  122037. onCollide: (collidedMesh: AbstractMesh) => void;
  122038. /**
  122039. * Defines whether the camera should check collision with the objects oh the scene.
  122040. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122041. */
  122042. checkCollisions: boolean;
  122043. /**
  122044. * Defines the collision radius of the camera.
  122045. * This simulates a sphere around the camera.
  122046. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122047. */
  122048. collisionRadius: Vector3;
  122049. protected _collider: Collider;
  122050. protected _previousPosition: Vector3;
  122051. protected _collisionVelocity: Vector3;
  122052. protected _newPosition: Vector3;
  122053. protected _previousAlpha: number;
  122054. protected _previousBeta: number;
  122055. protected _previousRadius: number;
  122056. protected _collisionTriggered: boolean;
  122057. protected _targetBoundingCenter: Nullable<Vector3>;
  122058. private _computationVector;
  122059. /**
  122060. * Instantiates a new ArcRotateCamera in a given scene
  122061. * @param name Defines the name of the camera
  122062. * @param alpha Defines the camera rotation along the logitudinal axis
  122063. * @param beta Defines the camera rotation along the latitudinal axis
  122064. * @param radius Defines the camera distance from its target
  122065. * @param target Defines the camera target
  122066. * @param scene Defines the scene the camera belongs to
  122067. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122068. */
  122069. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122070. /** @hidden */
  122071. _initCache(): void;
  122072. /** @hidden */
  122073. _updateCache(ignoreParentClass?: boolean): void;
  122074. protected _getTargetPosition(): Vector3;
  122075. private _storedAlpha;
  122076. private _storedBeta;
  122077. private _storedRadius;
  122078. private _storedTarget;
  122079. private _storedTargetScreenOffset;
  122080. /**
  122081. * Stores the current state of the camera (alpha, beta, radius and target)
  122082. * @returns the camera itself
  122083. */
  122084. storeState(): Camera;
  122085. /**
  122086. * @hidden
  122087. * Restored camera state. You must call storeState() first
  122088. */
  122089. _restoreStateValues(): boolean;
  122090. /** @hidden */
  122091. _isSynchronizedViewMatrix(): boolean;
  122092. /**
  122093. * Attached controls to the current camera.
  122094. * @param element Defines the element the controls should be listened from
  122095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122096. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122097. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122098. */
  122099. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122100. /**
  122101. * Detach the current controls from the camera.
  122102. * The camera will stop reacting to inputs.
  122103. * @param element Defines the element to stop listening the inputs from
  122104. */
  122105. detachControl(element: HTMLElement): void;
  122106. /** @hidden */
  122107. _checkInputs(): void;
  122108. protected _checkLimits(): void;
  122109. /**
  122110. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122111. */
  122112. rebuildAnglesAndRadius(): void;
  122113. /**
  122114. * Use a position to define the current camera related information like alpha, beta and radius
  122115. * @param position Defines the position to set the camera at
  122116. */
  122117. setPosition(position: Vector3): void;
  122118. /**
  122119. * Defines the target the camera should look at.
  122120. * This will automatically adapt alpha beta and radius to fit within the new target.
  122121. * @param target Defines the new target as a Vector or a mesh
  122122. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122123. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122124. */
  122125. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122126. /** @hidden */
  122127. _getViewMatrix(): Matrix;
  122128. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122129. /**
  122130. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122131. * @param meshes Defines the mesh to zoom on
  122132. * @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)
  122133. */
  122134. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122135. /**
  122136. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122137. * The target will be changed but the radius
  122138. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122139. * @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)
  122140. */
  122141. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122142. min: Vector3;
  122143. max: Vector3;
  122144. distance: number;
  122145. }, doNotUpdateMaxZ?: boolean): void;
  122146. /**
  122147. * @override
  122148. * Override Camera.createRigCamera
  122149. */
  122150. createRigCamera(name: string, cameraIndex: number): Camera;
  122151. /**
  122152. * @hidden
  122153. * @override
  122154. * Override Camera._updateRigCameras
  122155. */
  122156. _updateRigCameras(): void;
  122157. /**
  122158. * Destroy the camera and release the current resources hold by it.
  122159. */
  122160. dispose(): void;
  122161. /**
  122162. * Gets the current object class name.
  122163. * @return the class name
  122164. */
  122165. getClassName(): string;
  122166. }
  122167. }
  122168. declare module BABYLON {
  122169. /**
  122170. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  122171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122172. */
  122173. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  122174. /**
  122175. * Gets the name of the behavior.
  122176. */
  122177. get name(): string;
  122178. private _zoomStopsAnimation;
  122179. private _idleRotationSpeed;
  122180. private _idleRotationWaitTime;
  122181. private _idleRotationSpinupTime;
  122182. /**
  122183. * Sets the flag that indicates if user zooming should stop animation.
  122184. */
  122185. set zoomStopsAnimation(flag: boolean);
  122186. /**
  122187. * Gets the flag that indicates if user zooming should stop animation.
  122188. */
  122189. get zoomStopsAnimation(): boolean;
  122190. /**
  122191. * Sets the default speed at which the camera rotates around the model.
  122192. */
  122193. set idleRotationSpeed(speed: number);
  122194. /**
  122195. * Gets the default speed at which the camera rotates around the model.
  122196. */
  122197. get idleRotationSpeed(): number;
  122198. /**
  122199. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122200. */
  122201. set idleRotationWaitTime(time: number);
  122202. /**
  122203. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122204. */
  122205. get idleRotationWaitTime(): number;
  122206. /**
  122207. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122208. */
  122209. set idleRotationSpinupTime(time: number);
  122210. /**
  122211. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122212. */
  122213. get idleRotationSpinupTime(): number;
  122214. /**
  122215. * Gets a value indicating if the camera is currently rotating because of this behavior
  122216. */
  122217. get rotationInProgress(): boolean;
  122218. private _onPrePointerObservableObserver;
  122219. private _onAfterCheckInputsObserver;
  122220. private _attachedCamera;
  122221. private _isPointerDown;
  122222. private _lastFrameTime;
  122223. private _lastInteractionTime;
  122224. private _cameraRotationSpeed;
  122225. /**
  122226. * Initializes the behavior.
  122227. */
  122228. init(): void;
  122229. /**
  122230. * Attaches the behavior to its arc rotate camera.
  122231. * @param camera Defines the camera to attach the behavior to
  122232. */
  122233. attach(camera: ArcRotateCamera): void;
  122234. /**
  122235. * Detaches the behavior from its current arc rotate camera.
  122236. */
  122237. detach(): void;
  122238. /**
  122239. * Returns true if user is scrolling.
  122240. * @return true if user is scrolling.
  122241. */
  122242. private _userIsZooming;
  122243. private _lastFrameRadius;
  122244. private _shouldAnimationStopForInteraction;
  122245. /**
  122246. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122247. */
  122248. private _applyUserInteraction;
  122249. private _userIsMoving;
  122250. }
  122251. }
  122252. declare module BABYLON {
  122253. /**
  122254. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122255. */
  122256. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122257. private ui;
  122258. /**
  122259. * The name of the behavior
  122260. */
  122261. name: string;
  122262. /**
  122263. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122264. */
  122265. distanceAwayFromFace: number;
  122266. /**
  122267. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122268. */
  122269. distanceAwayFromBottomOfFace: number;
  122270. private _faceVectors;
  122271. private _target;
  122272. private _scene;
  122273. private _onRenderObserver;
  122274. private _tmpMatrix;
  122275. private _tmpVector;
  122276. /**
  122277. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122278. * @param ui The transform node that should be attched to the mesh
  122279. */
  122280. constructor(ui: TransformNode);
  122281. /**
  122282. * Initializes the behavior
  122283. */
  122284. init(): void;
  122285. private _closestFace;
  122286. private _zeroVector;
  122287. private _lookAtTmpMatrix;
  122288. private _lookAtToRef;
  122289. /**
  122290. * Attaches the AttachToBoxBehavior to the passed in mesh
  122291. * @param target The mesh that the specified node will be attached to
  122292. */
  122293. attach(target: Mesh): void;
  122294. /**
  122295. * Detaches the behavior from the mesh
  122296. */
  122297. detach(): void;
  122298. }
  122299. }
  122300. declare module BABYLON {
  122301. /**
  122302. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122303. */
  122304. export class FadeInOutBehavior implements Behavior<Mesh> {
  122305. /**
  122306. * Time in milliseconds to delay before fading in (Default: 0)
  122307. */
  122308. delay: number;
  122309. /**
  122310. * Time in milliseconds for the mesh to fade in (Default: 300)
  122311. */
  122312. fadeInTime: number;
  122313. private _millisecondsPerFrame;
  122314. private _hovered;
  122315. private _hoverValue;
  122316. private _ownerNode;
  122317. /**
  122318. * Instatiates the FadeInOutBehavior
  122319. */
  122320. constructor();
  122321. /**
  122322. * The name of the behavior
  122323. */
  122324. get name(): string;
  122325. /**
  122326. * Initializes the behavior
  122327. */
  122328. init(): void;
  122329. /**
  122330. * Attaches the fade behavior on the passed in mesh
  122331. * @param ownerNode The mesh that will be faded in/out once attached
  122332. */
  122333. attach(ownerNode: Mesh): void;
  122334. /**
  122335. * Detaches the behavior from the mesh
  122336. */
  122337. detach(): void;
  122338. /**
  122339. * Triggers the mesh to begin fading in or out
  122340. * @param value if the object should fade in or out (true to fade in)
  122341. */
  122342. fadeIn(value: boolean): void;
  122343. private _update;
  122344. private _setAllVisibility;
  122345. }
  122346. }
  122347. declare module BABYLON {
  122348. /**
  122349. * Class containing a set of static utilities functions for managing Pivots
  122350. * @hidden
  122351. */
  122352. export class PivotTools {
  122353. private static _PivotCached;
  122354. private static _OldPivotPoint;
  122355. private static _PivotTranslation;
  122356. private static _PivotTmpVector;
  122357. /** @hidden */
  122358. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122359. /** @hidden */
  122360. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122361. }
  122362. }
  122363. declare module BABYLON {
  122364. /**
  122365. * Class containing static functions to help procedurally build meshes
  122366. */
  122367. export class PlaneBuilder {
  122368. /**
  122369. * Creates a plane mesh
  122370. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122371. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122372. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122376. * @param name defines the name of the mesh
  122377. * @param options defines the options used to create the mesh
  122378. * @param scene defines the hosting scene
  122379. * @returns the plane mesh
  122380. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122381. */
  122382. static CreatePlane(name: string, options: {
  122383. size?: number;
  122384. width?: number;
  122385. height?: number;
  122386. sideOrientation?: number;
  122387. frontUVs?: Vector4;
  122388. backUVs?: Vector4;
  122389. updatable?: boolean;
  122390. sourcePlane?: Plane;
  122391. }, scene?: Nullable<Scene>): Mesh;
  122392. }
  122393. }
  122394. declare module BABYLON {
  122395. /**
  122396. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122397. */
  122398. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122399. private static _AnyMouseID;
  122400. /**
  122401. * Abstract mesh the behavior is set on
  122402. */
  122403. attachedNode: AbstractMesh;
  122404. private _dragPlane;
  122405. private _scene;
  122406. private _pointerObserver;
  122407. private _beforeRenderObserver;
  122408. private static _planeScene;
  122409. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122410. /**
  122411. * 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)
  122412. */
  122413. maxDragAngle: number;
  122414. /**
  122415. * @hidden
  122416. */
  122417. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122418. /**
  122419. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122420. */
  122421. currentDraggingPointerID: number;
  122422. /**
  122423. * The last position where the pointer hit the drag plane in world space
  122424. */
  122425. lastDragPosition: Vector3;
  122426. /**
  122427. * If the behavior is currently in a dragging state
  122428. */
  122429. dragging: boolean;
  122430. /**
  122431. * 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)
  122432. */
  122433. dragDeltaRatio: number;
  122434. /**
  122435. * If the drag plane orientation should be updated during the dragging (Default: true)
  122436. */
  122437. updateDragPlane: boolean;
  122438. private _debugMode;
  122439. private _moving;
  122440. /**
  122441. * Fires each time the attached mesh is dragged with the pointer
  122442. * * delta between last drag position and current drag position in world space
  122443. * * dragDistance along the drag axis
  122444. * * dragPlaneNormal normal of the current drag plane used during the drag
  122445. * * dragPlanePoint in world space where the drag intersects the drag plane
  122446. */
  122447. onDragObservable: Observable<{
  122448. delta: Vector3;
  122449. dragPlanePoint: Vector3;
  122450. dragPlaneNormal: Vector3;
  122451. dragDistance: number;
  122452. pointerId: number;
  122453. }>;
  122454. /**
  122455. * Fires each time a drag begins (eg. mouse down on mesh)
  122456. */
  122457. onDragStartObservable: Observable<{
  122458. dragPlanePoint: Vector3;
  122459. pointerId: number;
  122460. }>;
  122461. /**
  122462. * Fires each time a drag ends (eg. mouse release after drag)
  122463. */
  122464. onDragEndObservable: Observable<{
  122465. dragPlanePoint: Vector3;
  122466. pointerId: number;
  122467. }>;
  122468. /**
  122469. * If the attached mesh should be moved when dragged
  122470. */
  122471. moveAttached: boolean;
  122472. /**
  122473. * If the drag behavior will react to drag events (Default: true)
  122474. */
  122475. enabled: boolean;
  122476. /**
  122477. * If pointer events should start and release the drag (Default: true)
  122478. */
  122479. startAndReleaseDragOnPointerEvents: boolean;
  122480. /**
  122481. * If camera controls should be detached during the drag
  122482. */
  122483. detachCameraControls: boolean;
  122484. /**
  122485. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122486. */
  122487. useObjectOrientationForDragging: boolean;
  122488. private _options;
  122489. /**
  122490. * Gets the options used by the behavior
  122491. */
  122492. get options(): {
  122493. dragAxis?: Vector3;
  122494. dragPlaneNormal?: Vector3;
  122495. };
  122496. /**
  122497. * Sets the options used by the behavior
  122498. */
  122499. set options(options: {
  122500. dragAxis?: Vector3;
  122501. dragPlaneNormal?: Vector3;
  122502. });
  122503. /**
  122504. * Creates a pointer drag behavior that can be attached to a mesh
  122505. * @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)
  122506. */
  122507. constructor(options?: {
  122508. dragAxis?: Vector3;
  122509. dragPlaneNormal?: Vector3;
  122510. });
  122511. /**
  122512. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122513. */
  122514. validateDrag: (targetPosition: Vector3) => boolean;
  122515. /**
  122516. * The name of the behavior
  122517. */
  122518. get name(): string;
  122519. /**
  122520. * Initializes the behavior
  122521. */
  122522. init(): void;
  122523. private _tmpVector;
  122524. private _alternatePickedPoint;
  122525. private _worldDragAxis;
  122526. private _targetPosition;
  122527. private _attachedElement;
  122528. /**
  122529. * Attaches the drag behavior the passed in mesh
  122530. * @param ownerNode The mesh that will be dragged around once attached
  122531. * @param predicate Predicate to use for pick filtering
  122532. */
  122533. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122534. /**
  122535. * Force relase the drag action by code.
  122536. */
  122537. releaseDrag(): void;
  122538. private _startDragRay;
  122539. private _lastPointerRay;
  122540. /**
  122541. * Simulates the start of a pointer drag event on the behavior
  122542. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122543. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122544. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122545. */
  122546. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122547. private _startDrag;
  122548. private _dragDelta;
  122549. private _moveDrag;
  122550. private _pickWithRayOnDragPlane;
  122551. private _pointA;
  122552. private _pointC;
  122553. private _localAxis;
  122554. private _lookAt;
  122555. private _updateDragPlanePosition;
  122556. /**
  122557. * Detaches the behavior from the mesh
  122558. */
  122559. detach(): void;
  122560. }
  122561. }
  122562. declare module BABYLON {
  122563. /**
  122564. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122565. */
  122566. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122567. private _dragBehaviorA;
  122568. private _dragBehaviorB;
  122569. private _startDistance;
  122570. private _initialScale;
  122571. private _targetScale;
  122572. private _ownerNode;
  122573. private _sceneRenderObserver;
  122574. /**
  122575. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122576. */
  122577. constructor();
  122578. /**
  122579. * The name of the behavior
  122580. */
  122581. get name(): string;
  122582. /**
  122583. * Initializes the behavior
  122584. */
  122585. init(): void;
  122586. private _getCurrentDistance;
  122587. /**
  122588. * Attaches the scale behavior the passed in mesh
  122589. * @param ownerNode The mesh that will be scaled around once attached
  122590. */
  122591. attach(ownerNode: Mesh): void;
  122592. /**
  122593. * Detaches the behavior from the mesh
  122594. */
  122595. detach(): void;
  122596. }
  122597. }
  122598. declare module BABYLON {
  122599. /**
  122600. * 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
  122601. */
  122602. export class SixDofDragBehavior implements Behavior<Mesh> {
  122603. private static _virtualScene;
  122604. private _ownerNode;
  122605. private _sceneRenderObserver;
  122606. private _scene;
  122607. private _targetPosition;
  122608. private _virtualOriginMesh;
  122609. private _virtualDragMesh;
  122610. private _pointerObserver;
  122611. private _moving;
  122612. private _startingOrientation;
  122613. private _attachedElement;
  122614. /**
  122615. * 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)
  122616. */
  122617. private zDragFactor;
  122618. /**
  122619. * If the object should rotate to face the drag origin
  122620. */
  122621. rotateDraggedObject: boolean;
  122622. /**
  122623. * If the behavior is currently in a dragging state
  122624. */
  122625. dragging: boolean;
  122626. /**
  122627. * 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)
  122628. */
  122629. dragDeltaRatio: number;
  122630. /**
  122631. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122632. */
  122633. currentDraggingPointerID: number;
  122634. /**
  122635. * If camera controls should be detached during the drag
  122636. */
  122637. detachCameraControls: boolean;
  122638. /**
  122639. * Fires each time a drag starts
  122640. */
  122641. onDragStartObservable: Observable<{}>;
  122642. /**
  122643. * Fires each time a drag ends (eg. mouse release after drag)
  122644. */
  122645. onDragEndObservable: Observable<{}>;
  122646. /**
  122647. * 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
  122648. */
  122649. constructor();
  122650. /**
  122651. * The name of the behavior
  122652. */
  122653. get name(): string;
  122654. /**
  122655. * Initializes the behavior
  122656. */
  122657. init(): void;
  122658. /**
  122659. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122660. */
  122661. private get _pointerCamera();
  122662. /**
  122663. * Attaches the scale behavior the passed in mesh
  122664. * @param ownerNode The mesh that will be scaled around once attached
  122665. */
  122666. attach(ownerNode: Mesh): void;
  122667. /**
  122668. * Detaches the behavior from the mesh
  122669. */
  122670. detach(): void;
  122671. }
  122672. }
  122673. declare module BABYLON {
  122674. /**
  122675. * Class used to apply inverse kinematics to bones
  122676. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122677. */
  122678. export class BoneIKController {
  122679. private static _tmpVecs;
  122680. private static _tmpQuat;
  122681. private static _tmpMats;
  122682. /**
  122683. * Gets or sets the target mesh
  122684. */
  122685. targetMesh: AbstractMesh;
  122686. /** Gets or sets the mesh used as pole */
  122687. poleTargetMesh: AbstractMesh;
  122688. /**
  122689. * Gets or sets the bone used as pole
  122690. */
  122691. poleTargetBone: Nullable<Bone>;
  122692. /**
  122693. * Gets or sets the target position
  122694. */
  122695. targetPosition: Vector3;
  122696. /**
  122697. * Gets or sets the pole target position
  122698. */
  122699. poleTargetPosition: Vector3;
  122700. /**
  122701. * Gets or sets the pole target local offset
  122702. */
  122703. poleTargetLocalOffset: Vector3;
  122704. /**
  122705. * Gets or sets the pole angle
  122706. */
  122707. poleAngle: number;
  122708. /**
  122709. * Gets or sets the mesh associated with the controller
  122710. */
  122711. mesh: AbstractMesh;
  122712. /**
  122713. * 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)
  122714. */
  122715. slerpAmount: number;
  122716. private _bone1Quat;
  122717. private _bone1Mat;
  122718. private _bone2Ang;
  122719. private _bone1;
  122720. private _bone2;
  122721. private _bone1Length;
  122722. private _bone2Length;
  122723. private _maxAngle;
  122724. private _maxReach;
  122725. private _rightHandedSystem;
  122726. private _bendAxis;
  122727. private _slerping;
  122728. private _adjustRoll;
  122729. /**
  122730. * Gets or sets maximum allowed angle
  122731. */
  122732. get maxAngle(): number;
  122733. set maxAngle(value: number);
  122734. /**
  122735. * Creates a new BoneIKController
  122736. * @param mesh defines the mesh to control
  122737. * @param bone defines the bone to control
  122738. * @param options defines options to set up the controller
  122739. */
  122740. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122741. targetMesh?: AbstractMesh;
  122742. poleTargetMesh?: AbstractMesh;
  122743. poleTargetBone?: Bone;
  122744. poleTargetLocalOffset?: Vector3;
  122745. poleAngle?: number;
  122746. bendAxis?: Vector3;
  122747. maxAngle?: number;
  122748. slerpAmount?: number;
  122749. });
  122750. private _setMaxAngle;
  122751. /**
  122752. * Force the controller to update the bones
  122753. */
  122754. update(): void;
  122755. }
  122756. }
  122757. declare module BABYLON {
  122758. /**
  122759. * Class used to make a bone look toward a point in space
  122760. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122761. */
  122762. export class BoneLookController {
  122763. private static _tmpVecs;
  122764. private static _tmpQuat;
  122765. private static _tmpMats;
  122766. /**
  122767. * The target Vector3 that the bone will look at
  122768. */
  122769. target: Vector3;
  122770. /**
  122771. * The mesh that the bone is attached to
  122772. */
  122773. mesh: AbstractMesh;
  122774. /**
  122775. * The bone that will be looking to the target
  122776. */
  122777. bone: Bone;
  122778. /**
  122779. * The up axis of the coordinate system that is used when the bone is rotated
  122780. */
  122781. upAxis: Vector3;
  122782. /**
  122783. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122784. */
  122785. upAxisSpace: Space;
  122786. /**
  122787. * Used to make an adjustment to the yaw of the bone
  122788. */
  122789. adjustYaw: number;
  122790. /**
  122791. * Used to make an adjustment to the pitch of the bone
  122792. */
  122793. adjustPitch: number;
  122794. /**
  122795. * Used to make an adjustment to the roll of the bone
  122796. */
  122797. adjustRoll: number;
  122798. /**
  122799. * 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)
  122800. */
  122801. slerpAmount: number;
  122802. private _minYaw;
  122803. private _maxYaw;
  122804. private _minPitch;
  122805. private _maxPitch;
  122806. private _minYawSin;
  122807. private _minYawCos;
  122808. private _maxYawSin;
  122809. private _maxYawCos;
  122810. private _midYawConstraint;
  122811. private _minPitchTan;
  122812. private _maxPitchTan;
  122813. private _boneQuat;
  122814. private _slerping;
  122815. private _transformYawPitch;
  122816. private _transformYawPitchInv;
  122817. private _firstFrameSkipped;
  122818. private _yawRange;
  122819. private _fowardAxis;
  122820. /**
  122821. * Gets or sets the minimum yaw angle that the bone can look to
  122822. */
  122823. get minYaw(): number;
  122824. set minYaw(value: number);
  122825. /**
  122826. * Gets or sets the maximum yaw angle that the bone can look to
  122827. */
  122828. get maxYaw(): number;
  122829. set maxYaw(value: number);
  122830. /**
  122831. * Gets or sets the minimum pitch angle that the bone can look to
  122832. */
  122833. get minPitch(): number;
  122834. set minPitch(value: number);
  122835. /**
  122836. * Gets or sets the maximum pitch angle that the bone can look to
  122837. */
  122838. get maxPitch(): number;
  122839. set maxPitch(value: number);
  122840. /**
  122841. * Create a BoneLookController
  122842. * @param mesh the mesh that the bone belongs to
  122843. * @param bone the bone that will be looking to the target
  122844. * @param target the target Vector3 to look at
  122845. * @param options optional settings:
  122846. * * maxYaw: the maximum angle the bone will yaw to
  122847. * * minYaw: the minimum angle the bone will yaw to
  122848. * * maxPitch: the maximum angle the bone will pitch to
  122849. * * minPitch: the minimum angle the bone will yaw to
  122850. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122851. * * upAxis: the up axis of the coordinate system
  122852. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122853. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122854. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122855. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122856. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122857. * * adjustRoll: used to make an adjustment to the roll of the bone
  122858. **/
  122859. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122860. maxYaw?: number;
  122861. minYaw?: number;
  122862. maxPitch?: number;
  122863. minPitch?: number;
  122864. slerpAmount?: number;
  122865. upAxis?: Vector3;
  122866. upAxisSpace?: Space;
  122867. yawAxis?: Vector3;
  122868. pitchAxis?: Vector3;
  122869. adjustYaw?: number;
  122870. adjustPitch?: number;
  122871. adjustRoll?: number;
  122872. });
  122873. /**
  122874. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122875. */
  122876. update(): void;
  122877. private _getAngleDiff;
  122878. private _getAngleBetween;
  122879. private _isAngleBetween;
  122880. }
  122881. }
  122882. declare module BABYLON {
  122883. /**
  122884. * Manage the gamepad inputs to control an arc rotate camera.
  122885. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122886. */
  122887. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122888. /**
  122889. * Defines the camera the input is attached to.
  122890. */
  122891. camera: ArcRotateCamera;
  122892. /**
  122893. * Defines the gamepad the input is gathering event from.
  122894. */
  122895. gamepad: Nullable<Gamepad>;
  122896. /**
  122897. * Defines the gamepad rotation sensiblity.
  122898. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122899. */
  122900. gamepadRotationSensibility: number;
  122901. /**
  122902. * Defines the gamepad move sensiblity.
  122903. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122904. */
  122905. gamepadMoveSensibility: number;
  122906. private _yAxisScale;
  122907. /**
  122908. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122909. */
  122910. get invertYAxis(): boolean;
  122911. set invertYAxis(value: boolean);
  122912. private _onGamepadConnectedObserver;
  122913. private _onGamepadDisconnectedObserver;
  122914. /**
  122915. * Attach the input controls to a specific dom element to get the input from.
  122916. * @param element Defines the element the controls should be listened from
  122917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122918. */
  122919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122920. /**
  122921. * Detach the current controls from the specified dom element.
  122922. * @param element Defines the element to stop listening the inputs from
  122923. */
  122924. detachControl(element: Nullable<HTMLElement>): void;
  122925. /**
  122926. * Update the current camera state depending on the inputs that have been used this frame.
  122927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122928. */
  122929. checkInputs(): void;
  122930. /**
  122931. * Gets the class name of the current intput.
  122932. * @returns the class name
  122933. */
  122934. getClassName(): string;
  122935. /**
  122936. * Get the friendly name associated with the input class.
  122937. * @returns the input friendly name
  122938. */
  122939. getSimpleName(): string;
  122940. }
  122941. }
  122942. declare module BABYLON {
  122943. interface ArcRotateCameraInputsManager {
  122944. /**
  122945. * Add orientation input support to the input manager.
  122946. * @returns the current input manager
  122947. */
  122948. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122949. }
  122950. /**
  122951. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122952. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122953. */
  122954. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122955. /**
  122956. * Defines the camera the input is attached to.
  122957. */
  122958. camera: ArcRotateCamera;
  122959. /**
  122960. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122961. */
  122962. alphaCorrection: number;
  122963. /**
  122964. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122965. */
  122966. gammaCorrection: number;
  122967. private _alpha;
  122968. private _gamma;
  122969. private _dirty;
  122970. private _deviceOrientationHandler;
  122971. /**
  122972. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122973. */
  122974. constructor();
  122975. /**
  122976. * Attach the input controls to a specific dom element to get the input from.
  122977. * @param element Defines the element the controls should be listened from
  122978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122979. */
  122980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122981. /** @hidden */
  122982. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122983. /**
  122984. * Update the current camera state depending on the inputs that have been used this frame.
  122985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122986. */
  122987. checkInputs(): void;
  122988. /**
  122989. * Detach the current controls from the specified dom element.
  122990. * @param element Defines the element to stop listening the inputs from
  122991. */
  122992. detachControl(element: Nullable<HTMLElement>): void;
  122993. /**
  122994. * Gets the class name of the current intput.
  122995. * @returns the class name
  122996. */
  122997. getClassName(): string;
  122998. /**
  122999. * Get the friendly name associated with the input class.
  123000. * @returns the input friendly name
  123001. */
  123002. getSimpleName(): string;
  123003. }
  123004. }
  123005. declare module BABYLON {
  123006. /**
  123007. * Listen to mouse events to control the camera.
  123008. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123009. */
  123010. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123011. /**
  123012. * Defines the camera the input is attached to.
  123013. */
  123014. camera: FlyCamera;
  123015. /**
  123016. * Defines if touch is enabled. (Default is true.)
  123017. */
  123018. touchEnabled: boolean;
  123019. /**
  123020. * Defines the buttons associated with the input to handle camera rotation.
  123021. */
  123022. buttons: number[];
  123023. /**
  123024. * Assign buttons for Yaw control.
  123025. */
  123026. buttonsYaw: number[];
  123027. /**
  123028. * Assign buttons for Pitch control.
  123029. */
  123030. buttonsPitch: number[];
  123031. /**
  123032. * Assign buttons for Roll control.
  123033. */
  123034. buttonsRoll: number[];
  123035. /**
  123036. * Detect if any button is being pressed while mouse is moved.
  123037. * -1 = Mouse locked.
  123038. * 0 = Left button.
  123039. * 1 = Middle Button.
  123040. * 2 = Right Button.
  123041. */
  123042. activeButton: number;
  123043. /**
  123044. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123045. * Higher values reduce its sensitivity.
  123046. */
  123047. angularSensibility: number;
  123048. private _mousemoveCallback;
  123049. private _observer;
  123050. private _rollObserver;
  123051. private previousPosition;
  123052. private noPreventDefault;
  123053. private element;
  123054. /**
  123055. * Listen to mouse events to control the camera.
  123056. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123057. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123058. */
  123059. constructor(touchEnabled?: boolean);
  123060. /**
  123061. * Attach the mouse control to the HTML DOM element.
  123062. * @param element Defines the element that listens to the input events.
  123063. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123064. */
  123065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123066. /**
  123067. * Detach the current controls from the specified dom element.
  123068. * @param element Defines the element to stop listening the inputs from
  123069. */
  123070. detachControl(element: Nullable<HTMLElement>): void;
  123071. /**
  123072. * Gets the class name of the current input.
  123073. * @returns the class name.
  123074. */
  123075. getClassName(): string;
  123076. /**
  123077. * Get the friendly name associated with the input class.
  123078. * @returns the input's friendly name.
  123079. */
  123080. getSimpleName(): string;
  123081. private _pointerInput;
  123082. private _onMouseMove;
  123083. /**
  123084. * Rotate camera by mouse offset.
  123085. */
  123086. private rotateCamera;
  123087. }
  123088. }
  123089. declare module BABYLON {
  123090. /**
  123091. * Default Inputs manager for the FlyCamera.
  123092. * It groups all the default supported inputs for ease of use.
  123093. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123094. */
  123095. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123096. /**
  123097. * Instantiates a new FlyCameraInputsManager.
  123098. * @param camera Defines the camera the inputs belong to.
  123099. */
  123100. constructor(camera: FlyCamera);
  123101. /**
  123102. * Add keyboard input support to the input manager.
  123103. * @returns the new FlyCameraKeyboardMoveInput().
  123104. */
  123105. addKeyboard(): FlyCameraInputsManager;
  123106. /**
  123107. * Add mouse input support to the input manager.
  123108. * @param touchEnabled Enable touch screen support.
  123109. * @returns the new FlyCameraMouseInput().
  123110. */
  123111. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123112. }
  123113. }
  123114. declare module BABYLON {
  123115. /**
  123116. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123117. * such as in a 3D Space Shooter or a Flight Simulator.
  123118. */
  123119. export class FlyCamera extends TargetCamera {
  123120. /**
  123121. * Define the collision ellipsoid of the camera.
  123122. * This is helpful for simulating a camera body, like a player's body.
  123123. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123124. */
  123125. ellipsoid: Vector3;
  123126. /**
  123127. * Define an offset for the position of the ellipsoid around the camera.
  123128. * This can be helpful if the camera is attached away from the player's body center,
  123129. * such as at its head.
  123130. */
  123131. ellipsoidOffset: Vector3;
  123132. /**
  123133. * Enable or disable collisions of the camera with the rest of the scene objects.
  123134. */
  123135. checkCollisions: boolean;
  123136. /**
  123137. * Enable or disable gravity on the camera.
  123138. */
  123139. applyGravity: boolean;
  123140. /**
  123141. * Define the current direction the camera is moving to.
  123142. */
  123143. cameraDirection: Vector3;
  123144. /**
  123145. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  123146. * This overrides and empties cameraRotation.
  123147. */
  123148. rotationQuaternion: Quaternion;
  123149. /**
  123150. * Track Roll to maintain the wanted Rolling when looking around.
  123151. */
  123152. _trackRoll: number;
  123153. /**
  123154. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  123155. */
  123156. rollCorrect: number;
  123157. /**
  123158. * Mimic a banked turn, Rolling the camera when Yawing.
  123159. * It's recommended to use rollCorrect = 10 for faster banking correction.
  123160. */
  123161. bankedTurn: boolean;
  123162. /**
  123163. * Limit in radians for how much Roll banking will add. (Default: 90°)
  123164. */
  123165. bankedTurnLimit: number;
  123166. /**
  123167. * Value of 0 disables the banked Roll.
  123168. * Value of 1 is equal to the Yaw angle in radians.
  123169. */
  123170. bankedTurnMultiplier: number;
  123171. /**
  123172. * The inputs manager loads all the input sources, such as keyboard and mouse.
  123173. */
  123174. inputs: FlyCameraInputsManager;
  123175. /**
  123176. * Gets the input sensibility for mouse input.
  123177. * Higher values reduce sensitivity.
  123178. */
  123179. get angularSensibility(): number;
  123180. /**
  123181. * Sets the input sensibility for a mouse input.
  123182. * Higher values reduce sensitivity.
  123183. */
  123184. set angularSensibility(value: number);
  123185. /**
  123186. * Get the keys for camera movement forward.
  123187. */
  123188. get keysForward(): number[];
  123189. /**
  123190. * Set the keys for camera movement forward.
  123191. */
  123192. set keysForward(value: number[]);
  123193. /**
  123194. * Get the keys for camera movement backward.
  123195. */
  123196. get keysBackward(): number[];
  123197. set keysBackward(value: number[]);
  123198. /**
  123199. * Get the keys for camera movement up.
  123200. */
  123201. get keysUp(): number[];
  123202. /**
  123203. * Set the keys for camera movement up.
  123204. */
  123205. set keysUp(value: number[]);
  123206. /**
  123207. * Get the keys for camera movement down.
  123208. */
  123209. get keysDown(): number[];
  123210. /**
  123211. * Set the keys for camera movement down.
  123212. */
  123213. set keysDown(value: number[]);
  123214. /**
  123215. * Get the keys for camera movement left.
  123216. */
  123217. get keysLeft(): number[];
  123218. /**
  123219. * Set the keys for camera movement left.
  123220. */
  123221. set keysLeft(value: number[]);
  123222. /**
  123223. * Set the keys for camera movement right.
  123224. */
  123225. get keysRight(): number[];
  123226. /**
  123227. * Set the keys for camera movement right.
  123228. */
  123229. set keysRight(value: number[]);
  123230. /**
  123231. * Event raised when the camera collides with a mesh in the scene.
  123232. */
  123233. onCollide: (collidedMesh: AbstractMesh) => void;
  123234. private _collider;
  123235. private _needMoveForGravity;
  123236. private _oldPosition;
  123237. private _diffPosition;
  123238. private _newPosition;
  123239. /** @hidden */
  123240. _localDirection: Vector3;
  123241. /** @hidden */
  123242. _transformedDirection: Vector3;
  123243. /**
  123244. * Instantiates a FlyCamera.
  123245. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123246. * such as in a 3D Space Shooter or a Flight Simulator.
  123247. * @param name Define the name of the camera in the scene.
  123248. * @param position Define the starting position of the camera in the scene.
  123249. * @param scene Define the scene the camera belongs to.
  123250. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123251. */
  123252. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123253. /**
  123254. * Attach a control to the HTML DOM element.
  123255. * @param element Defines the element that listens to the input events.
  123256. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123257. */
  123258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123259. /**
  123260. * Detach a control from the HTML DOM element.
  123261. * The camera will stop reacting to that input.
  123262. * @param element Defines the element that listens to the input events.
  123263. */
  123264. detachControl(element: HTMLElement): void;
  123265. private _collisionMask;
  123266. /**
  123267. * Get the mask that the camera ignores in collision events.
  123268. */
  123269. get collisionMask(): number;
  123270. /**
  123271. * Set the mask that the camera ignores in collision events.
  123272. */
  123273. set collisionMask(mask: number);
  123274. /** @hidden */
  123275. _collideWithWorld(displacement: Vector3): void;
  123276. /** @hidden */
  123277. private _onCollisionPositionChange;
  123278. /** @hidden */
  123279. _checkInputs(): void;
  123280. /** @hidden */
  123281. _decideIfNeedsToMove(): boolean;
  123282. /** @hidden */
  123283. _updatePosition(): void;
  123284. /**
  123285. * Restore the Roll to its target value at the rate specified.
  123286. * @param rate - Higher means slower restoring.
  123287. * @hidden
  123288. */
  123289. restoreRoll(rate: number): void;
  123290. /**
  123291. * Destroy the camera and release the current resources held by it.
  123292. */
  123293. dispose(): void;
  123294. /**
  123295. * Get the current object class name.
  123296. * @returns the class name.
  123297. */
  123298. getClassName(): string;
  123299. }
  123300. }
  123301. declare module BABYLON {
  123302. /**
  123303. * Listen to keyboard events to control the camera.
  123304. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123305. */
  123306. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123307. /**
  123308. * Defines the camera the input is attached to.
  123309. */
  123310. camera: FlyCamera;
  123311. /**
  123312. * The list of keyboard keys used to control the forward move of the camera.
  123313. */
  123314. keysForward: number[];
  123315. /**
  123316. * The list of keyboard keys used to control the backward move of the camera.
  123317. */
  123318. keysBackward: number[];
  123319. /**
  123320. * The list of keyboard keys used to control the forward move of the camera.
  123321. */
  123322. keysUp: number[];
  123323. /**
  123324. * The list of keyboard keys used to control the backward move of the camera.
  123325. */
  123326. keysDown: number[];
  123327. /**
  123328. * The list of keyboard keys used to control the right strafe move of the camera.
  123329. */
  123330. keysRight: number[];
  123331. /**
  123332. * The list of keyboard keys used to control the left strafe move of the camera.
  123333. */
  123334. keysLeft: number[];
  123335. private _keys;
  123336. private _onCanvasBlurObserver;
  123337. private _onKeyboardObserver;
  123338. private _engine;
  123339. private _scene;
  123340. /**
  123341. * Attach the input controls to a specific dom element to get the input from.
  123342. * @param element Defines the element the controls should be listened from
  123343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123344. */
  123345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123346. /**
  123347. * Detach the current controls from the specified dom element.
  123348. * @param element Defines the element to stop listening the inputs from
  123349. */
  123350. detachControl(element: Nullable<HTMLElement>): void;
  123351. /**
  123352. * Gets the class name of the current intput.
  123353. * @returns the class name
  123354. */
  123355. getClassName(): string;
  123356. /** @hidden */
  123357. _onLostFocus(e: FocusEvent): void;
  123358. /**
  123359. * Get the friendly name associated with the input class.
  123360. * @returns the input friendly name
  123361. */
  123362. getSimpleName(): string;
  123363. /**
  123364. * Update the current camera state depending on the inputs that have been used this frame.
  123365. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123366. */
  123367. checkInputs(): void;
  123368. }
  123369. }
  123370. declare module BABYLON {
  123371. /**
  123372. * Manage the mouse wheel inputs to control a follow camera.
  123373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123374. */
  123375. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123376. /**
  123377. * Defines the camera the input is attached to.
  123378. */
  123379. camera: FollowCamera;
  123380. /**
  123381. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123382. */
  123383. axisControlRadius: boolean;
  123384. /**
  123385. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123386. */
  123387. axisControlHeight: boolean;
  123388. /**
  123389. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123390. */
  123391. axisControlRotation: boolean;
  123392. /**
  123393. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123394. * relation to mouseWheel events.
  123395. */
  123396. wheelPrecision: number;
  123397. /**
  123398. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123399. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123400. */
  123401. wheelDeltaPercentage: number;
  123402. private _wheel;
  123403. private _observer;
  123404. /**
  123405. * Attach the input controls to a specific dom element to get the input from.
  123406. * @param element Defines the element the controls should be listened from
  123407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123408. */
  123409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123410. /**
  123411. * Detach the current controls from the specified dom element.
  123412. * @param element Defines the element to stop listening the inputs from
  123413. */
  123414. detachControl(element: Nullable<HTMLElement>): void;
  123415. /**
  123416. * Gets the class name of the current intput.
  123417. * @returns the class name
  123418. */
  123419. getClassName(): string;
  123420. /**
  123421. * Get the friendly name associated with the input class.
  123422. * @returns the input friendly name
  123423. */
  123424. getSimpleName(): string;
  123425. }
  123426. }
  123427. declare module BABYLON {
  123428. /**
  123429. * Manage the pointers inputs to control an follow camera.
  123430. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123431. */
  123432. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123433. /**
  123434. * Defines the camera the input is attached to.
  123435. */
  123436. camera: FollowCamera;
  123437. /**
  123438. * Gets the class name of the current input.
  123439. * @returns the class name
  123440. */
  123441. getClassName(): string;
  123442. /**
  123443. * Defines the pointer angular sensibility along the X axis or how fast is
  123444. * the camera rotating.
  123445. * A negative number will reverse the axis direction.
  123446. */
  123447. angularSensibilityX: number;
  123448. /**
  123449. * Defines the pointer angular sensibility along the Y axis or how fast is
  123450. * the camera rotating.
  123451. * A negative number will reverse the axis direction.
  123452. */
  123453. angularSensibilityY: number;
  123454. /**
  123455. * Defines the pointer pinch precision or how fast is the camera zooming.
  123456. * A negative number will reverse the axis direction.
  123457. */
  123458. pinchPrecision: number;
  123459. /**
  123460. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123461. * from 0.
  123462. * It defines the percentage of current camera.radius to use as delta when
  123463. * pinch zoom is used.
  123464. */
  123465. pinchDeltaPercentage: number;
  123466. /**
  123467. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123468. */
  123469. axisXControlRadius: boolean;
  123470. /**
  123471. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123472. */
  123473. axisXControlHeight: boolean;
  123474. /**
  123475. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123476. */
  123477. axisXControlRotation: boolean;
  123478. /**
  123479. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123480. */
  123481. axisYControlRadius: boolean;
  123482. /**
  123483. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123484. */
  123485. axisYControlHeight: boolean;
  123486. /**
  123487. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123488. */
  123489. axisYControlRotation: boolean;
  123490. /**
  123491. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123492. */
  123493. axisPinchControlRadius: boolean;
  123494. /**
  123495. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123496. */
  123497. axisPinchControlHeight: boolean;
  123498. /**
  123499. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123500. */
  123501. axisPinchControlRotation: boolean;
  123502. /**
  123503. * Log error messages if basic misconfiguration has occurred.
  123504. */
  123505. warningEnable: boolean;
  123506. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123507. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123508. private _warningCounter;
  123509. private _warning;
  123510. }
  123511. }
  123512. declare module BABYLON {
  123513. /**
  123514. * Default Inputs manager for the FollowCamera.
  123515. * It groups all the default supported inputs for ease of use.
  123516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123517. */
  123518. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123519. /**
  123520. * Instantiates a new FollowCameraInputsManager.
  123521. * @param camera Defines the camera the inputs belong to
  123522. */
  123523. constructor(camera: FollowCamera);
  123524. /**
  123525. * Add keyboard input support to the input manager.
  123526. * @returns the current input manager
  123527. */
  123528. addKeyboard(): FollowCameraInputsManager;
  123529. /**
  123530. * Add mouse wheel input support to the input manager.
  123531. * @returns the current input manager
  123532. */
  123533. addMouseWheel(): FollowCameraInputsManager;
  123534. /**
  123535. * Add pointers input support to the input manager.
  123536. * @returns the current input manager
  123537. */
  123538. addPointers(): FollowCameraInputsManager;
  123539. /**
  123540. * Add orientation input support to the input manager.
  123541. * @returns the current input manager
  123542. */
  123543. addVRDeviceOrientation(): FollowCameraInputsManager;
  123544. }
  123545. }
  123546. declare module BABYLON {
  123547. /**
  123548. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123549. * an arc rotate version arcFollowCamera are available.
  123550. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123551. */
  123552. export class FollowCamera extends TargetCamera {
  123553. /**
  123554. * Distance the follow camera should follow an object at
  123555. */
  123556. radius: number;
  123557. /**
  123558. * Minimum allowed distance of the camera to the axis of rotation
  123559. * (The camera can not get closer).
  123560. * This can help limiting how the Camera is able to move in the scene.
  123561. */
  123562. lowerRadiusLimit: Nullable<number>;
  123563. /**
  123564. * Maximum allowed distance of the camera to the axis of rotation
  123565. * (The camera can not get further).
  123566. * This can help limiting how the Camera is able to move in the scene.
  123567. */
  123568. upperRadiusLimit: Nullable<number>;
  123569. /**
  123570. * Define a rotation offset between the camera and the object it follows
  123571. */
  123572. rotationOffset: number;
  123573. /**
  123574. * Minimum allowed angle to camera position relative to target object.
  123575. * This can help limiting how the Camera is able to move in the scene.
  123576. */
  123577. lowerRotationOffsetLimit: Nullable<number>;
  123578. /**
  123579. * Maximum allowed angle to camera position relative to target object.
  123580. * This can help limiting how the Camera is able to move in the scene.
  123581. */
  123582. upperRotationOffsetLimit: Nullable<number>;
  123583. /**
  123584. * Define a height offset between the camera and the object it follows.
  123585. * It can help following an object from the top (like a car chaing a plane)
  123586. */
  123587. heightOffset: number;
  123588. /**
  123589. * Minimum allowed height of camera position relative to target object.
  123590. * This can help limiting how the Camera is able to move in the scene.
  123591. */
  123592. lowerHeightOffsetLimit: Nullable<number>;
  123593. /**
  123594. * Maximum allowed height of camera position relative to target object.
  123595. * This can help limiting how the Camera is able to move in the scene.
  123596. */
  123597. upperHeightOffsetLimit: Nullable<number>;
  123598. /**
  123599. * Define how fast the camera can accelerate to follow it s target.
  123600. */
  123601. cameraAcceleration: number;
  123602. /**
  123603. * Define the speed limit of the camera following an object.
  123604. */
  123605. maxCameraSpeed: number;
  123606. /**
  123607. * Define the target of the camera.
  123608. */
  123609. lockedTarget: Nullable<AbstractMesh>;
  123610. /**
  123611. * Defines the input associated with the camera.
  123612. */
  123613. inputs: FollowCameraInputsManager;
  123614. /**
  123615. * Instantiates the follow camera.
  123616. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123617. * @param name Define the name of the camera in the scene
  123618. * @param position Define the position of the camera
  123619. * @param scene Define the scene the camera belong to
  123620. * @param lockedTarget Define the target of the camera
  123621. */
  123622. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123623. private _follow;
  123624. /**
  123625. * Attached controls to the current camera.
  123626. * @param element Defines the element the controls should be listened from
  123627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123628. */
  123629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123630. /**
  123631. * Detach the current controls from the camera.
  123632. * The camera will stop reacting to inputs.
  123633. * @param element Defines the element to stop listening the inputs from
  123634. */
  123635. detachControl(element: HTMLElement): void;
  123636. /** @hidden */
  123637. _checkInputs(): void;
  123638. private _checkLimits;
  123639. /**
  123640. * Gets the camera class name.
  123641. * @returns the class name
  123642. */
  123643. getClassName(): string;
  123644. }
  123645. /**
  123646. * Arc Rotate version of the follow camera.
  123647. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123648. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123649. */
  123650. export class ArcFollowCamera extends TargetCamera {
  123651. /** The longitudinal angle of the camera */
  123652. alpha: number;
  123653. /** The latitudinal angle of the camera */
  123654. beta: number;
  123655. /** The radius of the camera from its target */
  123656. radius: number;
  123657. private _cartesianCoordinates;
  123658. /** Define the camera target (the mesh it should follow) */
  123659. private _meshTarget;
  123660. /**
  123661. * Instantiates a new ArcFollowCamera
  123662. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123663. * @param name Define the name of the camera
  123664. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123665. * @param beta Define the rotation angle of the camera around the elevation axis
  123666. * @param radius Define the radius of the camera from its target point
  123667. * @param target Define the target of the camera
  123668. * @param scene Define the scene the camera belongs to
  123669. */
  123670. constructor(name: string,
  123671. /** The longitudinal angle of the camera */
  123672. alpha: number,
  123673. /** The latitudinal angle of the camera */
  123674. beta: number,
  123675. /** The radius of the camera from its target */
  123676. radius: number,
  123677. /** Define the camera target (the mesh it should follow) */
  123678. target: Nullable<AbstractMesh>, scene: Scene);
  123679. private _follow;
  123680. /** @hidden */
  123681. _checkInputs(): void;
  123682. /**
  123683. * Returns the class name of the object.
  123684. * It is mostly used internally for serialization purposes.
  123685. */
  123686. getClassName(): string;
  123687. }
  123688. }
  123689. declare module BABYLON {
  123690. /**
  123691. * Manage the keyboard inputs to control the movement of a follow camera.
  123692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123693. */
  123694. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123695. /**
  123696. * Defines the camera the input is attached to.
  123697. */
  123698. camera: FollowCamera;
  123699. /**
  123700. * Defines the list of key codes associated with the up action (increase heightOffset)
  123701. */
  123702. keysHeightOffsetIncr: number[];
  123703. /**
  123704. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123705. */
  123706. keysHeightOffsetDecr: number[];
  123707. /**
  123708. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123709. */
  123710. keysHeightOffsetModifierAlt: boolean;
  123711. /**
  123712. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123713. */
  123714. keysHeightOffsetModifierCtrl: boolean;
  123715. /**
  123716. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123717. */
  123718. keysHeightOffsetModifierShift: boolean;
  123719. /**
  123720. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123721. */
  123722. keysRotationOffsetIncr: number[];
  123723. /**
  123724. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123725. */
  123726. keysRotationOffsetDecr: number[];
  123727. /**
  123728. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123729. */
  123730. keysRotationOffsetModifierAlt: boolean;
  123731. /**
  123732. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123733. */
  123734. keysRotationOffsetModifierCtrl: boolean;
  123735. /**
  123736. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123737. */
  123738. keysRotationOffsetModifierShift: boolean;
  123739. /**
  123740. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123741. */
  123742. keysRadiusIncr: number[];
  123743. /**
  123744. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123745. */
  123746. keysRadiusDecr: number[];
  123747. /**
  123748. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123749. */
  123750. keysRadiusModifierAlt: boolean;
  123751. /**
  123752. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123753. */
  123754. keysRadiusModifierCtrl: boolean;
  123755. /**
  123756. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123757. */
  123758. keysRadiusModifierShift: boolean;
  123759. /**
  123760. * Defines the rate of change of heightOffset.
  123761. */
  123762. heightSensibility: number;
  123763. /**
  123764. * Defines the rate of change of rotationOffset.
  123765. */
  123766. rotationSensibility: number;
  123767. /**
  123768. * Defines the rate of change of radius.
  123769. */
  123770. radiusSensibility: number;
  123771. private _keys;
  123772. private _ctrlPressed;
  123773. private _altPressed;
  123774. private _shiftPressed;
  123775. private _onCanvasBlurObserver;
  123776. private _onKeyboardObserver;
  123777. private _engine;
  123778. private _scene;
  123779. /**
  123780. * Attach the input controls to a specific dom element to get the input from.
  123781. * @param element Defines the element the controls should be listened from
  123782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123783. */
  123784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123785. /**
  123786. * Detach the current controls from the specified dom element.
  123787. * @param element Defines the element to stop listening the inputs from
  123788. */
  123789. detachControl(element: Nullable<HTMLElement>): void;
  123790. /**
  123791. * Update the current camera state depending on the inputs that have been used this frame.
  123792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123793. */
  123794. checkInputs(): void;
  123795. /**
  123796. * Gets the class name of the current input.
  123797. * @returns the class name
  123798. */
  123799. getClassName(): string;
  123800. /**
  123801. * Get the friendly name associated with the input class.
  123802. * @returns the input friendly name
  123803. */
  123804. getSimpleName(): string;
  123805. /**
  123806. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123807. * allow modification of the heightOffset value.
  123808. */
  123809. private _modifierHeightOffset;
  123810. /**
  123811. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123812. * allow modification of the rotationOffset value.
  123813. */
  123814. private _modifierRotationOffset;
  123815. /**
  123816. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123817. * allow modification of the radius value.
  123818. */
  123819. private _modifierRadius;
  123820. }
  123821. }
  123822. declare module BABYLON {
  123823. interface FreeCameraInputsManager {
  123824. /**
  123825. * @hidden
  123826. */
  123827. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123828. /**
  123829. * Add orientation input support to the input manager.
  123830. * @returns the current input manager
  123831. */
  123832. addDeviceOrientation(): FreeCameraInputsManager;
  123833. }
  123834. /**
  123835. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123836. * Screen rotation is taken into account.
  123837. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123838. */
  123839. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123840. private _camera;
  123841. private _screenOrientationAngle;
  123842. private _constantTranform;
  123843. private _screenQuaternion;
  123844. private _alpha;
  123845. private _beta;
  123846. private _gamma;
  123847. /**
  123848. * Can be used to detect if a device orientation sensor is available on a device
  123849. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123850. * @returns a promise that will resolve on orientation change
  123851. */
  123852. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123853. /**
  123854. * @hidden
  123855. */
  123856. _onDeviceOrientationChangedObservable: Observable<void>;
  123857. /**
  123858. * Instantiates a new input
  123859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123860. */
  123861. constructor();
  123862. /**
  123863. * Define the camera controlled by the input.
  123864. */
  123865. get camera(): FreeCamera;
  123866. set camera(camera: FreeCamera);
  123867. /**
  123868. * Attach the input controls to a specific dom element to get the input from.
  123869. * @param element Defines the element the controls should be listened from
  123870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123871. */
  123872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123873. private _orientationChanged;
  123874. private _deviceOrientation;
  123875. /**
  123876. * Detach the current controls from the specified dom element.
  123877. * @param element Defines the element to stop listening the inputs from
  123878. */
  123879. detachControl(element: Nullable<HTMLElement>): void;
  123880. /**
  123881. * Update the current camera state depending on the inputs that have been used this frame.
  123882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123883. */
  123884. checkInputs(): void;
  123885. /**
  123886. * Gets the class name of the current intput.
  123887. * @returns the class name
  123888. */
  123889. getClassName(): string;
  123890. /**
  123891. * Get the friendly name associated with the input class.
  123892. * @returns the input friendly name
  123893. */
  123894. getSimpleName(): string;
  123895. }
  123896. }
  123897. declare module BABYLON {
  123898. /**
  123899. * Manage the gamepad inputs to control a free camera.
  123900. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123901. */
  123902. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123903. /**
  123904. * Define the camera the input is attached to.
  123905. */
  123906. camera: FreeCamera;
  123907. /**
  123908. * Define the Gamepad controlling the input
  123909. */
  123910. gamepad: Nullable<Gamepad>;
  123911. /**
  123912. * Defines the gamepad rotation sensiblity.
  123913. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123914. */
  123915. gamepadAngularSensibility: number;
  123916. /**
  123917. * Defines the gamepad move sensiblity.
  123918. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123919. */
  123920. gamepadMoveSensibility: number;
  123921. private _yAxisScale;
  123922. /**
  123923. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123924. */
  123925. get invertYAxis(): boolean;
  123926. set invertYAxis(value: boolean);
  123927. private _onGamepadConnectedObserver;
  123928. private _onGamepadDisconnectedObserver;
  123929. private _cameraTransform;
  123930. private _deltaTransform;
  123931. private _vector3;
  123932. private _vector2;
  123933. /**
  123934. * Attach the input controls to a specific dom element to get the input from.
  123935. * @param element Defines the element the controls should be listened from
  123936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123937. */
  123938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123939. /**
  123940. * Detach the current controls from the specified dom element.
  123941. * @param element Defines the element to stop listening the inputs from
  123942. */
  123943. detachControl(element: Nullable<HTMLElement>): void;
  123944. /**
  123945. * Update the current camera state depending on the inputs that have been used this frame.
  123946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123947. */
  123948. checkInputs(): void;
  123949. /**
  123950. * Gets the class name of the current intput.
  123951. * @returns the class name
  123952. */
  123953. getClassName(): string;
  123954. /**
  123955. * Get the friendly name associated with the input class.
  123956. * @returns the input friendly name
  123957. */
  123958. getSimpleName(): string;
  123959. }
  123960. }
  123961. declare module BABYLON {
  123962. /**
  123963. * Defines the potential axis of a Joystick
  123964. */
  123965. export enum JoystickAxis {
  123966. /** X axis */
  123967. X = 0,
  123968. /** Y axis */
  123969. Y = 1,
  123970. /** Z axis */
  123971. Z = 2
  123972. }
  123973. /**
  123974. * Represents the different customization options available
  123975. * for VirtualJoystick
  123976. */
  123977. interface VirtualJoystickCustomizations {
  123978. /**
  123979. * Size of the joystick's puck
  123980. */
  123981. puckSize: number;
  123982. /**
  123983. * Size of the joystick's container
  123984. */
  123985. containerSize: number;
  123986. /**
  123987. * Color of the joystick && puck
  123988. */
  123989. color: string;
  123990. /**
  123991. * Image URL for the joystick's puck
  123992. */
  123993. puckImage?: string;
  123994. /**
  123995. * Image URL for the joystick's container
  123996. */
  123997. containerImage?: string;
  123998. /**
  123999. * Defines the unmoving position of the joystick container
  124000. */
  124001. position?: {
  124002. x: number;
  124003. y: number;
  124004. };
  124005. /**
  124006. * Defines whether or not the joystick container is always visible
  124007. */
  124008. alwaysVisible: boolean;
  124009. /**
  124010. * Defines whether or not to limit the movement of the puck to the joystick's container
  124011. */
  124012. limitToContainer: boolean;
  124013. }
  124014. /**
  124015. * Class used to define virtual joystick (used in touch mode)
  124016. */
  124017. export class VirtualJoystick {
  124018. /**
  124019. * Gets or sets a boolean indicating that left and right values must be inverted
  124020. */
  124021. reverseLeftRight: boolean;
  124022. /**
  124023. * Gets or sets a boolean indicating that up and down values must be inverted
  124024. */
  124025. reverseUpDown: boolean;
  124026. /**
  124027. * Gets the offset value for the position (ie. the change of the position value)
  124028. */
  124029. deltaPosition: Vector3;
  124030. /**
  124031. * Gets a boolean indicating if the virtual joystick was pressed
  124032. */
  124033. pressed: boolean;
  124034. /**
  124035. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124036. */
  124037. static Canvas: Nullable<HTMLCanvasElement>;
  124038. /**
  124039. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124040. */
  124041. limitToContainer: boolean;
  124042. private static _globalJoystickIndex;
  124043. private static _alwaysVisibleSticks;
  124044. private static vjCanvasContext;
  124045. private static vjCanvasWidth;
  124046. private static vjCanvasHeight;
  124047. private static halfWidth;
  124048. private static _GetDefaultOptions;
  124049. private _action;
  124050. private _axisTargetedByLeftAndRight;
  124051. private _axisTargetedByUpAndDown;
  124052. private _joystickSensibility;
  124053. private _inversedSensibility;
  124054. private _joystickPointerID;
  124055. private _joystickColor;
  124056. private _joystickPointerPos;
  124057. private _joystickPreviousPointerPos;
  124058. private _joystickPointerStartPos;
  124059. private _deltaJoystickVector;
  124060. private _leftJoystick;
  124061. private _touches;
  124062. private _joystickPosition;
  124063. private _alwaysVisible;
  124064. private _puckImage;
  124065. private _containerImage;
  124066. private _joystickPuckSize;
  124067. private _joystickContainerSize;
  124068. private _clearPuckSize;
  124069. private _clearContainerSize;
  124070. private _clearPuckSizeOffset;
  124071. private _clearContainerSizeOffset;
  124072. private _onPointerDownHandlerRef;
  124073. private _onPointerMoveHandlerRef;
  124074. private _onPointerUpHandlerRef;
  124075. private _onResize;
  124076. /**
  124077. * Creates a new virtual joystick
  124078. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124079. * @param customizations Defines the options we want to customize the VirtualJoystick
  124080. */
  124081. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124082. /**
  124083. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124084. * @param newJoystickSensibility defines the new sensibility
  124085. */
  124086. setJoystickSensibility(newJoystickSensibility: number): void;
  124087. private _onPointerDown;
  124088. private _onPointerMove;
  124089. private _onPointerUp;
  124090. /**
  124091. * Change the color of the virtual joystick
  124092. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124093. */
  124094. setJoystickColor(newColor: string): void;
  124095. /**
  124096. * Size of the joystick's container
  124097. */
  124098. set containerSize(newSize: number);
  124099. get containerSize(): number;
  124100. /**
  124101. * Size of the joystick's puck
  124102. */
  124103. set puckSize(newSize: number);
  124104. get puckSize(): number;
  124105. /**
  124106. * Clears the set position of the joystick
  124107. */
  124108. clearPosition(): void;
  124109. /**
  124110. * Defines whether or not the joystick container is always visible
  124111. */
  124112. set alwaysVisible(value: boolean);
  124113. get alwaysVisible(): boolean;
  124114. /**
  124115. * Sets the constant position of the Joystick container
  124116. * @param x X axis coordinate
  124117. * @param y Y axis coordinate
  124118. */
  124119. setPosition(x: number, y: number): void;
  124120. /**
  124121. * Defines a callback to call when the joystick is touched
  124122. * @param action defines the callback
  124123. */
  124124. setActionOnTouch(action: () => any): void;
  124125. /**
  124126. * Defines which axis you'd like to control for left & right
  124127. * @param axis defines the axis to use
  124128. */
  124129. setAxisForLeftRight(axis: JoystickAxis): void;
  124130. /**
  124131. * Defines which axis you'd like to control for up & down
  124132. * @param axis defines the axis to use
  124133. */
  124134. setAxisForUpDown(axis: JoystickAxis): void;
  124135. /**
  124136. * Clears the canvas from the previous puck / container draw
  124137. */
  124138. private _clearPreviousDraw;
  124139. /**
  124140. * Loads `urlPath` to be used for the container's image
  124141. * @param urlPath defines the urlPath of an image to use
  124142. */
  124143. setContainerImage(urlPath: string): void;
  124144. /**
  124145. * Loads `urlPath` to be used for the puck's image
  124146. * @param urlPath defines the urlPath of an image to use
  124147. */
  124148. setPuckImage(urlPath: string): void;
  124149. /**
  124150. * Draws the Virtual Joystick's container
  124151. */
  124152. private _drawContainer;
  124153. /**
  124154. * Draws the Virtual Joystick's puck
  124155. */
  124156. private _drawPuck;
  124157. private _drawVirtualJoystick;
  124158. /**
  124159. * Release internal HTML canvas
  124160. */
  124161. releaseCanvas(): void;
  124162. }
  124163. }
  124164. declare module BABYLON {
  124165. interface FreeCameraInputsManager {
  124166. /**
  124167. * Add virtual joystick input support to the input manager.
  124168. * @returns the current input manager
  124169. */
  124170. addVirtualJoystick(): FreeCameraInputsManager;
  124171. }
  124172. /**
  124173. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  124174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124175. */
  124176. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124177. /**
  124178. * Defines the camera the input is attached to.
  124179. */
  124180. camera: FreeCamera;
  124181. private _leftjoystick;
  124182. private _rightjoystick;
  124183. /**
  124184. * Gets the left stick of the virtual joystick.
  124185. * @returns The virtual Joystick
  124186. */
  124187. getLeftJoystick(): VirtualJoystick;
  124188. /**
  124189. * Gets the right stick of the virtual joystick.
  124190. * @returns The virtual Joystick
  124191. */
  124192. getRightJoystick(): VirtualJoystick;
  124193. /**
  124194. * Update the current camera state depending on the inputs that have been used this frame.
  124195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124196. */
  124197. checkInputs(): void;
  124198. /**
  124199. * Attach the input controls to a specific dom element to get the input from.
  124200. * @param element Defines the element the controls should be listened from
  124201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124202. */
  124203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124204. /**
  124205. * Detach the current controls from the specified dom element.
  124206. * @param element Defines the element to stop listening the inputs from
  124207. */
  124208. detachControl(element: Nullable<HTMLElement>): void;
  124209. /**
  124210. * Gets the class name of the current intput.
  124211. * @returns the class name
  124212. */
  124213. getClassName(): string;
  124214. /**
  124215. * Get the friendly name associated with the input class.
  124216. * @returns the input friendly name
  124217. */
  124218. getSimpleName(): string;
  124219. }
  124220. }
  124221. declare module BABYLON {
  124222. /**
  124223. * This represents a FPS type of camera controlled by touch.
  124224. * This is like a universal camera minus the Gamepad controls.
  124225. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124226. */
  124227. export class TouchCamera extends FreeCamera {
  124228. /**
  124229. * Defines the touch sensibility for rotation.
  124230. * The higher the faster.
  124231. */
  124232. get touchAngularSensibility(): number;
  124233. set touchAngularSensibility(value: number);
  124234. /**
  124235. * Defines the touch sensibility for move.
  124236. * The higher the faster.
  124237. */
  124238. get touchMoveSensibility(): number;
  124239. set touchMoveSensibility(value: number);
  124240. /**
  124241. * Instantiates a new touch camera.
  124242. * This represents a FPS type of camera controlled by touch.
  124243. * This is like a universal camera minus the Gamepad controls.
  124244. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124245. * @param name Define the name of the camera in the scene
  124246. * @param position Define the start position of the camera in the scene
  124247. * @param scene Define the scene the camera belongs to
  124248. */
  124249. constructor(name: string, position: Vector3, scene: Scene);
  124250. /**
  124251. * Gets the current object class name.
  124252. * @return the class name
  124253. */
  124254. getClassName(): string;
  124255. /** @hidden */
  124256. _setupInputs(): void;
  124257. }
  124258. }
  124259. declare module BABYLON {
  124260. /**
  124261. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124262. * being tilted forward or back and left or right.
  124263. */
  124264. export class DeviceOrientationCamera extends FreeCamera {
  124265. private _initialQuaternion;
  124266. private _quaternionCache;
  124267. private _tmpDragQuaternion;
  124268. private _disablePointerInputWhenUsingDeviceOrientation;
  124269. /**
  124270. * Creates a new device orientation camera
  124271. * @param name The name of the camera
  124272. * @param position The start position camera
  124273. * @param scene The scene the camera belongs to
  124274. */
  124275. constructor(name: string, position: Vector3, scene: Scene);
  124276. /**
  124277. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124278. */
  124279. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124280. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124281. private _dragFactor;
  124282. /**
  124283. * Enabled turning on the y axis when the orientation sensor is active
  124284. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124285. */
  124286. enableHorizontalDragging(dragFactor?: number): void;
  124287. /**
  124288. * Gets the current instance class name ("DeviceOrientationCamera").
  124289. * This helps avoiding instanceof at run time.
  124290. * @returns the class name
  124291. */
  124292. getClassName(): string;
  124293. /**
  124294. * @hidden
  124295. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124296. */
  124297. _checkInputs(): void;
  124298. /**
  124299. * Reset the camera to its default orientation on the specified axis only.
  124300. * @param axis The axis to reset
  124301. */
  124302. resetToCurrentRotation(axis?: Axis): void;
  124303. }
  124304. }
  124305. declare module BABYLON {
  124306. /**
  124307. * Defines supported buttons for XBox360 compatible gamepads
  124308. */
  124309. export enum Xbox360Button {
  124310. /** A */
  124311. A = 0,
  124312. /** B */
  124313. B = 1,
  124314. /** X */
  124315. X = 2,
  124316. /** Y */
  124317. Y = 3,
  124318. /** Left button */
  124319. LB = 4,
  124320. /** Right button */
  124321. RB = 5,
  124322. /** Back */
  124323. Back = 8,
  124324. /** Start */
  124325. Start = 9,
  124326. /** Left stick */
  124327. LeftStick = 10,
  124328. /** Right stick */
  124329. RightStick = 11
  124330. }
  124331. /** Defines values for XBox360 DPad */
  124332. export enum Xbox360Dpad {
  124333. /** Up */
  124334. Up = 12,
  124335. /** Down */
  124336. Down = 13,
  124337. /** Left */
  124338. Left = 14,
  124339. /** Right */
  124340. Right = 15
  124341. }
  124342. /**
  124343. * Defines a XBox360 gamepad
  124344. */
  124345. export class Xbox360Pad extends Gamepad {
  124346. private _leftTrigger;
  124347. private _rightTrigger;
  124348. private _onlefttriggerchanged;
  124349. private _onrighttriggerchanged;
  124350. private _onbuttondown;
  124351. private _onbuttonup;
  124352. private _ondpaddown;
  124353. private _ondpadup;
  124354. /** Observable raised when a button is pressed */
  124355. onButtonDownObservable: Observable<Xbox360Button>;
  124356. /** Observable raised when a button is released */
  124357. onButtonUpObservable: Observable<Xbox360Button>;
  124358. /** Observable raised when a pad is pressed */
  124359. onPadDownObservable: Observable<Xbox360Dpad>;
  124360. /** Observable raised when a pad is released */
  124361. onPadUpObservable: Observable<Xbox360Dpad>;
  124362. private _buttonA;
  124363. private _buttonB;
  124364. private _buttonX;
  124365. private _buttonY;
  124366. private _buttonBack;
  124367. private _buttonStart;
  124368. private _buttonLB;
  124369. private _buttonRB;
  124370. private _buttonLeftStick;
  124371. private _buttonRightStick;
  124372. private _dPadUp;
  124373. private _dPadDown;
  124374. private _dPadLeft;
  124375. private _dPadRight;
  124376. private _isXboxOnePad;
  124377. /**
  124378. * Creates a new XBox360 gamepad object
  124379. * @param id defines the id of this gamepad
  124380. * @param index defines its index
  124381. * @param gamepad defines the internal HTML gamepad object
  124382. * @param xboxOne defines if it is a XBox One gamepad
  124383. */
  124384. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124385. /**
  124386. * Defines the callback to call when left trigger is pressed
  124387. * @param callback defines the callback to use
  124388. */
  124389. onlefttriggerchanged(callback: (value: number) => void): void;
  124390. /**
  124391. * Defines the callback to call when right trigger is pressed
  124392. * @param callback defines the callback to use
  124393. */
  124394. onrighttriggerchanged(callback: (value: number) => void): void;
  124395. /**
  124396. * Gets the left trigger value
  124397. */
  124398. get leftTrigger(): number;
  124399. /**
  124400. * Sets the left trigger value
  124401. */
  124402. set leftTrigger(newValue: number);
  124403. /**
  124404. * Gets the right trigger value
  124405. */
  124406. get rightTrigger(): number;
  124407. /**
  124408. * Sets the right trigger value
  124409. */
  124410. set rightTrigger(newValue: number);
  124411. /**
  124412. * Defines the callback to call when a button is pressed
  124413. * @param callback defines the callback to use
  124414. */
  124415. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124416. /**
  124417. * Defines the callback to call when a button is released
  124418. * @param callback defines the callback to use
  124419. */
  124420. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124421. /**
  124422. * Defines the callback to call when a pad is pressed
  124423. * @param callback defines the callback to use
  124424. */
  124425. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124426. /**
  124427. * Defines the callback to call when a pad is released
  124428. * @param callback defines the callback to use
  124429. */
  124430. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124431. private _setButtonValue;
  124432. private _setDPadValue;
  124433. /**
  124434. * Gets the value of the `A` button
  124435. */
  124436. get buttonA(): number;
  124437. /**
  124438. * Sets the value of the `A` button
  124439. */
  124440. set buttonA(value: number);
  124441. /**
  124442. * Gets the value of the `B` button
  124443. */
  124444. get buttonB(): number;
  124445. /**
  124446. * Sets the value of the `B` button
  124447. */
  124448. set buttonB(value: number);
  124449. /**
  124450. * Gets the value of the `X` button
  124451. */
  124452. get buttonX(): number;
  124453. /**
  124454. * Sets the value of the `X` button
  124455. */
  124456. set buttonX(value: number);
  124457. /**
  124458. * Gets the value of the `Y` button
  124459. */
  124460. get buttonY(): number;
  124461. /**
  124462. * Sets the value of the `Y` button
  124463. */
  124464. set buttonY(value: number);
  124465. /**
  124466. * Gets the value of the `Start` button
  124467. */
  124468. get buttonStart(): number;
  124469. /**
  124470. * Sets the value of the `Start` button
  124471. */
  124472. set buttonStart(value: number);
  124473. /**
  124474. * Gets the value of the `Back` button
  124475. */
  124476. get buttonBack(): number;
  124477. /**
  124478. * Sets the value of the `Back` button
  124479. */
  124480. set buttonBack(value: number);
  124481. /**
  124482. * Gets the value of the `Left` button
  124483. */
  124484. get buttonLB(): number;
  124485. /**
  124486. * Sets the value of the `Left` button
  124487. */
  124488. set buttonLB(value: number);
  124489. /**
  124490. * Gets the value of the `Right` button
  124491. */
  124492. get buttonRB(): number;
  124493. /**
  124494. * Sets the value of the `Right` button
  124495. */
  124496. set buttonRB(value: number);
  124497. /**
  124498. * Gets the value of the Left joystick
  124499. */
  124500. get buttonLeftStick(): number;
  124501. /**
  124502. * Sets the value of the Left joystick
  124503. */
  124504. set buttonLeftStick(value: number);
  124505. /**
  124506. * Gets the value of the Right joystick
  124507. */
  124508. get buttonRightStick(): number;
  124509. /**
  124510. * Sets the value of the Right joystick
  124511. */
  124512. set buttonRightStick(value: number);
  124513. /**
  124514. * Gets the value of D-pad up
  124515. */
  124516. get dPadUp(): number;
  124517. /**
  124518. * Sets the value of D-pad up
  124519. */
  124520. set dPadUp(value: number);
  124521. /**
  124522. * Gets the value of D-pad down
  124523. */
  124524. get dPadDown(): number;
  124525. /**
  124526. * Sets the value of D-pad down
  124527. */
  124528. set dPadDown(value: number);
  124529. /**
  124530. * Gets the value of D-pad left
  124531. */
  124532. get dPadLeft(): number;
  124533. /**
  124534. * Sets the value of D-pad left
  124535. */
  124536. set dPadLeft(value: number);
  124537. /**
  124538. * Gets the value of D-pad right
  124539. */
  124540. get dPadRight(): number;
  124541. /**
  124542. * Sets the value of D-pad right
  124543. */
  124544. set dPadRight(value: number);
  124545. /**
  124546. * Force the gamepad to synchronize with device values
  124547. */
  124548. update(): void;
  124549. /**
  124550. * Disposes the gamepad
  124551. */
  124552. dispose(): void;
  124553. }
  124554. }
  124555. declare module BABYLON {
  124556. /**
  124557. * Defines supported buttons for DualShock compatible gamepads
  124558. */
  124559. export enum DualShockButton {
  124560. /** Cross */
  124561. Cross = 0,
  124562. /** Circle */
  124563. Circle = 1,
  124564. /** Square */
  124565. Square = 2,
  124566. /** Triangle */
  124567. Triangle = 3,
  124568. /** L1 */
  124569. L1 = 4,
  124570. /** R1 */
  124571. R1 = 5,
  124572. /** Share */
  124573. Share = 8,
  124574. /** Options */
  124575. Options = 9,
  124576. /** Left stick */
  124577. LeftStick = 10,
  124578. /** Right stick */
  124579. RightStick = 11
  124580. }
  124581. /** Defines values for DualShock DPad */
  124582. export enum DualShockDpad {
  124583. /** Up */
  124584. Up = 12,
  124585. /** Down */
  124586. Down = 13,
  124587. /** Left */
  124588. Left = 14,
  124589. /** Right */
  124590. Right = 15
  124591. }
  124592. /**
  124593. * Defines a DualShock gamepad
  124594. */
  124595. export class DualShockPad extends Gamepad {
  124596. private _leftTrigger;
  124597. private _rightTrigger;
  124598. private _onlefttriggerchanged;
  124599. private _onrighttriggerchanged;
  124600. private _onbuttondown;
  124601. private _onbuttonup;
  124602. private _ondpaddown;
  124603. private _ondpadup;
  124604. /** Observable raised when a button is pressed */
  124605. onButtonDownObservable: Observable<DualShockButton>;
  124606. /** Observable raised when a button is released */
  124607. onButtonUpObservable: Observable<DualShockButton>;
  124608. /** Observable raised when a pad is pressed */
  124609. onPadDownObservable: Observable<DualShockDpad>;
  124610. /** Observable raised when a pad is released */
  124611. onPadUpObservable: Observable<DualShockDpad>;
  124612. private _buttonCross;
  124613. private _buttonCircle;
  124614. private _buttonSquare;
  124615. private _buttonTriangle;
  124616. private _buttonShare;
  124617. private _buttonOptions;
  124618. private _buttonL1;
  124619. private _buttonR1;
  124620. private _buttonLeftStick;
  124621. private _buttonRightStick;
  124622. private _dPadUp;
  124623. private _dPadDown;
  124624. private _dPadLeft;
  124625. private _dPadRight;
  124626. /**
  124627. * Creates a new DualShock gamepad object
  124628. * @param id defines the id of this gamepad
  124629. * @param index defines its index
  124630. * @param gamepad defines the internal HTML gamepad object
  124631. */
  124632. constructor(id: string, index: number, gamepad: any);
  124633. /**
  124634. * Defines the callback to call when left trigger is pressed
  124635. * @param callback defines the callback to use
  124636. */
  124637. onlefttriggerchanged(callback: (value: number) => void): void;
  124638. /**
  124639. * Defines the callback to call when right trigger is pressed
  124640. * @param callback defines the callback to use
  124641. */
  124642. onrighttriggerchanged(callback: (value: number) => void): void;
  124643. /**
  124644. * Gets the left trigger value
  124645. */
  124646. get leftTrigger(): number;
  124647. /**
  124648. * Sets the left trigger value
  124649. */
  124650. set leftTrigger(newValue: number);
  124651. /**
  124652. * Gets the right trigger value
  124653. */
  124654. get rightTrigger(): number;
  124655. /**
  124656. * Sets the right trigger value
  124657. */
  124658. set rightTrigger(newValue: number);
  124659. /**
  124660. * Defines the callback to call when a button is pressed
  124661. * @param callback defines the callback to use
  124662. */
  124663. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124664. /**
  124665. * Defines the callback to call when a button is released
  124666. * @param callback defines the callback to use
  124667. */
  124668. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124669. /**
  124670. * Defines the callback to call when a pad is pressed
  124671. * @param callback defines the callback to use
  124672. */
  124673. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124674. /**
  124675. * Defines the callback to call when a pad is released
  124676. * @param callback defines the callback to use
  124677. */
  124678. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124679. private _setButtonValue;
  124680. private _setDPadValue;
  124681. /**
  124682. * Gets the value of the `Cross` button
  124683. */
  124684. get buttonCross(): number;
  124685. /**
  124686. * Sets the value of the `Cross` button
  124687. */
  124688. set buttonCross(value: number);
  124689. /**
  124690. * Gets the value of the `Circle` button
  124691. */
  124692. get buttonCircle(): number;
  124693. /**
  124694. * Sets the value of the `Circle` button
  124695. */
  124696. set buttonCircle(value: number);
  124697. /**
  124698. * Gets the value of the `Square` button
  124699. */
  124700. get buttonSquare(): number;
  124701. /**
  124702. * Sets the value of the `Square` button
  124703. */
  124704. set buttonSquare(value: number);
  124705. /**
  124706. * Gets the value of the `Triangle` button
  124707. */
  124708. get buttonTriangle(): number;
  124709. /**
  124710. * Sets the value of the `Triangle` button
  124711. */
  124712. set buttonTriangle(value: number);
  124713. /**
  124714. * Gets the value of the `Options` button
  124715. */
  124716. get buttonOptions(): number;
  124717. /**
  124718. * Sets the value of the `Options` button
  124719. */
  124720. set buttonOptions(value: number);
  124721. /**
  124722. * Gets the value of the `Share` button
  124723. */
  124724. get buttonShare(): number;
  124725. /**
  124726. * Sets the value of the `Share` button
  124727. */
  124728. set buttonShare(value: number);
  124729. /**
  124730. * Gets the value of the `L1` button
  124731. */
  124732. get buttonL1(): number;
  124733. /**
  124734. * Sets the value of the `L1` button
  124735. */
  124736. set buttonL1(value: number);
  124737. /**
  124738. * Gets the value of the `R1` button
  124739. */
  124740. get buttonR1(): number;
  124741. /**
  124742. * Sets the value of the `R1` button
  124743. */
  124744. set buttonR1(value: number);
  124745. /**
  124746. * Gets the value of the Left joystick
  124747. */
  124748. get buttonLeftStick(): number;
  124749. /**
  124750. * Sets the value of the Left joystick
  124751. */
  124752. set buttonLeftStick(value: number);
  124753. /**
  124754. * Gets the value of the Right joystick
  124755. */
  124756. get buttonRightStick(): number;
  124757. /**
  124758. * Sets the value of the Right joystick
  124759. */
  124760. set buttonRightStick(value: number);
  124761. /**
  124762. * Gets the value of D-pad up
  124763. */
  124764. get dPadUp(): number;
  124765. /**
  124766. * Sets the value of D-pad up
  124767. */
  124768. set dPadUp(value: number);
  124769. /**
  124770. * Gets the value of D-pad down
  124771. */
  124772. get dPadDown(): number;
  124773. /**
  124774. * Sets the value of D-pad down
  124775. */
  124776. set dPadDown(value: number);
  124777. /**
  124778. * Gets the value of D-pad left
  124779. */
  124780. get dPadLeft(): number;
  124781. /**
  124782. * Sets the value of D-pad left
  124783. */
  124784. set dPadLeft(value: number);
  124785. /**
  124786. * Gets the value of D-pad right
  124787. */
  124788. get dPadRight(): number;
  124789. /**
  124790. * Sets the value of D-pad right
  124791. */
  124792. set dPadRight(value: number);
  124793. /**
  124794. * Force the gamepad to synchronize with device values
  124795. */
  124796. update(): void;
  124797. /**
  124798. * Disposes the gamepad
  124799. */
  124800. dispose(): void;
  124801. }
  124802. }
  124803. declare module BABYLON {
  124804. /**
  124805. * Manager for handling gamepads
  124806. */
  124807. export class GamepadManager {
  124808. private _scene?;
  124809. private _babylonGamepads;
  124810. private _oneGamepadConnected;
  124811. /** @hidden */
  124812. _isMonitoring: boolean;
  124813. private _gamepadEventSupported;
  124814. private _gamepadSupport?;
  124815. /**
  124816. * observable to be triggered when the gamepad controller has been connected
  124817. */
  124818. onGamepadConnectedObservable: Observable<Gamepad>;
  124819. /**
  124820. * observable to be triggered when the gamepad controller has been disconnected
  124821. */
  124822. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124823. private _onGamepadConnectedEvent;
  124824. private _onGamepadDisconnectedEvent;
  124825. /**
  124826. * Initializes the gamepad manager
  124827. * @param _scene BabylonJS scene
  124828. */
  124829. constructor(_scene?: Scene | undefined);
  124830. /**
  124831. * The gamepads in the game pad manager
  124832. */
  124833. get gamepads(): Gamepad[];
  124834. /**
  124835. * Get the gamepad controllers based on type
  124836. * @param type The type of gamepad controller
  124837. * @returns Nullable gamepad
  124838. */
  124839. getGamepadByType(type?: number): Nullable<Gamepad>;
  124840. /**
  124841. * Disposes the gamepad manager
  124842. */
  124843. dispose(): void;
  124844. private _addNewGamepad;
  124845. private _startMonitoringGamepads;
  124846. private _stopMonitoringGamepads;
  124847. /** @hidden */
  124848. _checkGamepadsStatus(): void;
  124849. private _updateGamepadObjects;
  124850. }
  124851. }
  124852. declare module BABYLON {
  124853. interface Scene {
  124854. /** @hidden */
  124855. _gamepadManager: Nullable<GamepadManager>;
  124856. /**
  124857. * Gets the gamepad manager associated with the scene
  124858. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124859. */
  124860. gamepadManager: GamepadManager;
  124861. }
  124862. /**
  124863. * Interface representing a free camera inputs manager
  124864. */
  124865. interface FreeCameraInputsManager {
  124866. /**
  124867. * Adds gamepad input support to the FreeCameraInputsManager.
  124868. * @returns the FreeCameraInputsManager
  124869. */
  124870. addGamepad(): FreeCameraInputsManager;
  124871. }
  124872. /**
  124873. * Interface representing an arc rotate camera inputs manager
  124874. */
  124875. interface ArcRotateCameraInputsManager {
  124876. /**
  124877. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124878. * @returns the camera inputs manager
  124879. */
  124880. addGamepad(): ArcRotateCameraInputsManager;
  124881. }
  124882. /**
  124883. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124884. */
  124885. export class GamepadSystemSceneComponent implements ISceneComponent {
  124886. /**
  124887. * The component name helpfull to identify the component in the list of scene components.
  124888. */
  124889. readonly name: string;
  124890. /**
  124891. * The scene the component belongs to.
  124892. */
  124893. scene: Scene;
  124894. /**
  124895. * Creates a new instance of the component for the given scene
  124896. * @param scene Defines the scene to register the component in
  124897. */
  124898. constructor(scene: Scene);
  124899. /**
  124900. * Registers the component in a given scene
  124901. */
  124902. register(): void;
  124903. /**
  124904. * Rebuilds the elements related to this component in case of
  124905. * context lost for instance.
  124906. */
  124907. rebuild(): void;
  124908. /**
  124909. * Disposes the component and the associated ressources
  124910. */
  124911. dispose(): void;
  124912. private _beforeCameraUpdate;
  124913. }
  124914. }
  124915. declare module BABYLON {
  124916. /**
  124917. * 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,
  124918. * which still works and will still be found in many Playgrounds.
  124919. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124920. */
  124921. export class UniversalCamera extends TouchCamera {
  124922. /**
  124923. * Defines the gamepad rotation sensiblity.
  124924. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124925. */
  124926. get gamepadAngularSensibility(): number;
  124927. set gamepadAngularSensibility(value: number);
  124928. /**
  124929. * Defines the gamepad move sensiblity.
  124930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124931. */
  124932. get gamepadMoveSensibility(): number;
  124933. set gamepadMoveSensibility(value: number);
  124934. /**
  124935. * 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,
  124936. * which still works and will still be found in many Playgrounds.
  124937. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124938. * @param name Define the name of the camera in the scene
  124939. * @param position Define the start position of the camera in the scene
  124940. * @param scene Define the scene the camera belongs to
  124941. */
  124942. constructor(name: string, position: Vector3, scene: Scene);
  124943. /**
  124944. * Gets the current object class name.
  124945. * @return the class name
  124946. */
  124947. getClassName(): string;
  124948. }
  124949. }
  124950. declare module BABYLON {
  124951. /**
  124952. * This represents a FPS type of camera. This is only here for back compat purpose.
  124953. * Please use the UniversalCamera instead as both are identical.
  124954. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124955. */
  124956. export class GamepadCamera extends UniversalCamera {
  124957. /**
  124958. * Instantiates a new Gamepad Camera
  124959. * This represents a FPS type of camera. This is only here for back compat purpose.
  124960. * Please use the UniversalCamera instead as both are identical.
  124961. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124962. * @param name Define the name of the camera in the scene
  124963. * @param position Define the start position of the camera in the scene
  124964. * @param scene Define the scene the camera belongs to
  124965. */
  124966. constructor(name: string, position: Vector3, scene: Scene);
  124967. /**
  124968. * Gets the current object class name.
  124969. * @return the class name
  124970. */
  124971. getClassName(): string;
  124972. }
  124973. }
  124974. declare module BABYLON {
  124975. /** @hidden */
  124976. export var passPixelShader: {
  124977. name: string;
  124978. shader: string;
  124979. };
  124980. }
  124981. declare module BABYLON {
  124982. /** @hidden */
  124983. export var passCubePixelShader: {
  124984. name: string;
  124985. shader: string;
  124986. };
  124987. }
  124988. declare module BABYLON {
  124989. /**
  124990. * PassPostProcess which produces an output the same as it's input
  124991. */
  124992. export class PassPostProcess extends PostProcess {
  124993. /**
  124994. * Creates the PassPostProcess
  124995. * @param name The name of the effect.
  124996. * @param options The required width/height ratio to downsize to before computing the render pass.
  124997. * @param camera The camera to apply the render pass to.
  124998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124999. * @param engine The engine which the post process will be applied. (default: current engine)
  125000. * @param reusable If the post process can be reused on the same frame. (default: false)
  125001. * @param textureType The type of texture to be used when performing the post processing.
  125002. * @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)
  125003. */
  125004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125005. }
  125006. /**
  125007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125008. */
  125009. export class PassCubePostProcess extends PostProcess {
  125010. private _face;
  125011. /**
  125012. * Gets or sets the cube face to display.
  125013. * * 0 is +X
  125014. * * 1 is -X
  125015. * * 2 is +Y
  125016. * * 3 is -Y
  125017. * * 4 is +Z
  125018. * * 5 is -Z
  125019. */
  125020. get face(): number;
  125021. set face(value: number);
  125022. /**
  125023. * Creates the PassCubePostProcess
  125024. * @param name The name of the effect.
  125025. * @param options The required width/height ratio to downsize to before computing the render pass.
  125026. * @param camera The camera to apply the render pass to.
  125027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125028. * @param engine The engine which the post process will be applied. (default: current engine)
  125029. * @param reusable If the post process can be reused on the same frame. (default: false)
  125030. * @param textureType The type of texture to be used when performing the post processing.
  125031. * @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)
  125032. */
  125033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125034. }
  125035. }
  125036. declare module BABYLON {
  125037. /** @hidden */
  125038. export var anaglyphPixelShader: {
  125039. name: string;
  125040. shader: string;
  125041. };
  125042. }
  125043. declare module BABYLON {
  125044. /**
  125045. * Postprocess used to generate anaglyphic rendering
  125046. */
  125047. export class AnaglyphPostProcess extends PostProcess {
  125048. private _passedProcess;
  125049. /**
  125050. * Creates a new AnaglyphPostProcess
  125051. * @param name defines postprocess name
  125052. * @param options defines creation options or target ratio scale
  125053. * @param rigCameras defines cameras using this postprocess
  125054. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125055. * @param engine defines hosting engine
  125056. * @param reusable defines if the postprocess will be reused multiple times per frame
  125057. */
  125058. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125059. }
  125060. }
  125061. declare module BABYLON {
  125062. /**
  125063. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125064. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125065. */
  125066. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125067. /**
  125068. * Creates a new AnaglyphArcRotateCamera
  125069. * @param name defines camera name
  125070. * @param alpha defines alpha angle (in radians)
  125071. * @param beta defines beta angle (in radians)
  125072. * @param radius defines radius
  125073. * @param target defines camera target
  125074. * @param interaxialDistance defines distance between each color axis
  125075. * @param scene defines the hosting scene
  125076. */
  125077. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125078. /**
  125079. * Gets camera class name
  125080. * @returns AnaglyphArcRotateCamera
  125081. */
  125082. getClassName(): string;
  125083. }
  125084. }
  125085. declare module BABYLON {
  125086. /**
  125087. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125088. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125089. */
  125090. export class AnaglyphFreeCamera extends FreeCamera {
  125091. /**
  125092. * Creates a new AnaglyphFreeCamera
  125093. * @param name defines camera name
  125094. * @param position defines initial position
  125095. * @param interaxialDistance defines distance between each color axis
  125096. * @param scene defines the hosting scene
  125097. */
  125098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125099. /**
  125100. * Gets camera class name
  125101. * @returns AnaglyphFreeCamera
  125102. */
  125103. getClassName(): string;
  125104. }
  125105. }
  125106. declare module BABYLON {
  125107. /**
  125108. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125109. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125110. */
  125111. export class AnaglyphGamepadCamera extends GamepadCamera {
  125112. /**
  125113. * Creates a new AnaglyphGamepadCamera
  125114. * @param name defines camera name
  125115. * @param position defines initial position
  125116. * @param interaxialDistance defines distance between each color axis
  125117. * @param scene defines the hosting scene
  125118. */
  125119. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125120. /**
  125121. * Gets camera class name
  125122. * @returns AnaglyphGamepadCamera
  125123. */
  125124. getClassName(): string;
  125125. }
  125126. }
  125127. declare module BABYLON {
  125128. /**
  125129. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  125130. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125131. */
  125132. export class AnaglyphUniversalCamera extends UniversalCamera {
  125133. /**
  125134. * Creates a new AnaglyphUniversalCamera
  125135. * @param name defines camera name
  125136. * @param position defines initial position
  125137. * @param interaxialDistance defines distance between each color axis
  125138. * @param scene defines the hosting scene
  125139. */
  125140. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125141. /**
  125142. * Gets camera class name
  125143. * @returns AnaglyphUniversalCamera
  125144. */
  125145. getClassName(): string;
  125146. }
  125147. }
  125148. declare module BABYLON {
  125149. /**
  125150. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  125151. * @see https://doc.babylonjs.com/features/cameras
  125152. */
  125153. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  125154. /**
  125155. * Creates a new StereoscopicArcRotateCamera
  125156. * @param name defines camera name
  125157. * @param alpha defines alpha angle (in radians)
  125158. * @param beta defines beta angle (in radians)
  125159. * @param radius defines radius
  125160. * @param target defines camera target
  125161. * @param interaxialDistance defines distance between each color axis
  125162. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125163. * @param scene defines the hosting scene
  125164. */
  125165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125166. /**
  125167. * Gets camera class name
  125168. * @returns StereoscopicArcRotateCamera
  125169. */
  125170. getClassName(): string;
  125171. }
  125172. }
  125173. declare module BABYLON {
  125174. /**
  125175. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125176. * @see https://doc.babylonjs.com/features/cameras
  125177. */
  125178. export class StereoscopicFreeCamera extends FreeCamera {
  125179. /**
  125180. * Creates a new StereoscopicFreeCamera
  125181. * @param name defines camera name
  125182. * @param position defines initial position
  125183. * @param interaxialDistance defines distance between each color axis
  125184. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125185. * @param scene defines the hosting scene
  125186. */
  125187. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125188. /**
  125189. * Gets camera class name
  125190. * @returns StereoscopicFreeCamera
  125191. */
  125192. getClassName(): string;
  125193. }
  125194. }
  125195. declare module BABYLON {
  125196. /**
  125197. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125198. * @see https://doc.babylonjs.com/features/cameras
  125199. */
  125200. export class StereoscopicGamepadCamera extends GamepadCamera {
  125201. /**
  125202. * Creates a new StereoscopicGamepadCamera
  125203. * @param name defines camera name
  125204. * @param position defines initial position
  125205. * @param interaxialDistance defines distance between each color axis
  125206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125207. * @param scene defines the hosting scene
  125208. */
  125209. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125210. /**
  125211. * Gets camera class name
  125212. * @returns StereoscopicGamepadCamera
  125213. */
  125214. getClassName(): string;
  125215. }
  125216. }
  125217. declare module BABYLON {
  125218. /**
  125219. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125220. * @see https://doc.babylonjs.com/features/cameras
  125221. */
  125222. export class StereoscopicUniversalCamera extends UniversalCamera {
  125223. /**
  125224. * Creates a new StereoscopicUniversalCamera
  125225. * @param name defines camera name
  125226. * @param position defines initial position
  125227. * @param interaxialDistance defines distance between each color axis
  125228. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125229. * @param scene defines the hosting scene
  125230. */
  125231. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125232. /**
  125233. * Gets camera class name
  125234. * @returns StereoscopicUniversalCamera
  125235. */
  125236. getClassName(): string;
  125237. }
  125238. }
  125239. declare module BABYLON {
  125240. /**
  125241. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125242. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125243. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125244. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125245. */
  125246. export class VirtualJoysticksCamera extends FreeCamera {
  125247. /**
  125248. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125249. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125250. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125251. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125252. * @param name Define the name of the camera in the scene
  125253. * @param position Define the start position of the camera in the scene
  125254. * @param scene Define the scene the camera belongs to
  125255. */
  125256. constructor(name: string, position: Vector3, scene: Scene);
  125257. /**
  125258. * Gets the current object class name.
  125259. * @return the class name
  125260. */
  125261. getClassName(): string;
  125262. }
  125263. }
  125264. declare module BABYLON {
  125265. /**
  125266. * This represents all the required metrics to create a VR camera.
  125267. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125268. */
  125269. export class VRCameraMetrics {
  125270. /**
  125271. * Define the horizontal resolution off the screen.
  125272. */
  125273. hResolution: number;
  125274. /**
  125275. * Define the vertical resolution off the screen.
  125276. */
  125277. vResolution: number;
  125278. /**
  125279. * Define the horizontal screen size.
  125280. */
  125281. hScreenSize: number;
  125282. /**
  125283. * Define the vertical screen size.
  125284. */
  125285. vScreenSize: number;
  125286. /**
  125287. * Define the vertical screen center position.
  125288. */
  125289. vScreenCenter: number;
  125290. /**
  125291. * Define the distance of the eyes to the screen.
  125292. */
  125293. eyeToScreenDistance: number;
  125294. /**
  125295. * Define the distance between both lenses
  125296. */
  125297. lensSeparationDistance: number;
  125298. /**
  125299. * Define the distance between both viewer's eyes.
  125300. */
  125301. interpupillaryDistance: number;
  125302. /**
  125303. * Define the distortion factor of the VR postprocess.
  125304. * Please, touch with care.
  125305. */
  125306. distortionK: number[];
  125307. /**
  125308. * Define the chromatic aberration correction factors for the VR post process.
  125309. */
  125310. chromaAbCorrection: number[];
  125311. /**
  125312. * Define the scale factor of the post process.
  125313. * The smaller the better but the slower.
  125314. */
  125315. postProcessScaleFactor: number;
  125316. /**
  125317. * Define an offset for the lens center.
  125318. */
  125319. lensCenterOffset: number;
  125320. /**
  125321. * Define if the current vr camera should compensate the distortion of the lense or not.
  125322. */
  125323. compensateDistortion: boolean;
  125324. /**
  125325. * Defines if multiview should be enabled when rendering (Default: false)
  125326. */
  125327. multiviewEnabled: boolean;
  125328. /**
  125329. * Gets the rendering aspect ratio based on the provided resolutions.
  125330. */
  125331. get aspectRatio(): number;
  125332. /**
  125333. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125334. */
  125335. get aspectRatioFov(): number;
  125336. /**
  125337. * @hidden
  125338. */
  125339. get leftHMatrix(): Matrix;
  125340. /**
  125341. * @hidden
  125342. */
  125343. get rightHMatrix(): Matrix;
  125344. /**
  125345. * @hidden
  125346. */
  125347. get leftPreViewMatrix(): Matrix;
  125348. /**
  125349. * @hidden
  125350. */
  125351. get rightPreViewMatrix(): Matrix;
  125352. /**
  125353. * Get the default VRMetrics based on the most generic setup.
  125354. * @returns the default vr metrics
  125355. */
  125356. static GetDefault(): VRCameraMetrics;
  125357. }
  125358. }
  125359. declare module BABYLON {
  125360. /** @hidden */
  125361. export var vrDistortionCorrectionPixelShader: {
  125362. name: string;
  125363. shader: string;
  125364. };
  125365. }
  125366. declare module BABYLON {
  125367. /**
  125368. * VRDistortionCorrectionPostProcess used for mobile VR
  125369. */
  125370. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125371. private _isRightEye;
  125372. private _distortionFactors;
  125373. private _postProcessScaleFactor;
  125374. private _lensCenterOffset;
  125375. private _scaleIn;
  125376. private _scaleFactor;
  125377. private _lensCenter;
  125378. /**
  125379. * Initializes the VRDistortionCorrectionPostProcess
  125380. * @param name The name of the effect.
  125381. * @param camera The camera to apply the render pass to.
  125382. * @param isRightEye If this is for the right eye distortion
  125383. * @param vrMetrics All the required metrics for the VR camera
  125384. */
  125385. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125386. }
  125387. }
  125388. declare module BABYLON {
  125389. /**
  125390. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125391. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125392. */
  125393. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125394. /**
  125395. * Creates a new VRDeviceOrientationArcRotateCamera
  125396. * @param name defines camera name
  125397. * @param alpha defines the camera rotation along the logitudinal axis
  125398. * @param beta defines the camera rotation along the latitudinal axis
  125399. * @param radius defines the camera distance from its target
  125400. * @param target defines the camera target
  125401. * @param scene defines the scene the camera belongs to
  125402. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125403. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125404. */
  125405. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125406. /**
  125407. * Gets camera class name
  125408. * @returns VRDeviceOrientationArcRotateCamera
  125409. */
  125410. getClassName(): string;
  125411. }
  125412. }
  125413. declare module BABYLON {
  125414. /**
  125415. * Camera used to simulate VR rendering (based on FreeCamera)
  125416. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125417. */
  125418. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125419. /**
  125420. * Creates a new VRDeviceOrientationFreeCamera
  125421. * @param name defines camera name
  125422. * @param position defines the start position of the camera
  125423. * @param scene defines the scene the camera belongs to
  125424. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125425. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125426. */
  125427. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125428. /**
  125429. * Gets camera class name
  125430. * @returns VRDeviceOrientationFreeCamera
  125431. */
  125432. getClassName(): string;
  125433. }
  125434. }
  125435. declare module BABYLON {
  125436. /**
  125437. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125438. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125439. */
  125440. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125441. /**
  125442. * Creates a new VRDeviceOrientationGamepadCamera
  125443. * @param name defines camera name
  125444. * @param position defines the start position of the camera
  125445. * @param scene defines the scene the camera belongs to
  125446. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125447. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125448. */
  125449. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125450. /**
  125451. * Gets camera class name
  125452. * @returns VRDeviceOrientationGamepadCamera
  125453. */
  125454. getClassName(): string;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * A class extending Texture allowing drawing on a texture
  125460. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125461. */
  125462. export class DynamicTexture extends Texture {
  125463. private _generateMipMaps;
  125464. private _canvas;
  125465. private _context;
  125466. /**
  125467. * Creates a DynamicTexture
  125468. * @param name defines the name of the texture
  125469. * @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
  125470. * @param scene defines the scene where you want the texture
  125471. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125472. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125473. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125474. */
  125475. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125476. /**
  125477. * Get the current class name of the texture useful for serialization or dynamic coding.
  125478. * @returns "DynamicTexture"
  125479. */
  125480. getClassName(): string;
  125481. /**
  125482. * Gets the current state of canRescale
  125483. */
  125484. get canRescale(): boolean;
  125485. private _recreate;
  125486. /**
  125487. * Scales the texture
  125488. * @param ratio the scale factor to apply to both width and height
  125489. */
  125490. scale(ratio: number): void;
  125491. /**
  125492. * Resizes the texture
  125493. * @param width the new width
  125494. * @param height the new height
  125495. */
  125496. scaleTo(width: number, height: number): void;
  125497. /**
  125498. * Gets the context of the canvas used by the texture
  125499. * @returns the canvas context of the dynamic texture
  125500. */
  125501. getContext(): CanvasRenderingContext2D;
  125502. /**
  125503. * Clears the texture
  125504. */
  125505. clear(): void;
  125506. /**
  125507. * Updates the texture
  125508. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125509. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125510. */
  125511. update(invertY?: boolean, premulAlpha?: boolean): void;
  125512. /**
  125513. * Draws text onto the texture
  125514. * @param text defines the text to be drawn
  125515. * @param x defines the placement of the text from the left
  125516. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125517. * @param font defines the font to be used with font-style, font-size, font-name
  125518. * @param color defines the color used for the text
  125519. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125520. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125521. * @param update defines whether texture is immediately update (default is true)
  125522. */
  125523. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125524. /**
  125525. * Clones the texture
  125526. * @returns the clone of the texture.
  125527. */
  125528. clone(): DynamicTexture;
  125529. /**
  125530. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125531. * @returns a serialized dynamic texture object
  125532. */
  125533. serialize(): any;
  125534. private _IsCanvasElement;
  125535. /** @hidden */
  125536. _rebuild(): void;
  125537. }
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * Class containing static functions to help procedurally build meshes
  125542. */
  125543. export class GroundBuilder {
  125544. /**
  125545. * Creates a ground mesh
  125546. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125547. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125549. * @param name defines the name of the mesh
  125550. * @param options defines the options used to create the mesh
  125551. * @param scene defines the hosting scene
  125552. * @returns the ground mesh
  125553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125554. */
  125555. static CreateGround(name: string, options: {
  125556. width?: number;
  125557. height?: number;
  125558. subdivisions?: number;
  125559. subdivisionsX?: number;
  125560. subdivisionsY?: number;
  125561. updatable?: boolean;
  125562. }, scene: any): Mesh;
  125563. /**
  125564. * Creates a tiled ground mesh
  125565. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125566. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125567. * * 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
  125568. * * 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
  125569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125570. * @param name defines the name of the mesh
  125571. * @param options defines the options used to create the mesh
  125572. * @param scene defines the hosting scene
  125573. * @returns the tiled ground mesh
  125574. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125575. */
  125576. static CreateTiledGround(name: string, options: {
  125577. xmin: number;
  125578. zmin: number;
  125579. xmax: number;
  125580. zmax: number;
  125581. subdivisions?: {
  125582. w: number;
  125583. h: number;
  125584. };
  125585. precision?: {
  125586. w: number;
  125587. h: number;
  125588. };
  125589. updatable?: boolean;
  125590. }, scene?: Nullable<Scene>): Mesh;
  125591. /**
  125592. * Creates a ground mesh from a height map
  125593. * * The parameter `url` sets the URL of the height map image resource.
  125594. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125595. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125596. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125597. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125598. * * 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.
  125599. * * 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).
  125600. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125602. * @param name defines the name of the mesh
  125603. * @param url defines the url to the height map
  125604. * @param options defines the options used to create the mesh
  125605. * @param scene defines the hosting scene
  125606. * @returns the ground mesh
  125607. * @see https://doc.babylonjs.com/babylon101/height_map
  125608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125609. */
  125610. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125611. width?: number;
  125612. height?: number;
  125613. subdivisions?: number;
  125614. minHeight?: number;
  125615. maxHeight?: number;
  125616. colorFilter?: Color3;
  125617. alphaFilter?: number;
  125618. updatable?: boolean;
  125619. onReady?: (mesh: GroundMesh) => void;
  125620. }, scene?: Nullable<Scene>): GroundMesh;
  125621. }
  125622. }
  125623. declare module BABYLON {
  125624. /**
  125625. * Class containing static functions to help procedurally build meshes
  125626. */
  125627. export class TorusBuilder {
  125628. /**
  125629. * Creates a torus mesh
  125630. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125631. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125632. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125636. * @param name defines the name of the mesh
  125637. * @param options defines the options used to create the mesh
  125638. * @param scene defines the hosting scene
  125639. * @returns the torus mesh
  125640. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125641. */
  125642. static CreateTorus(name: string, options: {
  125643. diameter?: number;
  125644. thickness?: number;
  125645. tessellation?: number;
  125646. updatable?: boolean;
  125647. sideOrientation?: number;
  125648. frontUVs?: Vector4;
  125649. backUVs?: Vector4;
  125650. }, scene: any): Mesh;
  125651. }
  125652. }
  125653. declare module BABYLON {
  125654. /**
  125655. * Class containing static functions to help procedurally build meshes
  125656. */
  125657. export class CylinderBuilder {
  125658. /**
  125659. * Creates a cylinder or a cone mesh
  125660. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125661. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125662. * * 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.
  125663. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125664. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125665. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125666. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125667. * * 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).
  125668. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125669. * * 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).
  125670. * * 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
  125671. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125672. * * 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
  125673. * * 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.
  125674. * * If `enclose` is false, a ring surface is one element.
  125675. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125676. * * 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
  125677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125680. * @param name defines the name of the mesh
  125681. * @param options defines the options used to create the mesh
  125682. * @param scene defines the hosting scene
  125683. * @returns the cylinder mesh
  125684. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125685. */
  125686. static CreateCylinder(name: string, options: {
  125687. height?: number;
  125688. diameterTop?: number;
  125689. diameterBottom?: number;
  125690. diameter?: number;
  125691. tessellation?: number;
  125692. subdivisions?: number;
  125693. arc?: number;
  125694. faceColors?: Color4[];
  125695. faceUV?: Vector4[];
  125696. updatable?: boolean;
  125697. hasRings?: boolean;
  125698. enclose?: boolean;
  125699. cap?: number;
  125700. sideOrientation?: number;
  125701. frontUVs?: Vector4;
  125702. backUVs?: Vector4;
  125703. }, scene: any): Mesh;
  125704. }
  125705. }
  125706. declare module BABYLON {
  125707. /**
  125708. * States of the webXR experience
  125709. */
  125710. export enum WebXRState {
  125711. /**
  125712. * Transitioning to being in XR mode
  125713. */
  125714. ENTERING_XR = 0,
  125715. /**
  125716. * Transitioning to non XR mode
  125717. */
  125718. EXITING_XR = 1,
  125719. /**
  125720. * In XR mode and presenting
  125721. */
  125722. IN_XR = 2,
  125723. /**
  125724. * Not entered XR mode
  125725. */
  125726. NOT_IN_XR = 3
  125727. }
  125728. /**
  125729. * Abstraction of the XR render target
  125730. */
  125731. export interface WebXRRenderTarget extends IDisposable {
  125732. /**
  125733. * xrpresent context of the canvas which can be used to display/mirror xr content
  125734. */
  125735. canvasContext: WebGLRenderingContext;
  125736. /**
  125737. * xr layer for the canvas
  125738. */
  125739. xrLayer: Nullable<XRWebGLLayer>;
  125740. /**
  125741. * Initializes the xr layer for the session
  125742. * @param xrSession xr session
  125743. * @returns a promise that will resolve once the XR Layer has been created
  125744. */
  125745. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125746. }
  125747. }
  125748. declare module BABYLON {
  125749. /**
  125750. * COnfiguration object for WebXR output canvas
  125751. */
  125752. export class WebXRManagedOutputCanvasOptions {
  125753. /**
  125754. * An optional canvas in case you wish to create it yourself and provide it here.
  125755. * If not provided, a new canvas will be created
  125756. */
  125757. canvasElement?: HTMLCanvasElement;
  125758. /**
  125759. * Options for this XR Layer output
  125760. */
  125761. canvasOptions?: XRWebGLLayerOptions;
  125762. /**
  125763. * CSS styling for a newly created canvas (if not provided)
  125764. */
  125765. newCanvasCssStyle?: string;
  125766. /**
  125767. * Get the default values of the configuration object
  125768. * @returns default values of this configuration object
  125769. */
  125770. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125771. }
  125772. /**
  125773. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125774. */
  125775. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125776. private _options;
  125777. private _canvas;
  125778. private _engine;
  125779. private _originalCanvasSize;
  125780. /**
  125781. * Rendering context of the canvas which can be used to display/mirror xr content
  125782. */
  125783. canvasContext: WebGLRenderingContext;
  125784. /**
  125785. * xr layer for the canvas
  125786. */
  125787. xrLayer: Nullable<XRWebGLLayer>;
  125788. /**
  125789. * Obseervers registered here will be triggered when the xr layer was initialized
  125790. */
  125791. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125792. /**
  125793. * Initializes the canvas to be added/removed upon entering/exiting xr
  125794. * @param _xrSessionManager The XR Session manager
  125795. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125796. */
  125797. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125798. /**
  125799. * Disposes of the object
  125800. */
  125801. dispose(): void;
  125802. /**
  125803. * Initializes the xr layer for the session
  125804. * @param xrSession xr session
  125805. * @returns a promise that will resolve once the XR Layer has been created
  125806. */
  125807. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125808. private _addCanvas;
  125809. private _removeCanvas;
  125810. private _setCanvasSize;
  125811. private _setManagedOutputCanvas;
  125812. }
  125813. }
  125814. declare module BABYLON {
  125815. /**
  125816. * Manages an XRSession to work with Babylon's engine
  125817. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125818. */
  125819. export class WebXRSessionManager implements IDisposable {
  125820. /** The scene which the session should be created for */
  125821. scene: Scene;
  125822. private _referenceSpace;
  125823. private _rttProvider;
  125824. private _sessionEnded;
  125825. private _xrNavigator;
  125826. private baseLayer;
  125827. /**
  125828. * The base reference space from which the session started. good if you want to reset your
  125829. * reference space
  125830. */
  125831. baseReferenceSpace: XRReferenceSpace;
  125832. /**
  125833. * Current XR frame
  125834. */
  125835. currentFrame: Nullable<XRFrame>;
  125836. /** WebXR timestamp updated every frame */
  125837. currentTimestamp: number;
  125838. /**
  125839. * Used just in case of a failure to initialize an immersive session.
  125840. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125841. */
  125842. defaultHeightCompensation: number;
  125843. /**
  125844. * Fires every time a new xrFrame arrives which can be used to update the camera
  125845. */
  125846. onXRFrameObservable: Observable<XRFrame>;
  125847. /**
  125848. * Fires when the reference space changed
  125849. */
  125850. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125851. /**
  125852. * Fires when the xr session is ended either by the device or manually done
  125853. */
  125854. onXRSessionEnded: Observable<any>;
  125855. /**
  125856. * Fires when the xr session is ended either by the device or manually done
  125857. */
  125858. onXRSessionInit: Observable<XRSession>;
  125859. /**
  125860. * Underlying xr session
  125861. */
  125862. session: XRSession;
  125863. /**
  125864. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125865. * or get the offset the player is currently at.
  125866. */
  125867. viewerReferenceSpace: XRReferenceSpace;
  125868. /**
  125869. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125870. * @param scene The scene which the session should be created for
  125871. */
  125872. constructor(
  125873. /** The scene which the session should be created for */
  125874. scene: Scene);
  125875. /**
  125876. * The current reference space used in this session. This reference space can constantly change!
  125877. * It is mainly used to offset the camera's position.
  125878. */
  125879. get referenceSpace(): XRReferenceSpace;
  125880. /**
  125881. * Set a new reference space and triggers the observable
  125882. */
  125883. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125884. /**
  125885. * Disposes of the session manager
  125886. */
  125887. dispose(): void;
  125888. /**
  125889. * Stops the xrSession and restores the render loop
  125890. * @returns Promise which resolves after it exits XR
  125891. */
  125892. exitXRAsync(): Promise<void>;
  125893. /**
  125894. * Gets the correct render target texture to be rendered this frame for this eye
  125895. * @param eye the eye for which to get the render target
  125896. * @returns the render target for the specified eye
  125897. */
  125898. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125899. /**
  125900. * Creates a WebXRRenderTarget object for the XR session
  125901. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125902. * @param options optional options to provide when creating a new render target
  125903. * @returns a WebXR render target to which the session can render
  125904. */
  125905. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125906. /**
  125907. * Initializes the manager
  125908. * After initialization enterXR can be called to start an XR session
  125909. * @returns Promise which resolves after it is initialized
  125910. */
  125911. initializeAsync(): Promise<void>;
  125912. /**
  125913. * Initializes an xr session
  125914. * @param xrSessionMode mode to initialize
  125915. * @param xrSessionInit defines optional and required values to pass to the session builder
  125916. * @returns a promise which will resolve once the session has been initialized
  125917. */
  125918. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125919. /**
  125920. * Checks if a session would be supported for the creation options specified
  125921. * @param sessionMode session mode to check if supported eg. immersive-vr
  125922. * @returns A Promise that resolves to true if supported and false if not
  125923. */
  125924. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125925. /**
  125926. * Resets the reference space to the one started the session
  125927. */
  125928. resetReferenceSpace(): void;
  125929. /**
  125930. * Starts rendering to the xr layer
  125931. */
  125932. runXRRenderLoop(): void;
  125933. /**
  125934. * Sets the reference space on the xr session
  125935. * @param referenceSpaceType space to set
  125936. * @returns a promise that will resolve once the reference space has been set
  125937. */
  125938. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125939. /**
  125940. * Updates the render state of the session
  125941. * @param state state to set
  125942. * @returns a promise that resolves once the render state has been updated
  125943. */
  125944. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125945. /**
  125946. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125947. * @param sessionMode defines the session to test
  125948. * @returns a promise with boolean as final value
  125949. */
  125950. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125951. private _createRenderTargetTexture;
  125952. }
  125953. }
  125954. declare module BABYLON {
  125955. /**
  125956. * WebXR Camera which holds the views for the xrSession
  125957. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125958. */
  125959. export class WebXRCamera extends FreeCamera {
  125960. private _xrSessionManager;
  125961. private _firstFrame;
  125962. private _referenceQuaternion;
  125963. private _referencedPosition;
  125964. private _xrInvPositionCache;
  125965. private _xrInvQuaternionCache;
  125966. /**
  125967. * Observable raised before camera teleportation
  125968. */
  125969. onBeforeCameraTeleport: Observable<Vector3>;
  125970. /**
  125971. * Observable raised after camera teleportation
  125972. */
  125973. onAfterCameraTeleport: Observable<Vector3>;
  125974. /**
  125975. * Should position compensation execute on first frame.
  125976. * This is used when copying the position from a native (non XR) camera
  125977. */
  125978. compensateOnFirstFrame: boolean;
  125979. /**
  125980. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125981. * @param name the name of the camera
  125982. * @param scene the scene to add the camera to
  125983. * @param _xrSessionManager a constructed xr session manager
  125984. */
  125985. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125986. /**
  125987. * Return the user's height, unrelated to the current ground.
  125988. * This will be the y position of this camera, when ground level is 0.
  125989. */
  125990. get realWorldHeight(): number;
  125991. /** @hidden */
  125992. _updateForDualEyeDebugging(): void;
  125993. /**
  125994. * Sets this camera's transformation based on a non-vr camera
  125995. * @param otherCamera the non-vr camera to copy the transformation from
  125996. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125997. */
  125998. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125999. /**
  126000. * Gets the current instance class name ("WebXRCamera").
  126001. * @returns the class name
  126002. */
  126003. getClassName(): string;
  126004. private _rotate180;
  126005. private _updateFromXRSession;
  126006. private _updateNumberOfRigCameras;
  126007. private _updateReferenceSpace;
  126008. private _updateReferenceSpaceOffset;
  126009. }
  126010. }
  126011. declare module BABYLON {
  126012. /**
  126013. * Defining the interface required for a (webxr) feature
  126014. */
  126015. export interface IWebXRFeature extends IDisposable {
  126016. /**
  126017. * Is this feature attached
  126018. */
  126019. attached: boolean;
  126020. /**
  126021. * Should auto-attach be disabled?
  126022. */
  126023. disableAutoAttach: boolean;
  126024. /**
  126025. * Attach the feature to the session
  126026. * Will usually be called by the features manager
  126027. *
  126028. * @param force should attachment be forced (even when already attached)
  126029. * @returns true if successful.
  126030. */
  126031. attach(force?: boolean): boolean;
  126032. /**
  126033. * Detach the feature from the session
  126034. * Will usually be called by the features manager
  126035. *
  126036. * @returns true if successful.
  126037. */
  126038. detach(): boolean;
  126039. /**
  126040. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126041. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126042. *
  126043. * @returns whether or not the feature is compatible in this environment
  126044. */
  126045. isCompatible(): boolean;
  126046. /**
  126047. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126048. */
  126049. xrNativeFeatureName?: string;
  126050. }
  126051. /**
  126052. * A list of the currently available features without referencing them
  126053. */
  126054. export class WebXRFeatureName {
  126055. /**
  126056. * The name of the anchor system feature
  126057. */
  126058. static ANCHOR_SYSTEM: string;
  126059. /**
  126060. * The name of the background remover feature
  126061. */
  126062. static BACKGROUND_REMOVER: string;
  126063. /**
  126064. * The name of the hit test feature
  126065. */
  126066. static HIT_TEST: string;
  126067. /**
  126068. * physics impostors for xr controllers feature
  126069. */
  126070. static PHYSICS_CONTROLLERS: string;
  126071. /**
  126072. * The name of the plane detection feature
  126073. */
  126074. static PLANE_DETECTION: string;
  126075. /**
  126076. * The name of the pointer selection feature
  126077. */
  126078. static POINTER_SELECTION: string;
  126079. /**
  126080. * The name of the teleportation feature
  126081. */
  126082. static TELEPORTATION: string;
  126083. }
  126084. /**
  126085. * Defining the constructor of a feature. Used to register the modules.
  126086. */
  126087. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126088. /**
  126089. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126090. * It is mainly used in AR sessions.
  126091. *
  126092. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126093. */
  126094. export class WebXRFeaturesManager implements IDisposable {
  126095. private _xrSessionManager;
  126096. private static readonly _AvailableFeatures;
  126097. private _features;
  126098. /**
  126099. * constructs a new features manages.
  126100. *
  126101. * @param _xrSessionManager an instance of WebXRSessionManager
  126102. */
  126103. constructor(_xrSessionManager: WebXRSessionManager);
  126104. /**
  126105. * Used to register a module. After calling this function a developer can use this feature in the scene.
  126106. * Mainly used internally.
  126107. *
  126108. * @param featureName the name of the feature to register
  126109. * @param constructorFunction the function used to construct the module
  126110. * @param version the (babylon) version of the module
  126111. * @param stable is that a stable version of this module
  126112. */
  126113. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  126114. /**
  126115. * Returns a constructor of a specific feature.
  126116. *
  126117. * @param featureName the name of the feature to construct
  126118. * @param version the version of the feature to load
  126119. * @param xrSessionManager the xrSessionManager. Used to construct the module
  126120. * @param options optional options provided to the module.
  126121. * @returns a function that, when called, will return a new instance of this feature
  126122. */
  126123. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  126124. /**
  126125. * Can be used to return the list of features currently registered
  126126. *
  126127. * @returns an Array of available features
  126128. */
  126129. static GetAvailableFeatures(): string[];
  126130. /**
  126131. * Gets the versions available for a specific feature
  126132. * @param featureName the name of the feature
  126133. * @returns an array with the available versions
  126134. */
  126135. static GetAvailableVersions(featureName: string): string[];
  126136. /**
  126137. * Return the latest unstable version of this feature
  126138. * @param featureName the name of the feature to search
  126139. * @returns the version number. if not found will return -1
  126140. */
  126141. static GetLatestVersionOfFeature(featureName: string): number;
  126142. /**
  126143. * Return the latest stable version of this feature
  126144. * @param featureName the name of the feature to search
  126145. * @returns the version number. if not found will return -1
  126146. */
  126147. static GetStableVersionOfFeature(featureName: string): number;
  126148. /**
  126149. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  126150. * Can be used during a session to start a feature
  126151. * @param featureName the name of feature to attach
  126152. */
  126153. attachFeature(featureName: string): void;
  126154. /**
  126155. * Can be used inside a session or when the session ends to detach a specific feature
  126156. * @param featureName the name of the feature to detach
  126157. */
  126158. detachFeature(featureName: string): void;
  126159. /**
  126160. * Used to disable an already-enabled feature
  126161. * The feature will be disposed and will be recreated once enabled.
  126162. * @param featureName the feature to disable
  126163. * @returns true if disable was successful
  126164. */
  126165. disableFeature(featureName: string | {
  126166. Name: string;
  126167. }): boolean;
  126168. /**
  126169. * dispose this features manager
  126170. */
  126171. dispose(): void;
  126172. /**
  126173. * 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.
  126174. * 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.
  126175. *
  126176. * @param featureName the name of the feature to load or the class of the feature
  126177. * @param version optional version to load. if not provided the latest version will be enabled
  126178. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126179. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126180. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126181. * @returns a new constructed feature or throws an error if feature not found.
  126182. */
  126183. enableFeature(featureName: string | {
  126184. Name: string;
  126185. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126186. /**
  126187. * get the implementation of an enabled feature.
  126188. * @param featureName the name of the feature to load
  126189. * @returns the feature class, if found
  126190. */
  126191. getEnabledFeature(featureName: string): IWebXRFeature;
  126192. /**
  126193. * Get the list of enabled features
  126194. * @returns an array of enabled features
  126195. */
  126196. getEnabledFeatures(): string[];
  126197. /**
  126198. * This function will exten the session creation configuration object with enabled features.
  126199. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126200. * according to the defined "required" variable, provided during enableFeature call
  126201. * @param xrSessionInit the xr Session init object to extend
  126202. *
  126203. * @returns an extended XRSessionInit object
  126204. */
  126205. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126206. }
  126207. }
  126208. declare module BABYLON {
  126209. /**
  126210. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126211. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126212. */
  126213. export class WebXRExperienceHelper implements IDisposable {
  126214. private scene;
  126215. private _nonVRCamera;
  126216. private _originalSceneAutoClear;
  126217. private _supported;
  126218. /**
  126219. * Camera used to render xr content
  126220. */
  126221. camera: WebXRCamera;
  126222. /** A features manager for this xr session */
  126223. featuresManager: WebXRFeaturesManager;
  126224. /**
  126225. * Observers registered here will be triggered after the camera's initial transformation is set
  126226. * This can be used to set a different ground level or an extra rotation.
  126227. *
  126228. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126229. * to the position set after this observable is done executing.
  126230. */
  126231. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126232. /**
  126233. * Fires when the state of the experience helper has changed
  126234. */
  126235. onStateChangedObservable: Observable<WebXRState>;
  126236. /** Session manager used to keep track of xr session */
  126237. sessionManager: WebXRSessionManager;
  126238. /**
  126239. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126240. */
  126241. state: WebXRState;
  126242. /**
  126243. * Creates a WebXRExperienceHelper
  126244. * @param scene The scene the helper should be created in
  126245. */
  126246. private constructor();
  126247. /**
  126248. * Creates the experience helper
  126249. * @param scene the scene to attach the experience helper to
  126250. * @returns a promise for the experience helper
  126251. */
  126252. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126253. /**
  126254. * Disposes of the experience helper
  126255. */
  126256. dispose(): void;
  126257. /**
  126258. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126259. * @param sessionMode options for the XR session
  126260. * @param referenceSpaceType frame of reference of the XR session
  126261. * @param renderTarget the output canvas that will be used to enter XR mode
  126262. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126263. * @returns promise that resolves after xr mode has entered
  126264. */
  126265. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126266. /**
  126267. * Exits XR mode and returns the scene to its original state
  126268. * @returns promise that resolves after xr mode has exited
  126269. */
  126270. exitXRAsync(): Promise<void>;
  126271. private _nonXRToXRCamera;
  126272. private _setState;
  126273. }
  126274. }
  126275. declare module BABYLON {
  126276. /**
  126277. * X-Y values for axes in WebXR
  126278. */
  126279. export interface IWebXRMotionControllerAxesValue {
  126280. /**
  126281. * The value of the x axis
  126282. */
  126283. x: number;
  126284. /**
  126285. * The value of the y-axis
  126286. */
  126287. y: number;
  126288. }
  126289. /**
  126290. * changed / previous values for the values of this component
  126291. */
  126292. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126293. /**
  126294. * current (this frame) value
  126295. */
  126296. current: T;
  126297. /**
  126298. * previous (last change) value
  126299. */
  126300. previous: T;
  126301. }
  126302. /**
  126303. * Represents changes in the component between current frame and last values recorded
  126304. */
  126305. export interface IWebXRMotionControllerComponentChanges {
  126306. /**
  126307. * will be populated with previous and current values if axes changed
  126308. */
  126309. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126310. /**
  126311. * will be populated with previous and current values if pressed changed
  126312. */
  126313. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126314. /**
  126315. * will be populated with previous and current values if touched changed
  126316. */
  126317. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126318. /**
  126319. * will be populated with previous and current values if value changed
  126320. */
  126321. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126322. }
  126323. /**
  126324. * This class represents a single component (for example button or thumbstick) of a motion controller
  126325. */
  126326. export class WebXRControllerComponent implements IDisposable {
  126327. /**
  126328. * the id of this component
  126329. */
  126330. id: string;
  126331. /**
  126332. * the type of the component
  126333. */
  126334. type: MotionControllerComponentType;
  126335. private _buttonIndex;
  126336. private _axesIndices;
  126337. private _axes;
  126338. private _changes;
  126339. private _currentValue;
  126340. private _hasChanges;
  126341. private _pressed;
  126342. private _touched;
  126343. /**
  126344. * button component type
  126345. */
  126346. static BUTTON_TYPE: MotionControllerComponentType;
  126347. /**
  126348. * squeeze component type
  126349. */
  126350. static SQUEEZE_TYPE: MotionControllerComponentType;
  126351. /**
  126352. * Thumbstick component type
  126353. */
  126354. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126355. /**
  126356. * Touchpad component type
  126357. */
  126358. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126359. /**
  126360. * trigger component type
  126361. */
  126362. static TRIGGER_TYPE: MotionControllerComponentType;
  126363. /**
  126364. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126365. * the axes data changes
  126366. */
  126367. onAxisValueChangedObservable: Observable<{
  126368. x: number;
  126369. y: number;
  126370. }>;
  126371. /**
  126372. * Observers registered here will be triggered when the state of a button changes
  126373. * State change is either pressed / touched / value
  126374. */
  126375. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126376. /**
  126377. * Creates a new component for a motion controller.
  126378. * It is created by the motion controller itself
  126379. *
  126380. * @param id the id of this component
  126381. * @param type the type of the component
  126382. * @param _buttonIndex index in the buttons array of the gamepad
  126383. * @param _axesIndices indices of the values in the axes array of the gamepad
  126384. */
  126385. constructor(
  126386. /**
  126387. * the id of this component
  126388. */
  126389. id: string,
  126390. /**
  126391. * the type of the component
  126392. */
  126393. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126394. /**
  126395. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126396. */
  126397. get axes(): IWebXRMotionControllerAxesValue;
  126398. /**
  126399. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126400. */
  126401. get changes(): IWebXRMotionControllerComponentChanges;
  126402. /**
  126403. * Return whether or not the component changed the last frame
  126404. */
  126405. get hasChanges(): boolean;
  126406. /**
  126407. * is the button currently pressed
  126408. */
  126409. get pressed(): boolean;
  126410. /**
  126411. * is the button currently touched
  126412. */
  126413. get touched(): boolean;
  126414. /**
  126415. * Get the current value of this component
  126416. */
  126417. get value(): number;
  126418. /**
  126419. * Dispose this component
  126420. */
  126421. dispose(): void;
  126422. /**
  126423. * Are there axes correlating to this component
  126424. * @return true is axes data is available
  126425. */
  126426. isAxes(): boolean;
  126427. /**
  126428. * Is this component a button (hence - pressable)
  126429. * @returns true if can be pressed
  126430. */
  126431. isButton(): boolean;
  126432. /**
  126433. * update this component using the gamepad object it is in. Called on every frame
  126434. * @param nativeController the native gamepad controller object
  126435. */
  126436. update(nativeController: IMinimalMotionControllerObject): void;
  126437. }
  126438. }
  126439. declare module BABYLON {
  126440. /**
  126441. * Interface used to represent data loading progression
  126442. */
  126443. export interface ISceneLoaderProgressEvent {
  126444. /**
  126445. * Defines if data length to load can be evaluated
  126446. */
  126447. readonly lengthComputable: boolean;
  126448. /**
  126449. * Defines the loaded data length
  126450. */
  126451. readonly loaded: number;
  126452. /**
  126453. * Defines the data length to load
  126454. */
  126455. readonly total: number;
  126456. }
  126457. /**
  126458. * Interface used by SceneLoader plugins to define supported file extensions
  126459. */
  126460. export interface ISceneLoaderPluginExtensions {
  126461. /**
  126462. * Defines the list of supported extensions
  126463. */
  126464. [extension: string]: {
  126465. isBinary: boolean;
  126466. };
  126467. }
  126468. /**
  126469. * Interface used by SceneLoader plugin factory
  126470. */
  126471. export interface ISceneLoaderPluginFactory {
  126472. /**
  126473. * Defines the name of the factory
  126474. */
  126475. name: string;
  126476. /**
  126477. * Function called to create a new plugin
  126478. * @return the new plugin
  126479. */
  126480. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126481. /**
  126482. * The callback that returns true if the data can be directly loaded.
  126483. * @param data string containing the file data
  126484. * @returns if the data can be loaded directly
  126485. */
  126486. canDirectLoad?(data: string): boolean;
  126487. }
  126488. /**
  126489. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126490. */
  126491. export interface ISceneLoaderPluginBase {
  126492. /**
  126493. * The friendly name of this plugin.
  126494. */
  126495. name: string;
  126496. /**
  126497. * The file extensions supported by this plugin.
  126498. */
  126499. extensions: string | ISceneLoaderPluginExtensions;
  126500. /**
  126501. * The callback called when loading from a url.
  126502. * @param scene scene loading this url
  126503. * @param url url to load
  126504. * @param onSuccess callback called when the file successfully loads
  126505. * @param onProgress callback called while file is loading (if the server supports this mode)
  126506. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126507. * @param onError callback called when the file fails to load
  126508. * @returns a file request object
  126509. */
  126510. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126511. /**
  126512. * The callback called when loading from a file object.
  126513. * @param scene scene loading this file
  126514. * @param file defines the file to load
  126515. * @param onSuccess defines the callback to call when data is loaded
  126516. * @param onProgress defines the callback to call during loading process
  126517. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126518. * @param onError defines the callback to call when an error occurs
  126519. * @returns a file request object
  126520. */
  126521. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126522. /**
  126523. * The callback that returns true if the data can be directly loaded.
  126524. * @param data string containing the file data
  126525. * @returns if the data can be loaded directly
  126526. */
  126527. canDirectLoad?(data: string): boolean;
  126528. /**
  126529. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126530. * @param scene scene loading this data
  126531. * @param data string containing the data
  126532. * @returns data to pass to the plugin
  126533. */
  126534. directLoad?(scene: Scene, data: string): any;
  126535. /**
  126536. * The callback that allows custom handling of the root url based on the response url.
  126537. * @param rootUrl the original root url
  126538. * @param responseURL the response url if available
  126539. * @returns the new root url
  126540. */
  126541. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126542. }
  126543. /**
  126544. * Interface used to define a SceneLoader plugin
  126545. */
  126546. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126547. /**
  126548. * Import meshes into a scene.
  126549. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126550. * @param scene The scene to import into
  126551. * @param data The data to import
  126552. * @param rootUrl The root url for scene and resources
  126553. * @param meshes The meshes array to import into
  126554. * @param particleSystems The particle systems array to import into
  126555. * @param skeletons The skeletons array to import into
  126556. * @param onError The callback when import fails
  126557. * @returns True if successful or false otherwise
  126558. */
  126559. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126560. /**
  126561. * Load into a scene.
  126562. * @param scene The scene to load into
  126563. * @param data The data to import
  126564. * @param rootUrl The root url for scene and resources
  126565. * @param onError The callback when import fails
  126566. * @returns True if successful or false otherwise
  126567. */
  126568. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126569. /**
  126570. * Load into an asset container.
  126571. * @param scene The scene to load into
  126572. * @param data The data to import
  126573. * @param rootUrl The root url for scene and resources
  126574. * @param onError The callback when import fails
  126575. * @returns The loaded asset container
  126576. */
  126577. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126578. }
  126579. /**
  126580. * Interface used to define an async SceneLoader plugin
  126581. */
  126582. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126583. /**
  126584. * Import meshes into a scene.
  126585. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126586. * @param scene The scene to import into
  126587. * @param data The data to import
  126588. * @param rootUrl The root url for scene and resources
  126589. * @param onProgress The callback when the load progresses
  126590. * @param fileName Defines the name of the file to load
  126591. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126592. */
  126593. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126594. meshes: AbstractMesh[];
  126595. particleSystems: IParticleSystem[];
  126596. skeletons: Skeleton[];
  126597. animationGroups: AnimationGroup[];
  126598. }>;
  126599. /**
  126600. * Load into a scene.
  126601. * @param scene The scene to load into
  126602. * @param data The data to import
  126603. * @param rootUrl The root url for scene and resources
  126604. * @param onProgress The callback when the load progresses
  126605. * @param fileName Defines the name of the file to load
  126606. * @returns Nothing
  126607. */
  126608. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126609. /**
  126610. * Load into an asset container.
  126611. * @param scene The scene to load into
  126612. * @param data The data to import
  126613. * @param rootUrl The root url for scene and resources
  126614. * @param onProgress The callback when the load progresses
  126615. * @param fileName Defines the name of the file to load
  126616. * @returns The loaded asset container
  126617. */
  126618. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126619. }
  126620. /**
  126621. * Mode that determines how to handle old animation groups before loading new ones.
  126622. */
  126623. export enum SceneLoaderAnimationGroupLoadingMode {
  126624. /**
  126625. * Reset all old animations to initial state then dispose them.
  126626. */
  126627. Clean = 0,
  126628. /**
  126629. * Stop all old animations.
  126630. */
  126631. Stop = 1,
  126632. /**
  126633. * Restart old animations from first frame.
  126634. */
  126635. Sync = 2,
  126636. /**
  126637. * Old animations remains untouched.
  126638. */
  126639. NoSync = 3
  126640. }
  126641. /**
  126642. * Defines a plugin registered by the SceneLoader
  126643. */
  126644. interface IRegisteredPlugin {
  126645. /**
  126646. * Defines the plugin to use
  126647. */
  126648. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126649. /**
  126650. * Defines if the plugin supports binary data
  126651. */
  126652. isBinary: boolean;
  126653. }
  126654. /**
  126655. * Class used to load scene from various file formats using registered plugins
  126656. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126657. */
  126658. export class SceneLoader {
  126659. /**
  126660. * No logging while loading
  126661. */
  126662. static readonly NO_LOGGING: number;
  126663. /**
  126664. * Minimal logging while loading
  126665. */
  126666. static readonly MINIMAL_LOGGING: number;
  126667. /**
  126668. * Summary logging while loading
  126669. */
  126670. static readonly SUMMARY_LOGGING: number;
  126671. /**
  126672. * Detailled logging while loading
  126673. */
  126674. static readonly DETAILED_LOGGING: number;
  126675. /**
  126676. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126677. */
  126678. static get ForceFullSceneLoadingForIncremental(): boolean;
  126679. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126680. /**
  126681. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126682. */
  126683. static get ShowLoadingScreen(): boolean;
  126684. static set ShowLoadingScreen(value: boolean);
  126685. /**
  126686. * Defines the current logging level (while loading the scene)
  126687. * @ignorenaming
  126688. */
  126689. static get loggingLevel(): number;
  126690. static set loggingLevel(value: number);
  126691. /**
  126692. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126693. */
  126694. static get CleanBoneMatrixWeights(): boolean;
  126695. static set CleanBoneMatrixWeights(value: boolean);
  126696. /**
  126697. * Event raised when a plugin is used to load a scene
  126698. */
  126699. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126700. private static _registeredPlugins;
  126701. private static _showingLoadingScreen;
  126702. /**
  126703. * Gets the default plugin (used to load Babylon files)
  126704. * @returns the .babylon plugin
  126705. */
  126706. static GetDefaultPlugin(): IRegisteredPlugin;
  126707. private static _GetPluginForExtension;
  126708. private static _GetPluginForDirectLoad;
  126709. private static _GetPluginForFilename;
  126710. private static _GetDirectLoad;
  126711. private static _LoadData;
  126712. private static _GetFileInfo;
  126713. /**
  126714. * Gets a plugin that can load the given extension
  126715. * @param extension defines the extension to load
  126716. * @returns a plugin or null if none works
  126717. */
  126718. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126719. /**
  126720. * Gets a boolean indicating that the given extension can be loaded
  126721. * @param extension defines the extension to load
  126722. * @returns true if the extension is supported
  126723. */
  126724. static IsPluginForExtensionAvailable(extension: string): boolean;
  126725. /**
  126726. * Adds a new plugin to the list of registered plugins
  126727. * @param plugin defines the plugin to add
  126728. */
  126729. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126730. /**
  126731. * Import meshes into a scene
  126732. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126733. * @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)
  126734. * @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)
  126735. * @param scene the instance of BABYLON.Scene to append to
  126736. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126737. * @param onProgress a callback with a progress event for each file being loaded
  126738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126739. * @param pluginExtension the extension used to determine the plugin
  126740. * @returns The loaded plugin
  126741. */
  126742. 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>;
  126743. /**
  126744. * Import meshes into a scene
  126745. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126746. * @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)
  126747. * @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)
  126748. * @param scene the instance of BABYLON.Scene to append to
  126749. * @param onProgress a callback with a progress event for each file being loaded
  126750. * @param pluginExtension the extension used to determine the plugin
  126751. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126752. */
  126753. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126754. meshes: AbstractMesh[];
  126755. particleSystems: IParticleSystem[];
  126756. skeletons: Skeleton[];
  126757. animationGroups: AnimationGroup[];
  126758. }>;
  126759. /**
  126760. * Load a scene
  126761. * @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)
  126762. * @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)
  126763. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126764. * @param onSuccess a callback with the scene when import succeeds
  126765. * @param onProgress a callback with a progress event for each file being loaded
  126766. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126767. * @param pluginExtension the extension used to determine the plugin
  126768. * @returns The loaded plugin
  126769. */
  126770. 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>;
  126771. /**
  126772. * Load a scene
  126773. * @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)
  126774. * @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)
  126775. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126776. * @param onProgress a callback with a progress event for each file being loaded
  126777. * @param pluginExtension the extension used to determine the plugin
  126778. * @returns The loaded scene
  126779. */
  126780. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126781. /**
  126782. * Append a scene
  126783. * @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)
  126784. * @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)
  126785. * @param scene is the instance of BABYLON.Scene to append to
  126786. * @param onSuccess a callback with the scene when import succeeds
  126787. * @param onProgress a callback with a progress event for each file being loaded
  126788. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126789. * @param pluginExtension the extension used to determine the plugin
  126790. * @returns The loaded plugin
  126791. */
  126792. 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>;
  126793. /**
  126794. * Append a scene
  126795. * @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)
  126796. * @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)
  126797. * @param scene is the instance of BABYLON.Scene to append to
  126798. * @param onProgress a callback with a progress event for each file being loaded
  126799. * @param pluginExtension the extension used to determine the plugin
  126800. * @returns The given scene
  126801. */
  126802. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126803. /**
  126804. * Load a scene into an asset container
  126805. * @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)
  126806. * @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)
  126807. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126808. * @param onSuccess a callback with the scene when import succeeds
  126809. * @param onProgress a callback with a progress event for each file being loaded
  126810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126811. * @param pluginExtension the extension used to determine the plugin
  126812. * @returns The loaded plugin
  126813. */
  126814. 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>;
  126815. /**
  126816. * Load a scene into an asset container
  126817. * @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)
  126818. * @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)
  126819. * @param scene is the instance of Scene to append to
  126820. * @param onProgress a callback with a progress event for each file being loaded
  126821. * @param pluginExtension the extension used to determine the plugin
  126822. * @returns The loaded asset container
  126823. */
  126824. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126825. /**
  126826. * Import animations from a file into a scene
  126827. * @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)
  126828. * @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)
  126829. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126830. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126831. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126832. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126833. * @param onSuccess a callback with the scene when import succeeds
  126834. * @param onProgress a callback with a progress event for each file being loaded
  126835. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126836. * @param pluginExtension the extension used to determine the plugin
  126837. */
  126838. 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;
  126839. /**
  126840. * Import animations from a file into a scene
  126841. * @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)
  126842. * @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)
  126843. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126844. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126845. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126846. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126847. * @param onSuccess a callback with the scene when import succeeds
  126848. * @param onProgress a callback with a progress event for each file being loaded
  126849. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126850. * @param pluginExtension the extension used to determine the plugin
  126851. * @returns the updated scene with imported animations
  126852. */
  126853. 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>;
  126854. }
  126855. }
  126856. declare module BABYLON {
  126857. /**
  126858. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126859. */
  126860. export type MotionControllerHandedness = "none" | "left" | "right";
  126861. /**
  126862. * The type of components available in motion controllers.
  126863. * This is not the name of the component.
  126864. */
  126865. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126866. /**
  126867. * The state of a controller component
  126868. */
  126869. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126870. /**
  126871. * The schema of motion controller layout.
  126872. * No object will be initialized using this interface
  126873. * This is used just to define the profile.
  126874. */
  126875. export interface IMotionControllerLayout {
  126876. /**
  126877. * Path to load the assets. Usually relative to the base path
  126878. */
  126879. assetPath: string;
  126880. /**
  126881. * Available components (unsorted)
  126882. */
  126883. components: {
  126884. /**
  126885. * A map of component Ids
  126886. */
  126887. [componentId: string]: {
  126888. /**
  126889. * The type of input the component outputs
  126890. */
  126891. type: MotionControllerComponentType;
  126892. /**
  126893. * The indices of this component in the gamepad object
  126894. */
  126895. gamepadIndices: {
  126896. /**
  126897. * Index of button
  126898. */
  126899. button?: number;
  126900. /**
  126901. * If available, index of x-axis
  126902. */
  126903. xAxis?: number;
  126904. /**
  126905. * If available, index of y-axis
  126906. */
  126907. yAxis?: number;
  126908. };
  126909. /**
  126910. * The mesh's root node name
  126911. */
  126912. rootNodeName: string;
  126913. /**
  126914. * Animation definitions for this model
  126915. */
  126916. visualResponses: {
  126917. [stateKey: string]: {
  126918. /**
  126919. * What property will be animated
  126920. */
  126921. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126922. /**
  126923. * What states influence this visual response
  126924. */
  126925. states: MotionControllerComponentStateType[];
  126926. /**
  126927. * Type of animation - movement or visibility
  126928. */
  126929. valueNodeProperty: "transform" | "visibility";
  126930. /**
  126931. * Base node name to move. Its position will be calculated according to the min and max nodes
  126932. */
  126933. valueNodeName?: string;
  126934. /**
  126935. * Minimum movement node
  126936. */
  126937. minNodeName?: string;
  126938. /**
  126939. * Max movement node
  126940. */
  126941. maxNodeName?: string;
  126942. };
  126943. };
  126944. /**
  126945. * If touch enabled, what is the name of node to display user feedback
  126946. */
  126947. touchPointNodeName?: string;
  126948. };
  126949. };
  126950. /**
  126951. * Is it xr standard mapping or not
  126952. */
  126953. gamepadMapping: "" | "xr-standard";
  126954. /**
  126955. * Base root node of this entire model
  126956. */
  126957. rootNodeName: string;
  126958. /**
  126959. * Defines the main button component id
  126960. */
  126961. selectComponentId: string;
  126962. }
  126963. /**
  126964. * A definition for the layout map in the input profile
  126965. */
  126966. export interface IMotionControllerLayoutMap {
  126967. /**
  126968. * Layouts with handedness type as a key
  126969. */
  126970. [handedness: string]: IMotionControllerLayout;
  126971. }
  126972. /**
  126973. * The XR Input profile schema
  126974. * Profiles can be found here:
  126975. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126976. */
  126977. export interface IMotionControllerProfile {
  126978. /**
  126979. * fallback profiles for this profileId
  126980. */
  126981. fallbackProfileIds: string[];
  126982. /**
  126983. * The layout map, with handedness as key
  126984. */
  126985. layouts: IMotionControllerLayoutMap;
  126986. /**
  126987. * The id of this profile
  126988. * correlates to the profile(s) in the xrInput.profiles array
  126989. */
  126990. profileId: string;
  126991. }
  126992. /**
  126993. * A helper-interface for the 3 meshes needed for controller button animation
  126994. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126995. */
  126996. export interface IMotionControllerButtonMeshMap {
  126997. /**
  126998. * the mesh that defines the pressed value mesh position.
  126999. * This is used to find the max-position of this button
  127000. */
  127001. pressedMesh: AbstractMesh;
  127002. /**
  127003. * the mesh that defines the unpressed value mesh position.
  127004. * This is used to find the min (or initial) position of this button
  127005. */
  127006. unpressedMesh: AbstractMesh;
  127007. /**
  127008. * The mesh that will be changed when value changes
  127009. */
  127010. valueMesh: AbstractMesh;
  127011. }
  127012. /**
  127013. * A helper-interface for the 3 meshes needed for controller axis animation.
  127014. * This will be expanded when touchpad animations are fully supported
  127015. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127016. */
  127017. export interface IMotionControllerMeshMap {
  127018. /**
  127019. * the mesh that defines the maximum value mesh position.
  127020. */
  127021. maxMesh?: AbstractMesh;
  127022. /**
  127023. * the mesh that defines the minimum value mesh position.
  127024. */
  127025. minMesh?: AbstractMesh;
  127026. /**
  127027. * The mesh that will be changed when axis value changes
  127028. */
  127029. valueMesh: AbstractMesh;
  127030. }
  127031. /**
  127032. * The elements needed for change-detection of the gamepad objects in motion controllers
  127033. */
  127034. export interface IMinimalMotionControllerObject {
  127035. /**
  127036. * Available axes of this controller
  127037. */
  127038. axes: number[];
  127039. /**
  127040. * An array of available buttons
  127041. */
  127042. buttons: Array<{
  127043. /**
  127044. * Value of the button/trigger
  127045. */
  127046. value: number;
  127047. /**
  127048. * If the button/trigger is currently touched
  127049. */
  127050. touched: boolean;
  127051. /**
  127052. * If the button/trigger is currently pressed
  127053. */
  127054. pressed: boolean;
  127055. }>;
  127056. /**
  127057. * EXPERIMENTAL haptic support.
  127058. */
  127059. hapticActuators?: Array<{
  127060. pulse: (value: number, duration: number) => Promise<boolean>;
  127061. }>;
  127062. }
  127063. /**
  127064. * An Abstract Motion controller
  127065. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127066. * Each component has an observable to check for changes in value and state
  127067. */
  127068. export abstract class WebXRAbstractMotionController implements IDisposable {
  127069. protected scene: Scene;
  127070. protected layout: IMotionControllerLayout;
  127071. /**
  127072. * The gamepad object correlating to this controller
  127073. */
  127074. gamepadObject: IMinimalMotionControllerObject;
  127075. /**
  127076. * handedness (left/right/none) of this controller
  127077. */
  127078. handedness: MotionControllerHandedness;
  127079. private _initComponent;
  127080. private _modelReady;
  127081. /**
  127082. * A map of components (WebXRControllerComponent) in this motion controller
  127083. * Components have a ComponentType and can also have both button and axis definitions
  127084. */
  127085. readonly components: {
  127086. [id: string]: WebXRControllerComponent;
  127087. };
  127088. /**
  127089. * Disable the model's animation. Can be set at any time.
  127090. */
  127091. disableAnimation: boolean;
  127092. /**
  127093. * Observers registered here will be triggered when the model of this controller is done loading
  127094. */
  127095. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127096. /**
  127097. * The profile id of this motion controller
  127098. */
  127099. abstract profileId: string;
  127100. /**
  127101. * The root mesh of the model. It is null if the model was not yet initialized
  127102. */
  127103. rootMesh: Nullable<AbstractMesh>;
  127104. /**
  127105. * constructs a new abstract motion controller
  127106. * @param scene the scene to which the model of the controller will be added
  127107. * @param layout The profile layout to load
  127108. * @param gamepadObject The gamepad object correlating to this controller
  127109. * @param handedness handedness (left/right/none) of this controller
  127110. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  127111. */
  127112. constructor(scene: Scene, layout: IMotionControllerLayout,
  127113. /**
  127114. * The gamepad object correlating to this controller
  127115. */
  127116. gamepadObject: IMinimalMotionControllerObject,
  127117. /**
  127118. * handedness (left/right/none) of this controller
  127119. */
  127120. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  127121. /**
  127122. * Dispose this controller, the model mesh and all its components
  127123. */
  127124. dispose(): void;
  127125. /**
  127126. * Returns all components of specific type
  127127. * @param type the type to search for
  127128. * @return an array of components with this type
  127129. */
  127130. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  127131. /**
  127132. * get a component based an its component id as defined in layout.components
  127133. * @param id the id of the component
  127134. * @returns the component correlates to the id or undefined if not found
  127135. */
  127136. getComponent(id: string): WebXRControllerComponent;
  127137. /**
  127138. * Get the list of components available in this motion controller
  127139. * @returns an array of strings correlating to available components
  127140. */
  127141. getComponentIds(): string[];
  127142. /**
  127143. * Get the first component of specific type
  127144. * @param type type of component to find
  127145. * @return a controller component or null if not found
  127146. */
  127147. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  127148. /**
  127149. * Get the main (Select) component of this controller as defined in the layout
  127150. * @returns the main component of this controller
  127151. */
  127152. getMainComponent(): WebXRControllerComponent;
  127153. /**
  127154. * Loads the model correlating to this controller
  127155. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  127156. * @returns A promise fulfilled with the result of the model loading
  127157. */
  127158. loadModel(): Promise<boolean>;
  127159. /**
  127160. * Update this model using the current XRFrame
  127161. * @param xrFrame the current xr frame to use and update the model
  127162. */
  127163. updateFromXRFrame(xrFrame: XRFrame): void;
  127164. /**
  127165. * Backwards compatibility due to a deeply-integrated typo
  127166. */
  127167. get handness(): XREye;
  127168. /**
  127169. * Pulse (vibrate) this controller
  127170. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  127171. * Consecutive calls to this function will cancel the last pulse call
  127172. *
  127173. * @param value the strength of the pulse in 0.0...1.0 range
  127174. * @param duration Duration of the pulse in milliseconds
  127175. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127176. * @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
  127177. */
  127178. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127179. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127180. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127181. /**
  127182. * Moves the axis on the controller mesh based on its current state
  127183. * @param axis the index of the axis
  127184. * @param axisValue the value of the axis which determines the meshes new position
  127185. * @hidden
  127186. */
  127187. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127188. /**
  127189. * Update the model itself with the current frame data
  127190. * @param xrFrame the frame to use for updating the model mesh
  127191. */
  127192. protected updateModel(xrFrame: XRFrame): void;
  127193. /**
  127194. * Get the filename and path for this controller's model
  127195. * @returns a map of filename and path
  127196. */
  127197. protected abstract _getFilenameAndPath(): {
  127198. filename: string;
  127199. path: string;
  127200. };
  127201. /**
  127202. * This function is called before the mesh is loaded. It checks for loading constraints.
  127203. * For example, this function can check if the GLB loader is available
  127204. * If this function returns false, the generic controller will be loaded instead
  127205. * @returns Is the client ready to load the mesh
  127206. */
  127207. protected abstract _getModelLoadingConstraints(): boolean;
  127208. /**
  127209. * This function will be called after the model was successfully loaded and can be used
  127210. * for mesh transformations before it is available for the user
  127211. * @param meshes the loaded meshes
  127212. */
  127213. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127214. /**
  127215. * Set the root mesh for this controller. Important for the WebXR controller class
  127216. * @param meshes the loaded meshes
  127217. */
  127218. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127219. /**
  127220. * A function executed each frame that updates the mesh (if needed)
  127221. * @param xrFrame the current xrFrame
  127222. */
  127223. protected abstract _updateModel(xrFrame: XRFrame): void;
  127224. private _getGenericFilenameAndPath;
  127225. private _getGenericParentMesh;
  127226. }
  127227. }
  127228. declare module BABYLON {
  127229. /**
  127230. * A generic trigger-only motion controller for WebXR
  127231. */
  127232. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127233. /**
  127234. * Static version of the profile id of this controller
  127235. */
  127236. static ProfileId: string;
  127237. profileId: string;
  127238. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127239. protected _getFilenameAndPath(): {
  127240. filename: string;
  127241. path: string;
  127242. };
  127243. protected _getModelLoadingConstraints(): boolean;
  127244. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127245. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127246. protected _updateModel(): void;
  127247. }
  127248. }
  127249. declare module BABYLON {
  127250. /**
  127251. * Class containing static functions to help procedurally build meshes
  127252. */
  127253. export class SphereBuilder {
  127254. /**
  127255. * Creates a sphere mesh
  127256. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127257. * * 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`)
  127258. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127259. * * 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
  127260. * * 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)
  127261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127264. * @param name defines the name of the mesh
  127265. * @param options defines the options used to create the mesh
  127266. * @param scene defines the hosting scene
  127267. * @returns the sphere mesh
  127268. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127269. */
  127270. static CreateSphere(name: string, options: {
  127271. segments?: number;
  127272. diameter?: number;
  127273. diameterX?: number;
  127274. diameterY?: number;
  127275. diameterZ?: number;
  127276. arc?: number;
  127277. slice?: number;
  127278. sideOrientation?: number;
  127279. frontUVs?: Vector4;
  127280. backUVs?: Vector4;
  127281. updatable?: boolean;
  127282. }, scene?: Nullable<Scene>): Mesh;
  127283. }
  127284. }
  127285. declare module BABYLON {
  127286. /**
  127287. * A profiled motion controller has its profile loaded from an online repository.
  127288. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127289. */
  127290. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127291. private _repositoryUrl;
  127292. private _buttonMeshMapping;
  127293. private _touchDots;
  127294. /**
  127295. * The profile ID of this controller. Will be populated when the controller initializes.
  127296. */
  127297. profileId: string;
  127298. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127299. dispose(): void;
  127300. protected _getFilenameAndPath(): {
  127301. filename: string;
  127302. path: string;
  127303. };
  127304. protected _getModelLoadingConstraints(): boolean;
  127305. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127306. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127307. protected _updateModel(_xrFrame: XRFrame): void;
  127308. }
  127309. }
  127310. declare module BABYLON {
  127311. /**
  127312. * A construction function type to create a new controller based on an xrInput object
  127313. */
  127314. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127315. /**
  127316. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127317. *
  127318. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127319. * it should be replaced with auto-loaded controllers.
  127320. *
  127321. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127322. */
  127323. export class WebXRMotionControllerManager {
  127324. private static _AvailableControllers;
  127325. private static _Fallbacks;
  127326. private static _ProfileLoadingPromises;
  127327. private static _ProfilesList;
  127328. /**
  127329. * The base URL of the online controller repository. Can be changed at any time.
  127330. */
  127331. static BaseRepositoryUrl: string;
  127332. /**
  127333. * Which repository gets priority - local or online
  127334. */
  127335. static PrioritizeOnlineRepository: boolean;
  127336. /**
  127337. * Use the online repository, or use only locally-defined controllers
  127338. */
  127339. static UseOnlineRepository: boolean;
  127340. /**
  127341. * Clear the cache used for profile loading and reload when requested again
  127342. */
  127343. static ClearProfilesCache(): void;
  127344. /**
  127345. * Register the default fallbacks.
  127346. * This function is called automatically when this file is imported.
  127347. */
  127348. static DefaultFallbacks(): void;
  127349. /**
  127350. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127351. * @param profileId the profile to which a fallback needs to be found
  127352. * @return an array with corresponding fallback profiles
  127353. */
  127354. static FindFallbackWithProfileId(profileId: string): string[];
  127355. /**
  127356. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127357. * The order of search:
  127358. *
  127359. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127360. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127361. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127362. * 4) return the generic trigger controller if none were found
  127363. *
  127364. * @param xrInput the xrInput to which a new controller is initialized
  127365. * @param scene the scene to which the model will be added
  127366. * @param forceProfile force a certain profile for this controller
  127367. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127368. */
  127369. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127370. /**
  127371. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127372. *
  127373. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127374. *
  127375. * @param type the profile type to register
  127376. * @param constructFunction the function to be called when loading this profile
  127377. */
  127378. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127379. /**
  127380. * Register a fallback to a specific profile.
  127381. * @param profileId the profileId that will receive the fallbacks
  127382. * @param fallbacks A list of fallback profiles
  127383. */
  127384. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127385. /**
  127386. * Will update the list of profiles available in the repository
  127387. * @return a promise that resolves to a map of profiles available online
  127388. */
  127389. static UpdateProfilesList(): Promise<{
  127390. [profile: string]: string;
  127391. }>;
  127392. private static _LoadProfileFromRepository;
  127393. private static _LoadProfilesFromAvailableControllers;
  127394. }
  127395. }
  127396. declare module BABYLON {
  127397. /**
  127398. * Configuration options for the WebXR controller creation
  127399. */
  127400. export interface IWebXRControllerOptions {
  127401. /**
  127402. * Should the controller mesh be animated when a user interacts with it
  127403. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127404. */
  127405. disableMotionControllerAnimation?: boolean;
  127406. /**
  127407. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127408. */
  127409. doNotLoadControllerMesh?: boolean;
  127410. /**
  127411. * Force a specific controller type for this controller.
  127412. * This can be used when creating your own profile or when testing different controllers
  127413. */
  127414. forceControllerProfile?: string;
  127415. /**
  127416. * Defines a rendering group ID for meshes that will be loaded.
  127417. * This is for the default controllers only.
  127418. */
  127419. renderingGroupId?: number;
  127420. }
  127421. /**
  127422. * Represents an XR controller
  127423. */
  127424. export class WebXRInputSource {
  127425. private _scene;
  127426. /** The underlying input source for the controller */
  127427. inputSource: XRInputSource;
  127428. private _options;
  127429. private _tmpVector;
  127430. private _uniqueId;
  127431. /**
  127432. * 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
  127433. */
  127434. grip?: AbstractMesh;
  127435. /**
  127436. * If available, this is the gamepad object related to this controller.
  127437. * Using this object it is possible to get click events and trackpad changes of the
  127438. * webxr controller that is currently being used.
  127439. */
  127440. motionController?: WebXRAbstractMotionController;
  127441. /**
  127442. * Event that fires when the controller is removed/disposed.
  127443. * The object provided as event data is this controller, after associated assets were disposed.
  127444. * uniqueId is still available.
  127445. */
  127446. onDisposeObservable: Observable<WebXRInputSource>;
  127447. /**
  127448. * Will be triggered when the mesh associated with the motion controller is done loading.
  127449. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127450. * A shortened version of controller -> motion controller -> on mesh loaded.
  127451. */
  127452. onMeshLoadedObservable: Observable<AbstractMesh>;
  127453. /**
  127454. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127455. */
  127456. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127457. /**
  127458. * Pointer which can be used to select objects or attach a visible laser to
  127459. */
  127460. pointer: AbstractMesh;
  127461. /**
  127462. * Creates the input source object
  127463. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127464. * @param _scene the scene which the controller should be associated to
  127465. * @param inputSource the underlying input source for the controller
  127466. * @param _options options for this controller creation
  127467. */
  127468. constructor(_scene: Scene,
  127469. /** The underlying input source for the controller */
  127470. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127471. /**
  127472. * Get this controllers unique id
  127473. */
  127474. get uniqueId(): string;
  127475. /**
  127476. * Disposes of the object
  127477. */
  127478. dispose(): void;
  127479. /**
  127480. * Gets a world space ray coming from the pointer or grip
  127481. * @param result the resulting ray
  127482. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127483. */
  127484. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127485. /**
  127486. * Updates the controller pose based on the given XRFrame
  127487. * @param xrFrame xr frame to update the pose with
  127488. * @param referenceSpace reference space to use
  127489. */
  127490. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127491. }
  127492. }
  127493. declare module BABYLON {
  127494. /**
  127495. * The schema for initialization options of the XR Input class
  127496. */
  127497. export interface IWebXRInputOptions {
  127498. /**
  127499. * If set to true no model will be automatically loaded
  127500. */
  127501. doNotLoadControllerMeshes?: boolean;
  127502. /**
  127503. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127504. * If not found, the xr input profile data will be used.
  127505. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127506. */
  127507. forceInputProfile?: string;
  127508. /**
  127509. * Do not send a request to the controller repository to load the profile.
  127510. *
  127511. * Instead, use the controllers available in babylon itself.
  127512. */
  127513. disableOnlineControllerRepository?: boolean;
  127514. /**
  127515. * A custom URL for the controllers repository
  127516. */
  127517. customControllersRepositoryURL?: string;
  127518. /**
  127519. * Should the controller model's components not move according to the user input
  127520. */
  127521. disableControllerAnimation?: boolean;
  127522. /**
  127523. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127524. */
  127525. controllerOptions?: IWebXRControllerOptions;
  127526. }
  127527. /**
  127528. * XR input used to track XR inputs such as controllers/rays
  127529. */
  127530. export class WebXRInput implements IDisposable {
  127531. /**
  127532. * the xr session manager for this session
  127533. */
  127534. xrSessionManager: WebXRSessionManager;
  127535. /**
  127536. * the WebXR camera for this session. Mainly used for teleportation
  127537. */
  127538. xrCamera: WebXRCamera;
  127539. private readonly options;
  127540. /**
  127541. * XR controllers being tracked
  127542. */
  127543. controllers: Array<WebXRInputSource>;
  127544. private _frameObserver;
  127545. private _sessionEndedObserver;
  127546. private _sessionInitObserver;
  127547. /**
  127548. * Event when a controller has been connected/added
  127549. */
  127550. onControllerAddedObservable: Observable<WebXRInputSource>;
  127551. /**
  127552. * Event when a controller has been removed/disconnected
  127553. */
  127554. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127555. /**
  127556. * Initializes the WebXRInput
  127557. * @param xrSessionManager the xr session manager for this session
  127558. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127559. * @param options = initialization options for this xr input
  127560. */
  127561. constructor(
  127562. /**
  127563. * the xr session manager for this session
  127564. */
  127565. xrSessionManager: WebXRSessionManager,
  127566. /**
  127567. * the WebXR camera for this session. Mainly used for teleportation
  127568. */
  127569. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127570. private _onInputSourcesChange;
  127571. private _addAndRemoveControllers;
  127572. /**
  127573. * Disposes of the object
  127574. */
  127575. dispose(): void;
  127576. }
  127577. }
  127578. declare module BABYLON {
  127579. /**
  127580. * This is the base class for all WebXR features.
  127581. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127582. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127583. */
  127584. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127585. protected _xrSessionManager: WebXRSessionManager;
  127586. private _attached;
  127587. private _removeOnDetach;
  127588. /**
  127589. * Should auto-attach be disabled?
  127590. */
  127591. disableAutoAttach: boolean;
  127592. /**
  127593. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127594. */
  127595. xrNativeFeatureName: string;
  127596. /**
  127597. * Construct a new (abstract) WebXR feature
  127598. * @param _xrSessionManager the xr session manager for this feature
  127599. */
  127600. constructor(_xrSessionManager: WebXRSessionManager);
  127601. /**
  127602. * Is this feature attached
  127603. */
  127604. get attached(): boolean;
  127605. /**
  127606. * attach this feature
  127607. *
  127608. * @param force should attachment be forced (even when already attached)
  127609. * @returns true if successful, false is failed or already attached
  127610. */
  127611. attach(force?: boolean): boolean;
  127612. /**
  127613. * detach this feature.
  127614. *
  127615. * @returns true if successful, false if failed or already detached
  127616. */
  127617. detach(): boolean;
  127618. /**
  127619. * Dispose this feature and all of the resources attached
  127620. */
  127621. dispose(): void;
  127622. /**
  127623. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127624. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127625. *
  127626. * @returns whether or not the feature is compatible in this environment
  127627. */
  127628. isCompatible(): boolean;
  127629. /**
  127630. * This is used to register callbacks that will automatically be removed when detach is called.
  127631. * @param observable the observable to which the observer will be attached
  127632. * @param callback the callback to register
  127633. */
  127634. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127635. /**
  127636. * Code in this function will be executed on each xrFrame received from the browser.
  127637. * This function will not execute after the feature is detached.
  127638. * @param _xrFrame the current frame
  127639. */
  127640. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127641. }
  127642. }
  127643. declare module BABYLON {
  127644. /**
  127645. * Renders a layer on top of an existing scene
  127646. */
  127647. export class UtilityLayerRenderer implements IDisposable {
  127648. /** the original scene that will be rendered on top of */
  127649. originalScene: Scene;
  127650. private _pointerCaptures;
  127651. private _lastPointerEvents;
  127652. private static _DefaultUtilityLayer;
  127653. private static _DefaultKeepDepthUtilityLayer;
  127654. private _sharedGizmoLight;
  127655. private _renderCamera;
  127656. /**
  127657. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127658. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127659. * @returns the camera that is used when rendering the utility layer
  127660. */
  127661. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127662. /**
  127663. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127664. * @param cam the camera that should be used when rendering the utility layer
  127665. */
  127666. setRenderCamera(cam: Nullable<Camera>): void;
  127667. /**
  127668. * @hidden
  127669. * Light which used by gizmos to get light shading
  127670. */
  127671. _getSharedGizmoLight(): HemisphericLight;
  127672. /**
  127673. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127674. */
  127675. pickUtilitySceneFirst: boolean;
  127676. /**
  127677. * 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)
  127678. */
  127679. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127680. /**
  127681. * 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)
  127682. */
  127683. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127684. /**
  127685. * The scene that is rendered on top of the original scene
  127686. */
  127687. utilityLayerScene: Scene;
  127688. /**
  127689. * If the utility layer should automatically be rendered on top of existing scene
  127690. */
  127691. shouldRender: boolean;
  127692. /**
  127693. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127694. */
  127695. onlyCheckPointerDownEvents: boolean;
  127696. /**
  127697. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127698. */
  127699. processAllEvents: boolean;
  127700. /**
  127701. * Observable raised when the pointer move from the utility layer scene to the main scene
  127702. */
  127703. onPointerOutObservable: Observable<number>;
  127704. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127705. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127706. private _afterRenderObserver;
  127707. private _sceneDisposeObserver;
  127708. private _originalPointerObserver;
  127709. /**
  127710. * Instantiates a UtilityLayerRenderer
  127711. * @param originalScene the original scene that will be rendered on top of
  127712. * @param handleEvents boolean indicating if the utility layer should handle events
  127713. */
  127714. constructor(
  127715. /** the original scene that will be rendered on top of */
  127716. originalScene: Scene, handleEvents?: boolean);
  127717. private _notifyObservers;
  127718. /**
  127719. * Renders the utility layers scene on top of the original scene
  127720. */
  127721. render(): void;
  127722. /**
  127723. * Disposes of the renderer
  127724. */
  127725. dispose(): void;
  127726. private _updateCamera;
  127727. }
  127728. }
  127729. declare module BABYLON {
  127730. /**
  127731. * Options interface for the pointer selection module
  127732. */
  127733. export interface IWebXRControllerPointerSelectionOptions {
  127734. /**
  127735. * if provided, this scene will be used to render meshes.
  127736. */
  127737. customUtilityLayerScene?: Scene;
  127738. /**
  127739. * 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)
  127740. * If not disabled, the last picked point will be used to execute a pointer up event
  127741. * If disabled, pointer up event will be triggered right after the pointer down event.
  127742. * Used in screen and gaze target ray mode only
  127743. */
  127744. disablePointerUpOnTouchOut: boolean;
  127745. /**
  127746. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127747. */
  127748. forceGazeMode: boolean;
  127749. /**
  127750. * 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
  127751. * to start a new countdown to the pointer down event.
  127752. * Defaults to 1.
  127753. */
  127754. gazeModePointerMovedFactor?: number;
  127755. /**
  127756. * Different button type to use instead of the main component
  127757. */
  127758. overrideButtonId?: string;
  127759. /**
  127760. * use this rendering group id for the meshes (optional)
  127761. */
  127762. renderingGroupId?: number;
  127763. /**
  127764. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127765. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127766. * 3000 means 3 seconds between pointing at something and selecting it
  127767. */
  127768. timeToSelect?: number;
  127769. /**
  127770. * Should meshes created here be added to a utility layer or the main scene
  127771. */
  127772. useUtilityLayer?: boolean;
  127773. /**
  127774. * Optional WebXR camera to be used for gaze selection
  127775. */
  127776. gazeCamera?: WebXRCamera;
  127777. /**
  127778. * the xr input to use with this pointer selection
  127779. */
  127780. xrInput: WebXRInput;
  127781. }
  127782. /**
  127783. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127784. */
  127785. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127786. private readonly _options;
  127787. private static _idCounter;
  127788. private _attachController;
  127789. private _controllers;
  127790. private _scene;
  127791. private _tmpVectorForPickCompare;
  127792. /**
  127793. * The module's name
  127794. */
  127795. static readonly Name: string;
  127796. /**
  127797. * The (Babylon) version of this module.
  127798. * This is an integer representing the implementation version.
  127799. * This number does not correspond to the WebXR specs version
  127800. */
  127801. static readonly Version: number;
  127802. /**
  127803. * Disable lighting on the laser pointer (so it will always be visible)
  127804. */
  127805. disablePointerLighting: boolean;
  127806. /**
  127807. * Disable lighting on the selection mesh (so it will always be visible)
  127808. */
  127809. disableSelectionMeshLighting: boolean;
  127810. /**
  127811. * Should the laser pointer be displayed
  127812. */
  127813. displayLaserPointer: boolean;
  127814. /**
  127815. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127816. */
  127817. displaySelectionMesh: boolean;
  127818. /**
  127819. * This color will be set to the laser pointer when selection is triggered
  127820. */
  127821. laserPointerPickedColor: Color3;
  127822. /**
  127823. * Default color of the laser pointer
  127824. */
  127825. laserPointerDefaultColor: Color3;
  127826. /**
  127827. * default color of the selection ring
  127828. */
  127829. selectionMeshDefaultColor: Color3;
  127830. /**
  127831. * This color will be applied to the selection ring when selection is triggered
  127832. */
  127833. selectionMeshPickedColor: Color3;
  127834. /**
  127835. * Optional filter to be used for ray selection. This predicate shares behavior with
  127836. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127837. */
  127838. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127839. /**
  127840. * constructs a new background remover module
  127841. * @param _xrSessionManager the session manager for this module
  127842. * @param _options read-only options to be used in this module
  127843. */
  127844. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127845. /**
  127846. * attach this feature
  127847. * Will usually be called by the features manager
  127848. *
  127849. * @returns true if successful.
  127850. */
  127851. attach(): boolean;
  127852. /**
  127853. * detach this feature.
  127854. * Will usually be called by the features manager
  127855. *
  127856. * @returns true if successful.
  127857. */
  127858. detach(): boolean;
  127859. /**
  127860. * Will get the mesh under a specific pointer.
  127861. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127862. * @param controllerId the controllerId to check
  127863. * @returns The mesh under pointer or null if no mesh is under the pointer
  127864. */
  127865. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127866. /**
  127867. * Get the xr controller that correlates to the pointer id in the pointer event
  127868. *
  127869. * @param id the pointer id to search for
  127870. * @returns the controller that correlates to this id or null if not found
  127871. */
  127872. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127873. protected _onXRFrame(_xrFrame: XRFrame): void;
  127874. private _attachGazeMode;
  127875. private _attachScreenRayMode;
  127876. private _attachTrackedPointerRayMode;
  127877. private _convertNormalToDirectionOfRay;
  127878. private _detachController;
  127879. private _generateNewMeshPair;
  127880. private _pickingMoved;
  127881. private _updatePointerDistance;
  127882. /** @hidden */
  127883. get lasterPointerDefaultColor(): Color3;
  127884. }
  127885. }
  127886. declare module BABYLON {
  127887. /**
  127888. * Button which can be used to enter a different mode of XR
  127889. */
  127890. export class WebXREnterExitUIButton {
  127891. /** button element */
  127892. element: HTMLElement;
  127893. /** XR initialization options for the button */
  127894. sessionMode: XRSessionMode;
  127895. /** Reference space type */
  127896. referenceSpaceType: XRReferenceSpaceType;
  127897. /**
  127898. * Creates a WebXREnterExitUIButton
  127899. * @param element button element
  127900. * @param sessionMode XR initialization session mode
  127901. * @param referenceSpaceType the type of reference space to be used
  127902. */
  127903. constructor(
  127904. /** button element */
  127905. element: HTMLElement,
  127906. /** XR initialization options for the button */
  127907. sessionMode: XRSessionMode,
  127908. /** Reference space type */
  127909. referenceSpaceType: XRReferenceSpaceType);
  127910. /**
  127911. * Extendable function which can be used to update the button's visuals when the state changes
  127912. * @param activeButton the current active button in the UI
  127913. */
  127914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127915. }
  127916. /**
  127917. * Options to create the webXR UI
  127918. */
  127919. export class WebXREnterExitUIOptions {
  127920. /**
  127921. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127922. */
  127923. customButtons?: Array<WebXREnterExitUIButton>;
  127924. /**
  127925. * A reference space type to use when creating the default button.
  127926. * Default is local-floor
  127927. */
  127928. referenceSpaceType?: XRReferenceSpaceType;
  127929. /**
  127930. * Context to enter xr with
  127931. */
  127932. renderTarget?: Nullable<WebXRRenderTarget>;
  127933. /**
  127934. * A session mode to use when creating the default button.
  127935. * Default is immersive-vr
  127936. */
  127937. sessionMode?: XRSessionMode;
  127938. /**
  127939. * A list of optional features to init the session with
  127940. */
  127941. optionalFeatures?: string[];
  127942. /**
  127943. * A list of optional features to init the session with
  127944. */
  127945. requiredFeatures?: string[];
  127946. }
  127947. /**
  127948. * UI to allow the user to enter/exit XR mode
  127949. */
  127950. export class WebXREnterExitUI implements IDisposable {
  127951. private scene;
  127952. /** version of the options passed to this UI */
  127953. options: WebXREnterExitUIOptions;
  127954. private _activeButton;
  127955. private _buttons;
  127956. private _overlay;
  127957. /**
  127958. * Fired every time the active button is changed.
  127959. *
  127960. * When xr is entered via a button that launches xr that button will be the callback parameter
  127961. *
  127962. * When exiting xr the callback parameter will be null)
  127963. */
  127964. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127965. /**
  127966. *
  127967. * @param scene babylon scene object to use
  127968. * @param options (read-only) version of the options passed to this UI
  127969. */
  127970. private constructor();
  127971. /**
  127972. * Creates UI to allow the user to enter/exit XR mode
  127973. * @param scene the scene to add the ui to
  127974. * @param helper the xr experience helper to enter/exit xr with
  127975. * @param options options to configure the UI
  127976. * @returns the created ui
  127977. */
  127978. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127979. /**
  127980. * Disposes of the XR UI component
  127981. */
  127982. dispose(): void;
  127983. private _updateButtons;
  127984. }
  127985. }
  127986. declare module BABYLON {
  127987. /**
  127988. * Class containing static functions to help procedurally build meshes
  127989. */
  127990. export class LinesBuilder {
  127991. /**
  127992. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127993. * * 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
  127994. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127995. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127996. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127997. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127999. * * 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
  128000. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128003. * @param name defines the name of the new line system
  128004. * @param options defines the options used to create the line system
  128005. * @param scene defines the hosting scene
  128006. * @returns a new line system mesh
  128007. */
  128008. static CreateLineSystem(name: string, options: {
  128009. lines: Vector3[][];
  128010. updatable?: boolean;
  128011. instance?: Nullable<LinesMesh>;
  128012. colors?: Nullable<Color4[][]>;
  128013. useVertexAlpha?: boolean;
  128014. }, scene: Nullable<Scene>): LinesMesh;
  128015. /**
  128016. * Creates a line mesh
  128017. * 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
  128018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128019. * * The parameter `points` is an array successive Vector3
  128020. * * 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
  128021. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128022. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128023. * * When updating an instance, remember that only point positions can change, not the number of points
  128024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128026. * @param name defines the name of the new line system
  128027. * @param options defines the options used to create the line system
  128028. * @param scene defines the hosting scene
  128029. * @returns a new line mesh
  128030. */
  128031. static CreateLines(name: string, options: {
  128032. points: Vector3[];
  128033. updatable?: boolean;
  128034. instance?: Nullable<LinesMesh>;
  128035. colors?: Color4[];
  128036. useVertexAlpha?: boolean;
  128037. }, scene?: Nullable<Scene>): LinesMesh;
  128038. /**
  128039. * Creates a dashed line mesh
  128040. * * 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
  128041. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128042. * * The parameter `points` is an array successive Vector3
  128043. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128044. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128045. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128046. * * 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
  128047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128048. * * When updating an instance, remember that only point positions can change, not the number of points
  128049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128050. * @param name defines the name of the mesh
  128051. * @param options defines the options used to create the mesh
  128052. * @param scene defines the hosting scene
  128053. * @returns the dashed line mesh
  128054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128055. */
  128056. static CreateDashedLines(name: string, options: {
  128057. points: Vector3[];
  128058. dashSize?: number;
  128059. gapSize?: number;
  128060. dashNb?: number;
  128061. updatable?: boolean;
  128062. instance?: LinesMesh;
  128063. useVertexAlpha?: boolean;
  128064. }, scene?: Nullable<Scene>): LinesMesh;
  128065. }
  128066. }
  128067. declare module BABYLON {
  128068. /**
  128069. * Construction options for a timer
  128070. */
  128071. export interface ITimerOptions<T> {
  128072. /**
  128073. * Time-to-end
  128074. */
  128075. timeout: number;
  128076. /**
  128077. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128078. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128079. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128080. */
  128081. contextObservable: Observable<T>;
  128082. /**
  128083. * Optional parameters when adding an observer to the observable
  128084. */
  128085. observableParameters?: {
  128086. mask?: number;
  128087. insertFirst?: boolean;
  128088. scope?: any;
  128089. };
  128090. /**
  128091. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128092. */
  128093. breakCondition?: (data?: ITimerData<T>) => boolean;
  128094. /**
  128095. * Will be triggered when the time condition has met
  128096. */
  128097. onEnded?: (data: ITimerData<any>) => void;
  128098. /**
  128099. * Will be triggered when the break condition has met (prematurely ended)
  128100. */
  128101. onAborted?: (data: ITimerData<any>) => void;
  128102. /**
  128103. * Optional function to execute on each tick (or count)
  128104. */
  128105. onTick?: (data: ITimerData<any>) => void;
  128106. }
  128107. /**
  128108. * An interface defining the data sent by the timer
  128109. */
  128110. export interface ITimerData<T> {
  128111. /**
  128112. * When did it start
  128113. */
  128114. startTime: number;
  128115. /**
  128116. * Time now
  128117. */
  128118. currentTime: number;
  128119. /**
  128120. * Time passed since started
  128121. */
  128122. deltaTime: number;
  128123. /**
  128124. * How much is completed, in [0.0...1.0].
  128125. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  128126. */
  128127. completeRate: number;
  128128. /**
  128129. * What the registered observable sent in the last count
  128130. */
  128131. payload: T;
  128132. }
  128133. /**
  128134. * The current state of the timer
  128135. */
  128136. export enum TimerState {
  128137. /**
  128138. * Timer initialized, not yet started
  128139. */
  128140. INIT = 0,
  128141. /**
  128142. * Timer started and counting
  128143. */
  128144. STARTED = 1,
  128145. /**
  128146. * Timer ended (whether aborted or time reached)
  128147. */
  128148. ENDED = 2
  128149. }
  128150. /**
  128151. * A simple version of the timer. Will take options and start the timer immediately after calling it
  128152. *
  128153. * @param options options with which to initialize this timer
  128154. */
  128155. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  128156. /**
  128157. * An advanced implementation of a timer class
  128158. */
  128159. export class AdvancedTimer<T = any> implements IDisposable {
  128160. /**
  128161. * Will notify each time the timer calculates the remaining time
  128162. */
  128163. onEachCountObservable: Observable<ITimerData<T>>;
  128164. /**
  128165. * Will trigger when the timer was aborted due to the break condition
  128166. */
  128167. onTimerAbortedObservable: Observable<ITimerData<T>>;
  128168. /**
  128169. * Will trigger when the timer ended successfully
  128170. */
  128171. onTimerEndedObservable: Observable<ITimerData<T>>;
  128172. /**
  128173. * Will trigger when the timer state has changed
  128174. */
  128175. onStateChangedObservable: Observable<TimerState>;
  128176. private _observer;
  128177. private _contextObservable;
  128178. private _observableParameters;
  128179. private _startTime;
  128180. private _timer;
  128181. private _state;
  128182. private _breakCondition;
  128183. private _timeToEnd;
  128184. private _breakOnNextTick;
  128185. /**
  128186. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128187. * @param options construction options for this advanced timer
  128188. */
  128189. constructor(options: ITimerOptions<T>);
  128190. /**
  128191. * set a breaking condition for this timer. Default is to never break during count
  128192. * @param predicate the new break condition. Returns true to break, false otherwise
  128193. */
  128194. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128195. /**
  128196. * Reset ALL associated observables in this advanced timer
  128197. */
  128198. clearObservables(): void;
  128199. /**
  128200. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128201. *
  128202. * @param timeToEnd how much time to measure until timer ended
  128203. */
  128204. start(timeToEnd?: number): void;
  128205. /**
  128206. * Will force a stop on the next tick.
  128207. */
  128208. stop(): void;
  128209. /**
  128210. * Dispose this timer, clearing all resources
  128211. */
  128212. dispose(): void;
  128213. private _setState;
  128214. private _tick;
  128215. private _stop;
  128216. }
  128217. }
  128218. declare module BABYLON {
  128219. /**
  128220. * The options container for the teleportation module
  128221. */
  128222. export interface IWebXRTeleportationOptions {
  128223. /**
  128224. * if provided, this scene will be used to render meshes.
  128225. */
  128226. customUtilityLayerScene?: Scene;
  128227. /**
  128228. * Values to configure the default target mesh
  128229. */
  128230. defaultTargetMeshOptions?: {
  128231. /**
  128232. * Fill color of the teleportation area
  128233. */
  128234. teleportationFillColor?: string;
  128235. /**
  128236. * Border color for the teleportation area
  128237. */
  128238. teleportationBorderColor?: string;
  128239. /**
  128240. * Disable the mesh's animation sequence
  128241. */
  128242. disableAnimation?: boolean;
  128243. /**
  128244. * Disable lighting on the material or the ring and arrow
  128245. */
  128246. disableLighting?: boolean;
  128247. /**
  128248. * Override the default material of the torus and arrow
  128249. */
  128250. torusArrowMaterial?: Material;
  128251. };
  128252. /**
  128253. * A list of meshes to use as floor meshes.
  128254. * Meshes can be added and removed after initializing the feature using the
  128255. * addFloorMesh and removeFloorMesh functions
  128256. * If empty, rotation will still work
  128257. */
  128258. floorMeshes?: AbstractMesh[];
  128259. /**
  128260. * use this rendering group id for the meshes (optional)
  128261. */
  128262. renderingGroupId?: number;
  128263. /**
  128264. * Should teleportation move only to snap points
  128265. */
  128266. snapPointsOnly?: boolean;
  128267. /**
  128268. * An array of points to which the teleportation will snap to.
  128269. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128270. */
  128271. snapPositions?: Vector3[];
  128272. /**
  128273. * How close should the teleportation ray be in order to snap to position.
  128274. * Default to 0.8 units (meters)
  128275. */
  128276. snapToPositionRadius?: number;
  128277. /**
  128278. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128279. * If you want to support rotation, make sure your mesh has a direction indicator.
  128280. *
  128281. * When left untouched, the default mesh will be initialized.
  128282. */
  128283. teleportationTargetMesh?: AbstractMesh;
  128284. /**
  128285. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128286. */
  128287. timeToTeleport?: number;
  128288. /**
  128289. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128290. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128291. */
  128292. useMainComponentOnly?: boolean;
  128293. /**
  128294. * Should meshes created here be added to a utility layer or the main scene
  128295. */
  128296. useUtilityLayer?: boolean;
  128297. /**
  128298. * Babylon XR Input class for controller
  128299. */
  128300. xrInput: WebXRInput;
  128301. }
  128302. /**
  128303. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128304. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128305. * the input of the attached controllers.
  128306. */
  128307. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128308. private _options;
  128309. private _controllers;
  128310. private _currentTeleportationControllerId;
  128311. private _floorMeshes;
  128312. private _quadraticBezierCurve;
  128313. private _selectionFeature;
  128314. private _snapToPositions;
  128315. private _snappedToPoint;
  128316. private _teleportationRingMaterial?;
  128317. private _tmpRay;
  128318. private _tmpVector;
  128319. /**
  128320. * The module's name
  128321. */
  128322. static readonly Name: string;
  128323. /**
  128324. * The (Babylon) version of this module.
  128325. * This is an integer representing the implementation version.
  128326. * This number does not correspond to the webxr specs version
  128327. */
  128328. static readonly Version: number;
  128329. /**
  128330. * Is movement backwards enabled
  128331. */
  128332. backwardsMovementEnabled: boolean;
  128333. /**
  128334. * Distance to travel when moving backwards
  128335. */
  128336. backwardsTeleportationDistance: number;
  128337. /**
  128338. * The distance from the user to the inspection point in the direction of the controller
  128339. * A higher number will allow the user to move further
  128340. * defaults to 5 (meters, in xr units)
  128341. */
  128342. parabolicCheckRadius: number;
  128343. /**
  128344. * Should the module support parabolic ray on top of direct ray
  128345. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128346. * Very helpful when moving between floors / different heights
  128347. */
  128348. parabolicRayEnabled: boolean;
  128349. /**
  128350. * How much rotation should be applied when rotating right and left
  128351. */
  128352. rotationAngle: number;
  128353. /**
  128354. * Is rotation enabled when moving forward?
  128355. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128356. */
  128357. rotationEnabled: boolean;
  128358. /**
  128359. * constructs a new anchor system
  128360. * @param _xrSessionManager an instance of WebXRSessionManager
  128361. * @param _options configuration object for this feature
  128362. */
  128363. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128364. /**
  128365. * Get the snapPointsOnly flag
  128366. */
  128367. get snapPointsOnly(): boolean;
  128368. /**
  128369. * Sets the snapPointsOnly flag
  128370. * @param snapToPoints should teleportation be exclusively to snap points
  128371. */
  128372. set snapPointsOnly(snapToPoints: boolean);
  128373. /**
  128374. * Add a new mesh to the floor meshes array
  128375. * @param mesh the mesh to use as floor mesh
  128376. */
  128377. addFloorMesh(mesh: AbstractMesh): void;
  128378. /**
  128379. * Add a new snap-to point to fix teleportation to this position
  128380. * @param newSnapPoint The new Snap-To point
  128381. */
  128382. addSnapPoint(newSnapPoint: Vector3): void;
  128383. attach(): boolean;
  128384. detach(): boolean;
  128385. dispose(): void;
  128386. /**
  128387. * Remove a mesh from the floor meshes array
  128388. * @param mesh the mesh to remove
  128389. */
  128390. removeFloorMesh(mesh: AbstractMesh): void;
  128391. /**
  128392. * Remove a mesh from the floor meshes array using its name
  128393. * @param name the mesh name to remove
  128394. */
  128395. removeFloorMeshByName(name: string): void;
  128396. /**
  128397. * 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
  128398. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128399. * @returns was the point found and removed or not
  128400. */
  128401. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128402. /**
  128403. * This function sets a selection feature that will be disabled when
  128404. * the forward ray is shown and will be reattached when hidden.
  128405. * This is used to remove the selection rays when moving.
  128406. * @param selectionFeature the feature to disable when forward movement is enabled
  128407. */
  128408. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128409. protected _onXRFrame(_xrFrame: XRFrame): void;
  128410. private _attachController;
  128411. private _createDefaultTargetMesh;
  128412. private _detachController;
  128413. private _findClosestSnapPointWithRadius;
  128414. private _setTargetMeshPosition;
  128415. private _setTargetMeshVisibility;
  128416. private _showParabolicPath;
  128417. private _teleportForward;
  128418. }
  128419. }
  128420. declare module BABYLON {
  128421. /**
  128422. * Options for the default xr helper
  128423. */
  128424. export class WebXRDefaultExperienceOptions {
  128425. /**
  128426. * Enable or disable default UI to enter XR
  128427. */
  128428. disableDefaultUI?: boolean;
  128429. /**
  128430. * Should teleportation not initialize. defaults to false.
  128431. */
  128432. disableTeleportation?: boolean;
  128433. /**
  128434. * Floor meshes that will be used for teleport
  128435. */
  128436. floorMeshes?: Array<AbstractMesh>;
  128437. /**
  128438. * If set to true, the first frame will not be used to reset position
  128439. * The first frame is mainly used when copying transformation from the old camera
  128440. * Mainly used in AR
  128441. */
  128442. ignoreNativeCameraTransformation?: boolean;
  128443. /**
  128444. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128445. */
  128446. inputOptions?: IWebXRInputOptions;
  128447. /**
  128448. * optional configuration for the output canvas
  128449. */
  128450. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128451. /**
  128452. * optional UI options. This can be used among other to change session mode and reference space type
  128453. */
  128454. uiOptions?: WebXREnterExitUIOptions;
  128455. /**
  128456. * When loading teleportation and pointer select, use stable versions instead of latest.
  128457. */
  128458. useStablePlugins?: boolean;
  128459. /**
  128460. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128461. */
  128462. renderingGroupId?: number;
  128463. /**
  128464. * A list of optional features to init the session with
  128465. * If set to true, all features we support will be added
  128466. */
  128467. optionalFeatures?: boolean | string[];
  128468. }
  128469. /**
  128470. * Default experience which provides a similar setup to the previous webVRExperience
  128471. */
  128472. export class WebXRDefaultExperience {
  128473. /**
  128474. * Base experience
  128475. */
  128476. baseExperience: WebXRExperienceHelper;
  128477. /**
  128478. * Enables ui for entering/exiting xr
  128479. */
  128480. enterExitUI: WebXREnterExitUI;
  128481. /**
  128482. * Input experience extension
  128483. */
  128484. input: WebXRInput;
  128485. /**
  128486. * Enables laser pointer and selection
  128487. */
  128488. pointerSelection: WebXRControllerPointerSelection;
  128489. /**
  128490. * Default target xr should render to
  128491. */
  128492. renderTarget: WebXRRenderTarget;
  128493. /**
  128494. * Enables teleportation
  128495. */
  128496. teleportation: WebXRMotionControllerTeleportation;
  128497. private constructor();
  128498. /**
  128499. * Creates the default xr experience
  128500. * @param scene scene
  128501. * @param options options for basic configuration
  128502. * @returns resulting WebXRDefaultExperience
  128503. */
  128504. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128505. /**
  128506. * DIsposes of the experience helper
  128507. */
  128508. dispose(): void;
  128509. }
  128510. }
  128511. declare module BABYLON {
  128512. /**
  128513. * Options to modify the vr teleportation behavior.
  128514. */
  128515. export interface VRTeleportationOptions {
  128516. /**
  128517. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128518. */
  128519. floorMeshName?: string;
  128520. /**
  128521. * A list of meshes to be used as the teleportation floor. (default: empty)
  128522. */
  128523. floorMeshes?: Mesh[];
  128524. /**
  128525. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128526. */
  128527. teleportationMode?: number;
  128528. /**
  128529. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128530. */
  128531. teleportationTime?: number;
  128532. /**
  128533. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128534. */
  128535. teleportationSpeed?: number;
  128536. /**
  128537. * The easing function used in the animation or null for Linear. (default CircleEase)
  128538. */
  128539. easingFunction?: EasingFunction;
  128540. }
  128541. /**
  128542. * Options to modify the vr experience helper's behavior.
  128543. */
  128544. export interface VRExperienceHelperOptions extends WebVROptions {
  128545. /**
  128546. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128547. */
  128548. createDeviceOrientationCamera?: boolean;
  128549. /**
  128550. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128551. */
  128552. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128553. /**
  128554. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128555. */
  128556. laserToggle?: boolean;
  128557. /**
  128558. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128559. */
  128560. floorMeshes?: Mesh[];
  128561. /**
  128562. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128563. */
  128564. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128565. /**
  128566. * Defines if WebXR should be used instead of WebVR (if available)
  128567. */
  128568. useXR?: boolean;
  128569. }
  128570. /**
  128571. * Event containing information after VR has been entered
  128572. */
  128573. export class OnAfterEnteringVRObservableEvent {
  128574. /**
  128575. * If entering vr was successful
  128576. */
  128577. success: boolean;
  128578. }
  128579. /**
  128580. * Helps to quickly add VR support to an existing scene.
  128581. * See https://doc.babylonjs.com/how_to/webvr_helper
  128582. */
  128583. export class VRExperienceHelper {
  128584. /** Options to modify the vr experience helper's behavior. */
  128585. webVROptions: VRExperienceHelperOptions;
  128586. private _scene;
  128587. private _position;
  128588. private _btnVR;
  128589. private _btnVRDisplayed;
  128590. private _webVRsupported;
  128591. private _webVRready;
  128592. private _webVRrequesting;
  128593. private _webVRpresenting;
  128594. private _hasEnteredVR;
  128595. private _fullscreenVRpresenting;
  128596. private _inputElement;
  128597. private _webVRCamera;
  128598. private _vrDeviceOrientationCamera;
  128599. private _deviceOrientationCamera;
  128600. private _existingCamera;
  128601. private _onKeyDown;
  128602. private _onVrDisplayPresentChange;
  128603. private _onVRDisplayChanged;
  128604. private _onVRRequestPresentStart;
  128605. private _onVRRequestPresentComplete;
  128606. /**
  128607. * 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)
  128608. */
  128609. enableGazeEvenWhenNoPointerLock: boolean;
  128610. /**
  128611. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128612. */
  128613. exitVROnDoubleTap: boolean;
  128614. /**
  128615. * Observable raised right before entering VR.
  128616. */
  128617. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128618. /**
  128619. * Observable raised when entering VR has completed.
  128620. */
  128621. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128622. /**
  128623. * Observable raised when exiting VR.
  128624. */
  128625. onExitingVRObservable: Observable<VRExperienceHelper>;
  128626. /**
  128627. * Observable raised when controller mesh is loaded.
  128628. */
  128629. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128630. /** Return this.onEnteringVRObservable
  128631. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128632. */
  128633. get onEnteringVR(): Observable<VRExperienceHelper>;
  128634. /** Return this.onExitingVRObservable
  128635. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128636. */
  128637. get onExitingVR(): Observable<VRExperienceHelper>;
  128638. /** Return this.onControllerMeshLoadedObservable
  128639. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128640. */
  128641. get onControllerMeshLoaded(): Observable<WebVRController>;
  128642. private _rayLength;
  128643. private _useCustomVRButton;
  128644. private _teleportationRequested;
  128645. private _teleportActive;
  128646. private _floorMeshName;
  128647. private _floorMeshesCollection;
  128648. private _teleportationMode;
  128649. private _teleportationTime;
  128650. private _teleportationSpeed;
  128651. private _teleportationEasing;
  128652. private _rotationAllowed;
  128653. private _teleportBackwardsVector;
  128654. private _teleportationTarget;
  128655. private _isDefaultTeleportationTarget;
  128656. private _postProcessMove;
  128657. private _teleportationFillColor;
  128658. private _teleportationBorderColor;
  128659. private _rotationAngle;
  128660. private _haloCenter;
  128661. private _cameraGazer;
  128662. private _padSensibilityUp;
  128663. private _padSensibilityDown;
  128664. private _leftController;
  128665. private _rightController;
  128666. private _gazeColor;
  128667. private _laserColor;
  128668. private _pickedLaserColor;
  128669. private _pickedGazeColor;
  128670. /**
  128671. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128672. */
  128673. onNewMeshSelected: Observable<AbstractMesh>;
  128674. /**
  128675. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128676. * This observable will provide the mesh and the controller used to select the mesh
  128677. */
  128678. onMeshSelectedWithController: Observable<{
  128679. mesh: AbstractMesh;
  128680. controller: WebVRController;
  128681. }>;
  128682. /**
  128683. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128684. */
  128685. onNewMeshPicked: Observable<PickingInfo>;
  128686. private _circleEase;
  128687. /**
  128688. * Observable raised before camera teleportation
  128689. */
  128690. onBeforeCameraTeleport: Observable<Vector3>;
  128691. /**
  128692. * Observable raised after camera teleportation
  128693. */
  128694. onAfterCameraTeleport: Observable<Vector3>;
  128695. /**
  128696. * Observable raised when current selected mesh gets unselected
  128697. */
  128698. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128699. private _raySelectionPredicate;
  128700. /**
  128701. * To be optionaly changed by user to define custom ray selection
  128702. */
  128703. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128704. /**
  128705. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128706. */
  128707. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128708. /**
  128709. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128710. */
  128711. teleportationEnabled: boolean;
  128712. private _defaultHeight;
  128713. private _teleportationInitialized;
  128714. private _interactionsEnabled;
  128715. private _interactionsRequested;
  128716. private _displayGaze;
  128717. private _displayLaserPointer;
  128718. /**
  128719. * The mesh used to display where the user is going to teleport.
  128720. */
  128721. get teleportationTarget(): Mesh;
  128722. /**
  128723. * Sets the mesh to be used to display where the user is going to teleport.
  128724. */
  128725. set teleportationTarget(value: Mesh);
  128726. /**
  128727. * 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
  128728. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128729. * See https://doc.babylonjs.com/resources/baking_transformations
  128730. */
  128731. get gazeTrackerMesh(): Mesh;
  128732. set gazeTrackerMesh(value: Mesh);
  128733. /**
  128734. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128735. */
  128736. updateGazeTrackerScale: boolean;
  128737. /**
  128738. * If the gaze trackers color should be updated when selecting meshes
  128739. */
  128740. updateGazeTrackerColor: boolean;
  128741. /**
  128742. * If the controller laser color should be updated when selecting meshes
  128743. */
  128744. updateControllerLaserColor: boolean;
  128745. /**
  128746. * The gaze tracking mesh corresponding to the left controller
  128747. */
  128748. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128749. /**
  128750. * The gaze tracking mesh corresponding to the right controller
  128751. */
  128752. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128753. /**
  128754. * If the ray of the gaze should be displayed.
  128755. */
  128756. get displayGaze(): boolean;
  128757. /**
  128758. * Sets if the ray of the gaze should be displayed.
  128759. */
  128760. set displayGaze(value: boolean);
  128761. /**
  128762. * If the ray of the LaserPointer should be displayed.
  128763. */
  128764. get displayLaserPointer(): boolean;
  128765. /**
  128766. * Sets if the ray of the LaserPointer should be displayed.
  128767. */
  128768. set displayLaserPointer(value: boolean);
  128769. /**
  128770. * The deviceOrientationCamera used as the camera when not in VR.
  128771. */
  128772. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128773. /**
  128774. * Based on the current WebVR support, returns the current VR camera used.
  128775. */
  128776. get currentVRCamera(): Nullable<Camera>;
  128777. /**
  128778. * The webVRCamera which is used when in VR.
  128779. */
  128780. get webVRCamera(): WebVRFreeCamera;
  128781. /**
  128782. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128783. */
  128784. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128785. /**
  128786. * The html button that is used to trigger entering into VR.
  128787. */
  128788. get vrButton(): Nullable<HTMLButtonElement>;
  128789. private get _teleportationRequestInitiated();
  128790. /**
  128791. * Defines whether or not Pointer lock should be requested when switching to
  128792. * full screen.
  128793. */
  128794. requestPointerLockOnFullScreen: boolean;
  128795. /**
  128796. * If asking to force XR, this will be populated with the default xr experience
  128797. */
  128798. xr: WebXRDefaultExperience;
  128799. /**
  128800. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128801. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128802. */
  128803. xrTestDone: boolean;
  128804. /**
  128805. * Instantiates a VRExperienceHelper.
  128806. * Helps to quickly add VR support to an existing scene.
  128807. * @param scene The scene the VRExperienceHelper belongs to.
  128808. * @param webVROptions Options to modify the vr experience helper's behavior.
  128809. */
  128810. constructor(scene: Scene,
  128811. /** Options to modify the vr experience helper's behavior. */
  128812. webVROptions?: VRExperienceHelperOptions);
  128813. private completeVRInit;
  128814. private _onDefaultMeshLoaded;
  128815. private _onResize;
  128816. private _onFullscreenChange;
  128817. /**
  128818. * Gets a value indicating if we are currently in VR mode.
  128819. */
  128820. get isInVRMode(): boolean;
  128821. private onVrDisplayPresentChange;
  128822. private onVRDisplayChanged;
  128823. private moveButtonToBottomRight;
  128824. private displayVRButton;
  128825. private updateButtonVisibility;
  128826. private _cachedAngularSensibility;
  128827. /**
  128828. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128829. * Otherwise, will use the fullscreen API.
  128830. */
  128831. enterVR(): void;
  128832. /**
  128833. * Attempt to exit VR, or fullscreen.
  128834. */
  128835. exitVR(): void;
  128836. /**
  128837. * The position of the vr experience helper.
  128838. */
  128839. get position(): Vector3;
  128840. /**
  128841. * Sets the position of the vr experience helper.
  128842. */
  128843. set position(value: Vector3);
  128844. /**
  128845. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128846. */
  128847. enableInteractions(): void;
  128848. private get _noControllerIsActive();
  128849. private beforeRender;
  128850. private _isTeleportationFloor;
  128851. /**
  128852. * Adds a floor mesh to be used for teleportation.
  128853. * @param floorMesh the mesh to be used for teleportation.
  128854. */
  128855. addFloorMesh(floorMesh: Mesh): void;
  128856. /**
  128857. * Removes a floor mesh from being used for teleportation.
  128858. * @param floorMesh the mesh to be removed.
  128859. */
  128860. removeFloorMesh(floorMesh: Mesh): void;
  128861. /**
  128862. * Enables interactions and teleportation using the VR controllers and gaze.
  128863. * @param vrTeleportationOptions options to modify teleportation behavior.
  128864. */
  128865. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128866. private _onNewGamepadConnected;
  128867. private _tryEnableInteractionOnController;
  128868. private _onNewGamepadDisconnected;
  128869. private _enableInteractionOnController;
  128870. private _checkTeleportWithRay;
  128871. private _checkRotate;
  128872. private _checkTeleportBackwards;
  128873. private _enableTeleportationOnController;
  128874. private _createTeleportationCircles;
  128875. private _displayTeleportationTarget;
  128876. private _hideTeleportationTarget;
  128877. private _rotateCamera;
  128878. private _moveTeleportationSelectorTo;
  128879. private _workingVector;
  128880. private _workingQuaternion;
  128881. private _workingMatrix;
  128882. /**
  128883. * Time Constant Teleportation Mode
  128884. */
  128885. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128886. /**
  128887. * Speed Constant Teleportation Mode
  128888. */
  128889. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128890. /**
  128891. * Teleports the users feet to the desired location
  128892. * @param location The location where the user's feet should be placed
  128893. */
  128894. teleportCamera(location: Vector3): void;
  128895. private _convertNormalToDirectionOfRay;
  128896. private _castRayAndSelectObject;
  128897. private _notifySelectedMeshUnselected;
  128898. /**
  128899. * Permanently set new colors for the laser pointer
  128900. * @param color the new laser color
  128901. * @param pickedColor the new laser color when picked mesh detected
  128902. */
  128903. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128904. /**
  128905. * Set lighting enabled / disabled on the laser pointer of both controllers
  128906. * @param enabled should the lighting be enabled on the laser pointer
  128907. */
  128908. setLaserLightingState(enabled?: boolean): void;
  128909. /**
  128910. * Permanently set new colors for the gaze pointer
  128911. * @param color the new gaze color
  128912. * @param pickedColor the new gaze color when picked mesh detected
  128913. */
  128914. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128915. /**
  128916. * Sets the color of the laser ray from the vr controllers.
  128917. * @param color new color for the ray.
  128918. */
  128919. changeLaserColor(color: Color3): void;
  128920. /**
  128921. * Sets the color of the ray from the vr headsets gaze.
  128922. * @param color new color for the ray.
  128923. */
  128924. changeGazeColor(color: Color3): void;
  128925. /**
  128926. * Exits VR and disposes of the vr experience helper
  128927. */
  128928. dispose(): void;
  128929. /**
  128930. * Gets the name of the VRExperienceHelper class
  128931. * @returns "VRExperienceHelper"
  128932. */
  128933. getClassName(): string;
  128934. }
  128935. }
  128936. declare module BABYLON {
  128937. /**
  128938. * Contains an array of blocks representing the octree
  128939. */
  128940. export interface IOctreeContainer<T> {
  128941. /**
  128942. * Blocks within the octree
  128943. */
  128944. blocks: Array<OctreeBlock<T>>;
  128945. }
  128946. /**
  128947. * Class used to store a cell in an octree
  128948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128949. */
  128950. export class OctreeBlock<T> {
  128951. /**
  128952. * Gets the content of the current block
  128953. */
  128954. entries: T[];
  128955. /**
  128956. * Gets the list of block children
  128957. */
  128958. blocks: Array<OctreeBlock<T>>;
  128959. private _depth;
  128960. private _maxDepth;
  128961. private _capacity;
  128962. private _minPoint;
  128963. private _maxPoint;
  128964. private _boundingVectors;
  128965. private _creationFunc;
  128966. /**
  128967. * Creates a new block
  128968. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128969. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128970. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128971. * @param depth defines the current depth of this block in the octree
  128972. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128973. * @param creationFunc defines a callback to call when an element is added to the block
  128974. */
  128975. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128976. /**
  128977. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128978. */
  128979. get capacity(): number;
  128980. /**
  128981. * Gets the minimum vector (in world space) of the block's bounding box
  128982. */
  128983. get minPoint(): Vector3;
  128984. /**
  128985. * Gets the maximum vector (in world space) of the block's bounding box
  128986. */
  128987. get maxPoint(): Vector3;
  128988. /**
  128989. * Add a new element to this block
  128990. * @param entry defines the element to add
  128991. */
  128992. addEntry(entry: T): void;
  128993. /**
  128994. * Remove an element from this block
  128995. * @param entry defines the element to remove
  128996. */
  128997. removeEntry(entry: T): void;
  128998. /**
  128999. * Add an array of elements to this block
  129000. * @param entries defines the array of elements to add
  129001. */
  129002. addEntries(entries: T[]): void;
  129003. /**
  129004. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129005. * @param frustumPlanes defines the frustum planes to test
  129006. * @param selection defines the array to store current content if selection is positive
  129007. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129008. */
  129009. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129010. /**
  129011. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129012. * @param sphereCenter defines the bounding sphere center
  129013. * @param sphereRadius defines the bounding sphere radius
  129014. * @param selection defines the array to store current content if selection is positive
  129015. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129016. */
  129017. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129018. /**
  129019. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129020. * @param ray defines the ray to test with
  129021. * @param selection defines the array to store current content if selection is positive
  129022. */
  129023. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129024. /**
  129025. * Subdivide the content into child blocks (this block will then be empty)
  129026. */
  129027. createInnerBlocks(): void;
  129028. /**
  129029. * @hidden
  129030. */
  129031. 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;
  129032. }
  129033. }
  129034. declare module BABYLON {
  129035. /**
  129036. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129038. */
  129039. export class Octree<T> {
  129040. /** 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.) */
  129041. maxDepth: number;
  129042. /**
  129043. * Blocks within the octree containing objects
  129044. */
  129045. blocks: Array<OctreeBlock<T>>;
  129046. /**
  129047. * Content stored in the octree
  129048. */
  129049. dynamicContent: T[];
  129050. private _maxBlockCapacity;
  129051. private _selectionContent;
  129052. private _creationFunc;
  129053. /**
  129054. * Creates a octree
  129055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129056. * @param creationFunc function to be used to instatiate the octree
  129057. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129058. * @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.)
  129059. */
  129060. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129061. /** 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.) */
  129062. maxDepth?: number);
  129063. /**
  129064. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129065. * @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);
  129066. * @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);
  129067. * @param entries meshes to be added to the octree blocks
  129068. */
  129069. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129070. /**
  129071. * Adds a mesh to the octree
  129072. * @param entry Mesh to add to the octree
  129073. */
  129074. addMesh(entry: T): void;
  129075. /**
  129076. * Remove an element from the octree
  129077. * @param entry defines the element to remove
  129078. */
  129079. removeMesh(entry: T): void;
  129080. /**
  129081. * Selects an array of meshes within the frustum
  129082. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129083. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129084. * @returns array of meshes within the frustum
  129085. */
  129086. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129087. /**
  129088. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129089. * @param sphereCenter defines the bounding sphere center
  129090. * @param sphereRadius defines the bounding sphere radius
  129091. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129092. * @returns an array of objects that intersect the sphere
  129093. */
  129094. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  129095. /**
  129096. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  129097. * @param ray defines the ray to test with
  129098. * @returns array of intersected objects
  129099. */
  129100. intersectsRay(ray: Ray): SmartArray<T>;
  129101. /**
  129102. * Adds a mesh into the octree block if it intersects the block
  129103. */
  129104. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  129105. /**
  129106. * Adds a submesh into the octree block if it intersects the block
  129107. */
  129108. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  129109. }
  129110. }
  129111. declare module BABYLON {
  129112. interface Scene {
  129113. /**
  129114. * @hidden
  129115. * Backing Filed
  129116. */
  129117. _selectionOctree: Octree<AbstractMesh>;
  129118. /**
  129119. * Gets the octree used to boost mesh selection (picking)
  129120. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129121. */
  129122. selectionOctree: Octree<AbstractMesh>;
  129123. /**
  129124. * Creates or updates the octree used to boost selection (picking)
  129125. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129126. * @param maxCapacity defines the maximum capacity per leaf
  129127. * @param maxDepth defines the maximum depth of the octree
  129128. * @returns an octree of AbstractMesh
  129129. */
  129130. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  129131. }
  129132. interface AbstractMesh {
  129133. /**
  129134. * @hidden
  129135. * Backing Field
  129136. */
  129137. _submeshesOctree: Octree<SubMesh>;
  129138. /**
  129139. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  129140. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  129141. * @param maxCapacity defines the maximum size of each block (64 by default)
  129142. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  129143. * @returns the new octree
  129144. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  129145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129146. */
  129147. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  129148. }
  129149. /**
  129150. * Defines the octree scene component responsible to manage any octrees
  129151. * in a given scene.
  129152. */
  129153. export class OctreeSceneComponent {
  129154. /**
  129155. * The component name help to identify the component in the list of scene components.
  129156. */
  129157. readonly name: string;
  129158. /**
  129159. * The scene the component belongs to.
  129160. */
  129161. scene: Scene;
  129162. /**
  129163. * Indicates if the meshes have been checked to make sure they are isEnabled()
  129164. */
  129165. readonly checksIsEnabled: boolean;
  129166. /**
  129167. * Creates a new instance of the component for the given scene
  129168. * @param scene Defines the scene to register the component in
  129169. */
  129170. constructor(scene: Scene);
  129171. /**
  129172. * Registers the component in a given scene
  129173. */
  129174. register(): void;
  129175. /**
  129176. * Return the list of active meshes
  129177. * @returns the list of active meshes
  129178. */
  129179. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129180. /**
  129181. * Return the list of active sub meshes
  129182. * @param mesh The mesh to get the candidates sub meshes from
  129183. * @returns the list of active sub meshes
  129184. */
  129185. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129186. private _tempRay;
  129187. /**
  129188. * Return the list of sub meshes intersecting with a given local ray
  129189. * @param mesh defines the mesh to find the submesh for
  129190. * @param localRay defines the ray in local space
  129191. * @returns the list of intersecting sub meshes
  129192. */
  129193. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129194. /**
  129195. * Return the list of sub meshes colliding with a collider
  129196. * @param mesh defines the mesh to find the submesh for
  129197. * @param collider defines the collider to evaluate the collision against
  129198. * @returns the list of colliding sub meshes
  129199. */
  129200. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129201. /**
  129202. * Rebuilds the elements related to this component in case of
  129203. * context lost for instance.
  129204. */
  129205. rebuild(): void;
  129206. /**
  129207. * Disposes the component and the associated ressources.
  129208. */
  129209. dispose(): void;
  129210. }
  129211. }
  129212. declare module BABYLON {
  129213. /**
  129214. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129215. */
  129216. export class Gizmo implements IDisposable {
  129217. /** The utility layer the gizmo will be added to */
  129218. gizmoLayer: UtilityLayerRenderer;
  129219. /**
  129220. * The root mesh of the gizmo
  129221. */
  129222. _rootMesh: Mesh;
  129223. private _attachedMesh;
  129224. private _attachedNode;
  129225. /**
  129226. * Ratio for the scale of the gizmo (Default: 1)
  129227. */
  129228. scaleRatio: number;
  129229. /**
  129230. * If a custom mesh has been set (Default: false)
  129231. */
  129232. protected _customMeshSet: boolean;
  129233. /**
  129234. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129235. * * When set, interactions will be enabled
  129236. */
  129237. get attachedMesh(): Nullable<AbstractMesh>;
  129238. set attachedMesh(value: Nullable<AbstractMesh>);
  129239. /**
  129240. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129241. * * When set, interactions will be enabled
  129242. */
  129243. get attachedNode(): Nullable<Node>;
  129244. set attachedNode(value: Nullable<Node>);
  129245. /**
  129246. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129247. * @param mesh The mesh to replace the default mesh of the gizmo
  129248. */
  129249. setCustomMesh(mesh: Mesh): void;
  129250. /**
  129251. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129252. */
  129253. updateGizmoRotationToMatchAttachedMesh: boolean;
  129254. /**
  129255. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129256. */
  129257. updateGizmoPositionToMatchAttachedMesh: boolean;
  129258. /**
  129259. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129260. */
  129261. updateScale: boolean;
  129262. protected _interactionsEnabled: boolean;
  129263. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129264. private _beforeRenderObserver;
  129265. private _tempQuaternion;
  129266. private _tempVector;
  129267. private _tempVector2;
  129268. /**
  129269. * Creates a gizmo
  129270. * @param gizmoLayer The utility layer the gizmo will be added to
  129271. */
  129272. constructor(
  129273. /** The utility layer the gizmo will be added to */
  129274. gizmoLayer?: UtilityLayerRenderer);
  129275. /**
  129276. * Updates the gizmo to match the attached mesh's position/rotation
  129277. */
  129278. protected _update(): void;
  129279. /**
  129280. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129281. * @param value Node, TransformNode or mesh
  129282. */
  129283. protected _matrixChanged(): void;
  129284. /**
  129285. * Disposes of the gizmo
  129286. */
  129287. dispose(): void;
  129288. }
  129289. }
  129290. declare module BABYLON {
  129291. /**
  129292. * Single plane drag gizmo
  129293. */
  129294. export class PlaneDragGizmo extends Gizmo {
  129295. /**
  129296. * Drag behavior responsible for the gizmos dragging interactions
  129297. */
  129298. dragBehavior: PointerDragBehavior;
  129299. private _pointerObserver;
  129300. /**
  129301. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129302. */
  129303. snapDistance: number;
  129304. /**
  129305. * Event that fires each time the gizmo snaps to a new location.
  129306. * * snapDistance is the the change in distance
  129307. */
  129308. onSnapObservable: Observable<{
  129309. snapDistance: number;
  129310. }>;
  129311. private _plane;
  129312. private _coloredMaterial;
  129313. private _hoverMaterial;
  129314. private _isEnabled;
  129315. private _parent;
  129316. /** @hidden */
  129317. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129318. /** @hidden */
  129319. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129320. /**
  129321. * Creates a PlaneDragGizmo
  129322. * @param gizmoLayer The utility layer the gizmo will be added to
  129323. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129324. * @param color The color of the gizmo
  129325. */
  129326. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129327. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129328. /**
  129329. * If the gizmo is enabled
  129330. */
  129331. set isEnabled(value: boolean);
  129332. get isEnabled(): boolean;
  129333. /**
  129334. * Disposes of the gizmo
  129335. */
  129336. dispose(): void;
  129337. }
  129338. }
  129339. declare module BABYLON {
  129340. /**
  129341. * Gizmo that enables dragging a mesh along 3 axis
  129342. */
  129343. export class PositionGizmo extends Gizmo {
  129344. /**
  129345. * Internal gizmo used for interactions on the x axis
  129346. */
  129347. xGizmo: AxisDragGizmo;
  129348. /**
  129349. * Internal gizmo used for interactions on the y axis
  129350. */
  129351. yGizmo: AxisDragGizmo;
  129352. /**
  129353. * Internal gizmo used for interactions on the z axis
  129354. */
  129355. zGizmo: AxisDragGizmo;
  129356. /**
  129357. * Internal gizmo used for interactions on the yz plane
  129358. */
  129359. xPlaneGizmo: PlaneDragGizmo;
  129360. /**
  129361. * Internal gizmo used for interactions on the xz plane
  129362. */
  129363. yPlaneGizmo: PlaneDragGizmo;
  129364. /**
  129365. * Internal gizmo used for interactions on the xy plane
  129366. */
  129367. zPlaneGizmo: PlaneDragGizmo;
  129368. /**
  129369. * private variables
  129370. */
  129371. private _meshAttached;
  129372. private _nodeAttached;
  129373. private _updateGizmoRotationToMatchAttachedMesh;
  129374. private _snapDistance;
  129375. private _scaleRatio;
  129376. /** Fires an event when any of it's sub gizmos are dragged */
  129377. onDragStartObservable: Observable<unknown>;
  129378. /** Fires an event when any of it's sub gizmos are released from dragging */
  129379. onDragEndObservable: Observable<unknown>;
  129380. /**
  129381. * If set to true, planar drag is enabled
  129382. */
  129383. private _planarGizmoEnabled;
  129384. get attachedMesh(): Nullable<AbstractMesh>;
  129385. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129386. get attachedNode(): Nullable<Node>;
  129387. set attachedNode(node: Nullable<Node>);
  129388. /**
  129389. * Creates a PositionGizmo
  129390. * @param gizmoLayer The utility layer the gizmo will be added to
  129391. @param thickness display gizmo axis thickness
  129392. */
  129393. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129394. /**
  129395. * If the planar drag gizmo is enabled
  129396. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129397. */
  129398. set planarGizmoEnabled(value: boolean);
  129399. get planarGizmoEnabled(): boolean;
  129400. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129401. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129402. /**
  129403. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129404. */
  129405. set snapDistance(value: number);
  129406. get snapDistance(): number;
  129407. /**
  129408. * Ratio for the scale of the gizmo (Default: 1)
  129409. */
  129410. set scaleRatio(value: number);
  129411. get scaleRatio(): number;
  129412. /**
  129413. * Disposes of the gizmo
  129414. */
  129415. dispose(): void;
  129416. /**
  129417. * CustomMeshes are not supported by this gizmo
  129418. * @param mesh The mesh to replace the default mesh of the gizmo
  129419. */
  129420. setCustomMesh(mesh: Mesh): void;
  129421. }
  129422. }
  129423. declare module BABYLON {
  129424. /**
  129425. * Single axis drag gizmo
  129426. */
  129427. export class AxisDragGizmo extends Gizmo {
  129428. /**
  129429. * Drag behavior responsible for the gizmos dragging interactions
  129430. */
  129431. dragBehavior: PointerDragBehavior;
  129432. private _pointerObserver;
  129433. /**
  129434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129435. */
  129436. snapDistance: number;
  129437. /**
  129438. * Event that fires each time the gizmo snaps to a new location.
  129439. * * snapDistance is the the change in distance
  129440. */
  129441. onSnapObservable: Observable<{
  129442. snapDistance: number;
  129443. }>;
  129444. private _isEnabled;
  129445. private _parent;
  129446. private _arrow;
  129447. private _coloredMaterial;
  129448. private _hoverMaterial;
  129449. /** @hidden */
  129450. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129451. /** @hidden */
  129452. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129453. /**
  129454. * Creates an AxisDragGizmo
  129455. * @param gizmoLayer The utility layer the gizmo will be added to
  129456. * @param dragAxis The axis which the gizmo will be able to drag on
  129457. * @param color The color of the gizmo
  129458. * @param thickness display gizmo axis thickness
  129459. */
  129460. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129461. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129462. /**
  129463. * If the gizmo is enabled
  129464. */
  129465. set isEnabled(value: boolean);
  129466. get isEnabled(): boolean;
  129467. /**
  129468. * Disposes of the gizmo
  129469. */
  129470. dispose(): void;
  129471. }
  129472. }
  129473. declare module BABYLON.Debug {
  129474. /**
  129475. * The Axes viewer will show 3 axes in a specific point in space
  129476. */
  129477. export class AxesViewer {
  129478. private _xAxis;
  129479. private _yAxis;
  129480. private _zAxis;
  129481. private _scaleLinesFactor;
  129482. private _instanced;
  129483. /**
  129484. * Gets the hosting scene
  129485. */
  129486. scene: Scene;
  129487. /**
  129488. * Gets or sets a number used to scale line length
  129489. */
  129490. scaleLines: number;
  129491. /** Gets the node hierarchy used to render x-axis */
  129492. get xAxis(): TransformNode;
  129493. /** Gets the node hierarchy used to render y-axis */
  129494. get yAxis(): TransformNode;
  129495. /** Gets the node hierarchy used to render z-axis */
  129496. get zAxis(): TransformNode;
  129497. /**
  129498. * Creates a new AxesViewer
  129499. * @param scene defines the hosting scene
  129500. * @param scaleLines defines a number used to scale line length (1 by default)
  129501. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129502. * @param xAxis defines the node hierarchy used to render the x-axis
  129503. * @param yAxis defines the node hierarchy used to render the y-axis
  129504. * @param zAxis defines the node hierarchy used to render the z-axis
  129505. */
  129506. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129507. /**
  129508. * Force the viewer to update
  129509. * @param position defines the position of the viewer
  129510. * @param xaxis defines the x axis of the viewer
  129511. * @param yaxis defines the y axis of the viewer
  129512. * @param zaxis defines the z axis of the viewer
  129513. */
  129514. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129515. /**
  129516. * Creates an instance of this axes viewer.
  129517. * @returns a new axes viewer with instanced meshes
  129518. */
  129519. createInstance(): AxesViewer;
  129520. /** Releases resources */
  129521. dispose(): void;
  129522. private static _SetRenderingGroupId;
  129523. }
  129524. }
  129525. declare module BABYLON.Debug {
  129526. /**
  129527. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129528. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129529. */
  129530. export class BoneAxesViewer extends AxesViewer {
  129531. /**
  129532. * Gets or sets the target mesh where to display the axes viewer
  129533. */
  129534. mesh: Nullable<Mesh>;
  129535. /**
  129536. * Gets or sets the target bone where to display the axes viewer
  129537. */
  129538. bone: Nullable<Bone>;
  129539. /** Gets current position */
  129540. pos: Vector3;
  129541. /** Gets direction of X axis */
  129542. xaxis: Vector3;
  129543. /** Gets direction of Y axis */
  129544. yaxis: Vector3;
  129545. /** Gets direction of Z axis */
  129546. zaxis: Vector3;
  129547. /**
  129548. * Creates a new BoneAxesViewer
  129549. * @param scene defines the hosting scene
  129550. * @param bone defines the target bone
  129551. * @param mesh defines the target mesh
  129552. * @param scaleLines defines a scaling factor for line length (1 by default)
  129553. */
  129554. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129555. /**
  129556. * Force the viewer to update
  129557. */
  129558. update(): void;
  129559. /** Releases resources */
  129560. dispose(): void;
  129561. }
  129562. }
  129563. declare module BABYLON {
  129564. /**
  129565. * Interface used to define scene explorer extensibility option
  129566. */
  129567. export interface IExplorerExtensibilityOption {
  129568. /**
  129569. * Define the option label
  129570. */
  129571. label: string;
  129572. /**
  129573. * Defines the action to execute on click
  129574. */
  129575. action: (entity: any) => void;
  129576. }
  129577. /**
  129578. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129579. */
  129580. export interface IExplorerExtensibilityGroup {
  129581. /**
  129582. * Defines a predicate to test if a given type mut be extended
  129583. */
  129584. predicate: (entity: any) => boolean;
  129585. /**
  129586. * Gets the list of options added to a type
  129587. */
  129588. entries: IExplorerExtensibilityOption[];
  129589. }
  129590. /**
  129591. * Interface used to define the options to use to create the Inspector
  129592. */
  129593. export interface IInspectorOptions {
  129594. /**
  129595. * Display in overlay mode (default: false)
  129596. */
  129597. overlay?: boolean;
  129598. /**
  129599. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129600. */
  129601. globalRoot?: HTMLElement;
  129602. /**
  129603. * Display the Scene explorer
  129604. */
  129605. showExplorer?: boolean;
  129606. /**
  129607. * Display the property inspector
  129608. */
  129609. showInspector?: boolean;
  129610. /**
  129611. * Display in embed mode (both panes on the right)
  129612. */
  129613. embedMode?: boolean;
  129614. /**
  129615. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129616. */
  129617. handleResize?: boolean;
  129618. /**
  129619. * Allow the panes to popup (default: true)
  129620. */
  129621. enablePopup?: boolean;
  129622. /**
  129623. * Allow the panes to be closed by users (default: true)
  129624. */
  129625. enableClose?: boolean;
  129626. /**
  129627. * Optional list of extensibility entries
  129628. */
  129629. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129630. /**
  129631. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129632. */
  129633. inspectorURL?: string;
  129634. /**
  129635. * Optional initial tab (default to DebugLayerTab.Properties)
  129636. */
  129637. initialTab?: DebugLayerTab;
  129638. }
  129639. interface Scene {
  129640. /**
  129641. * @hidden
  129642. * Backing field
  129643. */
  129644. _debugLayer: DebugLayer;
  129645. /**
  129646. * Gets the debug layer (aka Inspector) associated with the scene
  129647. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129648. */
  129649. debugLayer: DebugLayer;
  129650. }
  129651. /**
  129652. * Enum of inspector action tab
  129653. */
  129654. export enum DebugLayerTab {
  129655. /**
  129656. * Properties tag (default)
  129657. */
  129658. Properties = 0,
  129659. /**
  129660. * Debug tab
  129661. */
  129662. Debug = 1,
  129663. /**
  129664. * Statistics tab
  129665. */
  129666. Statistics = 2,
  129667. /**
  129668. * Tools tab
  129669. */
  129670. Tools = 3,
  129671. /**
  129672. * Settings tab
  129673. */
  129674. Settings = 4
  129675. }
  129676. /**
  129677. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129678. * what is happening in your scene
  129679. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129680. */
  129681. export class DebugLayer {
  129682. /**
  129683. * Define the url to get the inspector script from.
  129684. * By default it uses the babylonjs CDN.
  129685. * @ignoreNaming
  129686. */
  129687. static InspectorURL: string;
  129688. private _scene;
  129689. private BJSINSPECTOR;
  129690. private _onPropertyChangedObservable?;
  129691. /**
  129692. * Observable triggered when a property is changed through the inspector.
  129693. */
  129694. get onPropertyChangedObservable(): any;
  129695. /**
  129696. * Instantiates a new debug layer.
  129697. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129698. * what is happening in your scene
  129699. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129700. * @param scene Defines the scene to inspect
  129701. */
  129702. constructor(scene: Scene);
  129703. /** Creates the inspector window. */
  129704. private _createInspector;
  129705. /**
  129706. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129707. * @param entity defines the entity to select
  129708. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129709. */
  129710. select(entity: any, lineContainerTitles?: string | string[]): void;
  129711. /** Get the inspector from bundle or global */
  129712. private _getGlobalInspector;
  129713. /**
  129714. * Get if the inspector is visible or not.
  129715. * @returns true if visible otherwise, false
  129716. */
  129717. isVisible(): boolean;
  129718. /**
  129719. * Hide the inspector and close its window.
  129720. */
  129721. hide(): void;
  129722. /**
  129723. * Update the scene in the inspector
  129724. */
  129725. setAsActiveScene(): void;
  129726. /**
  129727. * Launch the debugLayer.
  129728. * @param config Define the configuration of the inspector
  129729. * @return a promise fulfilled when the debug layer is visible
  129730. */
  129731. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129732. }
  129733. }
  129734. declare module BABYLON {
  129735. /**
  129736. * Class containing static functions to help procedurally build meshes
  129737. */
  129738. export class BoxBuilder {
  129739. /**
  129740. * Creates a box mesh
  129741. * * The parameter `size` sets the size (float) of each box side (default 1)
  129742. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129743. * * 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)
  129744. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129748. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129749. * @param name defines the name of the mesh
  129750. * @param options defines the options used to create the mesh
  129751. * @param scene defines the hosting scene
  129752. * @returns the box mesh
  129753. */
  129754. static CreateBox(name: string, options: {
  129755. size?: number;
  129756. width?: number;
  129757. height?: number;
  129758. depth?: number;
  129759. faceUV?: Vector4[];
  129760. faceColors?: Color4[];
  129761. sideOrientation?: number;
  129762. frontUVs?: Vector4;
  129763. backUVs?: Vector4;
  129764. wrap?: boolean;
  129765. topBaseAt?: number;
  129766. bottomBaseAt?: number;
  129767. updatable?: boolean;
  129768. }, scene?: Nullable<Scene>): Mesh;
  129769. }
  129770. }
  129771. declare module BABYLON.Debug {
  129772. /**
  129773. * Used to show the physics impostor around the specific mesh
  129774. */
  129775. export class PhysicsViewer {
  129776. /** @hidden */
  129777. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129778. /** @hidden */
  129779. protected _meshes: Array<Nullable<AbstractMesh>>;
  129780. /** @hidden */
  129781. protected _scene: Nullable<Scene>;
  129782. /** @hidden */
  129783. protected _numMeshes: number;
  129784. /** @hidden */
  129785. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129786. private _renderFunction;
  129787. private _utilityLayer;
  129788. private _debugBoxMesh;
  129789. private _debugSphereMesh;
  129790. private _debugCylinderMesh;
  129791. private _debugMaterial;
  129792. private _debugMeshMeshes;
  129793. /**
  129794. * Creates a new PhysicsViewer
  129795. * @param scene defines the hosting scene
  129796. */
  129797. constructor(scene: Scene);
  129798. /** @hidden */
  129799. protected _updateDebugMeshes(): void;
  129800. /**
  129801. * Renders a specified physic impostor
  129802. * @param impostor defines the impostor to render
  129803. * @param targetMesh defines the mesh represented by the impostor
  129804. * @returns the new debug mesh used to render the impostor
  129805. */
  129806. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129807. /**
  129808. * Hides a specified physic impostor
  129809. * @param impostor defines the impostor to hide
  129810. */
  129811. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129812. private _getDebugMaterial;
  129813. private _getDebugBoxMesh;
  129814. private _getDebugSphereMesh;
  129815. private _getDebugCylinderMesh;
  129816. private _getDebugMeshMesh;
  129817. private _getDebugMesh;
  129818. /** Releases all resources */
  129819. dispose(): void;
  129820. }
  129821. }
  129822. declare module BABYLON {
  129823. /**
  129824. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129825. * in order to better appreciate the issue one might have.
  129826. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129827. */
  129828. export class RayHelper {
  129829. /**
  129830. * Defines the ray we are currently tryin to visualize.
  129831. */
  129832. ray: Nullable<Ray>;
  129833. private _renderPoints;
  129834. private _renderLine;
  129835. private _renderFunction;
  129836. private _scene;
  129837. private _onAfterRenderObserver;
  129838. private _onAfterStepObserver;
  129839. private _attachedToMesh;
  129840. private _meshSpaceDirection;
  129841. private _meshSpaceOrigin;
  129842. /**
  129843. * Helper function to create a colored helper in a scene in one line.
  129844. * @param ray Defines the ray we are currently tryin to visualize
  129845. * @param scene Defines the scene the ray is used in
  129846. * @param color Defines the color we want to see the ray in
  129847. * @returns The newly created ray helper.
  129848. */
  129849. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129850. /**
  129851. * Instantiate a new ray helper.
  129852. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129853. * in order to better appreciate the issue one might have.
  129854. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129855. * @param ray Defines the ray we are currently tryin to visualize
  129856. */
  129857. constructor(ray: Ray);
  129858. /**
  129859. * Shows the ray we are willing to debug.
  129860. * @param scene Defines the scene the ray needs to be rendered in
  129861. * @param color Defines the color the ray needs to be rendered in
  129862. */
  129863. show(scene: Scene, color?: Color3): void;
  129864. /**
  129865. * Hides the ray we are debugging.
  129866. */
  129867. hide(): void;
  129868. private _render;
  129869. /**
  129870. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129871. * @param mesh Defines the mesh we want the helper attached to
  129872. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129873. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129874. * @param length Defines the length of the ray
  129875. */
  129876. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129877. /**
  129878. * Detach the ray helper from the mesh it has previously been attached to.
  129879. */
  129880. detachFromMesh(): void;
  129881. private _updateToMesh;
  129882. /**
  129883. * Dispose the helper and release its associated resources.
  129884. */
  129885. dispose(): void;
  129886. }
  129887. }
  129888. declare module BABYLON {
  129889. /**
  129890. * Defines the options associated with the creation of a SkeletonViewer.
  129891. */
  129892. export interface ISkeletonViewerOptions {
  129893. /** Should the system pause animations before building the Viewer? */
  129894. pauseAnimations: boolean;
  129895. /** Should the system return the skeleton to rest before building? */
  129896. returnToRest: boolean;
  129897. /** public Display Mode of the Viewer */
  129898. displayMode: number;
  129899. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129900. displayOptions: ISkeletonViewerDisplayOptions;
  129901. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129902. computeBonesUsingShaders: boolean;
  129903. }
  129904. /**
  129905. * Defines how to display the various bone meshes for the viewer.
  129906. */
  129907. export interface ISkeletonViewerDisplayOptions {
  129908. /** How far down to start tapering the bone spurs */
  129909. midStep?: number;
  129910. /** How big is the midStep? */
  129911. midStepFactor?: number;
  129912. /** Base for the Sphere Size */
  129913. sphereBaseSize?: number;
  129914. /** The ratio of the sphere to the longest bone in units */
  129915. sphereScaleUnit?: number;
  129916. /** Ratio for the Sphere Size */
  129917. sphereFactor?: number;
  129918. }
  129919. }
  129920. declare module BABYLON {
  129921. /**
  129922. * Class containing static functions to help procedurally build meshes
  129923. */
  129924. export class RibbonBuilder {
  129925. /**
  129926. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129927. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129928. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129929. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129930. * * 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
  129931. * * 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
  129932. * * 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
  129933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129936. * * 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
  129937. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129938. * * 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
  129939. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129941. * @param name defines the name of the mesh
  129942. * @param options defines the options used to create the mesh
  129943. * @param scene defines the hosting scene
  129944. * @returns the ribbon mesh
  129945. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129946. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129947. */
  129948. static CreateRibbon(name: string, options: {
  129949. pathArray: Vector3[][];
  129950. closeArray?: boolean;
  129951. closePath?: boolean;
  129952. offset?: number;
  129953. updatable?: boolean;
  129954. sideOrientation?: number;
  129955. frontUVs?: Vector4;
  129956. backUVs?: Vector4;
  129957. instance?: Mesh;
  129958. invertUV?: boolean;
  129959. uvs?: Vector2[];
  129960. colors?: Color4[];
  129961. }, scene?: Nullable<Scene>): Mesh;
  129962. }
  129963. }
  129964. declare module BABYLON {
  129965. /**
  129966. * Class containing static functions to help procedurally build meshes
  129967. */
  129968. export class ShapeBuilder {
  129969. /**
  129970. * 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.
  129971. * * 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.
  129972. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129973. * * 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.
  129974. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129975. * * 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
  129976. * * 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
  129977. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129980. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129982. * @param name defines the name of the mesh
  129983. * @param options defines the options used to create the mesh
  129984. * @param scene defines the hosting scene
  129985. * @returns the extruded shape mesh
  129986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129988. */
  129989. static ExtrudeShape(name: string, options: {
  129990. shape: Vector3[];
  129991. path: Vector3[];
  129992. scale?: number;
  129993. rotation?: number;
  129994. cap?: number;
  129995. updatable?: boolean;
  129996. sideOrientation?: number;
  129997. frontUVs?: Vector4;
  129998. backUVs?: Vector4;
  129999. instance?: Mesh;
  130000. invertUV?: boolean;
  130001. }, scene?: Nullable<Scene>): Mesh;
  130002. /**
  130003. * Creates an custom extruded shape mesh.
  130004. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130005. * * 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.
  130006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130007. * * 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
  130008. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130009. * * 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
  130010. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130011. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130012. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130013. * * 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
  130014. * * 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
  130015. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130020. * @param name defines the name of the mesh
  130021. * @param options defines the options used to create the mesh
  130022. * @param scene defines the hosting scene
  130023. * @returns the custom extruded shape mesh
  130024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130027. */
  130028. static ExtrudeShapeCustom(name: string, options: {
  130029. shape: Vector3[];
  130030. path: Vector3[];
  130031. scaleFunction?: any;
  130032. rotationFunction?: any;
  130033. ribbonCloseArray?: boolean;
  130034. ribbonClosePath?: boolean;
  130035. cap?: number;
  130036. updatable?: boolean;
  130037. sideOrientation?: number;
  130038. frontUVs?: Vector4;
  130039. backUVs?: Vector4;
  130040. instance?: Mesh;
  130041. invertUV?: boolean;
  130042. }, scene?: Nullable<Scene>): Mesh;
  130043. private static _ExtrudeShapeGeneric;
  130044. }
  130045. }
  130046. declare module BABYLON.Debug {
  130047. /**
  130048. * Class used to render a debug view of a given skeleton
  130049. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  130050. */
  130051. export class SkeletonViewer {
  130052. /** defines the skeleton to render */
  130053. skeleton: Skeleton;
  130054. /** defines the mesh attached to the skeleton */
  130055. mesh: AbstractMesh;
  130056. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130057. autoUpdateBonesMatrices: boolean;
  130058. /** defines the rendering group id to use with the viewer */
  130059. renderingGroupId: number;
  130060. /** is the options for the viewer */
  130061. options: Partial<ISkeletonViewerOptions>;
  130062. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  130063. static readonly DISPLAY_LINES: number;
  130064. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  130065. static readonly DISPLAY_SPHERES: number;
  130066. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  130067. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  130068. /** If SkeletonViewer scene scope. */
  130069. private _scene;
  130070. /** Gets or sets the color used to render the skeleton */
  130071. color: Color3;
  130072. /** Array of the points of the skeleton fo the line view. */
  130073. private _debugLines;
  130074. /** The SkeletonViewers Mesh. */
  130075. private _debugMesh;
  130076. /** If SkeletonViewer is enabled. */
  130077. private _isEnabled;
  130078. /** If SkeletonViewer is ready. */
  130079. private _ready;
  130080. /** SkeletonViewer render observable. */
  130081. private _obs;
  130082. /** The Utility Layer to render the gizmos in. */
  130083. private _utilityLayer;
  130084. private _boneIndices;
  130085. /** Gets the Scene. */
  130086. get scene(): Scene;
  130087. /** Gets the utilityLayer. */
  130088. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  130089. /** Checks Ready Status. */
  130090. get isReady(): Boolean;
  130091. /** Sets Ready Status. */
  130092. set ready(value: boolean);
  130093. /** Gets the debugMesh */
  130094. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  130095. /** Sets the debugMesh */
  130096. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  130097. /** Gets the material */
  130098. get material(): StandardMaterial;
  130099. /** Sets the material */
  130100. set material(value: StandardMaterial);
  130101. /** Gets the material */
  130102. get displayMode(): number;
  130103. /** Sets the material */
  130104. set displayMode(value: number);
  130105. /**
  130106. * Creates a new SkeletonViewer
  130107. * @param skeleton defines the skeleton to render
  130108. * @param mesh defines the mesh attached to the skeleton
  130109. * @param scene defines the hosting scene
  130110. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  130111. * @param renderingGroupId defines the rendering group id to use with the viewer
  130112. * @param options All of the extra constructor options for the SkeletonViewer
  130113. */
  130114. constructor(
  130115. /** defines the skeleton to render */
  130116. skeleton: Skeleton,
  130117. /** defines the mesh attached to the skeleton */
  130118. mesh: AbstractMesh,
  130119. /** The Scene scope*/
  130120. scene: Scene,
  130121. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  130122. autoUpdateBonesMatrices?: boolean,
  130123. /** defines the rendering group id to use with the viewer */
  130124. renderingGroupId?: number,
  130125. /** is the options for the viewer */
  130126. options?: Partial<ISkeletonViewerOptions>);
  130127. /** The Dynamic bindings for the update functions */
  130128. private _bindObs;
  130129. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  130130. update(): void;
  130131. /** Gets or sets a boolean indicating if the viewer is enabled */
  130132. set isEnabled(value: boolean);
  130133. get isEnabled(): boolean;
  130134. private _getBonePosition;
  130135. private _getLinesForBonesWithLength;
  130136. private _getLinesForBonesNoLength;
  130137. /** function to revert the mesh and scene back to the initial state. */
  130138. private _revert;
  130139. /** function to build and bind sphere joint points and spur bone representations. */
  130140. private _buildSpheresAndSpurs;
  130141. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  130142. private _displayLinesUpdate;
  130143. /** Changes the displayMode of the skeleton viewer
  130144. * @param mode The displayMode numerical value
  130145. */
  130146. changeDisplayMode(mode: number): void;
  130147. /** Changes the displayMode of the skeleton viewer
  130148. * @param option String of the option name
  130149. * @param value The numerical option value
  130150. */
  130151. changeDisplayOptions(option: string, value: number): void;
  130152. /** Release associated resources */
  130153. dispose(): void;
  130154. }
  130155. }
  130156. declare module BABYLON {
  130157. /**
  130158. * Enum for Device Types
  130159. */
  130160. export enum DeviceType {
  130161. /** Generic */
  130162. Generic = 0,
  130163. /** Keyboard */
  130164. Keyboard = 1,
  130165. /** Mouse */
  130166. Mouse = 2,
  130167. /** Touch Pointers */
  130168. Touch = 3,
  130169. /** PS4 Dual Shock */
  130170. DualShock = 4,
  130171. /** Xbox */
  130172. Xbox = 5,
  130173. /** Switch Controller */
  130174. Switch = 6
  130175. }
  130176. /**
  130177. * Enum for All Pointers (Touch/Mouse)
  130178. */
  130179. export enum PointerInput {
  130180. /** Horizontal Axis */
  130181. Horizontal = 0,
  130182. /** Vertical Axis */
  130183. Vertical = 1,
  130184. /** Left Click or Touch */
  130185. LeftClick = 2,
  130186. /** Middle Click */
  130187. MiddleClick = 3,
  130188. /** Right Click */
  130189. RightClick = 4,
  130190. /** Browser Back */
  130191. BrowserBack = 5,
  130192. /** Browser Forward */
  130193. BrowserForward = 6
  130194. }
  130195. /**
  130196. * Enum for Dual Shock Gamepad
  130197. */
  130198. export enum DualShockInput {
  130199. /** Cross */
  130200. Cross = 0,
  130201. /** Circle */
  130202. Circle = 1,
  130203. /** Square */
  130204. Square = 2,
  130205. /** Triangle */
  130206. Triangle = 3,
  130207. /** L1 */
  130208. L1 = 4,
  130209. /** R1 */
  130210. R1 = 5,
  130211. /** L2 */
  130212. L2 = 6,
  130213. /** R2 */
  130214. R2 = 7,
  130215. /** Share */
  130216. Share = 8,
  130217. /** Options */
  130218. Options = 9,
  130219. /** L3 */
  130220. L3 = 10,
  130221. /** R3 */
  130222. R3 = 11,
  130223. /** DPadUp */
  130224. DPadUp = 12,
  130225. /** DPadDown */
  130226. DPadDown = 13,
  130227. /** DPadLeft */
  130228. DPadLeft = 14,
  130229. /** DRight */
  130230. DPadRight = 15,
  130231. /** Home */
  130232. Home = 16,
  130233. /** TouchPad */
  130234. TouchPad = 17,
  130235. /** LStickXAxis */
  130236. LStickXAxis = 18,
  130237. /** LStickYAxis */
  130238. LStickYAxis = 19,
  130239. /** RStickXAxis */
  130240. RStickXAxis = 20,
  130241. /** RStickYAxis */
  130242. RStickYAxis = 21
  130243. }
  130244. /**
  130245. * Enum for Xbox Gamepad
  130246. */
  130247. export enum XboxInput {
  130248. /** A */
  130249. A = 0,
  130250. /** B */
  130251. B = 1,
  130252. /** X */
  130253. X = 2,
  130254. /** Y */
  130255. Y = 3,
  130256. /** LB */
  130257. LB = 4,
  130258. /** RB */
  130259. RB = 5,
  130260. /** LT */
  130261. LT = 6,
  130262. /** RT */
  130263. RT = 7,
  130264. /** Back */
  130265. Back = 8,
  130266. /** Start */
  130267. Start = 9,
  130268. /** LS */
  130269. LS = 10,
  130270. /** RS */
  130271. RS = 11,
  130272. /** DPadUp */
  130273. DPadUp = 12,
  130274. /** DPadDown */
  130275. DPadDown = 13,
  130276. /** DPadLeft */
  130277. DPadLeft = 14,
  130278. /** DRight */
  130279. DPadRight = 15,
  130280. /** Home */
  130281. Home = 16,
  130282. /** LStickXAxis */
  130283. LStickXAxis = 17,
  130284. /** LStickYAxis */
  130285. LStickYAxis = 18,
  130286. /** RStickXAxis */
  130287. RStickXAxis = 19,
  130288. /** RStickYAxis */
  130289. RStickYAxis = 20
  130290. }
  130291. /**
  130292. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130293. */
  130294. export enum SwitchInput {
  130295. /** B */
  130296. B = 0,
  130297. /** A */
  130298. A = 1,
  130299. /** Y */
  130300. Y = 2,
  130301. /** X */
  130302. X = 3,
  130303. /** L */
  130304. L = 4,
  130305. /** R */
  130306. R = 5,
  130307. /** ZL */
  130308. ZL = 6,
  130309. /** ZR */
  130310. ZR = 7,
  130311. /** Minus */
  130312. Minus = 8,
  130313. /** Plus */
  130314. Plus = 9,
  130315. /** LS */
  130316. LS = 10,
  130317. /** RS */
  130318. RS = 11,
  130319. /** DPadUp */
  130320. DPadUp = 12,
  130321. /** DPadDown */
  130322. DPadDown = 13,
  130323. /** DPadLeft */
  130324. DPadLeft = 14,
  130325. /** DRight */
  130326. DPadRight = 15,
  130327. /** Home */
  130328. Home = 16,
  130329. /** Capture */
  130330. Capture = 17,
  130331. /** LStickXAxis */
  130332. LStickXAxis = 18,
  130333. /** LStickYAxis */
  130334. LStickYAxis = 19,
  130335. /** RStickXAxis */
  130336. RStickXAxis = 20,
  130337. /** RStickYAxis */
  130338. RStickYAxis = 21
  130339. }
  130340. }
  130341. declare module BABYLON {
  130342. /**
  130343. * This class will take all inputs from Keyboard, Pointer, and
  130344. * any Gamepads and provide a polling system that all devices
  130345. * will use. This class assumes that there will only be one
  130346. * pointer device and one keyboard.
  130347. */
  130348. export class DeviceInputSystem implements IDisposable {
  130349. /**
  130350. * Callback to be triggered when a device is connected
  130351. */
  130352. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130353. /**
  130354. * Callback to be triggered when a device is disconnected
  130355. */
  130356. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130357. /**
  130358. * Callback to be triggered when event driven input is updated
  130359. */
  130360. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130361. private _inputs;
  130362. private _gamepads;
  130363. private _keyboardActive;
  130364. private _pointerActive;
  130365. private _elementToAttachTo;
  130366. private _keyboardDownEvent;
  130367. private _keyboardUpEvent;
  130368. private _pointerMoveEvent;
  130369. private _pointerDownEvent;
  130370. private _pointerUpEvent;
  130371. private _gamepadConnectedEvent;
  130372. private _gamepadDisconnectedEvent;
  130373. private static _MAX_KEYCODES;
  130374. private static _MAX_POINTER_INPUTS;
  130375. private constructor();
  130376. /**
  130377. * Creates a new DeviceInputSystem instance
  130378. * @param engine Engine to pull input element from
  130379. * @returns The new instance
  130380. */
  130381. static Create(engine: Engine): DeviceInputSystem;
  130382. /**
  130383. * Checks for current device input value, given an id and input index
  130384. * @param deviceName Id of connected device
  130385. * @param inputIndex Index of device input
  130386. * @returns Current value of input
  130387. */
  130388. /**
  130389. * Checks for current device input value, given an id and input index
  130390. * @param deviceType Enum specifiying device type
  130391. * @param deviceSlot "Slot" or index that device is referenced in
  130392. * @param inputIndex Id of input to be checked
  130393. * @returns Current value of input
  130394. */
  130395. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130396. /**
  130397. * Dispose of all the eventlisteners
  130398. */
  130399. dispose(): void;
  130400. /**
  130401. * Add device and inputs to device array
  130402. * @param deviceType Enum specifiying device type
  130403. * @param deviceSlot "Slot" or index that device is referenced in
  130404. * @param numberOfInputs Number of input entries to create for given device
  130405. */
  130406. private _registerDevice;
  130407. /**
  130408. * Given a specific device name, remove that device from the device map
  130409. * @param deviceType Enum specifiying device type
  130410. * @param deviceSlot "Slot" or index that device is referenced in
  130411. */
  130412. private _unregisterDevice;
  130413. /**
  130414. * Handle all actions that come from keyboard interaction
  130415. */
  130416. private _handleKeyActions;
  130417. /**
  130418. * Handle all actions that come from pointer interaction
  130419. */
  130420. private _handlePointerActions;
  130421. /**
  130422. * Handle all actions that come from gamepad interaction
  130423. */
  130424. private _handleGamepadActions;
  130425. /**
  130426. * Update all non-event based devices with each frame
  130427. * @param deviceType Enum specifiying device type
  130428. * @param deviceSlot "Slot" or index that device is referenced in
  130429. * @param inputIndex Id of input to be checked
  130430. */
  130431. private _updateDevice;
  130432. /**
  130433. * Gets DeviceType from the device name
  130434. * @param deviceName Name of Device from DeviceInputSystem
  130435. * @returns DeviceType enum value
  130436. */
  130437. private _getGamepadDeviceType;
  130438. }
  130439. }
  130440. declare module BABYLON {
  130441. /**
  130442. * Type to handle enforcement of inputs
  130443. */
  130444. 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;
  130445. }
  130446. declare module BABYLON {
  130447. /**
  130448. * Class that handles all input for a specific device
  130449. */
  130450. export class DeviceSource<T extends DeviceType> {
  130451. /** Type of device */
  130452. readonly deviceType: DeviceType;
  130453. /** "Slot" or index that device is referenced in */
  130454. readonly deviceSlot: number;
  130455. /**
  130456. * Observable to handle device input changes per device
  130457. */
  130458. readonly onInputChangedObservable: Observable<{
  130459. inputIndex: DeviceInput<T>;
  130460. previousState: Nullable<number>;
  130461. currentState: Nullable<number>;
  130462. }>;
  130463. private readonly _deviceInputSystem;
  130464. /**
  130465. * Default Constructor
  130466. * @param deviceInputSystem Reference to DeviceInputSystem
  130467. * @param deviceType Type of device
  130468. * @param deviceSlot "Slot" or index that device is referenced in
  130469. */
  130470. constructor(deviceInputSystem: DeviceInputSystem,
  130471. /** Type of device */
  130472. deviceType: DeviceType,
  130473. /** "Slot" or index that device is referenced in */
  130474. deviceSlot?: number);
  130475. /**
  130476. * Get input for specific input
  130477. * @param inputIndex index of specific input on device
  130478. * @returns Input value from DeviceInputSystem
  130479. */
  130480. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130481. }
  130482. /**
  130483. * Class to keep track of devices
  130484. */
  130485. export class DeviceSourceManager implements IDisposable {
  130486. /**
  130487. * Observable to be triggered when before a device is connected
  130488. */
  130489. readonly onBeforeDeviceConnectedObservable: Observable<{
  130490. deviceType: DeviceType;
  130491. deviceSlot: number;
  130492. }>;
  130493. /**
  130494. * Observable to be triggered when before a device is disconnected
  130495. */
  130496. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130497. deviceType: DeviceType;
  130498. deviceSlot: number;
  130499. }>;
  130500. /**
  130501. * Observable to be triggered when after a device is connected
  130502. */
  130503. readonly onAfterDeviceConnectedObservable: Observable<{
  130504. deviceType: DeviceType;
  130505. deviceSlot: number;
  130506. }>;
  130507. /**
  130508. * Observable to be triggered when after a device is disconnected
  130509. */
  130510. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130511. deviceType: DeviceType;
  130512. deviceSlot: number;
  130513. }>;
  130514. private readonly _devices;
  130515. private readonly _firstDevice;
  130516. private readonly _deviceInputSystem;
  130517. /**
  130518. * Default Constructor
  130519. * @param engine engine to pull input element from
  130520. */
  130521. constructor(engine: Engine);
  130522. /**
  130523. * Gets a DeviceSource, given a type and slot
  130524. * @param deviceType Enum specifying device type
  130525. * @param deviceSlot "Slot" or index that device is referenced in
  130526. * @returns DeviceSource object
  130527. */
  130528. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130529. /**
  130530. * Gets an array of DeviceSource objects for a given device type
  130531. * @param deviceType Enum specifying device type
  130532. * @returns Array of DeviceSource objects
  130533. */
  130534. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130535. /**
  130536. * Dispose of DeviceInputSystem and other parts
  130537. */
  130538. dispose(): void;
  130539. /**
  130540. * Function to add device name to device list
  130541. * @param deviceType Enum specifying device type
  130542. * @param deviceSlot "Slot" or index that device is referenced in
  130543. */
  130544. private _addDevice;
  130545. /**
  130546. * Function to remove device name to device list
  130547. * @param deviceType Enum specifying device type
  130548. * @param deviceSlot "Slot" or index that device is referenced in
  130549. */
  130550. private _removeDevice;
  130551. /**
  130552. * Updates array storing first connected device of each type
  130553. * @param type Type of Device
  130554. */
  130555. private _updateFirstDevices;
  130556. }
  130557. }
  130558. declare module BABYLON {
  130559. /**
  130560. * Options to create the null engine
  130561. */
  130562. export class NullEngineOptions {
  130563. /**
  130564. * Render width (Default: 512)
  130565. */
  130566. renderWidth: number;
  130567. /**
  130568. * Render height (Default: 256)
  130569. */
  130570. renderHeight: number;
  130571. /**
  130572. * Texture size (Default: 512)
  130573. */
  130574. textureSize: number;
  130575. /**
  130576. * If delta time between frames should be constant
  130577. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130578. */
  130579. deterministicLockstep: boolean;
  130580. /**
  130581. * Maximum about of steps between frames (Default: 4)
  130582. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130583. */
  130584. lockstepMaxSteps: number;
  130585. /**
  130586. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130587. */
  130588. useHighPrecisionMatrix?: boolean;
  130589. }
  130590. /**
  130591. * The null engine class provides support for headless version of babylon.js.
  130592. * This can be used in server side scenario or for testing purposes
  130593. */
  130594. export class NullEngine extends Engine {
  130595. private _options;
  130596. /**
  130597. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130598. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130599. * @returns true if engine is in deterministic lock step mode
  130600. */
  130601. isDeterministicLockStep(): boolean;
  130602. /**
  130603. * Gets the max steps when engine is running in deterministic lock step
  130604. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130605. * @returns the max steps
  130606. */
  130607. getLockstepMaxSteps(): number;
  130608. /**
  130609. * Gets the current hardware scaling level.
  130610. * By default the hardware scaling level is computed from the window device ratio.
  130611. * 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.
  130612. * @returns a number indicating the current hardware scaling level
  130613. */
  130614. getHardwareScalingLevel(): number;
  130615. constructor(options?: NullEngineOptions);
  130616. /**
  130617. * Creates a vertex buffer
  130618. * @param vertices the data for the vertex buffer
  130619. * @returns the new WebGL static buffer
  130620. */
  130621. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130622. /**
  130623. * Creates a new index buffer
  130624. * @param indices defines the content of the index buffer
  130625. * @param updatable defines if the index buffer must be updatable
  130626. * @returns a new webGL buffer
  130627. */
  130628. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130629. /**
  130630. * Clear the current render buffer or the current render target (if any is set up)
  130631. * @param color defines the color to use
  130632. * @param backBuffer defines if the back buffer must be cleared
  130633. * @param depth defines if the depth buffer must be cleared
  130634. * @param stencil defines if the stencil buffer must be cleared
  130635. */
  130636. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130637. /**
  130638. * Gets the current render width
  130639. * @param useScreen defines if screen size must be used (or the current render target if any)
  130640. * @returns a number defining the current render width
  130641. */
  130642. getRenderWidth(useScreen?: boolean): number;
  130643. /**
  130644. * Gets the current render height
  130645. * @param useScreen defines if screen size must be used (or the current render target if any)
  130646. * @returns a number defining the current render height
  130647. */
  130648. getRenderHeight(useScreen?: boolean): number;
  130649. /**
  130650. * Set the WebGL's viewport
  130651. * @param viewport defines the viewport element to be used
  130652. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130653. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130654. */
  130655. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130656. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130657. /**
  130658. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130659. * @param pipelineContext defines the pipeline context to use
  130660. * @param uniformsNames defines the list of uniform names
  130661. * @returns an array of webGL uniform locations
  130662. */
  130663. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130664. /**
  130665. * Gets the lsit of active attributes for a given webGL program
  130666. * @param pipelineContext defines the pipeline context to use
  130667. * @param attributesNames defines the list of attribute names to get
  130668. * @returns an array of indices indicating the offset of each attribute
  130669. */
  130670. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130671. /**
  130672. * Binds an effect to the webGL context
  130673. * @param effect defines the effect to bind
  130674. */
  130675. bindSamplers(effect: Effect): void;
  130676. /**
  130677. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130678. * @param effect defines the effect to activate
  130679. */
  130680. enableEffect(effect: Effect): void;
  130681. /**
  130682. * Set various states to the webGL context
  130683. * @param culling defines backface culling state
  130684. * @param zOffset defines the value to apply to zOffset (0 by default)
  130685. * @param force defines if states must be applied even if cache is up to date
  130686. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130687. */
  130688. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130689. /**
  130690. * Set the value of an uniform to an array of int32
  130691. * @param uniform defines the webGL uniform location where to store the value
  130692. * @param array defines the array of int32 to store
  130693. */
  130694. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130695. /**
  130696. * Set the value of an uniform to an array of int32 (stored as vec2)
  130697. * @param uniform defines the webGL uniform location where to store the value
  130698. * @param array defines the array of int32 to store
  130699. */
  130700. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130701. /**
  130702. * Set the value of an uniform to an array of int32 (stored as vec3)
  130703. * @param uniform defines the webGL uniform location where to store the value
  130704. * @param array defines the array of int32 to store
  130705. */
  130706. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130707. /**
  130708. * Set the value of an uniform to an array of int32 (stored as vec4)
  130709. * @param uniform defines the webGL uniform location where to store the value
  130710. * @param array defines the array of int32 to store
  130711. */
  130712. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130713. /**
  130714. * Set the value of an uniform to an array of float32
  130715. * @param uniform defines the webGL uniform location where to store the value
  130716. * @param array defines the array of float32 to store
  130717. */
  130718. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130719. /**
  130720. * Set the value of an uniform to an array of float32 (stored as vec2)
  130721. * @param uniform defines the webGL uniform location where to store the value
  130722. * @param array defines the array of float32 to store
  130723. */
  130724. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130725. /**
  130726. * Set the value of an uniform to an array of float32 (stored as vec3)
  130727. * @param uniform defines the webGL uniform location where to store the value
  130728. * @param array defines the array of float32 to store
  130729. */
  130730. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130731. /**
  130732. * Set the value of an uniform to an array of float32 (stored as vec4)
  130733. * @param uniform defines the webGL uniform location where to store the value
  130734. * @param array defines the array of float32 to store
  130735. */
  130736. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130737. /**
  130738. * Set the value of an uniform to an array of number
  130739. * @param uniform defines the webGL uniform location where to store the value
  130740. * @param array defines the array of number to store
  130741. */
  130742. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130743. /**
  130744. * Set the value of an uniform to an array of number (stored as vec2)
  130745. * @param uniform defines the webGL uniform location where to store the value
  130746. * @param array defines the array of number to store
  130747. */
  130748. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130749. /**
  130750. * Set the value of an uniform to an array of number (stored as vec3)
  130751. * @param uniform defines the webGL uniform location where to store the value
  130752. * @param array defines the array of number to store
  130753. */
  130754. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130755. /**
  130756. * Set the value of an uniform to an array of number (stored as vec4)
  130757. * @param uniform defines the webGL uniform location where to store the value
  130758. * @param array defines the array of number to store
  130759. */
  130760. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130761. /**
  130762. * Set the value of an uniform to an array of float32 (stored as matrices)
  130763. * @param uniform defines the webGL uniform location where to store the value
  130764. * @param matrices defines the array of float32 to store
  130765. */
  130766. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130767. /**
  130768. * Set the value of an uniform to a matrix (3x3)
  130769. * @param uniform defines the webGL uniform location where to store the value
  130770. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130771. */
  130772. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130773. /**
  130774. * Set the value of an uniform to a matrix (2x2)
  130775. * @param uniform defines the webGL uniform location where to store the value
  130776. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130777. */
  130778. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130779. /**
  130780. * Set the value of an uniform to a number (float)
  130781. * @param uniform defines the webGL uniform location where to store the value
  130782. * @param value defines the float number to store
  130783. */
  130784. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130785. /**
  130786. * Set the value of an uniform to a vec2
  130787. * @param uniform defines the webGL uniform location where to store the value
  130788. * @param x defines the 1st component of the value
  130789. * @param y defines the 2nd component of the value
  130790. */
  130791. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130792. /**
  130793. * Set the value of an uniform to a vec3
  130794. * @param uniform defines the webGL uniform location where to store the value
  130795. * @param x defines the 1st component of the value
  130796. * @param y defines the 2nd component of the value
  130797. * @param z defines the 3rd component of the value
  130798. */
  130799. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130800. /**
  130801. * Set the value of an uniform to a boolean
  130802. * @param uniform defines the webGL uniform location where to store the value
  130803. * @param bool defines the boolean to store
  130804. */
  130805. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130806. /**
  130807. * Set the value of an uniform to a vec4
  130808. * @param uniform defines the webGL uniform location where to store the value
  130809. * @param x defines the 1st component of the value
  130810. * @param y defines the 2nd component of the value
  130811. * @param z defines the 3rd component of the value
  130812. * @param w defines the 4th component of the value
  130813. */
  130814. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130815. /**
  130816. * Sets the current alpha mode
  130817. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130818. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130820. */
  130821. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130822. /**
  130823. * Bind webGl buffers directly to the webGL context
  130824. * @param vertexBuffers defines the vertex buffer to bind
  130825. * @param indexBuffer defines the index buffer to bind
  130826. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130827. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130828. * @param effect defines the effect associated with the vertex buffer
  130829. */
  130830. bindBuffers(vertexBuffers: {
  130831. [key: string]: VertexBuffer;
  130832. }, indexBuffer: DataBuffer, effect: Effect): void;
  130833. /**
  130834. * Force the entire cache to be cleared
  130835. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130836. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130837. */
  130838. wipeCaches(bruteForce?: boolean): void;
  130839. /**
  130840. * Send a draw order
  130841. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130842. * @param indexStart defines the starting index
  130843. * @param indexCount defines the number of index to draw
  130844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130845. */
  130846. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130847. /**
  130848. * Draw a list of indexed primitives
  130849. * @param fillMode defines the primitive to use
  130850. * @param indexStart defines the starting index
  130851. * @param indexCount defines the number of index to draw
  130852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130853. */
  130854. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130855. /**
  130856. * Draw a list of unindexed primitives
  130857. * @param fillMode defines the primitive to use
  130858. * @param verticesStart defines the index of first vertex to draw
  130859. * @param verticesCount defines the count of vertices to draw
  130860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130861. */
  130862. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130863. /** @hidden */
  130864. _createTexture(): WebGLTexture;
  130865. /** @hidden */
  130866. _releaseTexture(texture: InternalTexture): void;
  130867. /**
  130868. * Usually called from Texture.ts.
  130869. * Passed information to create a WebGLTexture
  130870. * @param urlArg defines a value which contains one of the following:
  130871. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130872. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130873. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130874. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130875. * @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)
  130876. * @param scene needed for loading to the correct scene
  130877. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130878. * @param onLoad optional callback to be called upon successful completion
  130879. * @param onError optional callback to be called upon failure
  130880. * @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
  130881. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130882. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130883. * @param forcedExtension defines the extension to use to pick the right loader
  130884. * @param mimeType defines an optional mime type
  130885. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130886. */
  130887. 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;
  130888. /**
  130889. * Creates a new render target texture
  130890. * @param size defines the size of the texture
  130891. * @param options defines the options used to create the texture
  130892. * @returns a new render target texture stored in an InternalTexture
  130893. */
  130894. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130895. /**
  130896. * Update the sampling mode of a given texture
  130897. * @param samplingMode defines the required sampling mode
  130898. * @param texture defines the texture to update
  130899. */
  130900. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130901. /**
  130902. * Binds the frame buffer to the specified texture.
  130903. * @param texture The texture to render to or null for the default canvas
  130904. * @param faceIndex The face of the texture to render to in case of cube texture
  130905. * @param requiredWidth The width of the target to render to
  130906. * @param requiredHeight The height of the target to render to
  130907. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130908. * @param lodLevel defines le lod level to bind to the frame buffer
  130909. */
  130910. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130911. /**
  130912. * Unbind the current render target texture from the webGL context
  130913. * @param texture defines the render target texture to unbind
  130914. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130915. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130916. */
  130917. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130918. /**
  130919. * Creates a dynamic vertex buffer
  130920. * @param vertices the data for the dynamic vertex buffer
  130921. * @returns the new WebGL dynamic buffer
  130922. */
  130923. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130924. /**
  130925. * Update the content of a dynamic texture
  130926. * @param texture defines the texture to update
  130927. * @param canvas defines the canvas containing the source
  130928. * @param invertY defines if data must be stored with Y axis inverted
  130929. * @param premulAlpha defines if alpha is stored as premultiplied
  130930. * @param format defines the format of the data
  130931. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130932. */
  130933. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130934. /**
  130935. * Gets a boolean indicating if all created effects are ready
  130936. * @returns true if all effects are ready
  130937. */
  130938. areAllEffectsReady(): boolean;
  130939. /**
  130940. * @hidden
  130941. * Get the current error code of the webGL context
  130942. * @returns the error code
  130943. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130944. */
  130945. getError(): number;
  130946. /** @hidden */
  130947. _getUnpackAlignement(): number;
  130948. /** @hidden */
  130949. _unpackFlipY(value: boolean): void;
  130950. /**
  130951. * Update a dynamic index buffer
  130952. * @param indexBuffer defines the target index buffer
  130953. * @param indices defines the data to update
  130954. * @param offset defines the offset in the target index buffer where update should start
  130955. */
  130956. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130957. /**
  130958. * Updates a dynamic vertex buffer.
  130959. * @param vertexBuffer the vertex buffer to update
  130960. * @param vertices the data used to update the vertex buffer
  130961. * @param byteOffset the byte offset of the data (optional)
  130962. * @param byteLength the byte length of the data (optional)
  130963. */
  130964. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130965. /** @hidden */
  130966. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130967. /** @hidden */
  130968. _bindTexture(channel: number, texture: InternalTexture): void;
  130969. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130970. /**
  130971. * 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
  130972. */
  130973. releaseEffects(): void;
  130974. displayLoadingUI(): void;
  130975. hideLoadingUI(): void;
  130976. /** @hidden */
  130977. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130978. /** @hidden */
  130979. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130980. /** @hidden */
  130981. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130982. /** @hidden */
  130983. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130984. }
  130985. }
  130986. declare module BABYLON {
  130987. /**
  130988. * @hidden
  130989. **/
  130990. export class _TimeToken {
  130991. _startTimeQuery: Nullable<WebGLQuery>;
  130992. _endTimeQuery: Nullable<WebGLQuery>;
  130993. _timeElapsedQuery: Nullable<WebGLQuery>;
  130994. _timeElapsedQueryEnded: boolean;
  130995. }
  130996. }
  130997. declare module BABYLON {
  130998. /** @hidden */
  130999. export class _OcclusionDataStorage {
  131000. /** @hidden */
  131001. occlusionInternalRetryCounter: number;
  131002. /** @hidden */
  131003. isOcclusionQueryInProgress: boolean;
  131004. /** @hidden */
  131005. isOccluded: boolean;
  131006. /** @hidden */
  131007. occlusionRetryCount: number;
  131008. /** @hidden */
  131009. occlusionType: number;
  131010. /** @hidden */
  131011. occlusionQueryAlgorithmType: number;
  131012. }
  131013. interface Engine {
  131014. /**
  131015. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131016. * @return the new query
  131017. */
  131018. createQuery(): WebGLQuery;
  131019. /**
  131020. * Delete and release a webGL query
  131021. * @param query defines the query to delete
  131022. * @return the current engine
  131023. */
  131024. deleteQuery(query: WebGLQuery): Engine;
  131025. /**
  131026. * Check if a given query has resolved and got its value
  131027. * @param query defines the query to check
  131028. * @returns true if the query got its value
  131029. */
  131030. isQueryResultAvailable(query: WebGLQuery): boolean;
  131031. /**
  131032. * Gets the value of a given query
  131033. * @param query defines the query to check
  131034. * @returns the value of the query
  131035. */
  131036. getQueryResult(query: WebGLQuery): number;
  131037. /**
  131038. * Initiates an occlusion query
  131039. * @param algorithmType defines the algorithm to use
  131040. * @param query defines the query to use
  131041. * @returns the current engine
  131042. * @see https://doc.babylonjs.com/features/occlusionquery
  131043. */
  131044. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  131045. /**
  131046. * Ends an occlusion query
  131047. * @see https://doc.babylonjs.com/features/occlusionquery
  131048. * @param algorithmType defines the algorithm to use
  131049. * @returns the current engine
  131050. */
  131051. endOcclusionQuery(algorithmType: number): Engine;
  131052. /**
  131053. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  131054. * Please note that only one query can be issued at a time
  131055. * @returns a time token used to track the time span
  131056. */
  131057. startTimeQuery(): Nullable<_TimeToken>;
  131058. /**
  131059. * Ends a time query
  131060. * @param token defines the token used to measure the time span
  131061. * @returns the time spent (in ns)
  131062. */
  131063. endTimeQuery(token: _TimeToken): int;
  131064. /** @hidden */
  131065. _currentNonTimestampToken: Nullable<_TimeToken>;
  131066. /** @hidden */
  131067. _createTimeQuery(): WebGLQuery;
  131068. /** @hidden */
  131069. _deleteTimeQuery(query: WebGLQuery): void;
  131070. /** @hidden */
  131071. _getGlAlgorithmType(algorithmType: number): number;
  131072. /** @hidden */
  131073. _getTimeQueryResult(query: WebGLQuery): any;
  131074. /** @hidden */
  131075. _getTimeQueryAvailability(query: WebGLQuery): any;
  131076. }
  131077. interface AbstractMesh {
  131078. /**
  131079. * Backing filed
  131080. * @hidden
  131081. */
  131082. __occlusionDataStorage: _OcclusionDataStorage;
  131083. /**
  131084. * Access property
  131085. * @hidden
  131086. */
  131087. _occlusionDataStorage: _OcclusionDataStorage;
  131088. /**
  131089. * 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.
  131090. * The default value is -1 which means don't break the query and wait till the result
  131091. * @see https://doc.babylonjs.com/features/occlusionquery
  131092. */
  131093. occlusionRetryCount: number;
  131094. /**
  131095. * 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:
  131096. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  131097. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  131098. * * 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.
  131099. * @see https://doc.babylonjs.com/features/occlusionquery
  131100. */
  131101. occlusionType: number;
  131102. /**
  131103. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  131104. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  131105. * * 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.
  131106. * @see https://doc.babylonjs.com/features/occlusionquery
  131107. */
  131108. occlusionQueryAlgorithmType: number;
  131109. /**
  131110. * 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
  131111. * @see https://doc.babylonjs.com/features/occlusionquery
  131112. */
  131113. isOccluded: boolean;
  131114. /**
  131115. * Flag to check the progress status of the query
  131116. * @see https://doc.babylonjs.com/features/occlusionquery
  131117. */
  131118. isOcclusionQueryInProgress: boolean;
  131119. }
  131120. }
  131121. declare module BABYLON {
  131122. /** @hidden */
  131123. export var _forceTransformFeedbackToBundle: boolean;
  131124. interface Engine {
  131125. /**
  131126. * Creates a webGL transform feedback object
  131127. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  131128. * @returns the webGL transform feedback object
  131129. */
  131130. createTransformFeedback(): WebGLTransformFeedback;
  131131. /**
  131132. * Delete a webGL transform feedback object
  131133. * @param value defines the webGL transform feedback object to delete
  131134. */
  131135. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  131136. /**
  131137. * Bind a webGL transform feedback object to the webgl context
  131138. * @param value defines the webGL transform feedback object to bind
  131139. */
  131140. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  131141. /**
  131142. * Begins a transform feedback operation
  131143. * @param usePoints defines if points or triangles must be used
  131144. */
  131145. beginTransformFeedback(usePoints: boolean): void;
  131146. /**
  131147. * Ends a transform feedback operation
  131148. */
  131149. endTransformFeedback(): void;
  131150. /**
  131151. * Specify the varyings to use with transform feedback
  131152. * @param program defines the associated webGL program
  131153. * @param value defines the list of strings representing the varying names
  131154. */
  131155. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  131156. /**
  131157. * Bind a webGL buffer for a transform feedback operation
  131158. * @param value defines the webGL buffer to bind
  131159. */
  131160. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  131161. }
  131162. }
  131163. declare module BABYLON {
  131164. /**
  131165. * Class used to define an additional view for the engine
  131166. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131167. */
  131168. export class EngineView {
  131169. /** Defines the canvas where to render the view */
  131170. target: HTMLCanvasElement;
  131171. /** Defines an optional camera used to render the view (will use active camera else) */
  131172. camera?: Camera;
  131173. }
  131174. interface Engine {
  131175. /**
  131176. * Gets or sets the HTML element to use for attaching events
  131177. */
  131178. inputElement: Nullable<HTMLElement>;
  131179. /**
  131180. * Gets the current engine view
  131181. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131182. */
  131183. activeView: Nullable<EngineView>;
  131184. /** Gets or sets the list of views */
  131185. views: EngineView[];
  131186. /**
  131187. * Register a new child canvas
  131188. * @param canvas defines the canvas to register
  131189. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131190. * @returns the associated view
  131191. */
  131192. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131193. /**
  131194. * Remove a registered child canvas
  131195. * @param canvas defines the canvas to remove
  131196. * @returns the current engine
  131197. */
  131198. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131199. }
  131200. }
  131201. declare module BABYLON {
  131202. interface Engine {
  131203. /** @hidden */
  131204. _excludedCompressedTextures: string[];
  131205. /** @hidden */
  131206. _textureFormatInUse: string;
  131207. /**
  131208. * Gets the list of texture formats supported
  131209. */
  131210. readonly texturesSupported: Array<string>;
  131211. /**
  131212. * Gets the texture format in use
  131213. */
  131214. readonly textureFormatInUse: Nullable<string>;
  131215. /**
  131216. * Set the compressed texture extensions or file names to skip.
  131217. *
  131218. * @param skippedFiles defines the list of those texture files you want to skip
  131219. * Example: [".dds", ".env", "myfile.png"]
  131220. */
  131221. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131222. /**
  131223. * Set the compressed texture format to use, based on the formats you have, and the formats
  131224. * supported by the hardware / browser.
  131225. *
  131226. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131227. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131228. * to API arguments needed to compressed textures. This puts the burden on the container
  131229. * generator to house the arcane code for determining these for current & future formats.
  131230. *
  131231. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131232. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131233. *
  131234. * Note: The result of this call is not taken into account when a texture is base64.
  131235. *
  131236. * @param formatsAvailable defines the list of those format families you have created
  131237. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131238. *
  131239. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131240. * @returns The extension selected.
  131241. */
  131242. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131243. }
  131244. }
  131245. declare module BABYLON {
  131246. /**
  131247. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131248. */
  131249. export interface CubeMapInfo {
  131250. /**
  131251. * The pixel array for the front face.
  131252. * This is stored in format, left to right, up to down format.
  131253. */
  131254. front: Nullable<ArrayBufferView>;
  131255. /**
  131256. * The pixel array for the back face.
  131257. * This is stored in format, left to right, up to down format.
  131258. */
  131259. back: Nullable<ArrayBufferView>;
  131260. /**
  131261. * The pixel array for the left face.
  131262. * This is stored in format, left to right, up to down format.
  131263. */
  131264. left: Nullable<ArrayBufferView>;
  131265. /**
  131266. * The pixel array for the right face.
  131267. * This is stored in format, left to right, up to down format.
  131268. */
  131269. right: Nullable<ArrayBufferView>;
  131270. /**
  131271. * The pixel array for the up face.
  131272. * This is stored in format, left to right, up to down format.
  131273. */
  131274. up: Nullable<ArrayBufferView>;
  131275. /**
  131276. * The pixel array for the down face.
  131277. * This is stored in format, left to right, up to down format.
  131278. */
  131279. down: Nullable<ArrayBufferView>;
  131280. /**
  131281. * The size of the cubemap stored.
  131282. *
  131283. * Each faces will be size * size pixels.
  131284. */
  131285. size: number;
  131286. /**
  131287. * The format of the texture.
  131288. *
  131289. * RGBA, RGB.
  131290. */
  131291. format: number;
  131292. /**
  131293. * The type of the texture data.
  131294. *
  131295. * UNSIGNED_INT, FLOAT.
  131296. */
  131297. type: number;
  131298. /**
  131299. * Specifies whether the texture is in gamma space.
  131300. */
  131301. gammaSpace: boolean;
  131302. }
  131303. /**
  131304. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131305. */
  131306. export class PanoramaToCubeMapTools {
  131307. private static FACE_LEFT;
  131308. private static FACE_RIGHT;
  131309. private static FACE_FRONT;
  131310. private static FACE_BACK;
  131311. private static FACE_DOWN;
  131312. private static FACE_UP;
  131313. /**
  131314. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131315. *
  131316. * @param float32Array The source data.
  131317. * @param inputWidth The width of the input panorama.
  131318. * @param inputHeight The height of the input panorama.
  131319. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131320. * @return The cubemap data
  131321. */
  131322. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131323. private static CreateCubemapTexture;
  131324. private static CalcProjectionSpherical;
  131325. }
  131326. }
  131327. declare module BABYLON {
  131328. /**
  131329. * Helper class dealing with the extraction of spherical polynomial dataArray
  131330. * from a cube map.
  131331. */
  131332. export class CubeMapToSphericalPolynomialTools {
  131333. private static FileFaces;
  131334. /**
  131335. * Converts a texture to the according Spherical Polynomial data.
  131336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131337. *
  131338. * @param texture The texture to extract the information from.
  131339. * @return The Spherical Polynomial data.
  131340. */
  131341. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131342. /**
  131343. * Converts a cubemap to the according Spherical Polynomial data.
  131344. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131345. *
  131346. * @param cubeInfo The Cube map to extract the information from.
  131347. * @return The Spherical Polynomial data.
  131348. */
  131349. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131350. }
  131351. }
  131352. declare module BABYLON {
  131353. interface BaseTexture {
  131354. /**
  131355. * Get the polynomial representation of the texture data.
  131356. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131357. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131358. */
  131359. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131360. }
  131361. }
  131362. declare module BABYLON {
  131363. /** @hidden */
  131364. export var rgbdEncodePixelShader: {
  131365. name: string;
  131366. shader: string;
  131367. };
  131368. }
  131369. declare module BABYLON {
  131370. /** @hidden */
  131371. export var rgbdDecodePixelShader: {
  131372. name: string;
  131373. shader: string;
  131374. };
  131375. }
  131376. declare module BABYLON {
  131377. /**
  131378. * Raw texture data and descriptor sufficient for WebGL texture upload
  131379. */
  131380. export interface EnvironmentTextureInfo {
  131381. /**
  131382. * Version of the environment map
  131383. */
  131384. version: number;
  131385. /**
  131386. * Width of image
  131387. */
  131388. width: number;
  131389. /**
  131390. * Irradiance information stored in the file.
  131391. */
  131392. irradiance: any;
  131393. /**
  131394. * Specular information stored in the file.
  131395. */
  131396. specular: any;
  131397. }
  131398. /**
  131399. * Defines One Image in the file. It requires only the position in the file
  131400. * as well as the length.
  131401. */
  131402. interface BufferImageData {
  131403. /**
  131404. * Length of the image data.
  131405. */
  131406. length: number;
  131407. /**
  131408. * Position of the data from the null terminator delimiting the end of the JSON.
  131409. */
  131410. position: number;
  131411. }
  131412. /**
  131413. * Defines the specular data enclosed in the file.
  131414. * This corresponds to the version 1 of the data.
  131415. */
  131416. export interface EnvironmentTextureSpecularInfoV1 {
  131417. /**
  131418. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131419. */
  131420. specularDataPosition?: number;
  131421. /**
  131422. * This contains all the images data needed to reconstruct the cubemap.
  131423. */
  131424. mipmaps: Array<BufferImageData>;
  131425. /**
  131426. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131427. */
  131428. lodGenerationScale: number;
  131429. }
  131430. /**
  131431. * Sets of helpers addressing the serialization and deserialization of environment texture
  131432. * stored in a BabylonJS env file.
  131433. * Those files are usually stored as .env files.
  131434. */
  131435. export class EnvironmentTextureTools {
  131436. /**
  131437. * Magic number identifying the env file.
  131438. */
  131439. private static _MagicBytes;
  131440. /**
  131441. * Gets the environment info from an env file.
  131442. * @param data The array buffer containing the .env bytes.
  131443. * @returns the environment file info (the json header) if successfully parsed.
  131444. */
  131445. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131446. /**
  131447. * Creates an environment texture from a loaded cube texture.
  131448. * @param texture defines the cube texture to convert in env file
  131449. * @return a promise containing the environment data if succesfull.
  131450. */
  131451. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131452. /**
  131453. * Creates a JSON representation of the spherical data.
  131454. * @param texture defines the texture containing the polynomials
  131455. * @return the JSON representation of the spherical info
  131456. */
  131457. private static _CreateEnvTextureIrradiance;
  131458. /**
  131459. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131460. * @param data the image data
  131461. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131462. * @return the views described by info providing access to the underlying buffer
  131463. */
  131464. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131465. /**
  131466. * Uploads the texture info contained in the env file to the GPU.
  131467. * @param texture defines the internal texture to upload to
  131468. * @param data defines the data to load
  131469. * @param info defines the texture info retrieved through the GetEnvInfo method
  131470. * @returns a promise
  131471. */
  131472. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131473. private static _OnImageReadyAsync;
  131474. /**
  131475. * Uploads the levels of image data to the GPU.
  131476. * @param texture defines the internal texture to upload to
  131477. * @param imageData defines the array buffer views of image data [mipmap][face]
  131478. * @returns a promise
  131479. */
  131480. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131481. /**
  131482. * Uploads spherical polynomials information to the texture.
  131483. * @param texture defines the texture we are trying to upload the information to
  131484. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131485. */
  131486. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131487. /** @hidden */
  131488. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131489. }
  131490. }
  131491. declare module BABYLON {
  131492. /**
  131493. * Class used to inline functions in shader code
  131494. */
  131495. export class ShaderCodeInliner {
  131496. private static readonly _RegexpFindFunctionNameAndType;
  131497. private _sourceCode;
  131498. private _functionDescr;
  131499. private _numMaxIterations;
  131500. /** Gets or sets the token used to mark the functions to inline */
  131501. inlineToken: string;
  131502. /** Gets or sets the debug mode */
  131503. debug: boolean;
  131504. /** Gets the code after the inlining process */
  131505. get code(): string;
  131506. /**
  131507. * Initializes the inliner
  131508. * @param sourceCode shader code source to inline
  131509. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131510. */
  131511. constructor(sourceCode: string, numMaxIterations?: number);
  131512. /**
  131513. * Start the processing of the shader code
  131514. */
  131515. processCode(): void;
  131516. private _collectFunctions;
  131517. private _processInlining;
  131518. private _extractBetweenMarkers;
  131519. private _skipWhitespaces;
  131520. private _removeComments;
  131521. private _replaceFunctionCallsByCode;
  131522. private _findBackward;
  131523. private _escapeRegExp;
  131524. private _replaceNames;
  131525. }
  131526. }
  131527. declare module BABYLON {
  131528. /**
  131529. * Container for accessors for natively-stored mesh data buffers.
  131530. */
  131531. class NativeDataBuffer extends DataBuffer {
  131532. /**
  131533. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131534. */
  131535. nativeIndexBuffer?: any;
  131536. /**
  131537. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131538. */
  131539. nativeVertexBuffer?: any;
  131540. }
  131541. /** @hidden */
  131542. class NativeTexture extends InternalTexture {
  131543. getInternalTexture(): InternalTexture;
  131544. getViewCount(): number;
  131545. }
  131546. /** @hidden */
  131547. export class NativeEngine extends Engine {
  131548. private readonly _native;
  131549. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131550. private readonly INVALID_HANDLE;
  131551. private _boundBuffersVertexArray;
  131552. getHardwareScalingLevel(): number;
  131553. constructor();
  131554. dispose(): void;
  131555. /**
  131556. * Can be used to override the current requestAnimationFrame requester.
  131557. * @hidden
  131558. */
  131559. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131560. /**
  131561. * Override default engine behavior.
  131562. * @param color
  131563. * @param backBuffer
  131564. * @param depth
  131565. * @param stencil
  131566. */
  131567. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131568. /**
  131569. * Gets host document
  131570. * @returns the host document object
  131571. */
  131572. getHostDocument(): Nullable<Document>;
  131573. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131574. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131575. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131576. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  131577. [key: string]: VertexBuffer;
  131578. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131579. bindBuffers(vertexBuffers: {
  131580. [key: string]: VertexBuffer;
  131581. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131582. recordVertexArrayObject(vertexBuffers: {
  131583. [key: string]: VertexBuffer;
  131584. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131585. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131586. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131587. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131588. /**
  131589. * Draw a list of indexed primitives
  131590. * @param fillMode defines the primitive to use
  131591. * @param indexStart defines the starting index
  131592. * @param indexCount defines the number of index to draw
  131593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131594. */
  131595. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131596. /**
  131597. * Draw a list of unindexed primitives
  131598. * @param fillMode defines the primitive to use
  131599. * @param verticesStart defines the index of first vertex to draw
  131600. * @param verticesCount defines the count of vertices to draw
  131601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131602. */
  131603. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131604. createPipelineContext(): IPipelineContext;
  131605. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131606. /** @hidden */
  131607. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131608. /** @hidden */
  131609. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131610. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131611. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131612. protected _setProgram(program: WebGLProgram): void;
  131613. _releaseEffect(effect: Effect): void;
  131614. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131615. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131616. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131617. bindSamplers(effect: Effect): void;
  131618. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131619. getRenderWidth(useScreen?: boolean): number;
  131620. getRenderHeight(useScreen?: boolean): number;
  131621. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131622. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131623. /**
  131624. * Set the z offset to apply to current rendering
  131625. * @param value defines the offset to apply
  131626. */
  131627. setZOffset(value: number): void;
  131628. /**
  131629. * Gets the current value of the zOffset
  131630. * @returns the current zOffset state
  131631. */
  131632. getZOffset(): number;
  131633. /**
  131634. * Enable or disable depth buffering
  131635. * @param enable defines the state to set
  131636. */
  131637. setDepthBuffer(enable: boolean): void;
  131638. /**
  131639. * Gets a boolean indicating if depth writing is enabled
  131640. * @returns the current depth writing state
  131641. */
  131642. getDepthWrite(): boolean;
  131643. /**
  131644. * Enable or disable depth writing
  131645. * @param enable defines the state to set
  131646. */
  131647. setDepthWrite(enable: boolean): void;
  131648. /**
  131649. * Enable or disable color writing
  131650. * @param enable defines the state to set
  131651. */
  131652. setColorWrite(enable: boolean): void;
  131653. /**
  131654. * Gets a boolean indicating if color writing is enabled
  131655. * @returns the current color writing state
  131656. */
  131657. getColorWrite(): boolean;
  131658. /**
  131659. * Sets alpha constants used by some alpha blending modes
  131660. * @param r defines the red component
  131661. * @param g defines the green component
  131662. * @param b defines the blue component
  131663. * @param a defines the alpha component
  131664. */
  131665. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131666. /**
  131667. * Sets the current alpha mode
  131668. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131669. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131670. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131671. */
  131672. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131673. /**
  131674. * Gets the current alpha mode
  131675. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131676. * @returns the current alpha mode
  131677. */
  131678. getAlphaMode(): number;
  131679. setInt(uniform: WebGLUniformLocation, int: number): void;
  131680. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131681. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131682. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131683. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131684. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131685. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131686. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131687. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131688. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131689. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131690. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131691. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131692. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131693. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131694. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131695. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131696. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131697. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131698. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131699. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131700. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131701. wipeCaches(bruteForce?: boolean): void;
  131702. _createTexture(): WebGLTexture;
  131703. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131704. /**
  131705. * Usually called from Texture.ts.
  131706. * Passed information to create a WebGLTexture
  131707. * @param url defines a value which contains one of the following:
  131708. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131709. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131710. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131712. * @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)
  131713. * @param scene needed for loading to the correct scene
  131714. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131715. * @param onLoad optional callback to be called upon successful completion
  131716. * @param onError optional callback to be called upon failure
  131717. * @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
  131718. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131719. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131720. * @param forcedExtension defines the extension to use to pick the right loader
  131721. * @param mimeType defines an optional mime type
  131722. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131723. */
  131724. 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;
  131725. /**
  131726. * Creates a cube texture
  131727. * @param rootUrl defines the url where the files to load is located
  131728. * @param scene defines the current scene
  131729. * @param files defines the list of files to load (1 per face)
  131730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131731. * @param onLoad defines an optional callback raised when the texture is loaded
  131732. * @param onError defines an optional callback raised if there is an issue to load the texture
  131733. * @param format defines the format of the data
  131734. * @param forcedExtension defines the extension to use to pick the right loader
  131735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131738. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131739. * @returns the cube texture as an InternalTexture
  131740. */
  131741. 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;
  131742. private _getSamplingFilter;
  131743. private static _GetNativeTextureFormat;
  131744. createRenderTargetTexture(size: number | {
  131745. width: number;
  131746. height: number;
  131747. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131748. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131749. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131750. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131751. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131752. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131753. /**
  131754. * Updates a dynamic vertex buffer.
  131755. * @param vertexBuffer the vertex buffer to update
  131756. * @param data the data used to update the vertex buffer
  131757. * @param byteOffset the byte offset of the data (optional)
  131758. * @param byteLength the byte length of the data (optional)
  131759. */
  131760. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131761. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131762. private _updateAnisotropicLevel;
  131763. private _getAddressMode;
  131764. /** @hidden */
  131765. _bindTexture(channel: number, texture: InternalTexture): void;
  131766. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131767. releaseEffects(): void;
  131768. /** @hidden */
  131769. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131770. /** @hidden */
  131771. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131772. /** @hidden */
  131773. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131774. /** @hidden */
  131775. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131776. }
  131777. }
  131778. declare module BABYLON {
  131779. /**
  131780. * Gather the list of clipboard event types as constants.
  131781. */
  131782. export class ClipboardEventTypes {
  131783. /**
  131784. * The clipboard event is fired when a copy command is active (pressed).
  131785. */
  131786. static readonly COPY: number;
  131787. /**
  131788. * The clipboard event is fired when a cut command is active (pressed).
  131789. */
  131790. static readonly CUT: number;
  131791. /**
  131792. * The clipboard event is fired when a paste command is active (pressed).
  131793. */
  131794. static readonly PASTE: number;
  131795. }
  131796. /**
  131797. * This class is used to store clipboard related info for the onClipboardObservable event.
  131798. */
  131799. export class ClipboardInfo {
  131800. /**
  131801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131802. */
  131803. type: number;
  131804. /**
  131805. * Defines the related dom event
  131806. */
  131807. event: ClipboardEvent;
  131808. /**
  131809. *Creates an instance of ClipboardInfo.
  131810. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131811. * @param event Defines the related dom event
  131812. */
  131813. constructor(
  131814. /**
  131815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131816. */
  131817. type: number,
  131818. /**
  131819. * Defines the related dom event
  131820. */
  131821. event: ClipboardEvent);
  131822. /**
  131823. * Get the clipboard event's type from the keycode.
  131824. * @param keyCode Defines the keyCode for the current keyboard event.
  131825. * @return {number}
  131826. */
  131827. static GetTypeFromCharacter(keyCode: number): number;
  131828. }
  131829. }
  131830. declare module BABYLON {
  131831. /**
  131832. * Google Daydream controller
  131833. */
  131834. export class DaydreamController extends WebVRController {
  131835. /**
  131836. * Base Url for the controller model.
  131837. */
  131838. static MODEL_BASE_URL: string;
  131839. /**
  131840. * File name for the controller model.
  131841. */
  131842. static MODEL_FILENAME: string;
  131843. /**
  131844. * Gamepad Id prefix used to identify Daydream Controller.
  131845. */
  131846. static readonly GAMEPAD_ID_PREFIX: string;
  131847. /**
  131848. * Creates a new DaydreamController from a gamepad
  131849. * @param vrGamepad the gamepad that the controller should be created from
  131850. */
  131851. constructor(vrGamepad: any);
  131852. /**
  131853. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131854. * @param scene scene in which to add meshes
  131855. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131856. */
  131857. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131858. /**
  131859. * Called once for each button that changed state since the last frame
  131860. * @param buttonIdx Which button index changed
  131861. * @param state New state of the button
  131862. * @param changes Which properties on the state changed since last frame
  131863. */
  131864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131865. }
  131866. }
  131867. declare module BABYLON {
  131868. /**
  131869. * Gear VR Controller
  131870. */
  131871. export class GearVRController extends WebVRController {
  131872. /**
  131873. * Base Url for the controller model.
  131874. */
  131875. static MODEL_BASE_URL: string;
  131876. /**
  131877. * File name for the controller model.
  131878. */
  131879. static MODEL_FILENAME: string;
  131880. /**
  131881. * Gamepad Id prefix used to identify this controller.
  131882. */
  131883. static readonly GAMEPAD_ID_PREFIX: string;
  131884. private readonly _buttonIndexToObservableNameMap;
  131885. /**
  131886. * Creates a new GearVRController from a gamepad
  131887. * @param vrGamepad the gamepad that the controller should be created from
  131888. */
  131889. constructor(vrGamepad: any);
  131890. /**
  131891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131892. * @param scene scene in which to add meshes
  131893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131894. */
  131895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131896. /**
  131897. * Called once for each button that changed state since the last frame
  131898. * @param buttonIdx Which button index changed
  131899. * @param state New state of the button
  131900. * @param changes Which properties on the state changed since last frame
  131901. */
  131902. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131903. }
  131904. }
  131905. declare module BABYLON {
  131906. /**
  131907. * Generic Controller
  131908. */
  131909. export class GenericController extends WebVRController {
  131910. /**
  131911. * Base Url for the controller model.
  131912. */
  131913. static readonly MODEL_BASE_URL: string;
  131914. /**
  131915. * File name for the controller model.
  131916. */
  131917. static readonly MODEL_FILENAME: string;
  131918. /**
  131919. * Creates a new GenericController from a gamepad
  131920. * @param vrGamepad the gamepad that the controller should be created from
  131921. */
  131922. constructor(vrGamepad: any);
  131923. /**
  131924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131925. * @param scene scene in which to add meshes
  131926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131927. */
  131928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131929. /**
  131930. * Called once for each button that changed state since the last frame
  131931. * @param buttonIdx Which button index changed
  131932. * @param state New state of the button
  131933. * @param changes Which properties on the state changed since last frame
  131934. */
  131935. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131936. }
  131937. }
  131938. declare module BABYLON {
  131939. /**
  131940. * Oculus Touch Controller
  131941. */
  131942. export class OculusTouchController extends WebVRController {
  131943. /**
  131944. * Base Url for the controller model.
  131945. */
  131946. static MODEL_BASE_URL: string;
  131947. /**
  131948. * File name for the left controller model.
  131949. */
  131950. static MODEL_LEFT_FILENAME: string;
  131951. /**
  131952. * File name for the right controller model.
  131953. */
  131954. static MODEL_RIGHT_FILENAME: string;
  131955. /**
  131956. * Base Url for the Quest controller model.
  131957. */
  131958. static QUEST_MODEL_BASE_URL: string;
  131959. /**
  131960. * @hidden
  131961. * If the controllers are running on a device that needs the updated Quest controller models
  131962. */
  131963. static _IsQuest: boolean;
  131964. /**
  131965. * Fired when the secondary trigger on this controller is modified
  131966. */
  131967. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131968. /**
  131969. * Fired when the thumb rest on this controller is modified
  131970. */
  131971. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131972. /**
  131973. * Creates a new OculusTouchController from a gamepad
  131974. * @param vrGamepad the gamepad that the controller should be created from
  131975. */
  131976. constructor(vrGamepad: any);
  131977. /**
  131978. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131979. * @param scene scene in which to add meshes
  131980. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131981. */
  131982. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131983. /**
  131984. * Fired when the A button on this controller is modified
  131985. */
  131986. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131987. /**
  131988. * Fired when the B button on this controller is modified
  131989. */
  131990. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131991. /**
  131992. * Fired when the X button on this controller is modified
  131993. */
  131994. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131995. /**
  131996. * Fired when the Y button on this controller is modified
  131997. */
  131998. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131999. /**
  132000. * Called once for each button that changed state since the last frame
  132001. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132002. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132003. * 2) secondary trigger (same)
  132004. * 3) A (right) X (left), touch, pressed = value
  132005. * 4) B / Y
  132006. * 5) thumb rest
  132007. * @param buttonIdx Which button index changed
  132008. * @param state New state of the button
  132009. * @param changes Which properties on the state changed since last frame
  132010. */
  132011. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * Vive Controller
  132017. */
  132018. export class ViveController extends WebVRController {
  132019. /**
  132020. * Base Url for the controller model.
  132021. */
  132022. static MODEL_BASE_URL: string;
  132023. /**
  132024. * File name for the controller model.
  132025. */
  132026. static MODEL_FILENAME: string;
  132027. /**
  132028. * Creates a new ViveController from a gamepad
  132029. * @param vrGamepad the gamepad that the controller should be created from
  132030. */
  132031. constructor(vrGamepad: any);
  132032. /**
  132033. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132034. * @param scene scene in which to add meshes
  132035. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132036. */
  132037. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132038. /**
  132039. * Fired when the left button on this controller is modified
  132040. */
  132041. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132042. /**
  132043. * Fired when the right button on this controller is modified
  132044. */
  132045. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132046. /**
  132047. * Fired when the menu button on this controller is modified
  132048. */
  132049. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132050. /**
  132051. * Called once for each button that changed state since the last frame
  132052. * Vive mapping:
  132053. * 0: touchpad
  132054. * 1: trigger
  132055. * 2: left AND right buttons
  132056. * 3: menu button
  132057. * @param buttonIdx Which button index changed
  132058. * @param state New state of the button
  132059. * @param changes Which properties on the state changed since last frame
  132060. */
  132061. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132062. }
  132063. }
  132064. declare module BABYLON {
  132065. /**
  132066. * Defines the WindowsMotionController object that the state of the windows motion controller
  132067. */
  132068. export class WindowsMotionController extends WebVRController {
  132069. /**
  132070. * The base url used to load the left and right controller models
  132071. */
  132072. static MODEL_BASE_URL: string;
  132073. /**
  132074. * The name of the left controller model file
  132075. */
  132076. static MODEL_LEFT_FILENAME: string;
  132077. /**
  132078. * The name of the right controller model file
  132079. */
  132080. static MODEL_RIGHT_FILENAME: string;
  132081. /**
  132082. * The controller name prefix for this controller type
  132083. */
  132084. static readonly GAMEPAD_ID_PREFIX: string;
  132085. /**
  132086. * The controller id pattern for this controller type
  132087. */
  132088. private static readonly GAMEPAD_ID_PATTERN;
  132089. private _loadedMeshInfo;
  132090. protected readonly _mapping: {
  132091. buttons: string[];
  132092. buttonMeshNames: {
  132093. trigger: string;
  132094. menu: string;
  132095. grip: string;
  132096. thumbstick: string;
  132097. trackpad: string;
  132098. };
  132099. buttonObservableNames: {
  132100. trigger: string;
  132101. menu: string;
  132102. grip: string;
  132103. thumbstick: string;
  132104. trackpad: string;
  132105. };
  132106. axisMeshNames: string[];
  132107. pointingPoseMeshName: string;
  132108. };
  132109. /**
  132110. * Fired when the trackpad on this controller is clicked
  132111. */
  132112. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132113. /**
  132114. * Fired when the trackpad on this controller is modified
  132115. */
  132116. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132117. /**
  132118. * The current x and y values of this controller's trackpad
  132119. */
  132120. trackpad: StickValues;
  132121. /**
  132122. * Creates a new WindowsMotionController from a gamepad
  132123. * @param vrGamepad the gamepad that the controller should be created from
  132124. */
  132125. constructor(vrGamepad: any);
  132126. /**
  132127. * Fired when the trigger on this controller is modified
  132128. */
  132129. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132130. /**
  132131. * Fired when the menu button on this controller is modified
  132132. */
  132133. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132134. /**
  132135. * Fired when the grip button on this controller is modified
  132136. */
  132137. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132138. /**
  132139. * Fired when the thumbstick button on this controller is modified
  132140. */
  132141. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132142. /**
  132143. * Fired when the touchpad button on this controller is modified
  132144. */
  132145. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132146. /**
  132147. * Fired when the touchpad values on this controller are modified
  132148. */
  132149. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  132150. protected _updateTrackpad(): void;
  132151. /**
  132152. * Called once per frame by the engine.
  132153. */
  132154. update(): void;
  132155. /**
  132156. * Called once for each button that changed state since the last frame
  132157. * @param buttonIdx Which button index changed
  132158. * @param state New state of the button
  132159. * @param changes Which properties on the state changed since last frame
  132160. */
  132161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132162. /**
  132163. * Moves the buttons on the controller mesh based on their current state
  132164. * @param buttonName the name of the button to move
  132165. * @param buttonValue the value of the button which determines the buttons new position
  132166. */
  132167. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  132168. /**
  132169. * Moves the axis on the controller mesh based on its current state
  132170. * @param axis the index of the axis
  132171. * @param axisValue the value of the axis which determines the meshes new position
  132172. * @hidden
  132173. */
  132174. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  132175. /**
  132176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132177. * @param scene scene in which to add meshes
  132178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132179. */
  132180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  132181. /**
  132182. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132183. * can be transformed by button presses and axes values, based on this._mapping.
  132184. *
  132185. * @param scene scene in which the meshes exist
  132186. * @param meshes list of meshes that make up the controller model to process
  132187. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132188. */
  132189. private processModel;
  132190. private createMeshInfo;
  132191. /**
  132192. * Gets the ray of the controller in the direction the controller is pointing
  132193. * @param length the length the resulting ray should be
  132194. * @returns a ray in the direction the controller is pointing
  132195. */
  132196. getForwardRay(length?: number): Ray;
  132197. /**
  132198. * Disposes of the controller
  132199. */
  132200. dispose(): void;
  132201. }
  132202. /**
  132203. * This class represents a new windows motion controller in XR.
  132204. */
  132205. export class XRWindowsMotionController extends WindowsMotionController {
  132206. /**
  132207. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132208. */
  132209. protected readonly _mapping: {
  132210. buttons: string[];
  132211. buttonMeshNames: {
  132212. trigger: string;
  132213. menu: string;
  132214. grip: string;
  132215. thumbstick: string;
  132216. trackpad: string;
  132217. };
  132218. buttonObservableNames: {
  132219. trigger: string;
  132220. menu: string;
  132221. grip: string;
  132222. thumbstick: string;
  132223. trackpad: string;
  132224. };
  132225. axisMeshNames: string[];
  132226. pointingPoseMeshName: string;
  132227. };
  132228. /**
  132229. * Construct a new XR-Based windows motion controller
  132230. *
  132231. * @param gamepadInfo the gamepad object from the browser
  132232. */
  132233. constructor(gamepadInfo: any);
  132234. /**
  132235. * holds the thumbstick values (X,Y)
  132236. */
  132237. thumbstickValues: StickValues;
  132238. /**
  132239. * Fired when the thumbstick on this controller is clicked
  132240. */
  132241. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132242. /**
  132243. * Fired when the thumbstick on this controller is modified
  132244. */
  132245. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132246. /**
  132247. * Fired when the touchpad button on this controller is modified
  132248. */
  132249. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132250. /**
  132251. * Fired when the touchpad values on this controller are modified
  132252. */
  132253. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132254. /**
  132255. * Fired when the thumbstick button on this controller is modified
  132256. * here to prevent breaking changes
  132257. */
  132258. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132259. /**
  132260. * updating the thumbstick(!) and not the trackpad.
  132261. * This is named this way due to the difference between WebVR and XR and to avoid
  132262. * changing the parent class.
  132263. */
  132264. protected _updateTrackpad(): void;
  132265. /**
  132266. * Disposes the class with joy
  132267. */
  132268. dispose(): void;
  132269. }
  132270. }
  132271. declare module BABYLON {
  132272. /**
  132273. * Class containing static functions to help procedurally build meshes
  132274. */
  132275. export class PolyhedronBuilder {
  132276. /**
  132277. * Creates a polyhedron mesh
  132278. * * 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
  132279. * * The parameter `size` (positive float, default 1) sets the polygon size
  132280. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132281. * * 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`
  132282. * * 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
  132283. * * 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)`)
  132284. * * 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
  132285. * * 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
  132286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132289. * @param name defines the name of the mesh
  132290. * @param options defines the options used to create the mesh
  132291. * @param scene defines the hosting scene
  132292. * @returns the polyhedron mesh
  132293. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132294. */
  132295. static CreatePolyhedron(name: string, options: {
  132296. type?: number;
  132297. size?: number;
  132298. sizeX?: number;
  132299. sizeY?: number;
  132300. sizeZ?: number;
  132301. custom?: any;
  132302. faceUV?: Vector4[];
  132303. faceColors?: Color4[];
  132304. flat?: boolean;
  132305. updatable?: boolean;
  132306. sideOrientation?: number;
  132307. frontUVs?: Vector4;
  132308. backUVs?: Vector4;
  132309. }, scene?: Nullable<Scene>): Mesh;
  132310. }
  132311. }
  132312. declare module BABYLON {
  132313. /**
  132314. * Gizmo that enables scaling a mesh along 3 axis
  132315. */
  132316. export class ScaleGizmo extends Gizmo {
  132317. /**
  132318. * Internal gizmo used for interactions on the x axis
  132319. */
  132320. xGizmo: AxisScaleGizmo;
  132321. /**
  132322. * Internal gizmo used for interactions on the y axis
  132323. */
  132324. yGizmo: AxisScaleGizmo;
  132325. /**
  132326. * Internal gizmo used for interactions on the z axis
  132327. */
  132328. zGizmo: AxisScaleGizmo;
  132329. /**
  132330. * Internal gizmo used to scale all axis equally
  132331. */
  132332. uniformScaleGizmo: AxisScaleGizmo;
  132333. private _meshAttached;
  132334. private _nodeAttached;
  132335. private _updateGizmoRotationToMatchAttachedMesh;
  132336. private _snapDistance;
  132337. private _scaleRatio;
  132338. private _uniformScalingMesh;
  132339. private _octahedron;
  132340. private _sensitivity;
  132341. /** Fires an event when any of it's sub gizmos are dragged */
  132342. onDragStartObservable: Observable<unknown>;
  132343. /** Fires an event when any of it's sub gizmos are released from dragging */
  132344. onDragEndObservable: Observable<unknown>;
  132345. get attachedMesh(): Nullable<AbstractMesh>;
  132346. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132347. get attachedNode(): Nullable<Node>;
  132348. set attachedNode(node: Nullable<Node>);
  132349. /**
  132350. * Creates a ScaleGizmo
  132351. * @param gizmoLayer The utility layer the gizmo will be added to
  132352. * @param thickness display gizmo axis thickness
  132353. */
  132354. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132355. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132356. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132357. /**
  132358. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132359. */
  132360. set snapDistance(value: number);
  132361. get snapDistance(): number;
  132362. /**
  132363. * Ratio for the scale of the gizmo (Default: 1)
  132364. */
  132365. set scaleRatio(value: number);
  132366. get scaleRatio(): number;
  132367. /**
  132368. * Sensitivity factor for dragging (Default: 1)
  132369. */
  132370. set sensitivity(value: number);
  132371. get sensitivity(): number;
  132372. /**
  132373. * Disposes of the gizmo
  132374. */
  132375. dispose(): void;
  132376. }
  132377. }
  132378. declare module BABYLON {
  132379. /**
  132380. * Single axis scale gizmo
  132381. */
  132382. export class AxisScaleGizmo extends Gizmo {
  132383. /**
  132384. * Drag behavior responsible for the gizmos dragging interactions
  132385. */
  132386. dragBehavior: PointerDragBehavior;
  132387. private _pointerObserver;
  132388. /**
  132389. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132390. */
  132391. snapDistance: number;
  132392. /**
  132393. * Event that fires each time the gizmo snaps to a new location.
  132394. * * snapDistance is the the change in distance
  132395. */
  132396. onSnapObservable: Observable<{
  132397. snapDistance: number;
  132398. }>;
  132399. /**
  132400. * If the scaling operation should be done on all axis (default: false)
  132401. */
  132402. uniformScaling: boolean;
  132403. /**
  132404. * Custom sensitivity value for the drag strength
  132405. */
  132406. sensitivity: number;
  132407. private _isEnabled;
  132408. private _parent;
  132409. private _arrow;
  132410. private _coloredMaterial;
  132411. private _hoverMaterial;
  132412. /**
  132413. * Creates an AxisScaleGizmo
  132414. * @param gizmoLayer The utility layer the gizmo will be added to
  132415. * @param dragAxis The axis which the gizmo will be able to scale on
  132416. * @param color The color of the gizmo
  132417. * @param thickness display gizmo axis thickness
  132418. */
  132419. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132420. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132421. /**
  132422. * If the gizmo is enabled
  132423. */
  132424. set isEnabled(value: boolean);
  132425. get isEnabled(): boolean;
  132426. /**
  132427. * Disposes of the gizmo
  132428. */
  132429. dispose(): void;
  132430. /**
  132431. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132432. * @param mesh The mesh to replace the default mesh of the gizmo
  132433. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132434. */
  132435. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132436. }
  132437. }
  132438. declare module BABYLON {
  132439. /**
  132440. * Bounding box gizmo
  132441. */
  132442. export class BoundingBoxGizmo extends Gizmo {
  132443. private _lineBoundingBox;
  132444. private _rotateSpheresParent;
  132445. private _scaleBoxesParent;
  132446. private _boundingDimensions;
  132447. private _renderObserver;
  132448. private _pointerObserver;
  132449. private _scaleDragSpeed;
  132450. private _tmpQuaternion;
  132451. private _tmpVector;
  132452. private _tmpRotationMatrix;
  132453. /**
  132454. * 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)
  132455. */
  132456. ignoreChildren: boolean;
  132457. /**
  132458. * 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)
  132459. */
  132460. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132461. /**
  132462. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132463. */
  132464. rotationSphereSize: number;
  132465. /**
  132466. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132467. */
  132468. scaleBoxSize: number;
  132469. /**
  132470. * 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)
  132471. */
  132472. fixedDragMeshScreenSize: boolean;
  132473. /**
  132474. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132475. */
  132476. fixedDragMeshScreenSizeDistanceFactor: number;
  132477. /**
  132478. * Fired when a rotation sphere or scale box is dragged
  132479. */
  132480. onDragStartObservable: Observable<{}>;
  132481. /**
  132482. * Fired when a scale box is dragged
  132483. */
  132484. onScaleBoxDragObservable: Observable<{}>;
  132485. /**
  132486. * Fired when a scale box drag is ended
  132487. */
  132488. onScaleBoxDragEndObservable: Observable<{}>;
  132489. /**
  132490. * Fired when a rotation sphere is dragged
  132491. */
  132492. onRotationSphereDragObservable: Observable<{}>;
  132493. /**
  132494. * Fired when a rotation sphere drag is ended
  132495. */
  132496. onRotationSphereDragEndObservable: Observable<{}>;
  132497. /**
  132498. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  132499. */
  132500. scalePivot: Nullable<Vector3>;
  132501. /**
  132502. * Mesh used as a pivot to rotate the attached node
  132503. */
  132504. private _anchorMesh;
  132505. private _existingMeshScale;
  132506. private _dragMesh;
  132507. private pointerDragBehavior;
  132508. private coloredMaterial;
  132509. private hoverColoredMaterial;
  132510. /**
  132511. * Sets the color of the bounding box gizmo
  132512. * @param color the color to set
  132513. */
  132514. setColor(color: Color3): void;
  132515. /**
  132516. * Creates an BoundingBoxGizmo
  132517. * @param gizmoLayer The utility layer the gizmo will be added to
  132518. * @param color The color of the gizmo
  132519. */
  132520. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132521. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132522. private _selectNode;
  132523. /**
  132524. * Updates the bounding box information for the Gizmo
  132525. */
  132526. updateBoundingBox(): void;
  132527. private _updateRotationSpheres;
  132528. private _updateScaleBoxes;
  132529. /**
  132530. * Enables rotation on the specified axis and disables rotation on the others
  132531. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132532. */
  132533. setEnabledRotationAxis(axis: string): void;
  132534. /**
  132535. * Enables/disables scaling
  132536. * @param enable if scaling should be enabled
  132537. * @param homogeneousScaling defines if scaling should only be homogeneous
  132538. */
  132539. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132540. private _updateDummy;
  132541. /**
  132542. * Enables a pointer drag behavior on the bounding box of the gizmo
  132543. */
  132544. enableDragBehavior(): void;
  132545. /**
  132546. * Disposes of the gizmo
  132547. */
  132548. dispose(): void;
  132549. /**
  132550. * 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)
  132551. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132552. * @returns the bounding box mesh with the passed in mesh as a child
  132553. */
  132554. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132555. /**
  132556. * CustomMeshes are not supported by this gizmo
  132557. * @param mesh The mesh to replace the default mesh of the gizmo
  132558. */
  132559. setCustomMesh(mesh: Mesh): void;
  132560. }
  132561. }
  132562. declare module BABYLON {
  132563. /**
  132564. * Single plane rotation gizmo
  132565. */
  132566. export class PlaneRotationGizmo extends Gizmo {
  132567. /**
  132568. * Drag behavior responsible for the gizmos dragging interactions
  132569. */
  132570. dragBehavior: PointerDragBehavior;
  132571. private _pointerObserver;
  132572. /**
  132573. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132574. */
  132575. snapDistance: number;
  132576. /**
  132577. * Event that fires each time the gizmo snaps to a new location.
  132578. * * snapDistance is the the change in distance
  132579. */
  132580. onSnapObservable: Observable<{
  132581. snapDistance: number;
  132582. }>;
  132583. private _isEnabled;
  132584. private _parent;
  132585. /**
  132586. * Creates a PlaneRotationGizmo
  132587. * @param gizmoLayer The utility layer the gizmo will be added to
  132588. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132589. * @param color The color of the gizmo
  132590. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132591. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132592. * @param thickness display gizmo axis thickness
  132593. */
  132594. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132595. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132596. /**
  132597. * If the gizmo is enabled
  132598. */
  132599. set isEnabled(value: boolean);
  132600. get isEnabled(): boolean;
  132601. /**
  132602. * Disposes of the gizmo
  132603. */
  132604. dispose(): void;
  132605. }
  132606. }
  132607. declare module BABYLON {
  132608. /**
  132609. * Gizmo that enables rotating a mesh along 3 axis
  132610. */
  132611. export class RotationGizmo extends Gizmo {
  132612. /**
  132613. * Internal gizmo used for interactions on the x axis
  132614. */
  132615. xGizmo: PlaneRotationGizmo;
  132616. /**
  132617. * Internal gizmo used for interactions on the y axis
  132618. */
  132619. yGizmo: PlaneRotationGizmo;
  132620. /**
  132621. * Internal gizmo used for interactions on the z axis
  132622. */
  132623. zGizmo: PlaneRotationGizmo;
  132624. /** Fires an event when any of it's sub gizmos are dragged */
  132625. onDragStartObservable: Observable<unknown>;
  132626. /** Fires an event when any of it's sub gizmos are released from dragging */
  132627. onDragEndObservable: Observable<unknown>;
  132628. private _meshAttached;
  132629. private _nodeAttached;
  132630. get attachedMesh(): Nullable<AbstractMesh>;
  132631. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132632. get attachedNode(): Nullable<Node>;
  132633. set attachedNode(node: Nullable<Node>);
  132634. /**
  132635. * Creates a RotationGizmo
  132636. * @param gizmoLayer The utility layer the gizmo will be added to
  132637. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132638. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132639. * @param thickness display gizmo axis thickness
  132640. */
  132641. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132642. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132643. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132644. /**
  132645. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132646. */
  132647. set snapDistance(value: number);
  132648. get snapDistance(): number;
  132649. /**
  132650. * Ratio for the scale of the gizmo (Default: 1)
  132651. */
  132652. set scaleRatio(value: number);
  132653. get scaleRatio(): number;
  132654. /**
  132655. * Disposes of the gizmo
  132656. */
  132657. dispose(): void;
  132658. /**
  132659. * CustomMeshes are not supported by this gizmo
  132660. * @param mesh The mesh to replace the default mesh of the gizmo
  132661. */
  132662. setCustomMesh(mesh: Mesh): void;
  132663. }
  132664. }
  132665. declare module BABYLON {
  132666. /**
  132667. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  132668. */
  132669. export class GizmoManager implements IDisposable {
  132670. private scene;
  132671. /**
  132672. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132673. */
  132674. gizmos: {
  132675. positionGizmo: Nullable<PositionGizmo>;
  132676. rotationGizmo: Nullable<RotationGizmo>;
  132677. scaleGizmo: Nullable<ScaleGizmo>;
  132678. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132679. };
  132680. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132681. clearGizmoOnEmptyPointerEvent: boolean;
  132682. /** Fires an event when the manager is attached to a mesh */
  132683. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132684. /** Fires an event when the manager is attached to a node */
  132685. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  132686. private _gizmosEnabled;
  132687. private _pointerObserver;
  132688. private _attachedMesh;
  132689. private _attachedNode;
  132690. private _boundingBoxColor;
  132691. private _defaultUtilityLayer;
  132692. private _defaultKeepDepthUtilityLayer;
  132693. private _thickness;
  132694. /**
  132695. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132696. */
  132697. boundingBoxDragBehavior: SixDofDragBehavior;
  132698. /**
  132699. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132700. */
  132701. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132702. /**
  132703. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  132704. */
  132705. attachableNodes: Nullable<Array<Node>>;
  132706. /**
  132707. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  132708. */
  132709. usePointerToAttachGizmos: boolean;
  132710. /**
  132711. * Utility layer that the bounding box gizmo belongs to
  132712. */
  132713. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132714. /**
  132715. * Utility layer that all gizmos besides bounding box belong to
  132716. */
  132717. get utilityLayer(): UtilityLayerRenderer;
  132718. /**
  132719. * Instatiates a gizmo manager
  132720. * @param scene the scene to overlay the gizmos on top of
  132721. * @param thickness display gizmo axis thickness
  132722. */
  132723. constructor(scene: Scene, thickness?: number);
  132724. /**
  132725. * Attaches a set of gizmos to the specified mesh
  132726. * @param mesh The mesh the gizmo's should be attached to
  132727. */
  132728. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132729. /**
  132730. * Attaches a set of gizmos to the specified node
  132731. * @param node The node the gizmo's should be attached to
  132732. */
  132733. attachToNode(node: Nullable<Node>): void;
  132734. /**
  132735. * If the position gizmo is enabled
  132736. */
  132737. set positionGizmoEnabled(value: boolean);
  132738. get positionGizmoEnabled(): boolean;
  132739. /**
  132740. * If the rotation gizmo is enabled
  132741. */
  132742. set rotationGizmoEnabled(value: boolean);
  132743. get rotationGizmoEnabled(): boolean;
  132744. /**
  132745. * If the scale gizmo is enabled
  132746. */
  132747. set scaleGizmoEnabled(value: boolean);
  132748. get scaleGizmoEnabled(): boolean;
  132749. /**
  132750. * If the boundingBox gizmo is enabled
  132751. */
  132752. set boundingBoxGizmoEnabled(value: boolean);
  132753. get boundingBoxGizmoEnabled(): boolean;
  132754. /**
  132755. * Disposes of the gizmo manager
  132756. */
  132757. dispose(): void;
  132758. }
  132759. }
  132760. declare module BABYLON {
  132761. /**
  132762. * A directional light is defined by a direction (what a surprise!).
  132763. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132764. * 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.
  132765. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132766. */
  132767. export class DirectionalLight extends ShadowLight {
  132768. private _shadowFrustumSize;
  132769. /**
  132770. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132771. */
  132772. get shadowFrustumSize(): number;
  132773. /**
  132774. * Specifies a fix frustum size for the shadow generation.
  132775. */
  132776. set shadowFrustumSize(value: number);
  132777. private _shadowOrthoScale;
  132778. /**
  132779. * Gets the shadow projection scale against the optimal computed one.
  132780. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132781. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132782. */
  132783. get shadowOrthoScale(): number;
  132784. /**
  132785. * Sets the shadow projection scale against the optimal computed one.
  132786. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132787. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132788. */
  132789. set shadowOrthoScale(value: number);
  132790. /**
  132791. * Automatically compute the projection matrix to best fit (including all the casters)
  132792. * on each frame.
  132793. */
  132794. autoUpdateExtends: boolean;
  132795. /**
  132796. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132797. * on each frame. autoUpdateExtends must be set to true for this to work
  132798. */
  132799. autoCalcShadowZBounds: boolean;
  132800. private _orthoLeft;
  132801. private _orthoRight;
  132802. private _orthoTop;
  132803. private _orthoBottom;
  132804. /**
  132805. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132806. * The directional light is emitted from everywhere in the given direction.
  132807. * It can cast shadows.
  132808. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132809. * @param name The friendly name of the light
  132810. * @param direction The direction of the light
  132811. * @param scene The scene the light belongs to
  132812. */
  132813. constructor(name: string, direction: Vector3, scene: Scene);
  132814. /**
  132815. * Returns the string "DirectionalLight".
  132816. * @return The class name
  132817. */
  132818. getClassName(): string;
  132819. /**
  132820. * Returns the integer 1.
  132821. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132822. */
  132823. getTypeID(): number;
  132824. /**
  132825. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132826. * Returns the DirectionalLight Shadow projection matrix.
  132827. */
  132828. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132829. /**
  132830. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132831. * Returns the DirectionalLight Shadow projection matrix.
  132832. */
  132833. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132834. /**
  132835. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132836. * Returns the DirectionalLight Shadow projection matrix.
  132837. */
  132838. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132839. protected _buildUniformLayout(): void;
  132840. /**
  132841. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132842. * @param effect The effect to update
  132843. * @param lightIndex The index of the light in the effect to update
  132844. * @returns The directional light
  132845. */
  132846. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132847. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132848. /**
  132849. * Gets the minZ used for shadow according to both the scene and the light.
  132850. *
  132851. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132852. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132853. * @param activeCamera The camera we are returning the min for
  132854. * @returns the depth min z
  132855. */
  132856. getDepthMinZ(activeCamera: Camera): number;
  132857. /**
  132858. * Gets the maxZ used for shadow according to both the scene and the light.
  132859. *
  132860. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132861. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132862. * @param activeCamera The camera we are returning the max for
  132863. * @returns the depth max z
  132864. */
  132865. getDepthMaxZ(activeCamera: Camera): number;
  132866. /**
  132867. * Prepares the list of defines specific to the light type.
  132868. * @param defines the list of defines
  132869. * @param lightIndex defines the index of the light for the effect
  132870. */
  132871. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132872. }
  132873. }
  132874. declare module BABYLON {
  132875. /**
  132876. * Class containing static functions to help procedurally build meshes
  132877. */
  132878. export class HemisphereBuilder {
  132879. /**
  132880. * Creates a hemisphere mesh
  132881. * @param name defines the name of the mesh
  132882. * @param options defines the options used to create the mesh
  132883. * @param scene defines the hosting scene
  132884. * @returns the hemisphere mesh
  132885. */
  132886. static CreateHemisphere(name: string, options: {
  132887. segments?: number;
  132888. diameter?: number;
  132889. sideOrientation?: number;
  132890. }, scene: any): Mesh;
  132891. }
  132892. }
  132893. declare module BABYLON {
  132894. /**
  132895. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132896. * These values define a cone of light starting from the position, emitting toward the direction.
  132897. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132898. * and the exponent defines the speed of the decay of the light with distance (reach).
  132899. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132900. */
  132901. export class SpotLight extends ShadowLight {
  132902. private _angle;
  132903. private _innerAngle;
  132904. private _cosHalfAngle;
  132905. private _lightAngleScale;
  132906. private _lightAngleOffset;
  132907. /**
  132908. * Gets the cone angle of the spot light in Radians.
  132909. */
  132910. get angle(): number;
  132911. /**
  132912. * Sets the cone angle of the spot light in Radians.
  132913. */
  132914. set angle(value: number);
  132915. /**
  132916. * Only used in gltf falloff mode, this defines the angle where
  132917. * the directional falloff will start before cutting at angle which could be seen
  132918. * as outer angle.
  132919. */
  132920. get innerAngle(): number;
  132921. /**
  132922. * Only used in gltf falloff mode, this defines the angle where
  132923. * the directional falloff will start before cutting at angle which could be seen
  132924. * as outer angle.
  132925. */
  132926. set innerAngle(value: number);
  132927. private _shadowAngleScale;
  132928. /**
  132929. * Allows scaling the angle of the light for shadow generation only.
  132930. */
  132931. get shadowAngleScale(): number;
  132932. /**
  132933. * Allows scaling the angle of the light for shadow generation only.
  132934. */
  132935. set shadowAngleScale(value: number);
  132936. /**
  132937. * The light decay speed with the distance from the emission spot.
  132938. */
  132939. exponent: number;
  132940. private _projectionTextureMatrix;
  132941. /**
  132942. * Allows reading the projecton texture
  132943. */
  132944. get projectionTextureMatrix(): Matrix;
  132945. protected _projectionTextureLightNear: number;
  132946. /**
  132947. * Gets the near clip of the Spotlight for texture projection.
  132948. */
  132949. get projectionTextureLightNear(): number;
  132950. /**
  132951. * Sets the near clip of the Spotlight for texture projection.
  132952. */
  132953. set projectionTextureLightNear(value: number);
  132954. protected _projectionTextureLightFar: number;
  132955. /**
  132956. * Gets the far clip of the Spotlight for texture projection.
  132957. */
  132958. get projectionTextureLightFar(): number;
  132959. /**
  132960. * Sets the far clip of the Spotlight for texture projection.
  132961. */
  132962. set projectionTextureLightFar(value: number);
  132963. protected _projectionTextureUpDirection: Vector3;
  132964. /**
  132965. * Gets the Up vector of the Spotlight for texture projection.
  132966. */
  132967. get projectionTextureUpDirection(): Vector3;
  132968. /**
  132969. * Sets the Up vector of the Spotlight for texture projection.
  132970. */
  132971. set projectionTextureUpDirection(value: Vector3);
  132972. private _projectionTexture;
  132973. /**
  132974. * Gets the projection texture of the light.
  132975. */
  132976. get projectionTexture(): Nullable<BaseTexture>;
  132977. /**
  132978. * Sets the projection texture of the light.
  132979. */
  132980. set projectionTexture(value: Nullable<BaseTexture>);
  132981. private _projectionTextureViewLightDirty;
  132982. private _projectionTextureProjectionLightDirty;
  132983. private _projectionTextureDirty;
  132984. private _projectionTextureViewTargetVector;
  132985. private _projectionTextureViewLightMatrix;
  132986. private _projectionTextureProjectionLightMatrix;
  132987. private _projectionTextureScalingMatrix;
  132988. /**
  132989. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132990. * It can cast shadows.
  132991. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132992. * @param name The light friendly name
  132993. * @param position The position of the spot light in the scene
  132994. * @param direction The direction of the light in the scene
  132995. * @param angle The cone angle of the light in Radians
  132996. * @param exponent The light decay speed with the distance from the emission spot
  132997. * @param scene The scene the lights belongs to
  132998. */
  132999. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133000. /**
  133001. * Returns the string "SpotLight".
  133002. * @returns the class name
  133003. */
  133004. getClassName(): string;
  133005. /**
  133006. * Returns the integer 2.
  133007. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133008. */
  133009. getTypeID(): number;
  133010. /**
  133011. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133012. */
  133013. protected _setDirection(value: Vector3): void;
  133014. /**
  133015. * Overrides the position setter to recompute the projection texture view light Matrix.
  133016. */
  133017. protected _setPosition(value: Vector3): void;
  133018. /**
  133019. * 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.
  133020. * Returns the SpotLight.
  133021. */
  133022. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133023. protected _computeProjectionTextureViewLightMatrix(): void;
  133024. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133025. /**
  133026. * Main function for light texture projection matrix computing.
  133027. */
  133028. protected _computeProjectionTextureMatrix(): void;
  133029. protected _buildUniformLayout(): void;
  133030. private _computeAngleValues;
  133031. /**
  133032. * Sets the passed Effect "effect" with the Light textures.
  133033. * @param effect The effect to update
  133034. * @param lightIndex The index of the light in the effect to update
  133035. * @returns The light
  133036. */
  133037. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  133038. /**
  133039. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  133040. * @param effect The effect to update
  133041. * @param lightIndex The index of the light in the effect to update
  133042. * @returns The spot light
  133043. */
  133044. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  133045. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  133046. /**
  133047. * Disposes the light and the associated resources.
  133048. */
  133049. dispose(): void;
  133050. /**
  133051. * Prepares the list of defines specific to the light type.
  133052. * @param defines the list of defines
  133053. * @param lightIndex defines the index of the light for the effect
  133054. */
  133055. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133056. }
  133057. }
  133058. declare module BABYLON {
  133059. /**
  133060. * Gizmo that enables viewing a light
  133061. */
  133062. export class LightGizmo extends Gizmo {
  133063. private _lightMesh;
  133064. private _material;
  133065. private _cachedPosition;
  133066. private _cachedForward;
  133067. private _attachedMeshParent;
  133068. /**
  133069. * Creates a LightGizmo
  133070. * @param gizmoLayer The utility layer the gizmo will be added to
  133071. */
  133072. constructor(gizmoLayer?: UtilityLayerRenderer);
  133073. private _light;
  133074. /**
  133075. * The light that the gizmo is attached to
  133076. */
  133077. set light(light: Nullable<Light>);
  133078. get light(): Nullable<Light>;
  133079. /**
  133080. * Gets the material used to render the light gizmo
  133081. */
  133082. get material(): StandardMaterial;
  133083. /**
  133084. * @hidden
  133085. * Updates the gizmo to match the attached mesh's position/rotation
  133086. */
  133087. protected _update(): void;
  133088. private static _Scale;
  133089. /**
  133090. * Creates the lines for a light mesh
  133091. */
  133092. private static _CreateLightLines;
  133093. /**
  133094. * Disposes of the light gizmo
  133095. */
  133096. dispose(): void;
  133097. private static _CreateHemisphericLightMesh;
  133098. private static _CreatePointLightMesh;
  133099. private static _CreateSpotLightMesh;
  133100. private static _CreateDirectionalLightMesh;
  133101. }
  133102. }
  133103. declare module BABYLON {
  133104. /**
  133105. * Gizmo that enables viewing a camera
  133106. */
  133107. export class CameraGizmo extends Gizmo {
  133108. private _cameraMesh;
  133109. private _cameraLinesMesh;
  133110. private _material;
  133111. /**
  133112. * Creates a CameraGizmo
  133113. * @param gizmoLayer The utility layer the gizmo will be added to
  133114. */
  133115. constructor(gizmoLayer?: UtilityLayerRenderer);
  133116. private _camera;
  133117. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  133118. get displayFrustum(): boolean;
  133119. set displayFrustum(value: boolean);
  133120. /**
  133121. * The camera that the gizmo is attached to
  133122. */
  133123. set camera(camera: Nullable<Camera>);
  133124. get camera(): Nullable<Camera>;
  133125. /**
  133126. * Gets the material used to render the camera gizmo
  133127. */
  133128. get material(): StandardMaterial;
  133129. /**
  133130. * @hidden
  133131. * Updates the gizmo to match the attached mesh's position/rotation
  133132. */
  133133. protected _update(): void;
  133134. private static _Scale;
  133135. private _invProjection;
  133136. /**
  133137. * Disposes of the camera gizmo
  133138. */
  133139. dispose(): void;
  133140. private static _CreateCameraMesh;
  133141. private static _CreateCameraFrustum;
  133142. }
  133143. }
  133144. declare module BABYLON {
  133145. /** @hidden */
  133146. export var backgroundFragmentDeclaration: {
  133147. name: string;
  133148. shader: string;
  133149. };
  133150. }
  133151. declare module BABYLON {
  133152. /** @hidden */
  133153. export var backgroundUboDeclaration: {
  133154. name: string;
  133155. shader: string;
  133156. };
  133157. }
  133158. declare module BABYLON {
  133159. /** @hidden */
  133160. export var backgroundPixelShader: {
  133161. name: string;
  133162. shader: string;
  133163. };
  133164. }
  133165. declare module BABYLON {
  133166. /** @hidden */
  133167. export var backgroundVertexDeclaration: {
  133168. name: string;
  133169. shader: string;
  133170. };
  133171. }
  133172. declare module BABYLON {
  133173. /** @hidden */
  133174. export var backgroundVertexShader: {
  133175. name: string;
  133176. shader: string;
  133177. };
  133178. }
  133179. declare module BABYLON {
  133180. /**
  133181. * Background material used to create an efficient environement around your scene.
  133182. */
  133183. export class BackgroundMaterial extends PushMaterial {
  133184. /**
  133185. * Standard reflectance value at parallel view angle.
  133186. */
  133187. static StandardReflectance0: number;
  133188. /**
  133189. * Standard reflectance value at grazing angle.
  133190. */
  133191. static StandardReflectance90: number;
  133192. protected _primaryColor: Color3;
  133193. /**
  133194. * Key light Color (multiply against the environement texture)
  133195. */
  133196. primaryColor: Color3;
  133197. protected __perceptualColor: Nullable<Color3>;
  133198. /**
  133199. * Experimental Internal Use Only.
  133200. *
  133201. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  133202. * This acts as a helper to set the primary color to a more "human friendly" value.
  133203. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  133204. * output color as close as possible from the chosen value.
  133205. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  133206. * part of lighting setup.)
  133207. */
  133208. get _perceptualColor(): Nullable<Color3>;
  133209. set _perceptualColor(value: Nullable<Color3>);
  133210. protected _primaryColorShadowLevel: float;
  133211. /**
  133212. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  133213. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  133214. */
  133215. get primaryColorShadowLevel(): float;
  133216. set primaryColorShadowLevel(value: float);
  133217. protected _primaryColorHighlightLevel: float;
  133218. /**
  133219. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  133220. * The primary color is used at the level chosen to define what the white area would look.
  133221. */
  133222. get primaryColorHighlightLevel(): float;
  133223. set primaryColorHighlightLevel(value: float);
  133224. protected _reflectionTexture: Nullable<BaseTexture>;
  133225. /**
  133226. * Reflection Texture used in the material.
  133227. * Should be author in a specific way for the best result (refer to the documentation).
  133228. */
  133229. reflectionTexture: Nullable<BaseTexture>;
  133230. protected _reflectionBlur: float;
  133231. /**
  133232. * Reflection Texture level of blur.
  133233. *
  133234. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133235. * texture twice.
  133236. */
  133237. reflectionBlur: float;
  133238. protected _diffuseTexture: Nullable<BaseTexture>;
  133239. /**
  133240. * Diffuse Texture used in the material.
  133241. * Should be author in a specific way for the best result (refer to the documentation).
  133242. */
  133243. diffuseTexture: Nullable<BaseTexture>;
  133244. protected _shadowLights: Nullable<IShadowLight[]>;
  133245. /**
  133246. * Specify the list of lights casting shadow on the material.
  133247. * All scene shadow lights will be included if null.
  133248. */
  133249. shadowLights: Nullable<IShadowLight[]>;
  133250. protected _shadowLevel: float;
  133251. /**
  133252. * Helps adjusting the shadow to a softer level if required.
  133253. * 0 means black shadows and 1 means no shadows.
  133254. */
  133255. shadowLevel: float;
  133256. protected _sceneCenter: Vector3;
  133257. /**
  133258. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133259. * It is usually zero but might be interesting to modify according to your setup.
  133260. */
  133261. sceneCenter: Vector3;
  133262. protected _opacityFresnel: boolean;
  133263. /**
  133264. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133265. * This helps ensuring a nice transition when the camera goes under the ground.
  133266. */
  133267. opacityFresnel: boolean;
  133268. protected _reflectionFresnel: boolean;
  133269. /**
  133270. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133271. * This helps adding a mirror texture on the ground.
  133272. */
  133273. reflectionFresnel: boolean;
  133274. protected _reflectionFalloffDistance: number;
  133275. /**
  133276. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133277. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133278. */
  133279. reflectionFalloffDistance: number;
  133280. protected _reflectionAmount: number;
  133281. /**
  133282. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133283. */
  133284. reflectionAmount: number;
  133285. protected _reflectionReflectance0: number;
  133286. /**
  133287. * This specifies the weight of the reflection at grazing angle.
  133288. */
  133289. reflectionReflectance0: number;
  133290. protected _reflectionReflectance90: number;
  133291. /**
  133292. * This specifies the weight of the reflection at a perpendicular point of view.
  133293. */
  133294. reflectionReflectance90: number;
  133295. /**
  133296. * Sets the reflection reflectance fresnel values according to the default standard
  133297. * empirically know to work well :-)
  133298. */
  133299. set reflectionStandardFresnelWeight(value: number);
  133300. protected _useRGBColor: boolean;
  133301. /**
  133302. * Helps to directly use the maps channels instead of their level.
  133303. */
  133304. useRGBColor: boolean;
  133305. protected _enableNoise: boolean;
  133306. /**
  133307. * This helps reducing the banding effect that could occur on the background.
  133308. */
  133309. enableNoise: boolean;
  133310. /**
  133311. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133312. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133313. * Recommended to be keep at 1.0 except for special cases.
  133314. */
  133315. get fovMultiplier(): number;
  133316. set fovMultiplier(value: number);
  133317. private _fovMultiplier;
  133318. /**
  133319. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133320. */
  133321. useEquirectangularFOV: boolean;
  133322. private _maxSimultaneousLights;
  133323. /**
  133324. * Number of Simultaneous lights allowed on the material.
  133325. */
  133326. maxSimultaneousLights: int;
  133327. private _shadowOnly;
  133328. /**
  133329. * Make the material only render shadows
  133330. */
  133331. shadowOnly: boolean;
  133332. /**
  133333. * Default configuration related to image processing available in the Background Material.
  133334. */
  133335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133336. /**
  133337. * Keep track of the image processing observer to allow dispose and replace.
  133338. */
  133339. private _imageProcessingObserver;
  133340. /**
  133341. * Attaches a new image processing configuration to the PBR Material.
  133342. * @param configuration (if null the scene configuration will be use)
  133343. */
  133344. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133345. /**
  133346. * Gets the image processing configuration used either in this material.
  133347. */
  133348. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133349. /**
  133350. * Sets the Default image processing configuration used either in the this material.
  133351. *
  133352. * If sets to null, the scene one is in use.
  133353. */
  133354. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133355. /**
  133356. * Gets wether the color curves effect is enabled.
  133357. */
  133358. get cameraColorCurvesEnabled(): boolean;
  133359. /**
  133360. * Sets wether the color curves effect is enabled.
  133361. */
  133362. set cameraColorCurvesEnabled(value: boolean);
  133363. /**
  133364. * Gets wether the color grading effect is enabled.
  133365. */
  133366. get cameraColorGradingEnabled(): boolean;
  133367. /**
  133368. * Gets wether the color grading effect is enabled.
  133369. */
  133370. set cameraColorGradingEnabled(value: boolean);
  133371. /**
  133372. * Gets wether tonemapping is enabled or not.
  133373. */
  133374. get cameraToneMappingEnabled(): boolean;
  133375. /**
  133376. * Sets wether tonemapping is enabled or not
  133377. */
  133378. set cameraToneMappingEnabled(value: boolean);
  133379. /**
  133380. * The camera exposure used on this material.
  133381. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133382. * This corresponds to a photographic exposure.
  133383. */
  133384. get cameraExposure(): float;
  133385. /**
  133386. * The camera exposure used on this material.
  133387. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133388. * This corresponds to a photographic exposure.
  133389. */
  133390. set cameraExposure(value: float);
  133391. /**
  133392. * Gets The camera contrast used on this material.
  133393. */
  133394. get cameraContrast(): float;
  133395. /**
  133396. * Sets The camera contrast used on this material.
  133397. */
  133398. set cameraContrast(value: float);
  133399. /**
  133400. * Gets the Color Grading 2D Lookup Texture.
  133401. */
  133402. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133403. /**
  133404. * Sets the Color Grading 2D Lookup Texture.
  133405. */
  133406. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133407. /**
  133408. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133409. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133410. * 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;
  133411. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133412. */
  133413. get cameraColorCurves(): Nullable<ColorCurves>;
  133414. /**
  133415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133417. * 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;
  133418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133419. */
  133420. set cameraColorCurves(value: Nullable<ColorCurves>);
  133421. /**
  133422. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133423. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133424. */
  133425. switchToBGR: boolean;
  133426. private _renderTargets;
  133427. private _reflectionControls;
  133428. private _white;
  133429. private _primaryShadowColor;
  133430. private _primaryHighlightColor;
  133431. /**
  133432. * Instantiates a Background Material in the given scene
  133433. * @param name The friendly name of the material
  133434. * @param scene The scene to add the material to
  133435. */
  133436. constructor(name: string, scene: Scene);
  133437. /**
  133438. * Gets a boolean indicating that current material needs to register RTT
  133439. */
  133440. get hasRenderTargetTextures(): boolean;
  133441. /**
  133442. * The entire material has been created in order to prevent overdraw.
  133443. * @returns false
  133444. */
  133445. needAlphaTesting(): boolean;
  133446. /**
  133447. * The entire material has been created in order to prevent overdraw.
  133448. * @returns true if blending is enable
  133449. */
  133450. needAlphaBlending(): boolean;
  133451. /**
  133452. * Checks wether the material is ready to be rendered for a given mesh.
  133453. * @param mesh The mesh to render
  133454. * @param subMesh The submesh to check against
  133455. * @param useInstances Specify wether or not the material is used with instances
  133456. * @returns true if all the dependencies are ready (Textures, Effects...)
  133457. */
  133458. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133459. /**
  133460. * Compute the primary color according to the chosen perceptual color.
  133461. */
  133462. private _computePrimaryColorFromPerceptualColor;
  133463. /**
  133464. * Compute the highlights and shadow colors according to their chosen levels.
  133465. */
  133466. private _computePrimaryColors;
  133467. /**
  133468. * Build the uniform buffer used in the material.
  133469. */
  133470. buildUniformLayout(): void;
  133471. /**
  133472. * Unbind the material.
  133473. */
  133474. unbind(): void;
  133475. /**
  133476. * Bind only the world matrix to the material.
  133477. * @param world The world matrix to bind.
  133478. */
  133479. bindOnlyWorldMatrix(world: Matrix): void;
  133480. /**
  133481. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133482. * @param world The world matrix to bind.
  133483. * @param subMesh The submesh to bind for.
  133484. */
  133485. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133486. /**
  133487. * Checks to see if a texture is used in the material.
  133488. * @param texture - Base texture to use.
  133489. * @returns - Boolean specifying if a texture is used in the material.
  133490. */
  133491. hasTexture(texture: BaseTexture): boolean;
  133492. /**
  133493. * Dispose the material.
  133494. * @param forceDisposeEffect Force disposal of the associated effect.
  133495. * @param forceDisposeTextures Force disposal of the associated textures.
  133496. */
  133497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133498. /**
  133499. * Clones the material.
  133500. * @param name The cloned name.
  133501. * @returns The cloned material.
  133502. */
  133503. clone(name: string): BackgroundMaterial;
  133504. /**
  133505. * Serializes the current material to its JSON representation.
  133506. * @returns The JSON representation.
  133507. */
  133508. serialize(): any;
  133509. /**
  133510. * Gets the class name of the material
  133511. * @returns "BackgroundMaterial"
  133512. */
  133513. getClassName(): string;
  133514. /**
  133515. * Parse a JSON input to create back a background material.
  133516. * @param source The JSON data to parse
  133517. * @param scene The scene to create the parsed material in
  133518. * @param rootUrl The root url of the assets the material depends upon
  133519. * @returns the instantiated BackgroundMaterial.
  133520. */
  133521. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133522. }
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * Represents the different options available during the creation of
  133527. * a Environment helper.
  133528. *
  133529. * This can control the default ground, skybox and image processing setup of your scene.
  133530. */
  133531. export interface IEnvironmentHelperOptions {
  133532. /**
  133533. * Specifies whether or not to create a ground.
  133534. * True by default.
  133535. */
  133536. createGround: boolean;
  133537. /**
  133538. * Specifies the ground size.
  133539. * 15 by default.
  133540. */
  133541. groundSize: number;
  133542. /**
  133543. * The texture used on the ground for the main color.
  133544. * Comes from the BabylonJS CDN by default.
  133545. *
  133546. * Remarks: Can be either a texture or a url.
  133547. */
  133548. groundTexture: string | BaseTexture;
  133549. /**
  133550. * The color mixed in the ground texture by default.
  133551. * BabylonJS clearColor by default.
  133552. */
  133553. groundColor: Color3;
  133554. /**
  133555. * Specifies the ground opacity.
  133556. * 1 by default.
  133557. */
  133558. groundOpacity: number;
  133559. /**
  133560. * Enables the ground to receive shadows.
  133561. * True by default.
  133562. */
  133563. enableGroundShadow: boolean;
  133564. /**
  133565. * Helps preventing the shadow to be fully black on the ground.
  133566. * 0.5 by default.
  133567. */
  133568. groundShadowLevel: number;
  133569. /**
  133570. * Creates a mirror texture attach to the ground.
  133571. * false by default.
  133572. */
  133573. enableGroundMirror: boolean;
  133574. /**
  133575. * Specifies the ground mirror size ratio.
  133576. * 0.3 by default as the default kernel is 64.
  133577. */
  133578. groundMirrorSizeRatio: number;
  133579. /**
  133580. * Specifies the ground mirror blur kernel size.
  133581. * 64 by default.
  133582. */
  133583. groundMirrorBlurKernel: number;
  133584. /**
  133585. * Specifies the ground mirror visibility amount.
  133586. * 1 by default
  133587. */
  133588. groundMirrorAmount: number;
  133589. /**
  133590. * Specifies the ground mirror reflectance weight.
  133591. * This uses the standard weight of the background material to setup the fresnel effect
  133592. * of the mirror.
  133593. * 1 by default.
  133594. */
  133595. groundMirrorFresnelWeight: number;
  133596. /**
  133597. * Specifies the ground mirror Falloff distance.
  133598. * This can helps reducing the size of the reflection.
  133599. * 0 by Default.
  133600. */
  133601. groundMirrorFallOffDistance: number;
  133602. /**
  133603. * Specifies the ground mirror texture type.
  133604. * Unsigned Int by Default.
  133605. */
  133606. groundMirrorTextureType: number;
  133607. /**
  133608. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133609. * the shown objects.
  133610. */
  133611. groundYBias: number;
  133612. /**
  133613. * Specifies whether or not to create a skybox.
  133614. * True by default.
  133615. */
  133616. createSkybox: boolean;
  133617. /**
  133618. * Specifies the skybox size.
  133619. * 20 by default.
  133620. */
  133621. skyboxSize: number;
  133622. /**
  133623. * The texture used on the skybox for the main color.
  133624. * Comes from the BabylonJS CDN by default.
  133625. *
  133626. * Remarks: Can be either a texture or a url.
  133627. */
  133628. skyboxTexture: string | BaseTexture;
  133629. /**
  133630. * The color mixed in the skybox texture by default.
  133631. * BabylonJS clearColor by default.
  133632. */
  133633. skyboxColor: Color3;
  133634. /**
  133635. * The background rotation around the Y axis of the scene.
  133636. * This helps aligning the key lights of your scene with the background.
  133637. * 0 by default.
  133638. */
  133639. backgroundYRotation: number;
  133640. /**
  133641. * Compute automatically the size of the elements to best fit with the scene.
  133642. */
  133643. sizeAuto: boolean;
  133644. /**
  133645. * Default position of the rootMesh if autoSize is not true.
  133646. */
  133647. rootPosition: Vector3;
  133648. /**
  133649. * Sets up the image processing in the scene.
  133650. * true by default.
  133651. */
  133652. setupImageProcessing: boolean;
  133653. /**
  133654. * The texture used as your environment texture in the scene.
  133655. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133656. *
  133657. * Remarks: Can be either a texture or a url.
  133658. */
  133659. environmentTexture: string | BaseTexture;
  133660. /**
  133661. * The value of the exposure to apply to the scene.
  133662. * 0.6 by default if setupImageProcessing is true.
  133663. */
  133664. cameraExposure: number;
  133665. /**
  133666. * The value of the contrast to apply to the scene.
  133667. * 1.6 by default if setupImageProcessing is true.
  133668. */
  133669. cameraContrast: number;
  133670. /**
  133671. * Specifies whether or not tonemapping should be enabled in the scene.
  133672. * true by default if setupImageProcessing is true.
  133673. */
  133674. toneMappingEnabled: boolean;
  133675. }
  133676. /**
  133677. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133678. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133679. * It also helps with the default setup of your imageProcessing configuration.
  133680. */
  133681. export class EnvironmentHelper {
  133682. /**
  133683. * Default ground texture URL.
  133684. */
  133685. private static _groundTextureCDNUrl;
  133686. /**
  133687. * Default skybox texture URL.
  133688. */
  133689. private static _skyboxTextureCDNUrl;
  133690. /**
  133691. * Default environment texture URL.
  133692. */
  133693. private static _environmentTextureCDNUrl;
  133694. /**
  133695. * Creates the default options for the helper.
  133696. */
  133697. private static _getDefaultOptions;
  133698. private _rootMesh;
  133699. /**
  133700. * Gets the root mesh created by the helper.
  133701. */
  133702. get rootMesh(): Mesh;
  133703. private _skybox;
  133704. /**
  133705. * Gets the skybox created by the helper.
  133706. */
  133707. get skybox(): Nullable<Mesh>;
  133708. private _skyboxTexture;
  133709. /**
  133710. * Gets the skybox texture created by the helper.
  133711. */
  133712. get skyboxTexture(): Nullable<BaseTexture>;
  133713. private _skyboxMaterial;
  133714. /**
  133715. * Gets the skybox material created by the helper.
  133716. */
  133717. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133718. private _ground;
  133719. /**
  133720. * Gets the ground mesh created by the helper.
  133721. */
  133722. get ground(): Nullable<Mesh>;
  133723. private _groundTexture;
  133724. /**
  133725. * Gets the ground texture created by the helper.
  133726. */
  133727. get groundTexture(): Nullable<BaseTexture>;
  133728. private _groundMirror;
  133729. /**
  133730. * Gets the ground mirror created by the helper.
  133731. */
  133732. get groundMirror(): Nullable<MirrorTexture>;
  133733. /**
  133734. * Gets the ground mirror render list to helps pushing the meshes
  133735. * you wish in the ground reflection.
  133736. */
  133737. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133738. private _groundMaterial;
  133739. /**
  133740. * Gets the ground material created by the helper.
  133741. */
  133742. get groundMaterial(): Nullable<BackgroundMaterial>;
  133743. /**
  133744. * Stores the creation options.
  133745. */
  133746. private readonly _scene;
  133747. private _options;
  133748. /**
  133749. * This observable will be notified with any error during the creation of the environment,
  133750. * mainly texture creation errors.
  133751. */
  133752. onErrorObservable: Observable<{
  133753. message?: string;
  133754. exception?: any;
  133755. }>;
  133756. /**
  133757. * constructor
  133758. * @param options Defines the options we want to customize the helper
  133759. * @param scene The scene to add the material to
  133760. */
  133761. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133762. /**
  133763. * Updates the background according to the new options
  133764. * @param options
  133765. */
  133766. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133767. /**
  133768. * Sets the primary color of all the available elements.
  133769. * @param color the main color to affect to the ground and the background
  133770. */
  133771. setMainColor(color: Color3): void;
  133772. /**
  133773. * Setup the image processing according to the specified options.
  133774. */
  133775. private _setupImageProcessing;
  133776. /**
  133777. * Setup the environment texture according to the specified options.
  133778. */
  133779. private _setupEnvironmentTexture;
  133780. /**
  133781. * Setup the background according to the specified options.
  133782. */
  133783. private _setupBackground;
  133784. /**
  133785. * Get the scene sizes according to the setup.
  133786. */
  133787. private _getSceneSize;
  133788. /**
  133789. * Setup the ground according to the specified options.
  133790. */
  133791. private _setupGround;
  133792. /**
  133793. * Setup the ground material according to the specified options.
  133794. */
  133795. private _setupGroundMaterial;
  133796. /**
  133797. * Setup the ground diffuse texture according to the specified options.
  133798. */
  133799. private _setupGroundDiffuseTexture;
  133800. /**
  133801. * Setup the ground mirror texture according to the specified options.
  133802. */
  133803. private _setupGroundMirrorTexture;
  133804. /**
  133805. * Setup the ground to receive the mirror texture.
  133806. */
  133807. private _setupMirrorInGroundMaterial;
  133808. /**
  133809. * Setup the skybox according to the specified options.
  133810. */
  133811. private _setupSkybox;
  133812. /**
  133813. * Setup the skybox material according to the specified options.
  133814. */
  133815. private _setupSkyboxMaterial;
  133816. /**
  133817. * Setup the skybox reflection texture according to the specified options.
  133818. */
  133819. private _setupSkyboxReflectionTexture;
  133820. private _errorHandler;
  133821. /**
  133822. * Dispose all the elements created by the Helper.
  133823. */
  133824. dispose(): void;
  133825. }
  133826. }
  133827. declare module BABYLON {
  133828. /**
  133829. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133830. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133831. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133832. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133833. */
  133834. export class PhotoDome extends TransformNode {
  133835. /**
  133836. * Define the image as a Monoscopic panoramic 360 image.
  133837. */
  133838. static readonly MODE_MONOSCOPIC: number;
  133839. /**
  133840. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133841. */
  133842. static readonly MODE_TOPBOTTOM: number;
  133843. /**
  133844. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133845. */
  133846. static readonly MODE_SIDEBYSIDE: number;
  133847. private _useDirectMapping;
  133848. /**
  133849. * The texture being displayed on the sphere
  133850. */
  133851. protected _photoTexture: Texture;
  133852. /**
  133853. * Gets or sets the texture being displayed on the sphere
  133854. */
  133855. get photoTexture(): Texture;
  133856. set photoTexture(value: Texture);
  133857. /**
  133858. * Observable raised when an error occured while loading the 360 image
  133859. */
  133860. onLoadErrorObservable: Observable<string>;
  133861. /**
  133862. * The skybox material
  133863. */
  133864. protected _material: BackgroundMaterial;
  133865. /**
  133866. * The surface used for the skybox
  133867. */
  133868. protected _mesh: Mesh;
  133869. /**
  133870. * Gets the mesh used for the skybox.
  133871. */
  133872. get mesh(): Mesh;
  133873. /**
  133874. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133875. * Also see the options.resolution property.
  133876. */
  133877. get fovMultiplier(): number;
  133878. set fovMultiplier(value: number);
  133879. private _imageMode;
  133880. /**
  133881. * Gets or set the current video mode for the video. It can be:
  133882. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133883. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133884. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133885. */
  133886. get imageMode(): number;
  133887. set imageMode(value: number);
  133888. /**
  133889. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133890. * @param name Element's name, child elements will append suffixes for their own names.
  133891. * @param urlsOfPhoto defines the url of the photo to display
  133892. * @param options defines an object containing optional or exposed sub element properties
  133893. * @param onError defines a callback called when an error occured while loading the texture
  133894. */
  133895. constructor(name: string, urlOfPhoto: string, options: {
  133896. resolution?: number;
  133897. size?: number;
  133898. useDirectMapping?: boolean;
  133899. faceForward?: boolean;
  133900. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133901. private _onBeforeCameraRenderObserver;
  133902. private _changeImageMode;
  133903. /**
  133904. * Releases resources associated with this node.
  133905. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133906. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133907. */
  133908. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133909. }
  133910. }
  133911. declare module BABYLON {
  133912. /**
  133913. * Class used to host RGBD texture specific utilities
  133914. */
  133915. export class RGBDTextureTools {
  133916. /**
  133917. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133918. * @param texture the texture to expand.
  133919. */
  133920. static ExpandRGBDTexture(texture: Texture): void;
  133921. }
  133922. }
  133923. declare module BABYLON {
  133924. /**
  133925. * Class used to host texture specific utilities
  133926. */
  133927. export class BRDFTextureTools {
  133928. /**
  133929. * Prevents texture cache collision
  133930. */
  133931. private static _instanceNumber;
  133932. /**
  133933. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133934. * @param scene defines the hosting scene
  133935. * @returns the environment BRDF texture
  133936. */
  133937. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133938. private static _environmentBRDFBase64Texture;
  133939. }
  133940. }
  133941. declare module BABYLON {
  133942. /**
  133943. * @hidden
  133944. */
  133945. export interface IMaterialClearCoatDefines {
  133946. CLEARCOAT: boolean;
  133947. CLEARCOAT_DEFAULTIOR: boolean;
  133948. CLEARCOAT_TEXTURE: boolean;
  133949. CLEARCOAT_TEXTUREDIRECTUV: number;
  133950. CLEARCOAT_BUMP: boolean;
  133951. CLEARCOAT_BUMPDIRECTUV: number;
  133952. CLEARCOAT_TINT: boolean;
  133953. CLEARCOAT_TINT_TEXTURE: boolean;
  133954. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133955. /** @hidden */
  133956. _areTexturesDirty: boolean;
  133957. }
  133958. /**
  133959. * Define the code related to the clear coat parameters of the pbr material.
  133960. */
  133961. export class PBRClearCoatConfiguration {
  133962. /**
  133963. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133964. * The default fits with a polyurethane material.
  133965. */
  133966. private static readonly _DefaultIndexOfRefraction;
  133967. private _isEnabled;
  133968. /**
  133969. * Defines if the clear coat is enabled in the material.
  133970. */
  133971. isEnabled: boolean;
  133972. /**
  133973. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133974. */
  133975. intensity: number;
  133976. /**
  133977. * Defines the clear coat layer roughness.
  133978. */
  133979. roughness: number;
  133980. private _indexOfRefraction;
  133981. /**
  133982. * Defines the index of refraction of the clear coat.
  133983. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133984. * The default fits with a polyurethane material.
  133985. * Changing the default value is more performance intensive.
  133986. */
  133987. indexOfRefraction: number;
  133988. private _texture;
  133989. /**
  133990. * Stores the clear coat values in a texture.
  133991. */
  133992. texture: Nullable<BaseTexture>;
  133993. private _bumpTexture;
  133994. /**
  133995. * Define the clear coat specific bump texture.
  133996. */
  133997. bumpTexture: Nullable<BaseTexture>;
  133998. private _isTintEnabled;
  133999. /**
  134000. * Defines if the clear coat tint is enabled in the material.
  134001. */
  134002. isTintEnabled: boolean;
  134003. /**
  134004. * Defines the clear coat tint of the material.
  134005. * This is only use if tint is enabled
  134006. */
  134007. tintColor: Color3;
  134008. /**
  134009. * Defines the distance at which the tint color should be found in the
  134010. * clear coat media.
  134011. * This is only use if tint is enabled
  134012. */
  134013. tintColorAtDistance: number;
  134014. /**
  134015. * Defines the clear coat layer thickness.
  134016. * This is only use if tint is enabled
  134017. */
  134018. tintThickness: number;
  134019. private _tintTexture;
  134020. /**
  134021. * Stores the clear tint values in a texture.
  134022. * rgb is tint
  134023. * a is a thickness factor
  134024. */
  134025. tintTexture: Nullable<BaseTexture>;
  134026. /** @hidden */
  134027. private _internalMarkAllSubMeshesAsTexturesDirty;
  134028. /** @hidden */
  134029. _markAllSubMeshesAsTexturesDirty(): void;
  134030. /**
  134031. * Instantiate a new istance of clear coat configuration.
  134032. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134033. */
  134034. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134035. /**
  134036. * Gets wehter the submesh is ready to be used or not.
  134037. * @param defines the list of "defines" to update.
  134038. * @param scene defines the scene the material belongs to.
  134039. * @param engine defines the engine the material belongs to.
  134040. * @param disableBumpMap defines wether the material disables bump or not.
  134041. * @returns - boolean indicating that the submesh is ready or not.
  134042. */
  134043. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  134044. /**
  134045. * Checks to see if a texture is used in the material.
  134046. * @param defines the list of "defines" to update.
  134047. * @param scene defines the scene to the material belongs to.
  134048. */
  134049. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  134050. /**
  134051. * Binds the material data.
  134052. * @param uniformBuffer defines the Uniform buffer to fill in.
  134053. * @param scene defines the scene the material belongs to.
  134054. * @param engine defines the engine the material belongs to.
  134055. * @param disableBumpMap defines wether the material disables bump or not.
  134056. * @param isFrozen defines wether the material is frozen or not.
  134057. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134058. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134059. */
  134060. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  134061. /**
  134062. * Checks to see if a texture is used in the material.
  134063. * @param texture - Base texture to use.
  134064. * @returns - Boolean specifying if a texture is used in the material.
  134065. */
  134066. hasTexture(texture: BaseTexture): boolean;
  134067. /**
  134068. * Returns an array of the actively used textures.
  134069. * @param activeTextures Array of BaseTextures
  134070. */
  134071. getActiveTextures(activeTextures: BaseTexture[]): void;
  134072. /**
  134073. * Returns the animatable textures.
  134074. * @param animatables Array of animatable textures.
  134075. */
  134076. getAnimatables(animatables: IAnimatable[]): void;
  134077. /**
  134078. * Disposes the resources of the material.
  134079. * @param forceDisposeTextures - Forces the disposal of all textures.
  134080. */
  134081. dispose(forceDisposeTextures?: boolean): void;
  134082. /**
  134083. * Get the current class name of the texture useful for serialization or dynamic coding.
  134084. * @returns "PBRClearCoatConfiguration"
  134085. */
  134086. getClassName(): string;
  134087. /**
  134088. * Add fallbacks to the effect fallbacks list.
  134089. * @param defines defines the Base texture to use.
  134090. * @param fallbacks defines the current fallback list.
  134091. * @param currentRank defines the current fallback rank.
  134092. * @returns the new fallback rank.
  134093. */
  134094. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134095. /**
  134096. * Add the required uniforms to the current list.
  134097. * @param uniforms defines the current uniform list.
  134098. */
  134099. static AddUniforms(uniforms: string[]): void;
  134100. /**
  134101. * Add the required samplers to the current list.
  134102. * @param samplers defines the current sampler list.
  134103. */
  134104. static AddSamplers(samplers: string[]): void;
  134105. /**
  134106. * Add the required uniforms to the current buffer.
  134107. * @param uniformBuffer defines the current uniform buffer.
  134108. */
  134109. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134110. /**
  134111. * Makes a duplicate of the current configuration into another one.
  134112. * @param clearCoatConfiguration define the config where to copy the info
  134113. */
  134114. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  134115. /**
  134116. * Serializes this clear coat configuration.
  134117. * @returns - An object with the serialized config.
  134118. */
  134119. serialize(): any;
  134120. /**
  134121. * Parses a anisotropy Configuration from a serialized object.
  134122. * @param source - Serialized object.
  134123. * @param scene Defines the scene we are parsing for
  134124. * @param rootUrl Defines the rootUrl to load from
  134125. */
  134126. parse(source: any, scene: Scene, rootUrl: string): void;
  134127. }
  134128. }
  134129. declare module BABYLON {
  134130. /**
  134131. * @hidden
  134132. */
  134133. export interface IMaterialAnisotropicDefines {
  134134. ANISOTROPIC: boolean;
  134135. ANISOTROPIC_TEXTURE: boolean;
  134136. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134137. MAINUV1: boolean;
  134138. _areTexturesDirty: boolean;
  134139. _needUVs: boolean;
  134140. }
  134141. /**
  134142. * Define the code related to the anisotropic parameters of the pbr material.
  134143. */
  134144. export class PBRAnisotropicConfiguration {
  134145. private _isEnabled;
  134146. /**
  134147. * Defines if the anisotropy is enabled in the material.
  134148. */
  134149. isEnabled: boolean;
  134150. /**
  134151. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  134152. */
  134153. intensity: number;
  134154. /**
  134155. * Defines if the effect is along the tangents, bitangents or in between.
  134156. * By default, the effect is "strectching" the highlights along the tangents.
  134157. */
  134158. direction: Vector2;
  134159. private _texture;
  134160. /**
  134161. * Stores the anisotropy values in a texture.
  134162. * rg is direction (like normal from -1 to 1)
  134163. * b is a intensity
  134164. */
  134165. texture: Nullable<BaseTexture>;
  134166. /** @hidden */
  134167. private _internalMarkAllSubMeshesAsTexturesDirty;
  134168. /** @hidden */
  134169. _markAllSubMeshesAsTexturesDirty(): void;
  134170. /**
  134171. * Instantiate a new istance of anisotropy configuration.
  134172. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134173. */
  134174. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134175. /**
  134176. * Specifies that the submesh is ready to be used.
  134177. * @param defines the list of "defines" to update.
  134178. * @param scene defines the scene the material belongs to.
  134179. * @returns - boolean indicating that the submesh is ready or not.
  134180. */
  134181. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  134182. /**
  134183. * Checks to see if a texture is used in the material.
  134184. * @param defines the list of "defines" to update.
  134185. * @param mesh the mesh we are preparing the defines for.
  134186. * @param scene defines the scene the material belongs to.
  134187. */
  134188. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  134189. /**
  134190. * Binds the material data.
  134191. * @param uniformBuffer defines the Uniform buffer to fill in.
  134192. * @param scene defines the scene the material belongs to.
  134193. * @param isFrozen defines wether the material is frozen or not.
  134194. */
  134195. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134196. /**
  134197. * Checks to see if a texture is used in the material.
  134198. * @param texture - Base texture to use.
  134199. * @returns - Boolean specifying if a texture is used in the material.
  134200. */
  134201. hasTexture(texture: BaseTexture): boolean;
  134202. /**
  134203. * Returns an array of the actively used textures.
  134204. * @param activeTextures Array of BaseTextures
  134205. */
  134206. getActiveTextures(activeTextures: BaseTexture[]): void;
  134207. /**
  134208. * Returns the animatable textures.
  134209. * @param animatables Array of animatable textures.
  134210. */
  134211. getAnimatables(animatables: IAnimatable[]): void;
  134212. /**
  134213. * Disposes the resources of the material.
  134214. * @param forceDisposeTextures - Forces the disposal of all textures.
  134215. */
  134216. dispose(forceDisposeTextures?: boolean): void;
  134217. /**
  134218. * Get the current class name of the texture useful for serialization or dynamic coding.
  134219. * @returns "PBRAnisotropicConfiguration"
  134220. */
  134221. getClassName(): string;
  134222. /**
  134223. * Add fallbacks to the effect fallbacks list.
  134224. * @param defines defines the Base texture to use.
  134225. * @param fallbacks defines the current fallback list.
  134226. * @param currentRank defines the current fallback rank.
  134227. * @returns the new fallback rank.
  134228. */
  134229. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134230. /**
  134231. * Add the required uniforms to the current list.
  134232. * @param uniforms defines the current uniform list.
  134233. */
  134234. static AddUniforms(uniforms: string[]): void;
  134235. /**
  134236. * Add the required uniforms to the current buffer.
  134237. * @param uniformBuffer defines the current uniform buffer.
  134238. */
  134239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134240. /**
  134241. * Add the required samplers to the current list.
  134242. * @param samplers defines the current sampler list.
  134243. */
  134244. static AddSamplers(samplers: string[]): void;
  134245. /**
  134246. * Makes a duplicate of the current configuration into another one.
  134247. * @param anisotropicConfiguration define the config where to copy the info
  134248. */
  134249. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134250. /**
  134251. * Serializes this anisotropy configuration.
  134252. * @returns - An object with the serialized config.
  134253. */
  134254. serialize(): any;
  134255. /**
  134256. * Parses a anisotropy Configuration from a serialized object.
  134257. * @param source - Serialized object.
  134258. * @param scene Defines the scene we are parsing for
  134259. * @param rootUrl Defines the rootUrl to load from
  134260. */
  134261. parse(source: any, scene: Scene, rootUrl: string): void;
  134262. }
  134263. }
  134264. declare module BABYLON {
  134265. /**
  134266. * @hidden
  134267. */
  134268. export interface IMaterialBRDFDefines {
  134269. BRDF_V_HEIGHT_CORRELATED: boolean;
  134270. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134271. SPHERICAL_HARMONICS: boolean;
  134272. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134273. /** @hidden */
  134274. _areMiscDirty: boolean;
  134275. }
  134276. /**
  134277. * Define the code related to the BRDF parameters of the pbr material.
  134278. */
  134279. export class PBRBRDFConfiguration {
  134280. /**
  134281. * Default value used for the energy conservation.
  134282. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134283. */
  134284. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  134285. /**
  134286. * Default value used for the Smith Visibility Height Correlated mode.
  134287. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134288. */
  134289. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  134290. /**
  134291. * Default value used for the IBL diffuse part.
  134292. * This can help switching back to the polynomials mode globally which is a tiny bit
  134293. * less GPU intensive at the drawback of a lower quality.
  134294. */
  134295. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  134296. /**
  134297. * Default value used for activating energy conservation for the specular workflow.
  134298. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134299. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134300. */
  134301. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  134302. private _useEnergyConservation;
  134303. /**
  134304. * Defines if the material uses energy conservation.
  134305. */
  134306. useEnergyConservation: boolean;
  134307. private _useSmithVisibilityHeightCorrelated;
  134308. /**
  134309. * LEGACY Mode set to false
  134310. * Defines if the material uses height smith correlated visibility term.
  134311. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  134312. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  134313. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  134314. * Not relying on height correlated will also disable energy conservation.
  134315. */
  134316. useSmithVisibilityHeightCorrelated: boolean;
  134317. private _useSphericalHarmonics;
  134318. /**
  134319. * LEGACY Mode set to false
  134320. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  134321. * diffuse part of the IBL.
  134322. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  134323. * to the ground truth.
  134324. */
  134325. useSphericalHarmonics: boolean;
  134326. private _useSpecularGlossinessInputEnergyConservation;
  134327. /**
  134328. * Defines if the material uses energy conservation, when the specular workflow is active.
  134329. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134330. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134331. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  134332. */
  134333. useSpecularGlossinessInputEnergyConservation: boolean;
  134334. /** @hidden */
  134335. private _internalMarkAllSubMeshesAsMiscDirty;
  134336. /** @hidden */
  134337. _markAllSubMeshesAsMiscDirty(): void;
  134338. /**
  134339. * Instantiate a new istance of clear coat configuration.
  134340. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134341. */
  134342. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134343. /**
  134344. * Checks to see if a texture is used in the material.
  134345. * @param defines the list of "defines" to update.
  134346. */
  134347. prepareDefines(defines: IMaterialBRDFDefines): void;
  134348. /**
  134349. * Get the current class name of the texture useful for serialization or dynamic coding.
  134350. * @returns "PBRClearCoatConfiguration"
  134351. */
  134352. getClassName(): string;
  134353. /**
  134354. * Makes a duplicate of the current configuration into another one.
  134355. * @param brdfConfiguration define the config where to copy the info
  134356. */
  134357. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134358. /**
  134359. * Serializes this BRDF configuration.
  134360. * @returns - An object with the serialized config.
  134361. */
  134362. serialize(): any;
  134363. /**
  134364. * Parses a anisotropy Configuration from a serialized object.
  134365. * @param source - Serialized object.
  134366. * @param scene Defines the scene we are parsing for
  134367. * @param rootUrl Defines the rootUrl to load from
  134368. */
  134369. parse(source: any, scene: Scene, rootUrl: string): void;
  134370. }
  134371. }
  134372. declare module BABYLON {
  134373. /**
  134374. * @hidden
  134375. */
  134376. export interface IMaterialSheenDefines {
  134377. SHEEN: boolean;
  134378. SHEEN_TEXTURE: boolean;
  134379. SHEEN_TEXTUREDIRECTUV: number;
  134380. SHEEN_LINKWITHALBEDO: boolean;
  134381. SHEEN_ROUGHNESS: boolean;
  134382. SHEEN_ALBEDOSCALING: boolean;
  134383. /** @hidden */
  134384. _areTexturesDirty: boolean;
  134385. }
  134386. /**
  134387. * Define the code related to the Sheen parameters of the pbr material.
  134388. */
  134389. export class PBRSheenConfiguration {
  134390. private _isEnabled;
  134391. /**
  134392. * Defines if the material uses sheen.
  134393. */
  134394. isEnabled: boolean;
  134395. private _linkSheenWithAlbedo;
  134396. /**
  134397. * Defines if the sheen is linked to the sheen color.
  134398. */
  134399. linkSheenWithAlbedo: boolean;
  134400. /**
  134401. * Defines the sheen intensity.
  134402. */
  134403. intensity: number;
  134404. /**
  134405. * Defines the sheen color.
  134406. */
  134407. color: Color3;
  134408. private _texture;
  134409. /**
  134410. * Stores the sheen tint values in a texture.
  134411. * rgb is tint
  134412. * a is a intensity or roughness if roughness has been defined
  134413. */
  134414. texture: Nullable<BaseTexture>;
  134415. private _roughness;
  134416. /**
  134417. * Defines the sheen roughness.
  134418. * It is not taken into account if linkSheenWithAlbedo is true.
  134419. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134420. */
  134421. roughness: Nullable<number>;
  134422. private _albedoScaling;
  134423. /**
  134424. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134425. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134426. * making it easier to setup and tweak the effect
  134427. */
  134428. albedoScaling: boolean;
  134429. /** @hidden */
  134430. private _internalMarkAllSubMeshesAsTexturesDirty;
  134431. /** @hidden */
  134432. _markAllSubMeshesAsTexturesDirty(): void;
  134433. /**
  134434. * Instantiate a new istance of clear coat configuration.
  134435. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134436. */
  134437. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134438. /**
  134439. * Specifies that the submesh is ready to be used.
  134440. * @param defines the list of "defines" to update.
  134441. * @param scene defines the scene the material belongs to.
  134442. * @returns - boolean indicating that the submesh is ready or not.
  134443. */
  134444. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134445. /**
  134446. * Checks to see if a texture is used in the material.
  134447. * @param defines the list of "defines" to update.
  134448. * @param scene defines the scene the material belongs to.
  134449. */
  134450. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134451. /**
  134452. * Binds the material data.
  134453. * @param uniformBuffer defines the Uniform buffer to fill in.
  134454. * @param scene defines the scene the material belongs to.
  134455. * @param isFrozen defines wether the material is frozen or not.
  134456. */
  134457. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134458. /**
  134459. * Checks to see if a texture is used in the material.
  134460. * @param texture - Base texture to use.
  134461. * @returns - Boolean specifying if a texture is used in the material.
  134462. */
  134463. hasTexture(texture: BaseTexture): boolean;
  134464. /**
  134465. * Returns an array of the actively used textures.
  134466. * @param activeTextures Array of BaseTextures
  134467. */
  134468. getActiveTextures(activeTextures: BaseTexture[]): void;
  134469. /**
  134470. * Returns the animatable textures.
  134471. * @param animatables Array of animatable textures.
  134472. */
  134473. getAnimatables(animatables: IAnimatable[]): void;
  134474. /**
  134475. * Disposes the resources of the material.
  134476. * @param forceDisposeTextures - Forces the disposal of all textures.
  134477. */
  134478. dispose(forceDisposeTextures?: boolean): void;
  134479. /**
  134480. * Get the current class name of the texture useful for serialization or dynamic coding.
  134481. * @returns "PBRSheenConfiguration"
  134482. */
  134483. getClassName(): string;
  134484. /**
  134485. * Add fallbacks to the effect fallbacks list.
  134486. * @param defines defines the Base texture to use.
  134487. * @param fallbacks defines the current fallback list.
  134488. * @param currentRank defines the current fallback rank.
  134489. * @returns the new fallback rank.
  134490. */
  134491. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134492. /**
  134493. * Add the required uniforms to the current list.
  134494. * @param uniforms defines the current uniform list.
  134495. */
  134496. static AddUniforms(uniforms: string[]): void;
  134497. /**
  134498. * Add the required uniforms to the current buffer.
  134499. * @param uniformBuffer defines the current uniform buffer.
  134500. */
  134501. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134502. /**
  134503. * Add the required samplers to the current list.
  134504. * @param samplers defines the current sampler list.
  134505. */
  134506. static AddSamplers(samplers: string[]): void;
  134507. /**
  134508. * Makes a duplicate of the current configuration into another one.
  134509. * @param sheenConfiguration define the config where to copy the info
  134510. */
  134511. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134512. /**
  134513. * Serializes this BRDF configuration.
  134514. * @returns - An object with the serialized config.
  134515. */
  134516. serialize(): any;
  134517. /**
  134518. * Parses a anisotropy Configuration from a serialized object.
  134519. * @param source - Serialized object.
  134520. * @param scene Defines the scene we are parsing for
  134521. * @param rootUrl Defines the rootUrl to load from
  134522. */
  134523. parse(source: any, scene: Scene, rootUrl: string): void;
  134524. }
  134525. }
  134526. declare module BABYLON {
  134527. /**
  134528. * @hidden
  134529. */
  134530. export interface IMaterialSubSurfaceDefines {
  134531. SUBSURFACE: boolean;
  134532. SS_REFRACTION: boolean;
  134533. SS_TRANSLUCENCY: boolean;
  134534. SS_SCATTERING: boolean;
  134535. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134536. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134537. SS_REFRACTIONMAP_3D: boolean;
  134538. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134539. SS_LODINREFRACTIONALPHA: boolean;
  134540. SS_GAMMAREFRACTION: boolean;
  134541. SS_RGBDREFRACTION: boolean;
  134542. SS_LINEARSPECULARREFRACTION: boolean;
  134543. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134544. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134545. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134546. /** @hidden */
  134547. _areTexturesDirty: boolean;
  134548. }
  134549. /**
  134550. * Define the code related to the sub surface parameters of the pbr material.
  134551. */
  134552. export class PBRSubSurfaceConfiguration {
  134553. private _isRefractionEnabled;
  134554. /**
  134555. * Defines if the refraction is enabled in the material.
  134556. */
  134557. isRefractionEnabled: boolean;
  134558. private _isTranslucencyEnabled;
  134559. /**
  134560. * Defines if the translucency is enabled in the material.
  134561. */
  134562. isTranslucencyEnabled: boolean;
  134563. private _isScatteringEnabled;
  134564. /**
  134565. * Defines if the sub surface scattering is enabled in the material.
  134566. */
  134567. isScatteringEnabled: boolean;
  134568. private _scatteringDiffusionProfileIndex;
  134569. /**
  134570. * Diffusion profile for subsurface scattering.
  134571. * Useful for better scattering in the skins or foliages.
  134572. */
  134573. get scatteringDiffusionProfile(): Nullable<Color3>;
  134574. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134575. /**
  134576. * Defines the refraction intensity of the material.
  134577. * The refraction when enabled replaces the Diffuse part of the material.
  134578. * The intensity helps transitionning between diffuse and refraction.
  134579. */
  134580. refractionIntensity: number;
  134581. /**
  134582. * Defines the translucency intensity of the material.
  134583. * When translucency has been enabled, this defines how much of the "translucency"
  134584. * is addded to the diffuse part of the material.
  134585. */
  134586. translucencyIntensity: number;
  134587. /**
  134588. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134589. */
  134590. useAlbedoToTintRefraction: boolean;
  134591. private _thicknessTexture;
  134592. /**
  134593. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134594. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134595. * 0 would mean minimumThickness
  134596. * 1 would mean maximumThickness
  134597. * The other channels might be use as a mask to vary the different effects intensity.
  134598. */
  134599. thicknessTexture: Nullable<BaseTexture>;
  134600. private _refractionTexture;
  134601. /**
  134602. * Defines the texture to use for refraction.
  134603. */
  134604. refractionTexture: Nullable<BaseTexture>;
  134605. private _indexOfRefraction;
  134606. /**
  134607. * Index of refraction of the material base layer.
  134608. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134609. *
  134610. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134611. *
  134612. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134613. */
  134614. indexOfRefraction: number;
  134615. private _volumeIndexOfRefraction;
  134616. /**
  134617. * Index of refraction of the material's volume.
  134618. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134619. *
  134620. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134621. * the volume will use the same IOR as the surface.
  134622. */
  134623. get volumeIndexOfRefraction(): number;
  134624. set volumeIndexOfRefraction(value: number);
  134625. private _invertRefractionY;
  134626. /**
  134627. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134628. */
  134629. invertRefractionY: boolean;
  134630. private _linkRefractionWithTransparency;
  134631. /**
  134632. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134633. * Materials half opaque for instance using refraction could benefit from this control.
  134634. */
  134635. linkRefractionWithTransparency: boolean;
  134636. /**
  134637. * Defines the minimum thickness stored in the thickness map.
  134638. * If no thickness map is defined, this value will be used to simulate thickness.
  134639. */
  134640. minimumThickness: number;
  134641. /**
  134642. * Defines the maximum thickness stored in the thickness map.
  134643. */
  134644. maximumThickness: number;
  134645. /**
  134646. * Defines the volume tint of the material.
  134647. * This is used for both translucency and scattering.
  134648. */
  134649. tintColor: Color3;
  134650. /**
  134651. * Defines the distance at which the tint color should be found in the media.
  134652. * This is used for refraction only.
  134653. */
  134654. tintColorAtDistance: number;
  134655. /**
  134656. * Defines how far each channel transmit through the media.
  134657. * It is defined as a color to simplify it selection.
  134658. */
  134659. diffusionDistance: Color3;
  134660. private _useMaskFromThicknessTexture;
  134661. /**
  134662. * Stores the intensity of the different subsurface effects in the thickness texture.
  134663. * * the green channel is the translucency intensity.
  134664. * * the blue channel is the scattering intensity.
  134665. * * the alpha channel is the refraction intensity.
  134666. */
  134667. useMaskFromThicknessTexture: boolean;
  134668. private _scene;
  134669. /** @hidden */
  134670. private _internalMarkAllSubMeshesAsTexturesDirty;
  134671. private _internalMarkScenePrePassDirty;
  134672. /** @hidden */
  134673. _markAllSubMeshesAsTexturesDirty(): void;
  134674. /** @hidden */
  134675. _markScenePrePassDirty(): void;
  134676. /**
  134677. * Instantiate a new istance of sub surface configuration.
  134678. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134679. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134680. * @param scene The scene
  134681. */
  134682. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134683. /**
  134684. * Gets wehter the submesh is ready to be used or not.
  134685. * @param defines the list of "defines" to update.
  134686. * @param scene defines the scene the material belongs to.
  134687. * @returns - boolean indicating that the submesh is ready or not.
  134688. */
  134689. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134690. /**
  134691. * Checks to see if a texture is used in the material.
  134692. * @param defines the list of "defines" to update.
  134693. * @param scene defines the scene to the material belongs to.
  134694. */
  134695. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134696. /**
  134697. * Binds the material data.
  134698. * @param uniformBuffer defines the Uniform buffer to fill in.
  134699. * @param scene defines the scene the material belongs to.
  134700. * @param engine defines the engine the material belongs to.
  134701. * @param isFrozen defines whether the material is frozen or not.
  134702. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134703. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134704. */
  134705. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134706. /**
  134707. * Unbinds the material from the mesh.
  134708. * @param activeEffect defines the effect that should be unbound from.
  134709. * @returns true if unbound, otherwise false
  134710. */
  134711. unbind(activeEffect: Effect): boolean;
  134712. /**
  134713. * Returns the texture used for refraction or null if none is used.
  134714. * @param scene defines the scene the material belongs to.
  134715. * @returns - Refraction texture if present. If no refraction texture and refraction
  134716. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134717. */
  134718. private _getRefractionTexture;
  134719. /**
  134720. * Returns true if alpha blending should be disabled.
  134721. */
  134722. get disableAlphaBlending(): boolean;
  134723. /**
  134724. * Fills the list of render target textures.
  134725. * @param renderTargets the list of render targets to update
  134726. */
  134727. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134728. /**
  134729. * Checks to see if a texture is used in the material.
  134730. * @param texture - Base texture to use.
  134731. * @returns - Boolean specifying if a texture is used in the material.
  134732. */
  134733. hasTexture(texture: BaseTexture): boolean;
  134734. /**
  134735. * Gets a boolean indicating that current material needs to register RTT
  134736. * @returns true if this uses a render target otherwise false.
  134737. */
  134738. hasRenderTargetTextures(): boolean;
  134739. /**
  134740. * Returns an array of the actively used textures.
  134741. * @param activeTextures Array of BaseTextures
  134742. */
  134743. getActiveTextures(activeTextures: BaseTexture[]): void;
  134744. /**
  134745. * Returns the animatable textures.
  134746. * @param animatables Array of animatable textures.
  134747. */
  134748. getAnimatables(animatables: IAnimatable[]): void;
  134749. /**
  134750. * Disposes the resources of the material.
  134751. * @param forceDisposeTextures - Forces the disposal of all textures.
  134752. */
  134753. dispose(forceDisposeTextures?: boolean): void;
  134754. /**
  134755. * Get the current class name of the texture useful for serialization or dynamic coding.
  134756. * @returns "PBRSubSurfaceConfiguration"
  134757. */
  134758. getClassName(): string;
  134759. /**
  134760. * Add fallbacks to the effect fallbacks list.
  134761. * @param defines defines the Base texture to use.
  134762. * @param fallbacks defines the current fallback list.
  134763. * @param currentRank defines the current fallback rank.
  134764. * @returns the new fallback rank.
  134765. */
  134766. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134767. /**
  134768. * Add the required uniforms to the current list.
  134769. * @param uniforms defines the current uniform list.
  134770. */
  134771. static AddUniforms(uniforms: string[]): void;
  134772. /**
  134773. * Add the required samplers to the current list.
  134774. * @param samplers defines the current sampler list.
  134775. */
  134776. static AddSamplers(samplers: string[]): void;
  134777. /**
  134778. * Add the required uniforms to the current buffer.
  134779. * @param uniformBuffer defines the current uniform buffer.
  134780. */
  134781. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134782. /**
  134783. * Makes a duplicate of the current configuration into another one.
  134784. * @param configuration define the config where to copy the info
  134785. */
  134786. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134787. /**
  134788. * Serializes this Sub Surface configuration.
  134789. * @returns - An object with the serialized config.
  134790. */
  134791. serialize(): any;
  134792. /**
  134793. * Parses a anisotropy Configuration from a serialized object.
  134794. * @param source - Serialized object.
  134795. * @param scene Defines the scene we are parsing for
  134796. * @param rootUrl Defines the rootUrl to load from
  134797. */
  134798. parse(source: any, scene: Scene, rootUrl: string): void;
  134799. }
  134800. }
  134801. declare module BABYLON {
  134802. /** @hidden */
  134803. export var pbrFragmentDeclaration: {
  134804. name: string;
  134805. shader: string;
  134806. };
  134807. }
  134808. declare module BABYLON {
  134809. /** @hidden */
  134810. export var pbrUboDeclaration: {
  134811. name: string;
  134812. shader: string;
  134813. };
  134814. }
  134815. declare module BABYLON {
  134816. /** @hidden */
  134817. export var pbrFragmentExtraDeclaration: {
  134818. name: string;
  134819. shader: string;
  134820. };
  134821. }
  134822. declare module BABYLON {
  134823. /** @hidden */
  134824. export var pbrFragmentSamplersDeclaration: {
  134825. name: string;
  134826. shader: string;
  134827. };
  134828. }
  134829. declare module BABYLON {
  134830. /** @hidden */
  134831. export var importanceSampling: {
  134832. name: string;
  134833. shader: string;
  134834. };
  134835. }
  134836. declare module BABYLON {
  134837. /** @hidden */
  134838. export var pbrHelperFunctions: {
  134839. name: string;
  134840. shader: string;
  134841. };
  134842. }
  134843. declare module BABYLON {
  134844. /** @hidden */
  134845. export var harmonicsFunctions: {
  134846. name: string;
  134847. shader: string;
  134848. };
  134849. }
  134850. declare module BABYLON {
  134851. /** @hidden */
  134852. export var pbrDirectLightingSetupFunctions: {
  134853. name: string;
  134854. shader: string;
  134855. };
  134856. }
  134857. declare module BABYLON {
  134858. /** @hidden */
  134859. export var pbrDirectLightingFalloffFunctions: {
  134860. name: string;
  134861. shader: string;
  134862. };
  134863. }
  134864. declare module BABYLON {
  134865. /** @hidden */
  134866. export var pbrBRDFFunctions: {
  134867. name: string;
  134868. shader: string;
  134869. };
  134870. }
  134871. declare module BABYLON {
  134872. /** @hidden */
  134873. export var hdrFilteringFunctions: {
  134874. name: string;
  134875. shader: string;
  134876. };
  134877. }
  134878. declare module BABYLON {
  134879. /** @hidden */
  134880. export var pbrDirectLightingFunctions: {
  134881. name: string;
  134882. shader: string;
  134883. };
  134884. }
  134885. declare module BABYLON {
  134886. /** @hidden */
  134887. export var pbrIBLFunctions: {
  134888. name: string;
  134889. shader: string;
  134890. };
  134891. }
  134892. declare module BABYLON {
  134893. /** @hidden */
  134894. export var pbrBlockAlbedoOpacity: {
  134895. name: string;
  134896. shader: string;
  134897. };
  134898. }
  134899. declare module BABYLON {
  134900. /** @hidden */
  134901. export var pbrBlockReflectivity: {
  134902. name: string;
  134903. shader: string;
  134904. };
  134905. }
  134906. declare module BABYLON {
  134907. /** @hidden */
  134908. export var pbrBlockAmbientOcclusion: {
  134909. name: string;
  134910. shader: string;
  134911. };
  134912. }
  134913. declare module BABYLON {
  134914. /** @hidden */
  134915. export var pbrBlockAlphaFresnel: {
  134916. name: string;
  134917. shader: string;
  134918. };
  134919. }
  134920. declare module BABYLON {
  134921. /** @hidden */
  134922. export var pbrBlockAnisotropic: {
  134923. name: string;
  134924. shader: string;
  134925. };
  134926. }
  134927. declare module BABYLON {
  134928. /** @hidden */
  134929. export var pbrBlockReflection: {
  134930. name: string;
  134931. shader: string;
  134932. };
  134933. }
  134934. declare module BABYLON {
  134935. /** @hidden */
  134936. export var pbrBlockSheen: {
  134937. name: string;
  134938. shader: string;
  134939. };
  134940. }
  134941. declare module BABYLON {
  134942. /** @hidden */
  134943. export var pbrBlockClearcoat: {
  134944. name: string;
  134945. shader: string;
  134946. };
  134947. }
  134948. declare module BABYLON {
  134949. /** @hidden */
  134950. export var pbrBlockSubSurface: {
  134951. name: string;
  134952. shader: string;
  134953. };
  134954. }
  134955. declare module BABYLON {
  134956. /** @hidden */
  134957. export var pbrBlockNormalGeometric: {
  134958. name: string;
  134959. shader: string;
  134960. };
  134961. }
  134962. declare module BABYLON {
  134963. /** @hidden */
  134964. export var pbrBlockNormalFinal: {
  134965. name: string;
  134966. shader: string;
  134967. };
  134968. }
  134969. declare module BABYLON {
  134970. /** @hidden */
  134971. export var pbrBlockLightmapInit: {
  134972. name: string;
  134973. shader: string;
  134974. };
  134975. }
  134976. declare module BABYLON {
  134977. /** @hidden */
  134978. export var pbrBlockGeometryInfo: {
  134979. name: string;
  134980. shader: string;
  134981. };
  134982. }
  134983. declare module BABYLON {
  134984. /** @hidden */
  134985. export var pbrBlockReflectance0: {
  134986. name: string;
  134987. shader: string;
  134988. };
  134989. }
  134990. declare module BABYLON {
  134991. /** @hidden */
  134992. export var pbrBlockReflectance: {
  134993. name: string;
  134994. shader: string;
  134995. };
  134996. }
  134997. declare module BABYLON {
  134998. /** @hidden */
  134999. export var pbrBlockDirectLighting: {
  135000. name: string;
  135001. shader: string;
  135002. };
  135003. }
  135004. declare module BABYLON {
  135005. /** @hidden */
  135006. export var pbrBlockFinalLitComponents: {
  135007. name: string;
  135008. shader: string;
  135009. };
  135010. }
  135011. declare module BABYLON {
  135012. /** @hidden */
  135013. export var pbrBlockFinalUnlitComponents: {
  135014. name: string;
  135015. shader: string;
  135016. };
  135017. }
  135018. declare module BABYLON {
  135019. /** @hidden */
  135020. export var pbrBlockFinalColorComposition: {
  135021. name: string;
  135022. shader: string;
  135023. };
  135024. }
  135025. declare module BABYLON {
  135026. /** @hidden */
  135027. export var pbrBlockImageProcessing: {
  135028. name: string;
  135029. shader: string;
  135030. };
  135031. }
  135032. declare module BABYLON {
  135033. /** @hidden */
  135034. export var pbrDebug: {
  135035. name: string;
  135036. shader: string;
  135037. };
  135038. }
  135039. declare module BABYLON {
  135040. /** @hidden */
  135041. export var pbrPixelShader: {
  135042. name: string;
  135043. shader: string;
  135044. };
  135045. }
  135046. declare module BABYLON {
  135047. /** @hidden */
  135048. export var pbrVertexDeclaration: {
  135049. name: string;
  135050. shader: string;
  135051. };
  135052. }
  135053. declare module BABYLON {
  135054. /** @hidden */
  135055. export var pbrVertexShader: {
  135056. name: string;
  135057. shader: string;
  135058. };
  135059. }
  135060. declare module BABYLON {
  135061. /**
  135062. * Manages the defines for the PBR Material.
  135063. * @hidden
  135064. */
  135065. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  135066. PBR: boolean;
  135067. NUM_SAMPLES: string;
  135068. REALTIME_FILTERING: boolean;
  135069. MAINUV1: boolean;
  135070. MAINUV2: boolean;
  135071. UV1: boolean;
  135072. UV2: boolean;
  135073. ALBEDO: boolean;
  135074. GAMMAALBEDO: boolean;
  135075. ALBEDODIRECTUV: number;
  135076. VERTEXCOLOR: boolean;
  135077. DETAIL: boolean;
  135078. DETAILDIRECTUV: number;
  135079. DETAIL_NORMALBLENDMETHOD: number;
  135080. AMBIENT: boolean;
  135081. AMBIENTDIRECTUV: number;
  135082. AMBIENTINGRAYSCALE: boolean;
  135083. OPACITY: boolean;
  135084. VERTEXALPHA: boolean;
  135085. OPACITYDIRECTUV: number;
  135086. OPACITYRGB: boolean;
  135087. ALPHATEST: boolean;
  135088. DEPTHPREPASS: boolean;
  135089. ALPHABLEND: boolean;
  135090. ALPHAFROMALBEDO: boolean;
  135091. ALPHATESTVALUE: string;
  135092. SPECULAROVERALPHA: boolean;
  135093. RADIANCEOVERALPHA: boolean;
  135094. ALPHAFRESNEL: boolean;
  135095. LINEARALPHAFRESNEL: boolean;
  135096. PREMULTIPLYALPHA: boolean;
  135097. EMISSIVE: boolean;
  135098. EMISSIVEDIRECTUV: number;
  135099. REFLECTIVITY: boolean;
  135100. REFLECTIVITYDIRECTUV: number;
  135101. SPECULARTERM: boolean;
  135102. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  135103. MICROSURFACEAUTOMATIC: boolean;
  135104. LODBASEDMICROSFURACE: boolean;
  135105. MICROSURFACEMAP: boolean;
  135106. MICROSURFACEMAPDIRECTUV: number;
  135107. METALLICWORKFLOW: boolean;
  135108. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  135109. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  135110. METALLNESSSTOREINMETALMAPBLUE: boolean;
  135111. AOSTOREINMETALMAPRED: boolean;
  135112. METALLIC_REFLECTANCE: boolean;
  135113. METALLIC_REFLECTANCEDIRECTUV: number;
  135114. ENVIRONMENTBRDF: boolean;
  135115. ENVIRONMENTBRDF_RGBD: boolean;
  135116. NORMAL: boolean;
  135117. TANGENT: boolean;
  135118. BUMP: boolean;
  135119. BUMPDIRECTUV: number;
  135120. OBJECTSPACE_NORMALMAP: boolean;
  135121. PARALLAX: boolean;
  135122. PARALLAXOCCLUSION: boolean;
  135123. NORMALXYSCALE: boolean;
  135124. LIGHTMAP: boolean;
  135125. LIGHTMAPDIRECTUV: number;
  135126. USELIGHTMAPASSHADOWMAP: boolean;
  135127. GAMMALIGHTMAP: boolean;
  135128. RGBDLIGHTMAP: boolean;
  135129. REFLECTION: boolean;
  135130. REFLECTIONMAP_3D: boolean;
  135131. REFLECTIONMAP_SPHERICAL: boolean;
  135132. REFLECTIONMAP_PLANAR: boolean;
  135133. REFLECTIONMAP_CUBIC: boolean;
  135134. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  135135. REFLECTIONMAP_PROJECTION: boolean;
  135136. REFLECTIONMAP_SKYBOX: boolean;
  135137. REFLECTIONMAP_EXPLICIT: boolean;
  135138. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  135139. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  135140. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  135141. INVERTCUBICMAP: boolean;
  135142. USESPHERICALFROMREFLECTIONMAP: boolean;
  135143. USEIRRADIANCEMAP: boolean;
  135144. SPHERICAL_HARMONICS: boolean;
  135145. USESPHERICALINVERTEX: boolean;
  135146. REFLECTIONMAP_OPPOSITEZ: boolean;
  135147. LODINREFLECTIONALPHA: boolean;
  135148. GAMMAREFLECTION: boolean;
  135149. RGBDREFLECTION: boolean;
  135150. LINEARSPECULARREFLECTION: boolean;
  135151. RADIANCEOCCLUSION: boolean;
  135152. HORIZONOCCLUSION: boolean;
  135153. INSTANCES: boolean;
  135154. THIN_INSTANCES: boolean;
  135155. PREPASS: boolean;
  135156. SCENE_MRT_COUNT: number;
  135157. NUM_BONE_INFLUENCERS: number;
  135158. BonesPerMesh: number;
  135159. BONETEXTURE: boolean;
  135160. NONUNIFORMSCALING: boolean;
  135161. MORPHTARGETS: boolean;
  135162. MORPHTARGETS_NORMAL: boolean;
  135163. MORPHTARGETS_TANGENT: boolean;
  135164. MORPHTARGETS_UV: boolean;
  135165. NUM_MORPH_INFLUENCERS: number;
  135166. IMAGEPROCESSING: boolean;
  135167. VIGNETTE: boolean;
  135168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  135169. VIGNETTEBLENDMODEOPAQUE: boolean;
  135170. TONEMAPPING: boolean;
  135171. TONEMAPPING_ACES: boolean;
  135172. CONTRAST: boolean;
  135173. COLORCURVES: boolean;
  135174. COLORGRADING: boolean;
  135175. COLORGRADING3D: boolean;
  135176. SAMPLER3DGREENDEPTH: boolean;
  135177. SAMPLER3DBGRMAP: boolean;
  135178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  135179. EXPOSURE: boolean;
  135180. MULTIVIEW: boolean;
  135181. USEPHYSICALLIGHTFALLOFF: boolean;
  135182. USEGLTFLIGHTFALLOFF: boolean;
  135183. TWOSIDEDLIGHTING: boolean;
  135184. SHADOWFLOAT: boolean;
  135185. CLIPPLANE: boolean;
  135186. CLIPPLANE2: boolean;
  135187. CLIPPLANE3: boolean;
  135188. CLIPPLANE4: boolean;
  135189. CLIPPLANE5: boolean;
  135190. CLIPPLANE6: boolean;
  135191. POINTSIZE: boolean;
  135192. FOG: boolean;
  135193. LOGARITHMICDEPTH: boolean;
  135194. FORCENORMALFORWARD: boolean;
  135195. SPECULARAA: boolean;
  135196. CLEARCOAT: boolean;
  135197. CLEARCOAT_DEFAULTIOR: boolean;
  135198. CLEARCOAT_TEXTURE: boolean;
  135199. CLEARCOAT_TEXTUREDIRECTUV: number;
  135200. CLEARCOAT_BUMP: boolean;
  135201. CLEARCOAT_BUMPDIRECTUV: number;
  135202. CLEARCOAT_TINT: boolean;
  135203. CLEARCOAT_TINT_TEXTURE: boolean;
  135204. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135205. ANISOTROPIC: boolean;
  135206. ANISOTROPIC_TEXTURE: boolean;
  135207. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135208. BRDF_V_HEIGHT_CORRELATED: boolean;
  135209. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135210. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135211. SHEEN: boolean;
  135212. SHEEN_TEXTURE: boolean;
  135213. SHEEN_TEXTUREDIRECTUV: number;
  135214. SHEEN_LINKWITHALBEDO: boolean;
  135215. SHEEN_ROUGHNESS: boolean;
  135216. SHEEN_ALBEDOSCALING: boolean;
  135217. SUBSURFACE: boolean;
  135218. SS_REFRACTION: boolean;
  135219. SS_TRANSLUCENCY: boolean;
  135220. SS_SCATTERING: boolean;
  135221. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135222. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135223. SS_REFRACTIONMAP_3D: boolean;
  135224. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135225. SS_LODINREFRACTIONALPHA: boolean;
  135226. SS_GAMMAREFRACTION: boolean;
  135227. SS_RGBDREFRACTION: boolean;
  135228. SS_LINEARSPECULARREFRACTION: boolean;
  135229. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135230. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135231. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135232. UNLIT: boolean;
  135233. DEBUGMODE: number;
  135234. /**
  135235. * Initializes the PBR Material defines.
  135236. */
  135237. constructor();
  135238. /**
  135239. * Resets the PBR Material defines.
  135240. */
  135241. reset(): void;
  135242. }
  135243. /**
  135244. * The Physically based material base class of BJS.
  135245. *
  135246. * This offers the main features of a standard PBR material.
  135247. * For more information, please refer to the documentation :
  135248. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135249. */
  135250. export abstract class PBRBaseMaterial extends PushMaterial {
  135251. /**
  135252. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135253. */
  135254. static readonly PBRMATERIAL_OPAQUE: number;
  135255. /**
  135256. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135257. */
  135258. static readonly PBRMATERIAL_ALPHATEST: number;
  135259. /**
  135260. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135261. */
  135262. static readonly PBRMATERIAL_ALPHABLEND: number;
  135263. /**
  135264. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135265. * They are also discarded below the alpha cutoff threshold to improve performances.
  135266. */
  135267. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135268. /**
  135269. * Defines the default value of how much AO map is occluding the analytical lights
  135270. * (point spot...).
  135271. */
  135272. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135273. /**
  135274. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  135275. */
  135276. static readonly LIGHTFALLOFF_PHYSICAL: number;
  135277. /**
  135278. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  135279. * to enhance interoperability with other engines.
  135280. */
  135281. static readonly LIGHTFALLOFF_GLTF: number;
  135282. /**
  135283. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  135284. * to enhance interoperability with other materials.
  135285. */
  135286. static readonly LIGHTFALLOFF_STANDARD: number;
  135287. /**
  135288. * Intensity of the direct lights e.g. the four lights available in your scene.
  135289. * This impacts both the direct diffuse and specular highlights.
  135290. */
  135291. protected _directIntensity: number;
  135292. /**
  135293. * Intensity of the emissive part of the material.
  135294. * This helps controlling the emissive effect without modifying the emissive color.
  135295. */
  135296. protected _emissiveIntensity: number;
  135297. /**
  135298. * Intensity of the environment e.g. how much the environment will light the object
  135299. * either through harmonics for rough material or through the refelction for shiny ones.
  135300. */
  135301. protected _environmentIntensity: number;
  135302. /**
  135303. * This is a special control allowing the reduction of the specular highlights coming from the
  135304. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135305. */
  135306. protected _specularIntensity: number;
  135307. /**
  135308. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  135309. */
  135310. private _lightingInfos;
  135311. /**
  135312. * Debug Control allowing disabling the bump map on this material.
  135313. */
  135314. protected _disableBumpMap: boolean;
  135315. /**
  135316. * AKA Diffuse Texture in standard nomenclature.
  135317. */
  135318. protected _albedoTexture: Nullable<BaseTexture>;
  135319. /**
  135320. * AKA Occlusion Texture in other nomenclature.
  135321. */
  135322. protected _ambientTexture: Nullable<BaseTexture>;
  135323. /**
  135324. * AKA Occlusion Texture Intensity in other nomenclature.
  135325. */
  135326. protected _ambientTextureStrength: number;
  135327. /**
  135328. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135329. * 1 means it completely occludes it
  135330. * 0 mean it has no impact
  135331. */
  135332. protected _ambientTextureImpactOnAnalyticalLights: number;
  135333. /**
  135334. * Stores the alpha values in a texture.
  135335. */
  135336. protected _opacityTexture: Nullable<BaseTexture>;
  135337. /**
  135338. * Stores the reflection values in a texture.
  135339. */
  135340. protected _reflectionTexture: Nullable<BaseTexture>;
  135341. /**
  135342. * Stores the emissive values in a texture.
  135343. */
  135344. protected _emissiveTexture: Nullable<BaseTexture>;
  135345. /**
  135346. * AKA Specular texture in other nomenclature.
  135347. */
  135348. protected _reflectivityTexture: Nullable<BaseTexture>;
  135349. /**
  135350. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135351. */
  135352. protected _metallicTexture: Nullable<BaseTexture>;
  135353. /**
  135354. * Specifies the metallic scalar of the metallic/roughness workflow.
  135355. * Can also be used to scale the metalness values of the metallic texture.
  135356. */
  135357. protected _metallic: Nullable<number>;
  135358. /**
  135359. * Specifies the roughness scalar of the metallic/roughness workflow.
  135360. * Can also be used to scale the roughness values of the metallic texture.
  135361. */
  135362. protected _roughness: Nullable<number>;
  135363. /**
  135364. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135365. * By default the indexOfrefraction is used to compute F0;
  135366. *
  135367. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135368. *
  135369. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135370. * F90 = metallicReflectanceColor;
  135371. */
  135372. protected _metallicF0Factor: number;
  135373. /**
  135374. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135375. * By default the F90 is always 1;
  135376. *
  135377. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135378. *
  135379. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135380. * F90 = metallicReflectanceColor;
  135381. */
  135382. protected _metallicReflectanceColor: Color3;
  135383. /**
  135384. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135385. * This is multiply against the scalar values defined in the material.
  135386. */
  135387. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135388. /**
  135389. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135390. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135391. */
  135392. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135393. /**
  135394. * Stores surface normal data used to displace a mesh in a texture.
  135395. */
  135396. protected _bumpTexture: Nullable<BaseTexture>;
  135397. /**
  135398. * Stores the pre-calculated light information of a mesh in a texture.
  135399. */
  135400. protected _lightmapTexture: Nullable<BaseTexture>;
  135401. /**
  135402. * The color of a material in ambient lighting.
  135403. */
  135404. protected _ambientColor: Color3;
  135405. /**
  135406. * AKA Diffuse Color in other nomenclature.
  135407. */
  135408. protected _albedoColor: Color3;
  135409. /**
  135410. * AKA Specular Color in other nomenclature.
  135411. */
  135412. protected _reflectivityColor: Color3;
  135413. /**
  135414. * The color applied when light is reflected from a material.
  135415. */
  135416. protected _reflectionColor: Color3;
  135417. /**
  135418. * The color applied when light is emitted from a material.
  135419. */
  135420. protected _emissiveColor: Color3;
  135421. /**
  135422. * AKA Glossiness in other nomenclature.
  135423. */
  135424. protected _microSurface: number;
  135425. /**
  135426. * Specifies that the material will use the light map as a show map.
  135427. */
  135428. protected _useLightmapAsShadowmap: boolean;
  135429. /**
  135430. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135431. * makes the reflect vector face the model (under horizon).
  135432. */
  135433. protected _useHorizonOcclusion: boolean;
  135434. /**
  135435. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135436. * too much the area relying on ambient texture to define their ambient occlusion.
  135437. */
  135438. protected _useRadianceOcclusion: boolean;
  135439. /**
  135440. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135441. */
  135442. protected _useAlphaFromAlbedoTexture: boolean;
  135443. /**
  135444. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135445. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135446. */
  135447. protected _useSpecularOverAlpha: boolean;
  135448. /**
  135449. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135450. */
  135451. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135452. /**
  135453. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135454. */
  135455. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135456. /**
  135457. * Specifies if the metallic texture contains the roughness information in its green channel.
  135458. */
  135459. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135460. /**
  135461. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135462. */
  135463. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135464. /**
  135465. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135466. */
  135467. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135468. /**
  135469. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135470. */
  135471. protected _useAmbientInGrayScale: boolean;
  135472. /**
  135473. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135474. * The material will try to infer what glossiness each pixel should be.
  135475. */
  135476. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135477. /**
  135478. * Defines the falloff type used in this material.
  135479. * It by default is Physical.
  135480. */
  135481. protected _lightFalloff: number;
  135482. /**
  135483. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135484. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135485. */
  135486. protected _useRadianceOverAlpha: boolean;
  135487. /**
  135488. * Allows using an object space normal map (instead of tangent space).
  135489. */
  135490. protected _useObjectSpaceNormalMap: boolean;
  135491. /**
  135492. * Allows using the bump map in parallax mode.
  135493. */
  135494. protected _useParallax: boolean;
  135495. /**
  135496. * Allows using the bump map in parallax occlusion mode.
  135497. */
  135498. protected _useParallaxOcclusion: boolean;
  135499. /**
  135500. * Controls the scale bias of the parallax mode.
  135501. */
  135502. protected _parallaxScaleBias: number;
  135503. /**
  135504. * If sets to true, disables all the lights affecting the material.
  135505. */
  135506. protected _disableLighting: boolean;
  135507. /**
  135508. * Number of Simultaneous lights allowed on the material.
  135509. */
  135510. protected _maxSimultaneousLights: number;
  135511. /**
  135512. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135513. */
  135514. protected _invertNormalMapX: boolean;
  135515. /**
  135516. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135517. */
  135518. protected _invertNormalMapY: boolean;
  135519. /**
  135520. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135521. */
  135522. protected _twoSidedLighting: boolean;
  135523. /**
  135524. * Defines the alpha limits in alpha test mode.
  135525. */
  135526. protected _alphaCutOff: number;
  135527. /**
  135528. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135529. */
  135530. protected _forceAlphaTest: boolean;
  135531. /**
  135532. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135533. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135534. */
  135535. protected _useAlphaFresnel: boolean;
  135536. /**
  135537. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135538. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135539. */
  135540. protected _useLinearAlphaFresnel: boolean;
  135541. /**
  135542. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135543. * from cos thetav and roughness:
  135544. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135545. */
  135546. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135547. /**
  135548. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135549. */
  135550. protected _forceIrradianceInFragment: boolean;
  135551. private _realTimeFiltering;
  135552. /**
  135553. * Enables realtime filtering on the texture.
  135554. */
  135555. get realTimeFiltering(): boolean;
  135556. set realTimeFiltering(b: boolean);
  135557. private _realTimeFilteringQuality;
  135558. /**
  135559. * Quality switch for realtime filtering
  135560. */
  135561. get realTimeFilteringQuality(): number;
  135562. set realTimeFilteringQuality(n: number);
  135563. /**
  135564. * Can this material render to several textures at once
  135565. */
  135566. get canRenderToMRT(): boolean;
  135567. /**
  135568. * Force normal to face away from face.
  135569. */
  135570. protected _forceNormalForward: boolean;
  135571. /**
  135572. * Enables specular anti aliasing in the PBR shader.
  135573. * It will both interacts on the Geometry for analytical and IBL lighting.
  135574. * It also prefilter the roughness map based on the bump values.
  135575. */
  135576. protected _enableSpecularAntiAliasing: boolean;
  135577. /**
  135578. * Default configuration related to image processing available in the PBR Material.
  135579. */
  135580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135581. /**
  135582. * Keep track of the image processing observer to allow dispose and replace.
  135583. */
  135584. private _imageProcessingObserver;
  135585. /**
  135586. * Attaches a new image processing configuration to the PBR Material.
  135587. * @param configuration
  135588. */
  135589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135590. /**
  135591. * Stores the available render targets.
  135592. */
  135593. private _renderTargets;
  135594. /**
  135595. * Sets the global ambient color for the material used in lighting calculations.
  135596. */
  135597. private _globalAmbientColor;
  135598. /**
  135599. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135600. */
  135601. private _useLogarithmicDepth;
  135602. /**
  135603. * If set to true, no lighting calculations will be applied.
  135604. */
  135605. private _unlit;
  135606. private _debugMode;
  135607. /**
  135608. * @hidden
  135609. * This is reserved for the inspector.
  135610. * Defines the material debug mode.
  135611. * It helps seeing only some components of the material while troubleshooting.
  135612. */
  135613. debugMode: number;
  135614. /**
  135615. * @hidden
  135616. * This is reserved for the inspector.
  135617. * Specify from where on screen the debug mode should start.
  135618. * The value goes from -1 (full screen) to 1 (not visible)
  135619. * It helps with side by side comparison against the final render
  135620. * This defaults to -1
  135621. */
  135622. private debugLimit;
  135623. /**
  135624. * @hidden
  135625. * This is reserved for the inspector.
  135626. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135627. * You can use the factor to better multiply the final value.
  135628. */
  135629. private debugFactor;
  135630. /**
  135631. * Defines the clear coat layer parameters for the material.
  135632. */
  135633. readonly clearCoat: PBRClearCoatConfiguration;
  135634. /**
  135635. * Defines the anisotropic parameters for the material.
  135636. */
  135637. readonly anisotropy: PBRAnisotropicConfiguration;
  135638. /**
  135639. * Defines the BRDF parameters for the material.
  135640. */
  135641. readonly brdf: PBRBRDFConfiguration;
  135642. /**
  135643. * Defines the Sheen parameters for the material.
  135644. */
  135645. readonly sheen: PBRSheenConfiguration;
  135646. /**
  135647. * Defines the SubSurface parameters for the material.
  135648. */
  135649. readonly subSurface: PBRSubSurfaceConfiguration;
  135650. /**
  135651. * Defines the detail map parameters for the material.
  135652. */
  135653. readonly detailMap: DetailMapConfiguration;
  135654. protected _rebuildInParallel: boolean;
  135655. /**
  135656. * Instantiates a new PBRMaterial instance.
  135657. *
  135658. * @param name The material name
  135659. * @param scene The scene the material will be use in.
  135660. */
  135661. constructor(name: string, scene: Scene);
  135662. /**
  135663. * Gets a boolean indicating that current material needs to register RTT
  135664. */
  135665. get hasRenderTargetTextures(): boolean;
  135666. /**
  135667. * Gets the name of the material class.
  135668. */
  135669. getClassName(): string;
  135670. /**
  135671. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135672. */
  135673. get useLogarithmicDepth(): boolean;
  135674. /**
  135675. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135676. */
  135677. set useLogarithmicDepth(value: boolean);
  135678. /**
  135679. * Returns true if alpha blending should be disabled.
  135680. */
  135681. protected get _disableAlphaBlending(): boolean;
  135682. /**
  135683. * Specifies whether or not this material should be rendered in alpha blend mode.
  135684. */
  135685. needAlphaBlending(): boolean;
  135686. /**
  135687. * Specifies whether or not this material should be rendered in alpha test mode.
  135688. */
  135689. needAlphaTesting(): boolean;
  135690. /**
  135691. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135692. */
  135693. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135694. /**
  135695. * Gets the texture used for the alpha test.
  135696. */
  135697. getAlphaTestTexture(): Nullable<BaseTexture>;
  135698. /**
  135699. * Specifies that the submesh is ready to be used.
  135700. * @param mesh - BJS mesh.
  135701. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135702. * @param useInstances - Specifies that instances should be used.
  135703. * @returns - boolean indicating that the submesh is ready or not.
  135704. */
  135705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135706. /**
  135707. * Specifies if the material uses metallic roughness workflow.
  135708. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135709. */
  135710. isMetallicWorkflow(): boolean;
  135711. private _prepareEffect;
  135712. private _prepareDefines;
  135713. /**
  135714. * Force shader compilation
  135715. */
  135716. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135717. /**
  135718. * Initializes the uniform buffer layout for the shader.
  135719. */
  135720. buildUniformLayout(): void;
  135721. /**
  135722. * Unbinds the material from the mesh
  135723. */
  135724. unbind(): void;
  135725. /**
  135726. * Binds the submesh data.
  135727. * @param world - The world matrix.
  135728. * @param mesh - The BJS mesh.
  135729. * @param subMesh - A submesh of the BJS mesh.
  135730. */
  135731. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135732. /**
  135733. * Returns the animatable textures.
  135734. * @returns - Array of animatable textures.
  135735. */
  135736. getAnimatables(): IAnimatable[];
  135737. /**
  135738. * Returns the texture used for reflections.
  135739. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135740. */
  135741. private _getReflectionTexture;
  135742. /**
  135743. * Returns an array of the actively used textures.
  135744. * @returns - Array of BaseTextures
  135745. */
  135746. getActiveTextures(): BaseTexture[];
  135747. /**
  135748. * Checks to see if a texture is used in the material.
  135749. * @param texture - Base texture to use.
  135750. * @returns - Boolean specifying if a texture is used in the material.
  135751. */
  135752. hasTexture(texture: BaseTexture): boolean;
  135753. /**
  135754. * Sets the required values to the prepass renderer.
  135755. * @param prePassRenderer defines the prepass renderer to setup
  135756. */
  135757. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135758. /**
  135759. * Disposes the resources of the material.
  135760. * @param forceDisposeEffect - Forces the disposal of effects.
  135761. * @param forceDisposeTextures - Forces the disposal of all textures.
  135762. */
  135763. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135764. }
  135765. }
  135766. declare module BABYLON {
  135767. /**
  135768. * The Physically based material of BJS.
  135769. *
  135770. * This offers the main features of a standard PBR material.
  135771. * For more information, please refer to the documentation :
  135772. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135773. */
  135774. export class PBRMaterial extends PBRBaseMaterial {
  135775. /**
  135776. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135777. */
  135778. static readonly PBRMATERIAL_OPAQUE: number;
  135779. /**
  135780. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135781. */
  135782. static readonly PBRMATERIAL_ALPHATEST: number;
  135783. /**
  135784. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135785. */
  135786. static readonly PBRMATERIAL_ALPHABLEND: number;
  135787. /**
  135788. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135789. * They are also discarded below the alpha cutoff threshold to improve performances.
  135790. */
  135791. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135792. /**
  135793. * Defines the default value of how much AO map is occluding the analytical lights
  135794. * (point spot...).
  135795. */
  135796. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135797. /**
  135798. * Intensity of the direct lights e.g. the four lights available in your scene.
  135799. * This impacts both the direct diffuse and specular highlights.
  135800. */
  135801. directIntensity: number;
  135802. /**
  135803. * Intensity of the emissive part of the material.
  135804. * This helps controlling the emissive effect without modifying the emissive color.
  135805. */
  135806. emissiveIntensity: number;
  135807. /**
  135808. * Intensity of the environment e.g. how much the environment will light the object
  135809. * either through harmonics for rough material or through the refelction for shiny ones.
  135810. */
  135811. environmentIntensity: number;
  135812. /**
  135813. * This is a special control allowing the reduction of the specular highlights coming from the
  135814. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135815. */
  135816. specularIntensity: number;
  135817. /**
  135818. * Debug Control allowing disabling the bump map on this material.
  135819. */
  135820. disableBumpMap: boolean;
  135821. /**
  135822. * AKA Diffuse Texture in standard nomenclature.
  135823. */
  135824. albedoTexture: BaseTexture;
  135825. /**
  135826. * AKA Occlusion Texture in other nomenclature.
  135827. */
  135828. ambientTexture: BaseTexture;
  135829. /**
  135830. * AKA Occlusion Texture Intensity in other nomenclature.
  135831. */
  135832. ambientTextureStrength: number;
  135833. /**
  135834. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135835. * 1 means it completely occludes it
  135836. * 0 mean it has no impact
  135837. */
  135838. ambientTextureImpactOnAnalyticalLights: number;
  135839. /**
  135840. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135841. */
  135842. opacityTexture: BaseTexture;
  135843. /**
  135844. * Stores the reflection values in a texture.
  135845. */
  135846. reflectionTexture: Nullable<BaseTexture>;
  135847. /**
  135848. * Stores the emissive values in a texture.
  135849. */
  135850. emissiveTexture: BaseTexture;
  135851. /**
  135852. * AKA Specular texture in other nomenclature.
  135853. */
  135854. reflectivityTexture: BaseTexture;
  135855. /**
  135856. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135857. */
  135858. metallicTexture: BaseTexture;
  135859. /**
  135860. * Specifies the metallic scalar of the metallic/roughness workflow.
  135861. * Can also be used to scale the metalness values of the metallic texture.
  135862. */
  135863. metallic: Nullable<number>;
  135864. /**
  135865. * Specifies the roughness scalar of the metallic/roughness workflow.
  135866. * Can also be used to scale the roughness values of the metallic texture.
  135867. */
  135868. roughness: Nullable<number>;
  135869. /**
  135870. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135871. * By default the indexOfrefraction is used to compute F0;
  135872. *
  135873. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135874. *
  135875. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135876. * F90 = metallicReflectanceColor;
  135877. */
  135878. metallicF0Factor: number;
  135879. /**
  135880. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135881. * By default the F90 is always 1;
  135882. *
  135883. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135884. *
  135885. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135886. * F90 = metallicReflectanceColor;
  135887. */
  135888. metallicReflectanceColor: Color3;
  135889. /**
  135890. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135891. * This is multiply against the scalar values defined in the material.
  135892. */
  135893. metallicReflectanceTexture: Nullable<BaseTexture>;
  135894. /**
  135895. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135896. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135897. */
  135898. microSurfaceTexture: BaseTexture;
  135899. /**
  135900. * Stores surface normal data used to displace a mesh in a texture.
  135901. */
  135902. bumpTexture: BaseTexture;
  135903. /**
  135904. * Stores the pre-calculated light information of a mesh in a texture.
  135905. */
  135906. lightmapTexture: BaseTexture;
  135907. /**
  135908. * Stores the refracted light information in a texture.
  135909. */
  135910. get refractionTexture(): Nullable<BaseTexture>;
  135911. set refractionTexture(value: Nullable<BaseTexture>);
  135912. /**
  135913. * The color of a material in ambient lighting.
  135914. */
  135915. ambientColor: Color3;
  135916. /**
  135917. * AKA Diffuse Color in other nomenclature.
  135918. */
  135919. albedoColor: Color3;
  135920. /**
  135921. * AKA Specular Color in other nomenclature.
  135922. */
  135923. reflectivityColor: Color3;
  135924. /**
  135925. * The color reflected from the material.
  135926. */
  135927. reflectionColor: Color3;
  135928. /**
  135929. * The color emitted from the material.
  135930. */
  135931. emissiveColor: Color3;
  135932. /**
  135933. * AKA Glossiness in other nomenclature.
  135934. */
  135935. microSurface: number;
  135936. /**
  135937. * Index of refraction of the material base layer.
  135938. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135939. *
  135940. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135941. *
  135942. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135943. */
  135944. get indexOfRefraction(): number;
  135945. set indexOfRefraction(value: number);
  135946. /**
  135947. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135948. */
  135949. get invertRefractionY(): boolean;
  135950. set invertRefractionY(value: boolean);
  135951. /**
  135952. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135953. * Materials half opaque for instance using refraction could benefit from this control.
  135954. */
  135955. get linkRefractionWithTransparency(): boolean;
  135956. set linkRefractionWithTransparency(value: boolean);
  135957. /**
  135958. * If true, the light map contains occlusion information instead of lighting info.
  135959. */
  135960. useLightmapAsShadowmap: boolean;
  135961. /**
  135962. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135963. */
  135964. useAlphaFromAlbedoTexture: boolean;
  135965. /**
  135966. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135967. */
  135968. forceAlphaTest: boolean;
  135969. /**
  135970. * Defines the alpha limits in alpha test mode.
  135971. */
  135972. alphaCutOff: number;
  135973. /**
  135974. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135975. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135976. */
  135977. useSpecularOverAlpha: boolean;
  135978. /**
  135979. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135980. */
  135981. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135982. /**
  135983. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135984. */
  135985. useRoughnessFromMetallicTextureAlpha: boolean;
  135986. /**
  135987. * Specifies if the metallic texture contains the roughness information in its green channel.
  135988. */
  135989. useRoughnessFromMetallicTextureGreen: boolean;
  135990. /**
  135991. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135992. */
  135993. useMetallnessFromMetallicTextureBlue: boolean;
  135994. /**
  135995. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135996. */
  135997. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135998. /**
  135999. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136000. */
  136001. useAmbientInGrayScale: boolean;
  136002. /**
  136003. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136004. * The material will try to infer what glossiness each pixel should be.
  136005. */
  136006. useAutoMicroSurfaceFromReflectivityMap: boolean;
  136007. /**
  136008. * BJS is using an harcoded light falloff based on a manually sets up range.
  136009. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136010. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136011. */
  136012. get usePhysicalLightFalloff(): boolean;
  136013. /**
  136014. * BJS is using an harcoded light falloff based on a manually sets up range.
  136015. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  136016. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  136017. */
  136018. set usePhysicalLightFalloff(value: boolean);
  136019. /**
  136020. * In order to support the falloff compatibility with gltf, a special mode has been added
  136021. * to reproduce the gltf light falloff.
  136022. */
  136023. get useGLTFLightFalloff(): boolean;
  136024. /**
  136025. * In order to support the falloff compatibility with gltf, a special mode has been added
  136026. * to reproduce the gltf light falloff.
  136027. */
  136028. set useGLTFLightFalloff(value: boolean);
  136029. /**
  136030. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136031. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136032. */
  136033. useRadianceOverAlpha: boolean;
  136034. /**
  136035. * Allows using an object space normal map (instead of tangent space).
  136036. */
  136037. useObjectSpaceNormalMap: boolean;
  136038. /**
  136039. * Allows using the bump map in parallax mode.
  136040. */
  136041. useParallax: boolean;
  136042. /**
  136043. * Allows using the bump map in parallax occlusion mode.
  136044. */
  136045. useParallaxOcclusion: boolean;
  136046. /**
  136047. * Controls the scale bias of the parallax mode.
  136048. */
  136049. parallaxScaleBias: number;
  136050. /**
  136051. * If sets to true, disables all the lights affecting the material.
  136052. */
  136053. disableLighting: boolean;
  136054. /**
  136055. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136056. */
  136057. forceIrradianceInFragment: boolean;
  136058. /**
  136059. * Number of Simultaneous lights allowed on the material.
  136060. */
  136061. maxSimultaneousLights: number;
  136062. /**
  136063. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  136064. */
  136065. invertNormalMapX: boolean;
  136066. /**
  136067. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  136068. */
  136069. invertNormalMapY: boolean;
  136070. /**
  136071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136072. */
  136073. twoSidedLighting: boolean;
  136074. /**
  136075. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136076. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136077. */
  136078. useAlphaFresnel: boolean;
  136079. /**
  136080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136081. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136082. */
  136083. useLinearAlphaFresnel: boolean;
  136084. /**
  136085. * Let user defines the brdf lookup texture used for IBL.
  136086. * A default 8bit version is embedded but you could point at :
  136087. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  136088. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  136089. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  136090. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  136091. */
  136092. environmentBRDFTexture: Nullable<BaseTexture>;
  136093. /**
  136094. * Force normal to face away from face.
  136095. */
  136096. forceNormalForward: boolean;
  136097. /**
  136098. * Enables specular anti aliasing in the PBR shader.
  136099. * It will both interacts on the Geometry for analytical and IBL lighting.
  136100. * It also prefilter the roughness map based on the bump values.
  136101. */
  136102. enableSpecularAntiAliasing: boolean;
  136103. /**
  136104. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136105. * makes the reflect vector face the model (under horizon).
  136106. */
  136107. useHorizonOcclusion: boolean;
  136108. /**
  136109. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136110. * too much the area relying on ambient texture to define their ambient occlusion.
  136111. */
  136112. useRadianceOcclusion: boolean;
  136113. /**
  136114. * If set to true, no lighting calculations will be applied.
  136115. */
  136116. unlit: boolean;
  136117. /**
  136118. * Gets the image processing configuration used either in this material.
  136119. */
  136120. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  136121. /**
  136122. * Sets the Default image processing configuration used either in the this material.
  136123. *
  136124. * If sets to null, the scene one is in use.
  136125. */
  136126. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  136127. /**
  136128. * Gets wether the color curves effect is enabled.
  136129. */
  136130. get cameraColorCurvesEnabled(): boolean;
  136131. /**
  136132. * Sets wether the color curves effect is enabled.
  136133. */
  136134. set cameraColorCurvesEnabled(value: boolean);
  136135. /**
  136136. * Gets wether the color grading effect is enabled.
  136137. */
  136138. get cameraColorGradingEnabled(): boolean;
  136139. /**
  136140. * Gets wether the color grading effect is enabled.
  136141. */
  136142. set cameraColorGradingEnabled(value: boolean);
  136143. /**
  136144. * Gets wether tonemapping is enabled or not.
  136145. */
  136146. get cameraToneMappingEnabled(): boolean;
  136147. /**
  136148. * Sets wether tonemapping is enabled or not
  136149. */
  136150. set cameraToneMappingEnabled(value: boolean);
  136151. /**
  136152. * The camera exposure used on this material.
  136153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136154. * This corresponds to a photographic exposure.
  136155. */
  136156. get cameraExposure(): number;
  136157. /**
  136158. * The camera exposure used on this material.
  136159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  136160. * This corresponds to a photographic exposure.
  136161. */
  136162. set cameraExposure(value: number);
  136163. /**
  136164. * Gets The camera contrast used on this material.
  136165. */
  136166. get cameraContrast(): number;
  136167. /**
  136168. * Sets The camera contrast used on this material.
  136169. */
  136170. set cameraContrast(value: number);
  136171. /**
  136172. * Gets the Color Grading 2D Lookup Texture.
  136173. */
  136174. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  136175. /**
  136176. * Sets the Color Grading 2D Lookup Texture.
  136177. */
  136178. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  136179. /**
  136180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136182. * 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;
  136183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136184. */
  136185. get cameraColorCurves(): Nullable<ColorCurves>;
  136186. /**
  136187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  136188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  136189. * 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;
  136190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  136191. */
  136192. set cameraColorCurves(value: Nullable<ColorCurves>);
  136193. /**
  136194. * Instantiates a new PBRMaterial instance.
  136195. *
  136196. * @param name The material name
  136197. * @param scene The scene the material will be use in.
  136198. */
  136199. constructor(name: string, scene: Scene);
  136200. /**
  136201. * Returns the name of this material class.
  136202. */
  136203. getClassName(): string;
  136204. /**
  136205. * Makes a duplicate of the current material.
  136206. * @param name - name to use for the new material.
  136207. */
  136208. clone(name: string): PBRMaterial;
  136209. /**
  136210. * Serializes this PBR Material.
  136211. * @returns - An object with the serialized material.
  136212. */
  136213. serialize(): any;
  136214. /**
  136215. * Parses a PBR Material from a serialized object.
  136216. * @param source - Serialized object.
  136217. * @param scene - BJS scene instance.
  136218. * @param rootUrl - url for the scene object
  136219. * @returns - PBRMaterial
  136220. */
  136221. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  136222. }
  136223. }
  136224. declare module BABYLON {
  136225. /**
  136226. * Direct draw surface info
  136227. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  136228. */
  136229. export interface DDSInfo {
  136230. /**
  136231. * Width of the texture
  136232. */
  136233. width: number;
  136234. /**
  136235. * Width of the texture
  136236. */
  136237. height: number;
  136238. /**
  136239. * Number of Mipmaps for the texture
  136240. * @see https://en.wikipedia.org/wiki/Mipmap
  136241. */
  136242. mipmapCount: number;
  136243. /**
  136244. * If the textures format is a known fourCC format
  136245. * @see https://www.fourcc.org/
  136246. */
  136247. isFourCC: boolean;
  136248. /**
  136249. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136250. */
  136251. isRGB: boolean;
  136252. /**
  136253. * If the texture is a lumincance format
  136254. */
  136255. isLuminance: boolean;
  136256. /**
  136257. * If this is a cube texture
  136258. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  136259. */
  136260. isCube: boolean;
  136261. /**
  136262. * If the texture is a compressed format eg. FOURCC_DXT1
  136263. */
  136264. isCompressed: boolean;
  136265. /**
  136266. * The dxgiFormat of the texture
  136267. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  136268. */
  136269. dxgiFormat: number;
  136270. /**
  136271. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  136272. */
  136273. textureType: number;
  136274. /**
  136275. * Sphericle polynomial created for the dds texture
  136276. */
  136277. sphericalPolynomial?: SphericalPolynomial;
  136278. }
  136279. /**
  136280. * Class used to provide DDS decompression tools
  136281. */
  136282. export class DDSTools {
  136283. /**
  136284. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  136285. */
  136286. static StoreLODInAlphaChannel: boolean;
  136287. /**
  136288. * Gets DDS information from an array buffer
  136289. * @param data defines the array buffer view to read data from
  136290. * @returns the DDS information
  136291. */
  136292. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  136293. private static _FloatView;
  136294. private static _Int32View;
  136295. private static _ToHalfFloat;
  136296. private static _FromHalfFloat;
  136297. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  136298. private static _GetHalfFloatRGBAArrayBuffer;
  136299. private static _GetFloatRGBAArrayBuffer;
  136300. private static _GetFloatAsUIntRGBAArrayBuffer;
  136301. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  136302. private static _GetRGBAArrayBuffer;
  136303. private static _ExtractLongWordOrder;
  136304. private static _GetRGBArrayBuffer;
  136305. private static _GetLuminanceArrayBuffer;
  136306. /**
  136307. * Uploads DDS Levels to a Babylon Texture
  136308. * @hidden
  136309. */
  136310. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  136311. }
  136312. interface ThinEngine {
  136313. /**
  136314. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  136315. * @param rootUrl defines the url where the file to load is located
  136316. * @param scene defines the current scene
  136317. * @param lodScale defines scale to apply to the mip map selection
  136318. * @param lodOffset defines offset to apply to the mip map selection
  136319. * @param onLoad defines an optional callback raised when the texture is loaded
  136320. * @param onError defines an optional callback raised if there is an issue to load the texture
  136321. * @param format defines the format of the data
  136322. * @param forcedExtension defines the extension to use to pick the right loader
  136323. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  136324. * @returns the cube texture as an InternalTexture
  136325. */
  136326. 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;
  136327. }
  136328. }
  136329. declare module BABYLON {
  136330. /**
  136331. * Implementation of the DDS Texture Loader.
  136332. * @hidden
  136333. */
  136334. export class _DDSTextureLoader implements IInternalTextureLoader {
  136335. /**
  136336. * Defines wether the loader supports cascade loading the different faces.
  136337. */
  136338. readonly supportCascades: boolean;
  136339. /**
  136340. * This returns if the loader support the current file information.
  136341. * @param extension defines the file extension of the file being loaded
  136342. * @returns true if the loader can load the specified file
  136343. */
  136344. canLoad(extension: string): boolean;
  136345. /**
  136346. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136347. * @param data contains the texture data
  136348. * @param texture defines the BabylonJS internal texture
  136349. * @param createPolynomials will be true if polynomials have been requested
  136350. * @param onLoad defines the callback to trigger once the texture is ready
  136351. * @param onError defines the callback to trigger in case of error
  136352. */
  136353. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136354. /**
  136355. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136356. * @param data contains the texture data
  136357. * @param texture defines the BabylonJS internal texture
  136358. * @param callback defines the method to call once ready to upload
  136359. */
  136360. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136361. }
  136362. }
  136363. declare module BABYLON {
  136364. /**
  136365. * Implementation of the ENV Texture Loader.
  136366. * @hidden
  136367. */
  136368. export class _ENVTextureLoader implements IInternalTextureLoader {
  136369. /**
  136370. * Defines wether the loader supports cascade loading the different faces.
  136371. */
  136372. readonly supportCascades: boolean;
  136373. /**
  136374. * This returns if the loader support the current file information.
  136375. * @param extension defines the file extension of the file being loaded
  136376. * @returns true if the loader can load the specified file
  136377. */
  136378. canLoad(extension: string): boolean;
  136379. /**
  136380. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136381. * @param data contains the texture data
  136382. * @param texture defines the BabylonJS internal texture
  136383. * @param createPolynomials will be true if polynomials have been requested
  136384. * @param onLoad defines the callback to trigger once the texture is ready
  136385. * @param onError defines the callback to trigger in case of error
  136386. */
  136387. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136388. /**
  136389. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136390. * @param data contains the texture data
  136391. * @param texture defines the BabylonJS internal texture
  136392. * @param callback defines the method to call once ready to upload
  136393. */
  136394. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136395. }
  136396. }
  136397. declare module BABYLON {
  136398. /**
  136399. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136400. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136401. */
  136402. export class KhronosTextureContainer {
  136403. /** contents of the KTX container file */
  136404. data: ArrayBufferView;
  136405. private static HEADER_LEN;
  136406. private static COMPRESSED_2D;
  136407. private static COMPRESSED_3D;
  136408. private static TEX_2D;
  136409. private static TEX_3D;
  136410. /**
  136411. * Gets the openGL type
  136412. */
  136413. glType: number;
  136414. /**
  136415. * Gets the openGL type size
  136416. */
  136417. glTypeSize: number;
  136418. /**
  136419. * Gets the openGL format
  136420. */
  136421. glFormat: number;
  136422. /**
  136423. * Gets the openGL internal format
  136424. */
  136425. glInternalFormat: number;
  136426. /**
  136427. * Gets the base internal format
  136428. */
  136429. glBaseInternalFormat: number;
  136430. /**
  136431. * Gets image width in pixel
  136432. */
  136433. pixelWidth: number;
  136434. /**
  136435. * Gets image height in pixel
  136436. */
  136437. pixelHeight: number;
  136438. /**
  136439. * Gets image depth in pixels
  136440. */
  136441. pixelDepth: number;
  136442. /**
  136443. * Gets the number of array elements
  136444. */
  136445. numberOfArrayElements: number;
  136446. /**
  136447. * Gets the number of faces
  136448. */
  136449. numberOfFaces: number;
  136450. /**
  136451. * Gets the number of mipmap levels
  136452. */
  136453. numberOfMipmapLevels: number;
  136454. /**
  136455. * Gets the bytes of key value data
  136456. */
  136457. bytesOfKeyValueData: number;
  136458. /**
  136459. * Gets the load type
  136460. */
  136461. loadType: number;
  136462. /**
  136463. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136464. */
  136465. isInvalid: boolean;
  136466. /**
  136467. * Creates a new KhronosTextureContainer
  136468. * @param data contents of the KTX container file
  136469. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136470. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136471. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136472. */
  136473. constructor(
  136474. /** contents of the KTX container file */
  136475. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136476. /**
  136477. * Uploads KTX content to a Babylon Texture.
  136478. * It is assumed that the texture has already been created & is currently bound
  136479. * @hidden
  136480. */
  136481. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136482. private _upload2DCompressedLevels;
  136483. /**
  136484. * Checks if the given data starts with a KTX file identifier.
  136485. * @param data the data to check
  136486. * @returns true if the data is a KTX file or false otherwise
  136487. */
  136488. static IsValid(data: ArrayBufferView): boolean;
  136489. }
  136490. }
  136491. declare module BABYLON {
  136492. /**
  136493. * Class for loading KTX2 files
  136494. * !!! Experimental Extension Subject to Changes !!!
  136495. * @hidden
  136496. */
  136497. export class KhronosTextureContainer2 {
  136498. private static _ModulePromise;
  136499. private static _TranscodeFormat;
  136500. constructor(engine: ThinEngine);
  136501. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136502. private _determineTranscodeFormat;
  136503. /**
  136504. * Checks if the given data starts with a KTX2 file identifier.
  136505. * @param data the data to check
  136506. * @returns true if the data is a KTX2 file or false otherwise
  136507. */
  136508. static IsValid(data: ArrayBufferView): boolean;
  136509. }
  136510. }
  136511. declare module BABYLON {
  136512. /**
  136513. * Implementation of the KTX Texture Loader.
  136514. * @hidden
  136515. */
  136516. export class _KTXTextureLoader implements IInternalTextureLoader {
  136517. /**
  136518. * Defines wether the loader supports cascade loading the different faces.
  136519. */
  136520. readonly supportCascades: boolean;
  136521. /**
  136522. * This returns if the loader support the current file information.
  136523. * @param extension defines the file extension of the file being loaded
  136524. * @param mimeType defines the optional mime type of the file being loaded
  136525. * @returns true if the loader can load the specified file
  136526. */
  136527. canLoad(extension: string, mimeType?: string): boolean;
  136528. /**
  136529. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136530. * @param data contains the texture data
  136531. * @param texture defines the BabylonJS internal texture
  136532. * @param createPolynomials will be true if polynomials have been requested
  136533. * @param onLoad defines the callback to trigger once the texture is ready
  136534. * @param onError defines the callback to trigger in case of error
  136535. */
  136536. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136537. /**
  136538. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136539. * @param data contains the texture data
  136540. * @param texture defines the BabylonJS internal texture
  136541. * @param callback defines the method to call once ready to upload
  136542. */
  136543. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136544. }
  136545. }
  136546. declare module BABYLON {
  136547. /** @hidden */
  136548. export var _forceSceneHelpersToBundle: boolean;
  136549. interface Scene {
  136550. /**
  136551. * Creates a default light for the scene.
  136552. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136553. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136554. */
  136555. createDefaultLight(replace?: boolean): void;
  136556. /**
  136557. * Creates a default camera for the scene.
  136558. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136559. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136560. * @param replace has default false, when true replaces the active camera in the scene
  136561. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136562. */
  136563. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136564. /**
  136565. * Creates a default camera and a default light.
  136566. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136567. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136568. * @param replace has the default false, when true replaces the active camera/light in the scene
  136569. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136570. */
  136571. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136572. /**
  136573. * Creates a new sky box
  136574. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136575. * @param environmentTexture defines the texture to use as environment texture
  136576. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136577. * @param scale defines the overall scale of the skybox
  136578. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136579. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136580. * @returns a new mesh holding the sky box
  136581. */
  136582. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136583. /**
  136584. * Creates a new environment
  136585. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136586. * @param options defines the options you can use to configure the environment
  136587. * @returns the new EnvironmentHelper
  136588. */
  136589. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136590. /**
  136591. * Creates a new VREXperienceHelper
  136592. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136593. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136594. * @returns a new VREXperienceHelper
  136595. */
  136596. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136597. /**
  136598. * Creates a new WebXRDefaultExperience
  136599. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136600. * @param options experience options
  136601. * @returns a promise for a new WebXRDefaultExperience
  136602. */
  136603. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136604. }
  136605. }
  136606. declare module BABYLON {
  136607. /**
  136608. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136609. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136610. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136611. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136612. */
  136613. export class VideoDome extends TransformNode {
  136614. /**
  136615. * Define the video source as a Monoscopic panoramic 360 video.
  136616. */
  136617. static readonly MODE_MONOSCOPIC: number;
  136618. /**
  136619. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136620. */
  136621. static readonly MODE_TOPBOTTOM: number;
  136622. /**
  136623. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136624. */
  136625. static readonly MODE_SIDEBYSIDE: number;
  136626. private _halfDome;
  136627. private _useDirectMapping;
  136628. /**
  136629. * The video texture being displayed on the sphere
  136630. */
  136631. protected _videoTexture: VideoTexture;
  136632. /**
  136633. * Gets the video texture being displayed on the sphere
  136634. */
  136635. get videoTexture(): VideoTexture;
  136636. /**
  136637. * The skybox material
  136638. */
  136639. protected _material: BackgroundMaterial;
  136640. /**
  136641. * The surface used for the video dome
  136642. */
  136643. protected _mesh: Mesh;
  136644. /**
  136645. * Gets the mesh used for the video dome.
  136646. */
  136647. get mesh(): Mesh;
  136648. /**
  136649. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136650. */
  136651. private _halfDomeMask;
  136652. /**
  136653. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136654. * Also see the options.resolution property.
  136655. */
  136656. get fovMultiplier(): number;
  136657. set fovMultiplier(value: number);
  136658. private _videoMode;
  136659. /**
  136660. * Gets or set the current video mode for the video. It can be:
  136661. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136662. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136663. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136664. */
  136665. get videoMode(): number;
  136666. set videoMode(value: number);
  136667. /**
  136668. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136669. *
  136670. */
  136671. get halfDome(): boolean;
  136672. /**
  136673. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136674. */
  136675. set halfDome(enabled: boolean);
  136676. /**
  136677. * Oberserver used in Stereoscopic VR Mode.
  136678. */
  136679. private _onBeforeCameraRenderObserver;
  136680. /**
  136681. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136682. * @param name Element's name, child elements will append suffixes for their own names.
  136683. * @param urlsOrVideo defines the url(s) or the video element to use
  136684. * @param options An object containing optional or exposed sub element properties
  136685. */
  136686. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136687. resolution?: number;
  136688. clickToPlay?: boolean;
  136689. autoPlay?: boolean;
  136690. loop?: boolean;
  136691. size?: number;
  136692. poster?: string;
  136693. faceForward?: boolean;
  136694. useDirectMapping?: boolean;
  136695. halfDomeMode?: boolean;
  136696. }, scene: Scene);
  136697. private _changeVideoMode;
  136698. /**
  136699. * Releases resources associated with this node.
  136700. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136701. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136702. */
  136703. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136704. }
  136705. }
  136706. declare module BABYLON {
  136707. /**
  136708. * This class can be used to get instrumentation data from a Babylon engine
  136709. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136710. */
  136711. export class EngineInstrumentation implements IDisposable {
  136712. /**
  136713. * Define the instrumented engine.
  136714. */
  136715. engine: Engine;
  136716. private _captureGPUFrameTime;
  136717. private _gpuFrameTimeToken;
  136718. private _gpuFrameTime;
  136719. private _captureShaderCompilationTime;
  136720. private _shaderCompilationTime;
  136721. private _onBeginFrameObserver;
  136722. private _onEndFrameObserver;
  136723. private _onBeforeShaderCompilationObserver;
  136724. private _onAfterShaderCompilationObserver;
  136725. /**
  136726. * Gets the perf counter used for GPU frame time
  136727. */
  136728. get gpuFrameTimeCounter(): PerfCounter;
  136729. /**
  136730. * Gets the GPU frame time capture status
  136731. */
  136732. get captureGPUFrameTime(): boolean;
  136733. /**
  136734. * Enable or disable the GPU frame time capture
  136735. */
  136736. set captureGPUFrameTime(value: boolean);
  136737. /**
  136738. * Gets the perf counter used for shader compilation time
  136739. */
  136740. get shaderCompilationTimeCounter(): PerfCounter;
  136741. /**
  136742. * Gets the shader compilation time capture status
  136743. */
  136744. get captureShaderCompilationTime(): boolean;
  136745. /**
  136746. * Enable or disable the shader compilation time capture
  136747. */
  136748. set captureShaderCompilationTime(value: boolean);
  136749. /**
  136750. * Instantiates a new engine instrumentation.
  136751. * This class can be used to get instrumentation data from a Babylon engine
  136752. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136753. * @param engine Defines the engine to instrument
  136754. */
  136755. constructor(
  136756. /**
  136757. * Define the instrumented engine.
  136758. */
  136759. engine: Engine);
  136760. /**
  136761. * Dispose and release associated resources.
  136762. */
  136763. dispose(): void;
  136764. }
  136765. }
  136766. declare module BABYLON {
  136767. /**
  136768. * This class can be used to get instrumentation data from a Babylon engine
  136769. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136770. */
  136771. export class SceneInstrumentation implements IDisposable {
  136772. /**
  136773. * Defines the scene to instrument
  136774. */
  136775. scene: Scene;
  136776. private _captureActiveMeshesEvaluationTime;
  136777. private _activeMeshesEvaluationTime;
  136778. private _captureRenderTargetsRenderTime;
  136779. private _renderTargetsRenderTime;
  136780. private _captureFrameTime;
  136781. private _frameTime;
  136782. private _captureRenderTime;
  136783. private _renderTime;
  136784. private _captureInterFrameTime;
  136785. private _interFrameTime;
  136786. private _captureParticlesRenderTime;
  136787. private _particlesRenderTime;
  136788. private _captureSpritesRenderTime;
  136789. private _spritesRenderTime;
  136790. private _capturePhysicsTime;
  136791. private _physicsTime;
  136792. private _captureAnimationsTime;
  136793. private _animationsTime;
  136794. private _captureCameraRenderTime;
  136795. private _cameraRenderTime;
  136796. private _onBeforeActiveMeshesEvaluationObserver;
  136797. private _onAfterActiveMeshesEvaluationObserver;
  136798. private _onBeforeRenderTargetsRenderObserver;
  136799. private _onAfterRenderTargetsRenderObserver;
  136800. private _onAfterRenderObserver;
  136801. private _onBeforeDrawPhaseObserver;
  136802. private _onAfterDrawPhaseObserver;
  136803. private _onBeforeAnimationsObserver;
  136804. private _onBeforeParticlesRenderingObserver;
  136805. private _onAfterParticlesRenderingObserver;
  136806. private _onBeforeSpritesRenderingObserver;
  136807. private _onAfterSpritesRenderingObserver;
  136808. private _onBeforePhysicsObserver;
  136809. private _onAfterPhysicsObserver;
  136810. private _onAfterAnimationsObserver;
  136811. private _onBeforeCameraRenderObserver;
  136812. private _onAfterCameraRenderObserver;
  136813. /**
  136814. * Gets the perf counter used for active meshes evaluation time
  136815. */
  136816. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136817. /**
  136818. * Gets the active meshes evaluation time capture status
  136819. */
  136820. get captureActiveMeshesEvaluationTime(): boolean;
  136821. /**
  136822. * Enable or disable the active meshes evaluation time capture
  136823. */
  136824. set captureActiveMeshesEvaluationTime(value: boolean);
  136825. /**
  136826. * Gets the perf counter used for render targets render time
  136827. */
  136828. get renderTargetsRenderTimeCounter(): PerfCounter;
  136829. /**
  136830. * Gets the render targets render time capture status
  136831. */
  136832. get captureRenderTargetsRenderTime(): boolean;
  136833. /**
  136834. * Enable or disable the render targets render time capture
  136835. */
  136836. set captureRenderTargetsRenderTime(value: boolean);
  136837. /**
  136838. * Gets the perf counter used for particles render time
  136839. */
  136840. get particlesRenderTimeCounter(): PerfCounter;
  136841. /**
  136842. * Gets the particles render time capture status
  136843. */
  136844. get captureParticlesRenderTime(): boolean;
  136845. /**
  136846. * Enable or disable the particles render time capture
  136847. */
  136848. set captureParticlesRenderTime(value: boolean);
  136849. /**
  136850. * Gets the perf counter used for sprites render time
  136851. */
  136852. get spritesRenderTimeCounter(): PerfCounter;
  136853. /**
  136854. * Gets the sprites render time capture status
  136855. */
  136856. get captureSpritesRenderTime(): boolean;
  136857. /**
  136858. * Enable or disable the sprites render time capture
  136859. */
  136860. set captureSpritesRenderTime(value: boolean);
  136861. /**
  136862. * Gets the perf counter used for physics time
  136863. */
  136864. get physicsTimeCounter(): PerfCounter;
  136865. /**
  136866. * Gets the physics time capture status
  136867. */
  136868. get capturePhysicsTime(): boolean;
  136869. /**
  136870. * Enable or disable the physics time capture
  136871. */
  136872. set capturePhysicsTime(value: boolean);
  136873. /**
  136874. * Gets the perf counter used for animations time
  136875. */
  136876. get animationsTimeCounter(): PerfCounter;
  136877. /**
  136878. * Gets the animations time capture status
  136879. */
  136880. get captureAnimationsTime(): boolean;
  136881. /**
  136882. * Enable or disable the animations time capture
  136883. */
  136884. set captureAnimationsTime(value: boolean);
  136885. /**
  136886. * Gets the perf counter used for frame time capture
  136887. */
  136888. get frameTimeCounter(): PerfCounter;
  136889. /**
  136890. * Gets the frame time capture status
  136891. */
  136892. get captureFrameTime(): boolean;
  136893. /**
  136894. * Enable or disable the frame time capture
  136895. */
  136896. set captureFrameTime(value: boolean);
  136897. /**
  136898. * Gets the perf counter used for inter-frames time capture
  136899. */
  136900. get interFrameTimeCounter(): PerfCounter;
  136901. /**
  136902. * Gets the inter-frames time capture status
  136903. */
  136904. get captureInterFrameTime(): boolean;
  136905. /**
  136906. * Enable or disable the inter-frames time capture
  136907. */
  136908. set captureInterFrameTime(value: boolean);
  136909. /**
  136910. * Gets the perf counter used for render time capture
  136911. */
  136912. get renderTimeCounter(): PerfCounter;
  136913. /**
  136914. * Gets the render time capture status
  136915. */
  136916. get captureRenderTime(): boolean;
  136917. /**
  136918. * Enable or disable the render time capture
  136919. */
  136920. set captureRenderTime(value: boolean);
  136921. /**
  136922. * Gets the perf counter used for camera render time capture
  136923. */
  136924. get cameraRenderTimeCounter(): PerfCounter;
  136925. /**
  136926. * Gets the camera render time capture status
  136927. */
  136928. get captureCameraRenderTime(): boolean;
  136929. /**
  136930. * Enable or disable the camera render time capture
  136931. */
  136932. set captureCameraRenderTime(value: boolean);
  136933. /**
  136934. * Gets the perf counter used for draw calls
  136935. */
  136936. get drawCallsCounter(): PerfCounter;
  136937. /**
  136938. * Instantiates a new scene instrumentation.
  136939. * This class can be used to get instrumentation data from a Babylon engine
  136940. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136941. * @param scene Defines the scene to instrument
  136942. */
  136943. constructor(
  136944. /**
  136945. * Defines the scene to instrument
  136946. */
  136947. scene: Scene);
  136948. /**
  136949. * Dispose and release associated resources.
  136950. */
  136951. dispose(): void;
  136952. }
  136953. }
  136954. declare module BABYLON {
  136955. /** @hidden */
  136956. export var glowMapGenerationPixelShader: {
  136957. name: string;
  136958. shader: string;
  136959. };
  136960. }
  136961. declare module BABYLON {
  136962. /** @hidden */
  136963. export var glowMapGenerationVertexShader: {
  136964. name: string;
  136965. shader: string;
  136966. };
  136967. }
  136968. declare module BABYLON {
  136969. /**
  136970. * Effect layer options. This helps customizing the behaviour
  136971. * of the effect layer.
  136972. */
  136973. export interface IEffectLayerOptions {
  136974. /**
  136975. * Multiplication factor apply to the canvas size to compute the render target size
  136976. * used to generated the objects (the smaller the faster).
  136977. */
  136978. mainTextureRatio: number;
  136979. /**
  136980. * Enforces a fixed size texture to ensure effect stability across devices.
  136981. */
  136982. mainTextureFixedSize?: number;
  136983. /**
  136984. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136985. */
  136986. alphaBlendingMode: number;
  136987. /**
  136988. * The camera attached to the layer.
  136989. */
  136990. camera: Nullable<Camera>;
  136991. /**
  136992. * The rendering group to draw the layer in.
  136993. */
  136994. renderingGroupId: number;
  136995. }
  136996. /**
  136997. * The effect layer Helps adding post process effect blended with the main pass.
  136998. *
  136999. * This can be for instance use to generate glow or higlight effects on the scene.
  137000. *
  137001. * The effect layer class can not be used directly and is intented to inherited from to be
  137002. * customized per effects.
  137003. */
  137004. export abstract class EffectLayer {
  137005. private _vertexBuffers;
  137006. private _indexBuffer;
  137007. private _cachedDefines;
  137008. private _effectLayerMapGenerationEffect;
  137009. private _effectLayerOptions;
  137010. private _mergeEffect;
  137011. protected _scene: Scene;
  137012. protected _engine: Engine;
  137013. protected _maxSize: number;
  137014. protected _mainTextureDesiredSize: ISize;
  137015. protected _mainTexture: RenderTargetTexture;
  137016. protected _shouldRender: boolean;
  137017. protected _postProcesses: PostProcess[];
  137018. protected _textures: BaseTexture[];
  137019. protected _emissiveTextureAndColor: {
  137020. texture: Nullable<BaseTexture>;
  137021. color: Color4;
  137022. };
  137023. /**
  137024. * The name of the layer
  137025. */
  137026. name: string;
  137027. /**
  137028. * The clear color of the texture used to generate the glow map.
  137029. */
  137030. neutralColor: Color4;
  137031. /**
  137032. * Specifies whether the highlight layer is enabled or not.
  137033. */
  137034. isEnabled: boolean;
  137035. /**
  137036. * Gets the camera attached to the layer.
  137037. */
  137038. get camera(): Nullable<Camera>;
  137039. /**
  137040. * Gets the rendering group id the layer should render in.
  137041. */
  137042. get renderingGroupId(): number;
  137043. set renderingGroupId(renderingGroupId: number);
  137044. /**
  137045. * An event triggered when the effect layer has been disposed.
  137046. */
  137047. onDisposeObservable: Observable<EffectLayer>;
  137048. /**
  137049. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  137050. */
  137051. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  137052. /**
  137053. * An event triggered when the generated texture is being merged in the scene.
  137054. */
  137055. onBeforeComposeObservable: Observable<EffectLayer>;
  137056. /**
  137057. * An event triggered when the mesh is rendered into the effect render target.
  137058. */
  137059. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  137060. /**
  137061. * An event triggered after the mesh has been rendered into the effect render target.
  137062. */
  137063. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  137064. /**
  137065. * An event triggered when the generated texture has been merged in the scene.
  137066. */
  137067. onAfterComposeObservable: Observable<EffectLayer>;
  137068. /**
  137069. * An event triggered when the efffect layer changes its size.
  137070. */
  137071. onSizeChangedObservable: Observable<EffectLayer>;
  137072. /** @hidden */
  137073. static _SceneComponentInitialization: (scene: Scene) => void;
  137074. /**
  137075. * Instantiates a new effect Layer and references it in the scene.
  137076. * @param name The name of the layer
  137077. * @param scene The scene to use the layer in
  137078. */
  137079. constructor(
  137080. /** The Friendly of the effect in the scene */
  137081. name: string, scene: Scene);
  137082. /**
  137083. * Get the effect name of the layer.
  137084. * @return The effect name
  137085. */
  137086. abstract getEffectName(): string;
  137087. /**
  137088. * Checks for the readiness of the element composing the layer.
  137089. * @param subMesh the mesh to check for
  137090. * @param useInstances specify whether or not to use instances to render the mesh
  137091. * @return true if ready otherwise, false
  137092. */
  137093. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137094. /**
  137095. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137096. * @returns true if the effect requires stencil during the main canvas render pass.
  137097. */
  137098. abstract needStencil(): boolean;
  137099. /**
  137100. * Create the merge effect. This is the shader use to blit the information back
  137101. * to the main canvas at the end of the scene rendering.
  137102. * @returns The effect containing the shader used to merge the effect on the main canvas
  137103. */
  137104. protected abstract _createMergeEffect(): Effect;
  137105. /**
  137106. * Creates the render target textures and post processes used in the effect layer.
  137107. */
  137108. protected abstract _createTextureAndPostProcesses(): void;
  137109. /**
  137110. * Implementation specific of rendering the generating effect on the main canvas.
  137111. * @param effect The effect used to render through
  137112. */
  137113. protected abstract _internalRender(effect: Effect): void;
  137114. /**
  137115. * Sets the required values for both the emissive texture and and the main color.
  137116. */
  137117. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137118. /**
  137119. * Free any resources and references associated to a mesh.
  137120. * Internal use
  137121. * @param mesh The mesh to free.
  137122. */
  137123. abstract _disposeMesh(mesh: Mesh): void;
  137124. /**
  137125. * Serializes this layer (Glow or Highlight for example)
  137126. * @returns a serialized layer object
  137127. */
  137128. abstract serialize?(): any;
  137129. /**
  137130. * Initializes the effect layer with the required options.
  137131. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  137132. */
  137133. protected _init(options: Partial<IEffectLayerOptions>): void;
  137134. /**
  137135. * Generates the index buffer of the full screen quad blending to the main canvas.
  137136. */
  137137. private _generateIndexBuffer;
  137138. /**
  137139. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  137140. */
  137141. private _generateVertexBuffer;
  137142. /**
  137143. * Sets the main texture desired size which is the closest power of two
  137144. * of the engine canvas size.
  137145. */
  137146. private _setMainTextureSize;
  137147. /**
  137148. * Creates the main texture for the effect layer.
  137149. */
  137150. protected _createMainTexture(): void;
  137151. /**
  137152. * Adds specific effects defines.
  137153. * @param defines The defines to add specifics to.
  137154. */
  137155. protected _addCustomEffectDefines(defines: string[]): void;
  137156. /**
  137157. * Checks for the readiness of the element composing the layer.
  137158. * @param subMesh the mesh to check for
  137159. * @param useInstances specify whether or not to use instances to render the mesh
  137160. * @param emissiveTexture the associated emissive texture used to generate the glow
  137161. * @return true if ready otherwise, false
  137162. */
  137163. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  137164. /**
  137165. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  137166. */
  137167. render(): void;
  137168. /**
  137169. * Determine if a given mesh will be used in the current effect.
  137170. * @param mesh mesh to test
  137171. * @returns true if the mesh will be used
  137172. */
  137173. hasMesh(mesh: AbstractMesh): boolean;
  137174. /**
  137175. * Returns true if the layer contains information to display, otherwise false.
  137176. * @returns true if the glow layer should be rendered
  137177. */
  137178. shouldRender(): boolean;
  137179. /**
  137180. * Returns true if the mesh should render, otherwise false.
  137181. * @param mesh The mesh to render
  137182. * @returns true if it should render otherwise false
  137183. */
  137184. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  137185. /**
  137186. * Returns true if the mesh can be rendered, otherwise false.
  137187. * @param mesh The mesh to render
  137188. * @param material The material used on the mesh
  137189. * @returns true if it can be rendered otherwise false
  137190. */
  137191. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137192. /**
  137193. * Returns true if the mesh should render, otherwise false.
  137194. * @param mesh The mesh to render
  137195. * @returns true if it should render otherwise false
  137196. */
  137197. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  137198. /**
  137199. * Renders the submesh passed in parameter to the generation map.
  137200. */
  137201. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  137202. /**
  137203. * Defines whether the current material of the mesh should be use to render the effect.
  137204. * @param mesh defines the current mesh to render
  137205. */
  137206. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137207. /**
  137208. * Rebuild the required buffers.
  137209. * @hidden Internal use only.
  137210. */
  137211. _rebuild(): void;
  137212. /**
  137213. * Dispose only the render target textures and post process.
  137214. */
  137215. private _disposeTextureAndPostProcesses;
  137216. /**
  137217. * Dispose the highlight layer and free resources.
  137218. */
  137219. dispose(): void;
  137220. /**
  137221. * Gets the class name of the effect layer
  137222. * @returns the string with the class name of the effect layer
  137223. */
  137224. getClassName(): string;
  137225. /**
  137226. * Creates an effect layer from parsed effect layer data
  137227. * @param parsedEffectLayer defines effect layer data
  137228. * @param scene defines the current scene
  137229. * @param rootUrl defines the root URL containing the effect layer information
  137230. * @returns a parsed effect Layer
  137231. */
  137232. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  137233. }
  137234. }
  137235. declare module BABYLON {
  137236. interface AbstractScene {
  137237. /**
  137238. * The list of effect layers (highlights/glow) added to the scene
  137239. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137240. * @see https://doc.babylonjs.com/how_to/glow_layer
  137241. */
  137242. effectLayers: Array<EffectLayer>;
  137243. /**
  137244. * Removes the given effect layer from this scene.
  137245. * @param toRemove defines the effect layer to remove
  137246. * @returns the index of the removed effect layer
  137247. */
  137248. removeEffectLayer(toRemove: EffectLayer): number;
  137249. /**
  137250. * Adds the given effect layer to this scene
  137251. * @param newEffectLayer defines the effect layer to add
  137252. */
  137253. addEffectLayer(newEffectLayer: EffectLayer): void;
  137254. }
  137255. /**
  137256. * Defines the layer scene component responsible to manage any effect layers
  137257. * in a given scene.
  137258. */
  137259. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137260. /**
  137261. * The component name helpfull to identify the component in the list of scene components.
  137262. */
  137263. readonly name: string;
  137264. /**
  137265. * The scene the component belongs to.
  137266. */
  137267. scene: Scene;
  137268. private _engine;
  137269. private _renderEffects;
  137270. private _needStencil;
  137271. private _previousStencilState;
  137272. /**
  137273. * Creates a new instance of the component for the given scene
  137274. * @param scene Defines the scene to register the component in
  137275. */
  137276. constructor(scene: Scene);
  137277. /**
  137278. * Registers the component in a given scene
  137279. */
  137280. register(): void;
  137281. /**
  137282. * Rebuilds the elements related to this component in case of
  137283. * context lost for instance.
  137284. */
  137285. rebuild(): void;
  137286. /**
  137287. * Serializes the component data to the specified json object
  137288. * @param serializationObject The object to serialize to
  137289. */
  137290. serialize(serializationObject: any): void;
  137291. /**
  137292. * Adds all the elements from the container to the scene
  137293. * @param container the container holding the elements
  137294. */
  137295. addFromContainer(container: AbstractScene): void;
  137296. /**
  137297. * Removes all the elements in the container from the scene
  137298. * @param container contains the elements to remove
  137299. * @param dispose if the removed element should be disposed (default: false)
  137300. */
  137301. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137302. /**
  137303. * Disposes the component and the associated ressources.
  137304. */
  137305. dispose(): void;
  137306. private _isReadyForMesh;
  137307. private _renderMainTexture;
  137308. private _setStencil;
  137309. private _setStencilBack;
  137310. private _draw;
  137311. private _drawCamera;
  137312. private _drawRenderingGroup;
  137313. }
  137314. }
  137315. declare module BABYLON {
  137316. /** @hidden */
  137317. export var glowMapMergePixelShader: {
  137318. name: string;
  137319. shader: string;
  137320. };
  137321. }
  137322. declare module BABYLON {
  137323. /** @hidden */
  137324. export var glowMapMergeVertexShader: {
  137325. name: string;
  137326. shader: string;
  137327. };
  137328. }
  137329. declare module BABYLON {
  137330. interface AbstractScene {
  137331. /**
  137332. * Return a the first highlight layer of the scene with a given name.
  137333. * @param name The name of the highlight layer to look for.
  137334. * @return The highlight layer if found otherwise null.
  137335. */
  137336. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  137337. }
  137338. /**
  137339. * Glow layer options. This helps customizing the behaviour
  137340. * of the glow layer.
  137341. */
  137342. export interface IGlowLayerOptions {
  137343. /**
  137344. * Multiplication factor apply to the canvas size to compute the render target size
  137345. * used to generated the glowing objects (the smaller the faster).
  137346. */
  137347. mainTextureRatio: number;
  137348. /**
  137349. * Enforces a fixed size texture to ensure resize independant blur.
  137350. */
  137351. mainTextureFixedSize?: number;
  137352. /**
  137353. * How big is the kernel of the blur texture.
  137354. */
  137355. blurKernelSize: number;
  137356. /**
  137357. * The camera attached to the layer.
  137358. */
  137359. camera: Nullable<Camera>;
  137360. /**
  137361. * Enable MSAA by chosing the number of samples.
  137362. */
  137363. mainTextureSamples?: number;
  137364. /**
  137365. * The rendering group to draw the layer in.
  137366. */
  137367. renderingGroupId: number;
  137368. }
  137369. /**
  137370. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137371. *
  137372. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137373. *
  137374. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137375. */
  137376. export class GlowLayer extends EffectLayer {
  137377. /**
  137378. * Effect Name of the layer.
  137379. */
  137380. static readonly EffectName: string;
  137381. /**
  137382. * The default blur kernel size used for the glow.
  137383. */
  137384. static DefaultBlurKernelSize: number;
  137385. /**
  137386. * The default texture size ratio used for the glow.
  137387. */
  137388. static DefaultTextureRatio: number;
  137389. /**
  137390. * Sets the kernel size of the blur.
  137391. */
  137392. set blurKernelSize(value: number);
  137393. /**
  137394. * Gets the kernel size of the blur.
  137395. */
  137396. get blurKernelSize(): number;
  137397. /**
  137398. * Sets the glow intensity.
  137399. */
  137400. set intensity(value: number);
  137401. /**
  137402. * Gets the glow intensity.
  137403. */
  137404. get intensity(): number;
  137405. private _options;
  137406. private _intensity;
  137407. private _horizontalBlurPostprocess1;
  137408. private _verticalBlurPostprocess1;
  137409. private _horizontalBlurPostprocess2;
  137410. private _verticalBlurPostprocess2;
  137411. private _blurTexture1;
  137412. private _blurTexture2;
  137413. private _postProcesses1;
  137414. private _postProcesses2;
  137415. private _includedOnlyMeshes;
  137416. private _excludedMeshes;
  137417. private _meshesUsingTheirOwnMaterials;
  137418. /**
  137419. * Callback used to let the user override the color selection on a per mesh basis
  137420. */
  137421. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137422. /**
  137423. * Callback used to let the user override the texture selection on a per mesh basis
  137424. */
  137425. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137426. /**
  137427. * Instantiates a new glow Layer and references it to the scene.
  137428. * @param name The name of the layer
  137429. * @param scene The scene to use the layer in
  137430. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137431. */
  137432. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137433. /**
  137434. * Get the effect name of the layer.
  137435. * @return The effect name
  137436. */
  137437. getEffectName(): string;
  137438. /**
  137439. * Create the merge effect. This is the shader use to blit the information back
  137440. * to the main canvas at the end of the scene rendering.
  137441. */
  137442. protected _createMergeEffect(): Effect;
  137443. /**
  137444. * Creates the render target textures and post processes used in the glow layer.
  137445. */
  137446. protected _createTextureAndPostProcesses(): void;
  137447. /**
  137448. * Checks for the readiness of the element composing the layer.
  137449. * @param subMesh the mesh to check for
  137450. * @param useInstances specify wether or not to use instances to render the mesh
  137451. * @param emissiveTexture the associated emissive texture used to generate the glow
  137452. * @return true if ready otherwise, false
  137453. */
  137454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137455. /**
  137456. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137457. */
  137458. needStencil(): boolean;
  137459. /**
  137460. * Returns true if the mesh can be rendered, otherwise false.
  137461. * @param mesh The mesh to render
  137462. * @param material The material used on the mesh
  137463. * @returns true if it can be rendered otherwise false
  137464. */
  137465. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137466. /**
  137467. * Implementation specific of rendering the generating effect on the main canvas.
  137468. * @param effect The effect used to render through
  137469. */
  137470. protected _internalRender(effect: Effect): void;
  137471. /**
  137472. * Sets the required values for both the emissive texture and and the main color.
  137473. */
  137474. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137475. /**
  137476. * Returns true if the mesh should render, otherwise false.
  137477. * @param mesh The mesh to render
  137478. * @returns true if it should render otherwise false
  137479. */
  137480. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137481. /**
  137482. * Adds specific effects defines.
  137483. * @param defines The defines to add specifics to.
  137484. */
  137485. protected _addCustomEffectDefines(defines: string[]): void;
  137486. /**
  137487. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137488. * @param mesh The mesh to exclude from the glow layer
  137489. */
  137490. addExcludedMesh(mesh: Mesh): void;
  137491. /**
  137492. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137493. * @param mesh The mesh to remove
  137494. */
  137495. removeExcludedMesh(mesh: Mesh): void;
  137496. /**
  137497. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137498. * @param mesh The mesh to include in the glow layer
  137499. */
  137500. addIncludedOnlyMesh(mesh: Mesh): void;
  137501. /**
  137502. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137503. * @param mesh The mesh to remove
  137504. */
  137505. removeIncludedOnlyMesh(mesh: Mesh): void;
  137506. /**
  137507. * Determine if a given mesh will be used in the glow layer
  137508. * @param mesh The mesh to test
  137509. * @returns true if the mesh will be highlighted by the current glow layer
  137510. */
  137511. hasMesh(mesh: AbstractMesh): boolean;
  137512. /**
  137513. * Defines whether the current material of the mesh should be use to render the effect.
  137514. * @param mesh defines the current mesh to render
  137515. */
  137516. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137517. /**
  137518. * Add a mesh to be rendered through its own material and not with emissive only.
  137519. * @param mesh The mesh for which we need to use its material
  137520. */
  137521. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137522. /**
  137523. * Remove a mesh from being rendered through its own material and not with emissive only.
  137524. * @param mesh The mesh for which we need to not use its material
  137525. */
  137526. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137527. /**
  137528. * Free any resources and references associated to a mesh.
  137529. * Internal use
  137530. * @param mesh The mesh to free.
  137531. * @hidden
  137532. */
  137533. _disposeMesh(mesh: Mesh): void;
  137534. /**
  137535. * Gets the class name of the effect layer
  137536. * @returns the string with the class name of the effect layer
  137537. */
  137538. getClassName(): string;
  137539. /**
  137540. * Serializes this glow layer
  137541. * @returns a serialized glow layer object
  137542. */
  137543. serialize(): any;
  137544. /**
  137545. * Creates a Glow Layer from parsed glow layer data
  137546. * @param parsedGlowLayer defines glow layer data
  137547. * @param scene defines the current scene
  137548. * @param rootUrl defines the root URL containing the glow layer information
  137549. * @returns a parsed Glow Layer
  137550. */
  137551. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137552. }
  137553. }
  137554. declare module BABYLON {
  137555. /** @hidden */
  137556. export var glowBlurPostProcessPixelShader: {
  137557. name: string;
  137558. shader: string;
  137559. };
  137560. }
  137561. declare module BABYLON {
  137562. interface AbstractScene {
  137563. /**
  137564. * Return a the first highlight layer of the scene with a given name.
  137565. * @param name The name of the highlight layer to look for.
  137566. * @return The highlight layer if found otherwise null.
  137567. */
  137568. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137569. }
  137570. /**
  137571. * Highlight layer options. This helps customizing the behaviour
  137572. * of the highlight layer.
  137573. */
  137574. export interface IHighlightLayerOptions {
  137575. /**
  137576. * Multiplication factor apply to the canvas size to compute the render target size
  137577. * used to generated the glowing objects (the smaller the faster).
  137578. */
  137579. mainTextureRatio: number;
  137580. /**
  137581. * Enforces a fixed size texture to ensure resize independant blur.
  137582. */
  137583. mainTextureFixedSize?: number;
  137584. /**
  137585. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137586. * of the picture to blur (the smaller the faster).
  137587. */
  137588. blurTextureSizeRatio: number;
  137589. /**
  137590. * How big in texel of the blur texture is the vertical blur.
  137591. */
  137592. blurVerticalSize: number;
  137593. /**
  137594. * How big in texel of the blur texture is the horizontal blur.
  137595. */
  137596. blurHorizontalSize: number;
  137597. /**
  137598. * Alpha blending mode used to apply the blur. Default is combine.
  137599. */
  137600. alphaBlendingMode: number;
  137601. /**
  137602. * The camera attached to the layer.
  137603. */
  137604. camera: Nullable<Camera>;
  137605. /**
  137606. * Should we display highlight as a solid stroke?
  137607. */
  137608. isStroke?: boolean;
  137609. /**
  137610. * The rendering group to draw the layer in.
  137611. */
  137612. renderingGroupId: number;
  137613. }
  137614. /**
  137615. * The highlight layer Helps adding a glow effect around a mesh.
  137616. *
  137617. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137618. * glowy meshes to your scene.
  137619. *
  137620. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137621. */
  137622. export class HighlightLayer extends EffectLayer {
  137623. name: string;
  137624. /**
  137625. * Effect Name of the highlight layer.
  137626. */
  137627. static readonly EffectName: string;
  137628. /**
  137629. * The neutral color used during the preparation of the glow effect.
  137630. * This is black by default as the blend operation is a blend operation.
  137631. */
  137632. static NeutralColor: Color4;
  137633. /**
  137634. * Stencil value used for glowing meshes.
  137635. */
  137636. static GlowingMeshStencilReference: number;
  137637. /**
  137638. * Stencil value used for the other meshes in the scene.
  137639. */
  137640. static NormalMeshStencilReference: number;
  137641. /**
  137642. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137643. */
  137644. innerGlow: boolean;
  137645. /**
  137646. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137647. */
  137648. outerGlow: boolean;
  137649. /**
  137650. * Specifies the horizontal size of the blur.
  137651. */
  137652. set blurHorizontalSize(value: number);
  137653. /**
  137654. * Specifies the vertical size of the blur.
  137655. */
  137656. set blurVerticalSize(value: number);
  137657. /**
  137658. * Gets the horizontal size of the blur.
  137659. */
  137660. get blurHorizontalSize(): number;
  137661. /**
  137662. * Gets the vertical size of the blur.
  137663. */
  137664. get blurVerticalSize(): number;
  137665. /**
  137666. * An event triggered when the highlight layer is being blurred.
  137667. */
  137668. onBeforeBlurObservable: Observable<HighlightLayer>;
  137669. /**
  137670. * An event triggered when the highlight layer has been blurred.
  137671. */
  137672. onAfterBlurObservable: Observable<HighlightLayer>;
  137673. private _instanceGlowingMeshStencilReference;
  137674. private _options;
  137675. private _downSamplePostprocess;
  137676. private _horizontalBlurPostprocess;
  137677. private _verticalBlurPostprocess;
  137678. private _blurTexture;
  137679. private _meshes;
  137680. private _excludedMeshes;
  137681. /**
  137682. * Instantiates a new highlight Layer and references it to the scene..
  137683. * @param name The name of the layer
  137684. * @param scene The scene to use the layer in
  137685. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137686. */
  137687. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137688. /**
  137689. * Get the effect name of the layer.
  137690. * @return The effect name
  137691. */
  137692. getEffectName(): string;
  137693. /**
  137694. * Create the merge effect. This is the shader use to blit the information back
  137695. * to the main canvas at the end of the scene rendering.
  137696. */
  137697. protected _createMergeEffect(): Effect;
  137698. /**
  137699. * Creates the render target textures and post processes used in the highlight layer.
  137700. */
  137701. protected _createTextureAndPostProcesses(): void;
  137702. /**
  137703. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137704. */
  137705. needStencil(): boolean;
  137706. /**
  137707. * Checks for the readiness of the element composing the layer.
  137708. * @param subMesh the mesh to check for
  137709. * @param useInstances specify wether or not to use instances to render the mesh
  137710. * @param emissiveTexture the associated emissive texture used to generate the glow
  137711. * @return true if ready otherwise, false
  137712. */
  137713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137714. /**
  137715. * Implementation specific of rendering the generating effect on the main canvas.
  137716. * @param effect The effect used to render through
  137717. */
  137718. protected _internalRender(effect: Effect): void;
  137719. /**
  137720. * Returns true if the layer contains information to display, otherwise false.
  137721. */
  137722. shouldRender(): boolean;
  137723. /**
  137724. * Returns true if the mesh should render, otherwise false.
  137725. * @param mesh The mesh to render
  137726. * @returns true if it should render otherwise false
  137727. */
  137728. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137729. /**
  137730. * Returns true if the mesh can be rendered, otherwise false.
  137731. * @param mesh The mesh to render
  137732. * @param material The material used on the mesh
  137733. * @returns true if it can be rendered otherwise false
  137734. */
  137735. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137736. /**
  137737. * Adds specific effects defines.
  137738. * @param defines The defines to add specifics to.
  137739. */
  137740. protected _addCustomEffectDefines(defines: string[]): void;
  137741. /**
  137742. * Sets the required values for both the emissive texture and and the main color.
  137743. */
  137744. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137745. /**
  137746. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137747. * @param mesh The mesh to exclude from the highlight layer
  137748. */
  137749. addExcludedMesh(mesh: Mesh): void;
  137750. /**
  137751. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137752. * @param mesh The mesh to highlight
  137753. */
  137754. removeExcludedMesh(mesh: Mesh): void;
  137755. /**
  137756. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137757. * @param mesh mesh to test
  137758. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137759. */
  137760. hasMesh(mesh: AbstractMesh): boolean;
  137761. /**
  137762. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137763. * @param mesh The mesh to highlight
  137764. * @param color The color of the highlight
  137765. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137766. */
  137767. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137768. /**
  137769. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137770. * @param mesh The mesh to highlight
  137771. */
  137772. removeMesh(mesh: Mesh): void;
  137773. /**
  137774. * Remove all the meshes currently referenced in the highlight layer
  137775. */
  137776. removeAllMeshes(): void;
  137777. /**
  137778. * Force the stencil to the normal expected value for none glowing parts
  137779. */
  137780. private _defaultStencilReference;
  137781. /**
  137782. * Free any resources and references associated to a mesh.
  137783. * Internal use
  137784. * @param mesh The mesh to free.
  137785. * @hidden
  137786. */
  137787. _disposeMesh(mesh: Mesh): void;
  137788. /**
  137789. * Dispose the highlight layer and free resources.
  137790. */
  137791. dispose(): void;
  137792. /**
  137793. * Gets the class name of the effect layer
  137794. * @returns the string with the class name of the effect layer
  137795. */
  137796. getClassName(): string;
  137797. /**
  137798. * Serializes this Highlight layer
  137799. * @returns a serialized Highlight layer object
  137800. */
  137801. serialize(): any;
  137802. /**
  137803. * Creates a Highlight layer from parsed Highlight layer data
  137804. * @param parsedHightlightLayer defines the Highlight layer data
  137805. * @param scene defines the current scene
  137806. * @param rootUrl defines the root URL containing the Highlight layer information
  137807. * @returns a parsed Highlight layer
  137808. */
  137809. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137810. }
  137811. }
  137812. declare module BABYLON {
  137813. interface AbstractScene {
  137814. /**
  137815. * The list of layers (background and foreground) of the scene
  137816. */
  137817. layers: Array<Layer>;
  137818. }
  137819. /**
  137820. * Defines the layer scene component responsible to manage any layers
  137821. * in a given scene.
  137822. */
  137823. export class LayerSceneComponent implements ISceneComponent {
  137824. /**
  137825. * The component name helpfull to identify the component in the list of scene components.
  137826. */
  137827. readonly name: string;
  137828. /**
  137829. * The scene the component belongs to.
  137830. */
  137831. scene: Scene;
  137832. private _engine;
  137833. /**
  137834. * Creates a new instance of the component for the given scene
  137835. * @param scene Defines the scene to register the component in
  137836. */
  137837. constructor(scene: Scene);
  137838. /**
  137839. * Registers the component in a given scene
  137840. */
  137841. register(): void;
  137842. /**
  137843. * Rebuilds the elements related to this component in case of
  137844. * context lost for instance.
  137845. */
  137846. rebuild(): void;
  137847. /**
  137848. * Disposes the component and the associated ressources.
  137849. */
  137850. dispose(): void;
  137851. private _draw;
  137852. private _drawCameraPredicate;
  137853. private _drawCameraBackground;
  137854. private _drawCameraForeground;
  137855. private _drawRenderTargetPredicate;
  137856. private _drawRenderTargetBackground;
  137857. private _drawRenderTargetForeground;
  137858. /**
  137859. * Adds all the elements from the container to the scene
  137860. * @param container the container holding the elements
  137861. */
  137862. addFromContainer(container: AbstractScene): void;
  137863. /**
  137864. * Removes all the elements in the container from the scene
  137865. * @param container contains the elements to remove
  137866. * @param dispose if the removed element should be disposed (default: false)
  137867. */
  137868. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137869. }
  137870. }
  137871. declare module BABYLON {
  137872. /** @hidden */
  137873. export var layerPixelShader: {
  137874. name: string;
  137875. shader: string;
  137876. };
  137877. }
  137878. declare module BABYLON {
  137879. /** @hidden */
  137880. export var layerVertexShader: {
  137881. name: string;
  137882. shader: string;
  137883. };
  137884. }
  137885. declare module BABYLON {
  137886. /**
  137887. * This represents a full screen 2d layer.
  137888. * This can be useful to display a picture in the background of your scene for instance.
  137889. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137890. */
  137891. export class Layer {
  137892. /**
  137893. * Define the name of the layer.
  137894. */
  137895. name: string;
  137896. /**
  137897. * Define the texture the layer should display.
  137898. */
  137899. texture: Nullable<Texture>;
  137900. /**
  137901. * Is the layer in background or foreground.
  137902. */
  137903. isBackground: boolean;
  137904. /**
  137905. * Define the color of the layer (instead of texture).
  137906. */
  137907. color: Color4;
  137908. /**
  137909. * Define the scale of the layer in order to zoom in out of the texture.
  137910. */
  137911. scale: Vector2;
  137912. /**
  137913. * Define an offset for the layer in order to shift the texture.
  137914. */
  137915. offset: Vector2;
  137916. /**
  137917. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137918. */
  137919. alphaBlendingMode: number;
  137920. /**
  137921. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137922. * Alpha test will not mix with the background color in case of transparency.
  137923. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137924. */
  137925. alphaTest: boolean;
  137926. /**
  137927. * Define a mask to restrict the layer to only some of the scene cameras.
  137928. */
  137929. layerMask: number;
  137930. /**
  137931. * Define the list of render target the layer is visible into.
  137932. */
  137933. renderTargetTextures: RenderTargetTexture[];
  137934. /**
  137935. * Define if the layer is only used in renderTarget or if it also
  137936. * renders in the main frame buffer of the canvas.
  137937. */
  137938. renderOnlyInRenderTargetTextures: boolean;
  137939. private _scene;
  137940. private _vertexBuffers;
  137941. private _indexBuffer;
  137942. private _effect;
  137943. private _previousDefines;
  137944. /**
  137945. * An event triggered when the layer is disposed.
  137946. */
  137947. onDisposeObservable: Observable<Layer>;
  137948. private _onDisposeObserver;
  137949. /**
  137950. * Back compatibility with callback before the onDisposeObservable existed.
  137951. * The set callback will be triggered when the layer has been disposed.
  137952. */
  137953. set onDispose(callback: () => void);
  137954. /**
  137955. * An event triggered before rendering the scene
  137956. */
  137957. onBeforeRenderObservable: Observable<Layer>;
  137958. private _onBeforeRenderObserver;
  137959. /**
  137960. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137961. * The set callback will be triggered just before rendering the layer.
  137962. */
  137963. set onBeforeRender(callback: () => void);
  137964. /**
  137965. * An event triggered after rendering the scene
  137966. */
  137967. onAfterRenderObservable: Observable<Layer>;
  137968. private _onAfterRenderObserver;
  137969. /**
  137970. * Back compatibility with callback before the onAfterRenderObservable existed.
  137971. * The set callback will be triggered just after rendering the layer.
  137972. */
  137973. set onAfterRender(callback: () => void);
  137974. /**
  137975. * Instantiates a new layer.
  137976. * This represents a full screen 2d layer.
  137977. * This can be useful to display a picture in the background of your scene for instance.
  137978. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137979. * @param name Define the name of the layer in the scene
  137980. * @param imgUrl Define the url of the texture to display in the layer
  137981. * @param scene Define the scene the layer belongs to
  137982. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137983. * @param color Defines a color for the layer
  137984. */
  137985. constructor(
  137986. /**
  137987. * Define the name of the layer.
  137988. */
  137989. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137990. private _createIndexBuffer;
  137991. /** @hidden */
  137992. _rebuild(): void;
  137993. /**
  137994. * Renders the layer in the scene.
  137995. */
  137996. render(): void;
  137997. /**
  137998. * Disposes and releases the associated ressources.
  137999. */
  138000. dispose(): void;
  138001. }
  138002. }
  138003. declare module BABYLON {
  138004. /** @hidden */
  138005. export var lensFlarePixelShader: {
  138006. name: string;
  138007. shader: string;
  138008. };
  138009. }
  138010. declare module BABYLON {
  138011. /** @hidden */
  138012. export var lensFlareVertexShader: {
  138013. name: string;
  138014. shader: string;
  138015. };
  138016. }
  138017. declare module BABYLON {
  138018. /**
  138019. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138020. * It is usually composed of several `lensFlare`.
  138021. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138022. */
  138023. export class LensFlareSystem {
  138024. /**
  138025. * Define the name of the lens flare system
  138026. */
  138027. name: string;
  138028. /**
  138029. * List of lens flares used in this system.
  138030. */
  138031. lensFlares: LensFlare[];
  138032. /**
  138033. * Define a limit from the border the lens flare can be visible.
  138034. */
  138035. borderLimit: number;
  138036. /**
  138037. * Define a viewport border we do not want to see the lens flare in.
  138038. */
  138039. viewportBorder: number;
  138040. /**
  138041. * Define a predicate which could limit the list of meshes able to occlude the effect.
  138042. */
  138043. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  138044. /**
  138045. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  138046. */
  138047. layerMask: number;
  138048. /**
  138049. * Define the id of the lens flare system in the scene.
  138050. * (equal to name by default)
  138051. */
  138052. id: string;
  138053. private _scene;
  138054. private _emitter;
  138055. private _vertexBuffers;
  138056. private _indexBuffer;
  138057. private _effect;
  138058. private _positionX;
  138059. private _positionY;
  138060. private _isEnabled;
  138061. /** @hidden */
  138062. static _SceneComponentInitialization: (scene: Scene) => void;
  138063. /**
  138064. * Instantiates a lens flare system.
  138065. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  138066. * It is usually composed of several `lensFlare`.
  138067. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138068. * @param name Define the name of the lens flare system in the scene
  138069. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  138070. * @param scene Define the scene the lens flare system belongs to
  138071. */
  138072. constructor(
  138073. /**
  138074. * Define the name of the lens flare system
  138075. */
  138076. name: string, emitter: any, scene: Scene);
  138077. /**
  138078. * Define if the lens flare system is enabled.
  138079. */
  138080. get isEnabled(): boolean;
  138081. set isEnabled(value: boolean);
  138082. /**
  138083. * Get the scene the effects belongs to.
  138084. * @returns the scene holding the lens flare system
  138085. */
  138086. getScene(): Scene;
  138087. /**
  138088. * Get the emitter of the lens flare system.
  138089. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138090. * @returns the emitter of the lens flare system
  138091. */
  138092. getEmitter(): any;
  138093. /**
  138094. * Set the emitter of the lens flare system.
  138095. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  138096. * @param newEmitter Define the new emitter of the system
  138097. */
  138098. setEmitter(newEmitter: any): void;
  138099. /**
  138100. * Get the lens flare system emitter position.
  138101. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  138102. * @returns the position
  138103. */
  138104. getEmitterPosition(): Vector3;
  138105. /**
  138106. * @hidden
  138107. */
  138108. computeEffectivePosition(globalViewport: Viewport): boolean;
  138109. /** @hidden */
  138110. _isVisible(): boolean;
  138111. /**
  138112. * @hidden
  138113. */
  138114. render(): boolean;
  138115. /**
  138116. * Dispose and release the lens flare with its associated resources.
  138117. */
  138118. dispose(): void;
  138119. /**
  138120. * Parse a lens flare system from a JSON repressentation
  138121. * @param parsedLensFlareSystem Define the JSON to parse
  138122. * @param scene Define the scene the parsed system should be instantiated in
  138123. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  138124. * @returns the parsed system
  138125. */
  138126. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  138127. /**
  138128. * Serialize the current Lens Flare System into a JSON representation.
  138129. * @returns the serialized JSON
  138130. */
  138131. serialize(): any;
  138132. }
  138133. }
  138134. declare module BABYLON {
  138135. /**
  138136. * This represents one of the lens effect in a `lensFlareSystem`.
  138137. * It controls one of the indiviual texture used in the effect.
  138138. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138139. */
  138140. export class LensFlare {
  138141. /**
  138142. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138143. */
  138144. size: number;
  138145. /**
  138146. * 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.
  138147. */
  138148. position: number;
  138149. /**
  138150. * Define the lens color.
  138151. */
  138152. color: Color3;
  138153. /**
  138154. * Define the lens texture.
  138155. */
  138156. texture: Nullable<Texture>;
  138157. /**
  138158. * Define the alpha mode to render this particular lens.
  138159. */
  138160. alphaMode: number;
  138161. private _system;
  138162. /**
  138163. * Creates a new Lens Flare.
  138164. * This represents one of the lens effect in a `lensFlareSystem`.
  138165. * It controls one of the indiviual texture used in the effect.
  138166. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138167. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  138168. * @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.
  138169. * @param color Define the lens color
  138170. * @param imgUrl Define the lens texture url
  138171. * @param system Define the `lensFlareSystem` this flare is part of
  138172. * @returns The newly created Lens Flare
  138173. */
  138174. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  138175. /**
  138176. * Instantiates a new Lens Flare.
  138177. * This represents one of the lens effect in a `lensFlareSystem`.
  138178. * It controls one of the indiviual texture used in the effect.
  138179. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138180. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  138181. * @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.
  138182. * @param color Define the lens color
  138183. * @param imgUrl Define the lens texture url
  138184. * @param system Define the `lensFlareSystem` this flare is part of
  138185. */
  138186. constructor(
  138187. /**
  138188. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  138189. */
  138190. size: number,
  138191. /**
  138192. * 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.
  138193. */
  138194. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  138195. /**
  138196. * Dispose and release the lens flare with its associated resources.
  138197. */
  138198. dispose(): void;
  138199. }
  138200. }
  138201. declare module BABYLON {
  138202. interface AbstractScene {
  138203. /**
  138204. * The list of lens flare system added to the scene
  138205. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  138206. */
  138207. lensFlareSystems: Array<LensFlareSystem>;
  138208. /**
  138209. * Removes the given lens flare system from this scene.
  138210. * @param toRemove The lens flare system to remove
  138211. * @returns The index of the removed lens flare system
  138212. */
  138213. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  138214. /**
  138215. * Adds the given lens flare system to this scene
  138216. * @param newLensFlareSystem The lens flare system to add
  138217. */
  138218. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  138219. /**
  138220. * Gets a lens flare system using its name
  138221. * @param name defines the name to look for
  138222. * @returns the lens flare system or null if not found
  138223. */
  138224. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  138225. /**
  138226. * Gets a lens flare system using its id
  138227. * @param id defines the id to look for
  138228. * @returns the lens flare system or null if not found
  138229. */
  138230. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  138231. }
  138232. /**
  138233. * Defines the lens flare scene component responsible to manage any lens flares
  138234. * in a given scene.
  138235. */
  138236. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138237. /**
  138238. * The component name helpfull to identify the component in the list of scene components.
  138239. */
  138240. readonly name: string;
  138241. /**
  138242. * The scene the component belongs to.
  138243. */
  138244. scene: Scene;
  138245. /**
  138246. * Creates a new instance of the component for the given scene
  138247. * @param scene Defines the scene to register the component in
  138248. */
  138249. constructor(scene: Scene);
  138250. /**
  138251. * Registers the component in a given scene
  138252. */
  138253. register(): void;
  138254. /**
  138255. * Rebuilds the elements related to this component in case of
  138256. * context lost for instance.
  138257. */
  138258. rebuild(): void;
  138259. /**
  138260. * Adds all the elements from the container to the scene
  138261. * @param container the container holding the elements
  138262. */
  138263. addFromContainer(container: AbstractScene): void;
  138264. /**
  138265. * Removes all the elements in the container from the scene
  138266. * @param container contains the elements to remove
  138267. * @param dispose if the removed element should be disposed (default: false)
  138268. */
  138269. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138270. /**
  138271. * Serializes the component data to the specified json object
  138272. * @param serializationObject The object to serialize to
  138273. */
  138274. serialize(serializationObject: any): void;
  138275. /**
  138276. * Disposes the component and the associated ressources.
  138277. */
  138278. dispose(): void;
  138279. private _draw;
  138280. }
  138281. }
  138282. declare module BABYLON {
  138283. /** @hidden */
  138284. export var depthPixelShader: {
  138285. name: string;
  138286. shader: string;
  138287. };
  138288. }
  138289. declare module BABYLON {
  138290. /** @hidden */
  138291. export var depthVertexShader: {
  138292. name: string;
  138293. shader: string;
  138294. };
  138295. }
  138296. declare module BABYLON {
  138297. /**
  138298. * This represents a depth renderer in Babylon.
  138299. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138300. */
  138301. export class DepthRenderer {
  138302. private _scene;
  138303. private _depthMap;
  138304. private _effect;
  138305. private readonly _storeNonLinearDepth;
  138306. private readonly _clearColor;
  138307. /** Get if the depth renderer is using packed depth or not */
  138308. readonly isPacked: boolean;
  138309. private _cachedDefines;
  138310. private _camera;
  138311. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138312. enabled: boolean;
  138313. /**
  138314. * Specifiess that the depth renderer will only be used within
  138315. * the camera it is created for.
  138316. * This can help forcing its rendering during the camera processing.
  138317. */
  138318. useOnlyInActiveCamera: boolean;
  138319. /** @hidden */
  138320. static _SceneComponentInitialization: (scene: Scene) => void;
  138321. /**
  138322. * Instantiates a depth renderer
  138323. * @param scene The scene the renderer belongs to
  138324. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  138325. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  138326. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138327. */
  138328. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  138329. /**
  138330. * Creates the depth rendering effect and checks if the effect is ready.
  138331. * @param subMesh The submesh to be used to render the depth map of
  138332. * @param useInstances If multiple world instances should be used
  138333. * @returns if the depth renderer is ready to render the depth map
  138334. */
  138335. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138336. /**
  138337. * Gets the texture which the depth map will be written to.
  138338. * @returns The depth map texture
  138339. */
  138340. getDepthMap(): RenderTargetTexture;
  138341. /**
  138342. * Disposes of the depth renderer.
  138343. */
  138344. dispose(): void;
  138345. }
  138346. }
  138347. declare module BABYLON {
  138348. /** @hidden */
  138349. export var minmaxReduxPixelShader: {
  138350. name: string;
  138351. shader: string;
  138352. };
  138353. }
  138354. declare module BABYLON {
  138355. /**
  138356. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138357. * and maximum values from all values of the texture.
  138358. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138359. * The source values are read from the red channel of the texture.
  138360. */
  138361. export class MinMaxReducer {
  138362. /**
  138363. * Observable triggered when the computation has been performed
  138364. */
  138365. onAfterReductionPerformed: Observable<{
  138366. min: number;
  138367. max: number;
  138368. }>;
  138369. protected _camera: Camera;
  138370. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138371. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138372. protected _postProcessManager: PostProcessManager;
  138373. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138374. protected _forceFullscreenViewport: boolean;
  138375. /**
  138376. * Creates a min/max reducer
  138377. * @param camera The camera to use for the post processes
  138378. */
  138379. constructor(camera: Camera);
  138380. /**
  138381. * Gets the texture used to read the values from.
  138382. */
  138383. get sourceTexture(): Nullable<RenderTargetTexture>;
  138384. /**
  138385. * Sets the source texture to read the values from.
  138386. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138387. * because in such textures '1' value must not be taken into account to compute the maximum
  138388. * as this value is used to clear the texture.
  138389. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138390. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138391. * @param depthRedux Indicates if the texture is a depth texture or not
  138392. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138393. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138394. */
  138395. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138396. /**
  138397. * Defines the refresh rate of the computation.
  138398. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138399. */
  138400. get refreshRate(): number;
  138401. set refreshRate(value: number);
  138402. protected _activated: boolean;
  138403. /**
  138404. * Gets the activation status of the reducer
  138405. */
  138406. get activated(): boolean;
  138407. /**
  138408. * Activates the reduction computation.
  138409. * When activated, the observers registered in onAfterReductionPerformed are
  138410. * called after the compuation is performed
  138411. */
  138412. activate(): void;
  138413. /**
  138414. * Deactivates the reduction computation.
  138415. */
  138416. deactivate(): void;
  138417. /**
  138418. * Disposes the min/max reducer
  138419. * @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.
  138420. */
  138421. dispose(disposeAll?: boolean): void;
  138422. }
  138423. }
  138424. declare module BABYLON {
  138425. /**
  138426. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138427. */
  138428. export class DepthReducer extends MinMaxReducer {
  138429. private _depthRenderer;
  138430. private _depthRendererId;
  138431. /**
  138432. * Gets the depth renderer used for the computation.
  138433. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138434. */
  138435. get depthRenderer(): Nullable<DepthRenderer>;
  138436. /**
  138437. * Creates a depth reducer
  138438. * @param camera The camera used to render the depth texture
  138439. */
  138440. constructor(camera: Camera);
  138441. /**
  138442. * Sets the depth renderer to use to generate the depth map
  138443. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138444. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138445. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138446. */
  138447. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138448. /** @hidden */
  138449. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138450. /**
  138451. * Activates the reduction computation.
  138452. * When activated, the observers registered in onAfterReductionPerformed are
  138453. * called after the compuation is performed
  138454. */
  138455. activate(): void;
  138456. /**
  138457. * Deactivates the reduction computation.
  138458. */
  138459. deactivate(): void;
  138460. /**
  138461. * Disposes the depth reducer
  138462. * @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.
  138463. */
  138464. dispose(disposeAll?: boolean): void;
  138465. }
  138466. }
  138467. declare module BABYLON {
  138468. /**
  138469. * A CSM implementation allowing casting shadows on large scenes.
  138470. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138471. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138472. */
  138473. export class CascadedShadowGenerator extends ShadowGenerator {
  138474. private static readonly frustumCornersNDCSpace;
  138475. /**
  138476. * Name of the CSM class
  138477. */
  138478. static CLASSNAME: string;
  138479. /**
  138480. * Defines the default number of cascades used by the CSM.
  138481. */
  138482. static readonly DEFAULT_CASCADES_COUNT: number;
  138483. /**
  138484. * Defines the minimum number of cascades used by the CSM.
  138485. */
  138486. static readonly MIN_CASCADES_COUNT: number;
  138487. /**
  138488. * Defines the maximum number of cascades used by the CSM.
  138489. */
  138490. static readonly MAX_CASCADES_COUNT: number;
  138491. protected _validateFilter(filter: number): number;
  138492. /**
  138493. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138494. */
  138495. penumbraDarkness: number;
  138496. private _numCascades;
  138497. /**
  138498. * Gets or set the number of cascades used by the CSM.
  138499. */
  138500. get numCascades(): number;
  138501. set numCascades(value: number);
  138502. /**
  138503. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138504. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138505. */
  138506. stabilizeCascades: boolean;
  138507. private _freezeShadowCastersBoundingInfo;
  138508. private _freezeShadowCastersBoundingInfoObservable;
  138509. /**
  138510. * Enables or disables the shadow casters bounding info computation.
  138511. * If your shadow casters don't move, you can disable this feature.
  138512. * If it is enabled, the bounding box computation is done every frame.
  138513. */
  138514. get freezeShadowCastersBoundingInfo(): boolean;
  138515. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138516. private _scbiMin;
  138517. private _scbiMax;
  138518. protected _computeShadowCastersBoundingInfo(): void;
  138519. protected _shadowCastersBoundingInfo: BoundingInfo;
  138520. /**
  138521. * Gets or sets the shadow casters bounding info.
  138522. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138523. * so that the system won't overwrite the bounds you provide
  138524. */
  138525. get shadowCastersBoundingInfo(): BoundingInfo;
  138526. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138527. protected _breaksAreDirty: boolean;
  138528. protected _minDistance: number;
  138529. protected _maxDistance: number;
  138530. /**
  138531. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138532. *
  138533. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138534. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138535. * @param min minimal distance for the breaks (default to 0.)
  138536. * @param max maximal distance for the breaks (default to 1.)
  138537. */
  138538. setMinMaxDistance(min: number, max: number): void;
  138539. /** Gets the minimal distance used in the cascade break computation */
  138540. get minDistance(): number;
  138541. /** Gets the maximal distance used in the cascade break computation */
  138542. get maxDistance(): number;
  138543. /**
  138544. * Gets the class name of that object
  138545. * @returns "CascadedShadowGenerator"
  138546. */
  138547. getClassName(): string;
  138548. private _cascadeMinExtents;
  138549. private _cascadeMaxExtents;
  138550. /**
  138551. * Gets a cascade minimum extents
  138552. * @param cascadeIndex index of the cascade
  138553. * @returns the minimum cascade extents
  138554. */
  138555. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138556. /**
  138557. * Gets a cascade maximum extents
  138558. * @param cascadeIndex index of the cascade
  138559. * @returns the maximum cascade extents
  138560. */
  138561. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138562. private _cascades;
  138563. private _currentLayer;
  138564. private _viewSpaceFrustumsZ;
  138565. private _viewMatrices;
  138566. private _projectionMatrices;
  138567. private _transformMatrices;
  138568. private _transformMatricesAsArray;
  138569. private _frustumLengths;
  138570. private _lightSizeUVCorrection;
  138571. private _depthCorrection;
  138572. private _frustumCornersWorldSpace;
  138573. private _frustumCenter;
  138574. private _shadowCameraPos;
  138575. private _shadowMaxZ;
  138576. /**
  138577. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138578. * It defaults to camera.maxZ
  138579. */
  138580. get shadowMaxZ(): number;
  138581. /**
  138582. * Sets the shadow max z distance.
  138583. */
  138584. set shadowMaxZ(value: number);
  138585. protected _debug: boolean;
  138586. /**
  138587. * Gets or sets the debug flag.
  138588. * When enabled, the cascades are materialized by different colors on the screen.
  138589. */
  138590. get debug(): boolean;
  138591. set debug(dbg: boolean);
  138592. private _depthClamp;
  138593. /**
  138594. * Gets or sets the depth clamping value.
  138595. *
  138596. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138597. * to account for the shadow casters far away.
  138598. *
  138599. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138600. */
  138601. get depthClamp(): boolean;
  138602. set depthClamp(value: boolean);
  138603. private _cascadeBlendPercentage;
  138604. /**
  138605. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138606. * It defaults to 0.1 (10% blending).
  138607. */
  138608. get cascadeBlendPercentage(): number;
  138609. set cascadeBlendPercentage(value: number);
  138610. private _lambda;
  138611. /**
  138612. * Gets or set the lambda parameter.
  138613. * This parameter is used to split the camera frustum and create the cascades.
  138614. * 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.
  138615. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138616. */
  138617. get lambda(): number;
  138618. set lambda(value: number);
  138619. /**
  138620. * Gets the view matrix corresponding to a given cascade
  138621. * @param cascadeNum cascade to retrieve the view matrix from
  138622. * @returns the cascade view matrix
  138623. */
  138624. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138625. /**
  138626. * Gets the projection matrix corresponding to a given cascade
  138627. * @param cascadeNum cascade to retrieve the projection matrix from
  138628. * @returns the cascade projection matrix
  138629. */
  138630. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138631. /**
  138632. * Gets the transformation matrix corresponding to a given cascade
  138633. * @param cascadeNum cascade to retrieve the transformation matrix from
  138634. * @returns the cascade transformation matrix
  138635. */
  138636. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138637. private _depthRenderer;
  138638. /**
  138639. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138640. *
  138641. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138642. *
  138643. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138644. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138645. * @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
  138646. */
  138647. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138648. private _depthReducer;
  138649. private _autoCalcDepthBounds;
  138650. /**
  138651. * Gets or sets the autoCalcDepthBounds property.
  138652. *
  138653. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138654. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138655. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138656. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138657. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138658. */
  138659. get autoCalcDepthBounds(): boolean;
  138660. set autoCalcDepthBounds(value: boolean);
  138661. /**
  138662. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138663. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138664. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138665. * for setting the refresh rate on the renderer yourself!
  138666. */
  138667. get autoCalcDepthBoundsRefreshRate(): number;
  138668. set autoCalcDepthBoundsRefreshRate(value: number);
  138669. /**
  138670. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138671. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138672. * you change the camera near/far planes!
  138673. */
  138674. splitFrustum(): void;
  138675. private _splitFrustum;
  138676. private _computeMatrices;
  138677. private _computeFrustumInWorldSpace;
  138678. private _computeCascadeFrustum;
  138679. /**
  138680. * Support test.
  138681. */
  138682. static get IsSupported(): boolean;
  138683. /** @hidden */
  138684. static _SceneComponentInitialization: (scene: Scene) => void;
  138685. /**
  138686. * Creates a Cascaded Shadow Generator object.
  138687. * A ShadowGenerator is the required tool to use the shadows.
  138688. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138689. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138690. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138691. * @param light The directional light object generating the shadows.
  138692. * @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.
  138693. */
  138694. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138695. protected _initializeGenerator(): void;
  138696. protected _createTargetRenderTexture(): void;
  138697. protected _initializeShadowMap(): void;
  138698. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138699. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138700. /**
  138701. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138702. * @param defines Defines of the material we want to update
  138703. * @param lightIndex Index of the light in the enabled light list of the material
  138704. */
  138705. prepareDefines(defines: any, lightIndex: number): void;
  138706. /**
  138707. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138708. * defined in the generator but impacting the effect).
  138709. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138710. * @param effect The effect we are binfing the information for
  138711. */
  138712. bindShadowLight(lightIndex: string, effect: Effect): void;
  138713. /**
  138714. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138715. * (eq to view projection * shadow projection matrices)
  138716. * @returns The transform matrix used to create the shadow map
  138717. */
  138718. getTransformMatrix(): Matrix;
  138719. /**
  138720. * Disposes the ShadowGenerator.
  138721. * Returns nothing.
  138722. */
  138723. dispose(): void;
  138724. /**
  138725. * Serializes the shadow generator setup to a json object.
  138726. * @returns The serialized JSON object
  138727. */
  138728. serialize(): any;
  138729. /**
  138730. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138731. * @param parsedShadowGenerator The JSON object to parse
  138732. * @param scene The scene to create the shadow map for
  138733. * @returns The parsed shadow generator
  138734. */
  138735. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138736. }
  138737. }
  138738. declare module BABYLON {
  138739. /**
  138740. * Defines the shadow generator component responsible to manage any shadow generators
  138741. * in a given scene.
  138742. */
  138743. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138744. /**
  138745. * The component name helpfull to identify the component in the list of scene components.
  138746. */
  138747. readonly name: string;
  138748. /**
  138749. * The scene the component belongs to.
  138750. */
  138751. scene: Scene;
  138752. /**
  138753. * Creates a new instance of the component for the given scene
  138754. * @param scene Defines the scene to register the component in
  138755. */
  138756. constructor(scene: Scene);
  138757. /**
  138758. * Registers the component in a given scene
  138759. */
  138760. register(): void;
  138761. /**
  138762. * Rebuilds the elements related to this component in case of
  138763. * context lost for instance.
  138764. */
  138765. rebuild(): void;
  138766. /**
  138767. * Serializes the component data to the specified json object
  138768. * @param serializationObject The object to serialize to
  138769. */
  138770. serialize(serializationObject: any): void;
  138771. /**
  138772. * Adds all the elements from the container to the scene
  138773. * @param container the container holding the elements
  138774. */
  138775. addFromContainer(container: AbstractScene): void;
  138776. /**
  138777. * Removes all the elements in the container from the scene
  138778. * @param container contains the elements to remove
  138779. * @param dispose if the removed element should be disposed (default: false)
  138780. */
  138781. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138782. /**
  138783. * Rebuilds the elements related to this component in case of
  138784. * context lost for instance.
  138785. */
  138786. dispose(): void;
  138787. private _gatherRenderTargets;
  138788. }
  138789. }
  138790. declare module BABYLON {
  138791. /**
  138792. * A point light is a light defined by an unique point in world space.
  138793. * The light is emitted in every direction from this point.
  138794. * A good example of a point light is a standard light bulb.
  138795. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138796. */
  138797. export class PointLight extends ShadowLight {
  138798. private _shadowAngle;
  138799. /**
  138800. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138801. * This specifies what angle the shadow will use to be created.
  138802. *
  138803. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138804. */
  138805. get shadowAngle(): number;
  138806. /**
  138807. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138808. * This specifies what angle the shadow will use to be created.
  138809. *
  138810. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138811. */
  138812. set shadowAngle(value: number);
  138813. /**
  138814. * Gets the direction if it has been set.
  138815. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138816. */
  138817. get direction(): Vector3;
  138818. /**
  138819. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138820. */
  138821. set direction(value: Vector3);
  138822. /**
  138823. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138824. * A PointLight emits the light in every direction.
  138825. * It can cast shadows.
  138826. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138827. * ```javascript
  138828. * var pointLight = new PointLight("pl", camera.position, scene);
  138829. * ```
  138830. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138831. * @param name The light friendly name
  138832. * @param position The position of the point light in the scene
  138833. * @param scene The scene the lights belongs to
  138834. */
  138835. constructor(name: string, position: Vector3, scene: Scene);
  138836. /**
  138837. * Returns the string "PointLight"
  138838. * @returns the class name
  138839. */
  138840. getClassName(): string;
  138841. /**
  138842. * Returns the integer 0.
  138843. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138844. */
  138845. getTypeID(): number;
  138846. /**
  138847. * Specifies wether or not the shadowmap should be a cube texture.
  138848. * @returns true if the shadowmap needs to be a cube texture.
  138849. */
  138850. needCube(): boolean;
  138851. /**
  138852. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138853. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138854. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138855. */
  138856. getShadowDirection(faceIndex?: number): Vector3;
  138857. /**
  138858. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138859. * - fov = PI / 2
  138860. * - aspect ratio : 1.0
  138861. * - z-near and far equal to the active camera minZ and maxZ.
  138862. * Returns the PointLight.
  138863. */
  138864. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138865. protected _buildUniformLayout(): void;
  138866. /**
  138867. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138868. * @param effect The effect to update
  138869. * @param lightIndex The index of the light in the effect to update
  138870. * @returns The point light
  138871. */
  138872. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138873. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138874. /**
  138875. * Prepares the list of defines specific to the light type.
  138876. * @param defines the list of defines
  138877. * @param lightIndex defines the index of the light for the effect
  138878. */
  138879. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138880. }
  138881. }
  138882. declare module BABYLON {
  138883. /**
  138884. * Header information of HDR texture files.
  138885. */
  138886. export interface HDRInfo {
  138887. /**
  138888. * The height of the texture in pixels.
  138889. */
  138890. height: number;
  138891. /**
  138892. * The width of the texture in pixels.
  138893. */
  138894. width: number;
  138895. /**
  138896. * The index of the beginning of the data in the binary file.
  138897. */
  138898. dataPosition: number;
  138899. }
  138900. /**
  138901. * This groups tools to convert HDR texture to native colors array.
  138902. */
  138903. export class HDRTools {
  138904. private static Ldexp;
  138905. private static Rgbe2float;
  138906. private static readStringLine;
  138907. /**
  138908. * Reads header information from an RGBE texture stored in a native array.
  138909. * More information on this format are available here:
  138910. * https://en.wikipedia.org/wiki/RGBE_image_format
  138911. *
  138912. * @param uint8array The binary file stored in native array.
  138913. * @return The header information.
  138914. */
  138915. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138916. /**
  138917. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138918. * This RGBE texture needs to store the information as a panorama.
  138919. *
  138920. * More information on this format are available here:
  138921. * https://en.wikipedia.org/wiki/RGBE_image_format
  138922. *
  138923. * @param buffer The binary file stored in an array buffer.
  138924. * @param size The expected size of the extracted cubemap.
  138925. * @return The Cube Map information.
  138926. */
  138927. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138928. /**
  138929. * Returns the pixels data extracted from an RGBE texture.
  138930. * This pixels will be stored left to right up to down in the R G B order in one array.
  138931. *
  138932. * More information on this format are available here:
  138933. * https://en.wikipedia.org/wiki/RGBE_image_format
  138934. *
  138935. * @param uint8array The binary file stored in an array buffer.
  138936. * @param hdrInfo The header information of the file.
  138937. * @return The pixels data in RGB right to left up to down order.
  138938. */
  138939. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138940. private static RGBE_ReadPixels_RLE;
  138941. private static RGBE_ReadPixels_NOT_RLE;
  138942. }
  138943. }
  138944. declare module BABYLON {
  138945. /**
  138946. * Effect Render Options
  138947. */
  138948. export interface IEffectRendererOptions {
  138949. /**
  138950. * Defines the vertices positions.
  138951. */
  138952. positions?: number[];
  138953. /**
  138954. * Defines the indices.
  138955. */
  138956. indices?: number[];
  138957. }
  138958. /**
  138959. * Helper class to render one or more effects.
  138960. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138961. */
  138962. export class EffectRenderer {
  138963. private engine;
  138964. private static _DefaultOptions;
  138965. private _vertexBuffers;
  138966. private _indexBuffer;
  138967. private _fullscreenViewport;
  138968. /**
  138969. * Creates an effect renderer
  138970. * @param engine the engine to use for rendering
  138971. * @param options defines the options of the effect renderer
  138972. */
  138973. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138974. /**
  138975. * Sets the current viewport in normalized coordinates 0-1
  138976. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138977. */
  138978. setViewport(viewport?: Viewport): void;
  138979. /**
  138980. * Binds the embedded attributes buffer to the effect.
  138981. * @param effect Defines the effect to bind the attributes for
  138982. */
  138983. bindBuffers(effect: Effect): void;
  138984. /**
  138985. * Sets the current effect wrapper to use during draw.
  138986. * The effect needs to be ready before calling this api.
  138987. * This also sets the default full screen position attribute.
  138988. * @param effectWrapper Defines the effect to draw with
  138989. */
  138990. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138991. /**
  138992. * Restores engine states
  138993. */
  138994. restoreStates(): void;
  138995. /**
  138996. * Draws a full screen quad.
  138997. */
  138998. draw(): void;
  138999. private isRenderTargetTexture;
  139000. /**
  139001. * renders one or more effects to a specified texture
  139002. * @param effectWrapper the effect to renderer
  139003. * @param outputTexture texture to draw to, if null it will render to the screen.
  139004. */
  139005. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  139006. /**
  139007. * Disposes of the effect renderer
  139008. */
  139009. dispose(): void;
  139010. }
  139011. /**
  139012. * Options to create an EffectWrapper
  139013. */
  139014. interface EffectWrapperCreationOptions {
  139015. /**
  139016. * Engine to use to create the effect
  139017. */
  139018. engine: ThinEngine;
  139019. /**
  139020. * Fragment shader for the effect
  139021. */
  139022. fragmentShader: string;
  139023. /**
  139024. * Use the shader store instead of direct source code
  139025. */
  139026. useShaderStore?: boolean;
  139027. /**
  139028. * Vertex shader for the effect
  139029. */
  139030. vertexShader?: string;
  139031. /**
  139032. * Attributes to use in the shader
  139033. */
  139034. attributeNames?: Array<string>;
  139035. /**
  139036. * Uniforms to use in the shader
  139037. */
  139038. uniformNames?: Array<string>;
  139039. /**
  139040. * Texture sampler names to use in the shader
  139041. */
  139042. samplerNames?: Array<string>;
  139043. /**
  139044. * Defines to use in the shader
  139045. */
  139046. defines?: Array<string>;
  139047. /**
  139048. * Callback when effect is compiled
  139049. */
  139050. onCompiled?: Nullable<(effect: Effect) => void>;
  139051. /**
  139052. * The friendly name of the effect displayed in Spector.
  139053. */
  139054. name?: string;
  139055. }
  139056. /**
  139057. * Wraps an effect to be used for rendering
  139058. */
  139059. export class EffectWrapper {
  139060. /**
  139061. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  139062. */
  139063. onApplyObservable: Observable<{}>;
  139064. /**
  139065. * The underlying effect
  139066. */
  139067. effect: Effect;
  139068. /**
  139069. * Creates an effect to be renderer
  139070. * @param creationOptions options to create the effect
  139071. */
  139072. constructor(creationOptions: EffectWrapperCreationOptions);
  139073. /**
  139074. * Disposes of the effect wrapper
  139075. */
  139076. dispose(): void;
  139077. }
  139078. }
  139079. declare module BABYLON {
  139080. /** @hidden */
  139081. export var hdrFilteringVertexShader: {
  139082. name: string;
  139083. shader: string;
  139084. };
  139085. }
  139086. declare module BABYLON {
  139087. /** @hidden */
  139088. export var hdrFilteringPixelShader: {
  139089. name: string;
  139090. shader: string;
  139091. };
  139092. }
  139093. declare module BABYLON {
  139094. /**
  139095. * Options for texture filtering
  139096. */
  139097. interface IHDRFilteringOptions {
  139098. /**
  139099. * Scales pixel intensity for the input HDR map.
  139100. */
  139101. hdrScale?: number;
  139102. /**
  139103. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  139104. */
  139105. quality?: number;
  139106. }
  139107. /**
  139108. * Filters HDR maps to get correct renderings of PBR reflections
  139109. */
  139110. export class HDRFiltering {
  139111. private _engine;
  139112. private _effectRenderer;
  139113. private _effectWrapper;
  139114. private _lodGenerationOffset;
  139115. private _lodGenerationScale;
  139116. /**
  139117. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  139118. * you care about baking speed.
  139119. */
  139120. quality: number;
  139121. /**
  139122. * Scales pixel intensity for the input HDR map.
  139123. */
  139124. hdrScale: number;
  139125. /**
  139126. * Instantiates HDR filter for reflection maps
  139127. *
  139128. * @param engine Thin engine
  139129. * @param options Options
  139130. */
  139131. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  139132. private _createRenderTarget;
  139133. private _prefilterInternal;
  139134. private _createEffect;
  139135. /**
  139136. * Get a value indicating if the filter is ready to be used
  139137. * @param texture Texture to filter
  139138. * @returns true if the filter is ready
  139139. */
  139140. isReady(texture: BaseTexture): boolean;
  139141. /**
  139142. * Prefilters a cube texture to have mipmap levels representing roughness values.
  139143. * Prefiltering will be invoked at the end of next rendering pass.
  139144. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  139145. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  139146. * @param texture Texture to filter
  139147. * @param onFinished Callback when filtering is done
  139148. * @return Promise called when prefiltering is done
  139149. */
  139150. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  139151. }
  139152. }
  139153. declare module BABYLON {
  139154. /**
  139155. * This represents a texture coming from an HDR input.
  139156. *
  139157. * The only supported format is currently panorama picture stored in RGBE format.
  139158. * Example of such files can be found on HDRLib: http://hdrlib.com/
  139159. */
  139160. export class HDRCubeTexture extends BaseTexture {
  139161. private static _facesMapping;
  139162. private _generateHarmonics;
  139163. private _noMipmap;
  139164. private _prefilterOnLoad;
  139165. private _textureMatrix;
  139166. private _size;
  139167. private _onLoad;
  139168. private _onError;
  139169. /**
  139170. * The texture URL.
  139171. */
  139172. url: string;
  139173. /**
  139174. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  139175. */
  139176. coordinatesMode: number;
  139177. protected _isBlocking: boolean;
  139178. /**
  139179. * Sets wether or not the texture is blocking during loading.
  139180. */
  139181. set isBlocking(value: boolean);
  139182. /**
  139183. * Gets wether or not the texture is blocking during loading.
  139184. */
  139185. get isBlocking(): boolean;
  139186. protected _rotationY: number;
  139187. /**
  139188. * Sets texture matrix rotation angle around Y axis in radians.
  139189. */
  139190. set rotationY(value: number);
  139191. /**
  139192. * Gets texture matrix rotation angle around Y axis radians.
  139193. */
  139194. get rotationY(): number;
  139195. /**
  139196. * Gets or sets the center of the bounding box associated with the cube texture
  139197. * It must define where the camera used to render the texture was set
  139198. */
  139199. boundingBoxPosition: Vector3;
  139200. private _boundingBoxSize;
  139201. /**
  139202. * Gets or sets the size of the bounding box associated with the cube texture
  139203. * When defined, the cubemap will switch to local mode
  139204. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  139205. * @example https://www.babylonjs-playground.com/#RNASML
  139206. */
  139207. set boundingBoxSize(value: Vector3);
  139208. get boundingBoxSize(): Vector3;
  139209. /**
  139210. * Instantiates an HDRTexture from the following parameters.
  139211. *
  139212. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  139213. * @param sceneOrEngine The scene or engine the texture will be used in
  139214. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139215. * @param noMipmap Forces to not generate the mipmap if true
  139216. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  139217. * @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)
  139218. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  139219. */
  139220. 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>);
  139221. /**
  139222. * Get the current class name of the texture useful for serialization or dynamic coding.
  139223. * @returns "HDRCubeTexture"
  139224. */
  139225. getClassName(): string;
  139226. /**
  139227. * Occurs when the file is raw .hdr file.
  139228. */
  139229. private loadTexture;
  139230. clone(): HDRCubeTexture;
  139231. delayLoad(): void;
  139232. /**
  139233. * Get the texture reflection matrix used to rotate/transform the reflection.
  139234. * @returns the reflection matrix
  139235. */
  139236. getReflectionTextureMatrix(): Matrix;
  139237. /**
  139238. * Set the texture reflection matrix used to rotate/transform the reflection.
  139239. * @param value Define the reflection matrix to set
  139240. */
  139241. setReflectionTextureMatrix(value: Matrix): void;
  139242. /**
  139243. * Parses a JSON representation of an HDR Texture in order to create the texture
  139244. * @param parsedTexture Define the JSON representation
  139245. * @param scene Define the scene the texture should be created in
  139246. * @param rootUrl Define the root url in case we need to load relative dependencies
  139247. * @returns the newly created texture after parsing
  139248. */
  139249. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139250. serialize(): any;
  139251. }
  139252. }
  139253. declare module BABYLON {
  139254. /**
  139255. * Class used to control physics engine
  139256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139257. */
  139258. export class PhysicsEngine implements IPhysicsEngine {
  139259. private _physicsPlugin;
  139260. /**
  139261. * Global value used to control the smallest number supported by the simulation
  139262. */
  139263. static Epsilon: number;
  139264. private _impostors;
  139265. private _joints;
  139266. private _subTimeStep;
  139267. /**
  139268. * Gets the gravity vector used by the simulation
  139269. */
  139270. gravity: Vector3;
  139271. /**
  139272. * Factory used to create the default physics plugin.
  139273. * @returns The default physics plugin
  139274. */
  139275. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139276. /**
  139277. * Creates a new Physics Engine
  139278. * @param gravity defines the gravity vector used by the simulation
  139279. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139280. */
  139281. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139282. /**
  139283. * Sets the gravity vector used by the simulation
  139284. * @param gravity defines the gravity vector to use
  139285. */
  139286. setGravity(gravity: Vector3): void;
  139287. /**
  139288. * Set the time step of the physics engine.
  139289. * Default is 1/60.
  139290. * To slow it down, enter 1/600 for example.
  139291. * To speed it up, 1/30
  139292. * @param newTimeStep defines the new timestep to apply to this world.
  139293. */
  139294. setTimeStep(newTimeStep?: number): void;
  139295. /**
  139296. * Get the time step of the physics engine.
  139297. * @returns the current time step
  139298. */
  139299. getTimeStep(): number;
  139300. /**
  139301. * Set the sub time step of the physics engine.
  139302. * Default is 0 meaning there is no sub steps
  139303. * To increase physics resolution precision, set a small value (like 1 ms)
  139304. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139305. */
  139306. setSubTimeStep(subTimeStep?: number): void;
  139307. /**
  139308. * Get the sub time step of the physics engine.
  139309. * @returns the current sub time step
  139310. */
  139311. getSubTimeStep(): number;
  139312. /**
  139313. * Release all resources
  139314. */
  139315. dispose(): void;
  139316. /**
  139317. * Gets the name of the current physics plugin
  139318. * @returns the name of the plugin
  139319. */
  139320. getPhysicsPluginName(): string;
  139321. /**
  139322. * Adding a new impostor for the impostor tracking.
  139323. * This will be done by the impostor itself.
  139324. * @param impostor the impostor to add
  139325. */
  139326. addImpostor(impostor: PhysicsImpostor): void;
  139327. /**
  139328. * Remove an impostor from the engine.
  139329. * This impostor and its mesh will not longer be updated by the physics engine.
  139330. * @param impostor the impostor to remove
  139331. */
  139332. removeImpostor(impostor: PhysicsImpostor): void;
  139333. /**
  139334. * Add a joint to the physics engine
  139335. * @param mainImpostor defines the main impostor to which the joint is added.
  139336. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  139337. * @param joint defines the joint that will connect both impostors.
  139338. */
  139339. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139340. /**
  139341. * Removes a joint from the simulation
  139342. * @param mainImpostor defines the impostor used with the joint
  139343. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139344. * @param joint defines the joint to remove
  139345. */
  139346. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139347. /**
  139348. * Called by the scene. No need to call it.
  139349. * @param delta defines the timespam between frames
  139350. */
  139351. _step(delta: number): void;
  139352. /**
  139353. * Gets the current plugin used to run the simulation
  139354. * @returns current plugin
  139355. */
  139356. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139357. /**
  139358. * Gets the list of physic impostors
  139359. * @returns an array of PhysicsImpostor
  139360. */
  139361. getImpostors(): Array<PhysicsImpostor>;
  139362. /**
  139363. * Gets the impostor for a physics enabled object
  139364. * @param object defines the object impersonated by the impostor
  139365. * @returns the PhysicsImpostor or null if not found
  139366. */
  139367. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139368. /**
  139369. * Gets the impostor for a physics body object
  139370. * @param body defines physics body used by the impostor
  139371. * @returns the PhysicsImpostor or null if not found
  139372. */
  139373. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139374. /**
  139375. * Does a raycast in the physics world
  139376. * @param from when should the ray start?
  139377. * @param to when should the ray end?
  139378. * @returns PhysicsRaycastResult
  139379. */
  139380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139381. }
  139382. }
  139383. declare module BABYLON {
  139384. /** @hidden */
  139385. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139386. private _useDeltaForWorldStep;
  139387. world: any;
  139388. name: string;
  139389. private _physicsMaterials;
  139390. private _fixedTimeStep;
  139391. private _cannonRaycastResult;
  139392. private _raycastResult;
  139393. private _physicsBodysToRemoveAfterStep;
  139394. private _firstFrame;
  139395. BJSCANNON: any;
  139396. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139397. setGravity(gravity: Vector3): void;
  139398. setTimeStep(timeStep: number): void;
  139399. getTimeStep(): number;
  139400. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139401. private _removeMarkedPhysicsBodiesFromWorld;
  139402. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139403. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139404. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139405. private _processChildMeshes;
  139406. removePhysicsBody(impostor: PhysicsImpostor): void;
  139407. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139408. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139409. private _addMaterial;
  139410. private _checkWithEpsilon;
  139411. private _createShape;
  139412. private _createHeightmap;
  139413. private _minus90X;
  139414. private _plus90X;
  139415. private _tmpPosition;
  139416. private _tmpDeltaPosition;
  139417. private _tmpUnityRotation;
  139418. private _updatePhysicsBodyTransformation;
  139419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139420. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139421. isSupported(): boolean;
  139422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139427. getBodyMass(impostor: PhysicsImpostor): number;
  139428. getBodyFriction(impostor: PhysicsImpostor): number;
  139429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139430. getBodyRestitution(impostor: PhysicsImpostor): number;
  139431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139432. sleepBody(impostor: PhysicsImpostor): void;
  139433. wakeUpBody(impostor: PhysicsImpostor): void;
  139434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139435. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139437. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139438. getRadius(impostor: PhysicsImpostor): number;
  139439. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139440. dispose(): void;
  139441. private _extendNamespace;
  139442. /**
  139443. * Does a raycast in the physics world
  139444. * @param from when should the ray start?
  139445. * @param to when should the ray end?
  139446. * @returns PhysicsRaycastResult
  139447. */
  139448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139449. }
  139450. }
  139451. declare module BABYLON {
  139452. /** @hidden */
  139453. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139454. private _useDeltaForWorldStep;
  139455. world: any;
  139456. name: string;
  139457. BJSOIMO: any;
  139458. private _raycastResult;
  139459. private _fixedTimeStep;
  139460. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139461. setGravity(gravity: Vector3): void;
  139462. setTimeStep(timeStep: number): void;
  139463. getTimeStep(): number;
  139464. private _tmpImpostorsArray;
  139465. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139466. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139468. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139469. private _tmpPositionVector;
  139470. removePhysicsBody(impostor: PhysicsImpostor): void;
  139471. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139472. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139473. isSupported(): boolean;
  139474. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139475. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139476. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139477. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139478. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139479. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139480. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139481. getBodyMass(impostor: PhysicsImpostor): number;
  139482. getBodyFriction(impostor: PhysicsImpostor): number;
  139483. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139484. getBodyRestitution(impostor: PhysicsImpostor): number;
  139485. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139486. sleepBody(impostor: PhysicsImpostor): void;
  139487. wakeUpBody(impostor: PhysicsImpostor): void;
  139488. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139489. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139490. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139491. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139492. getRadius(impostor: PhysicsImpostor): number;
  139493. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139494. dispose(): void;
  139495. /**
  139496. * Does a raycast in the physics world
  139497. * @param from when should the ray start?
  139498. * @param to when should the ray end?
  139499. * @returns PhysicsRaycastResult
  139500. */
  139501. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139502. }
  139503. }
  139504. declare module BABYLON {
  139505. /**
  139506. * AmmoJS Physics plugin
  139507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139508. * @see https://github.com/kripken/ammo.js/
  139509. */
  139510. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139511. private _useDeltaForWorldStep;
  139512. /**
  139513. * Reference to the Ammo library
  139514. */
  139515. bjsAMMO: any;
  139516. /**
  139517. * Created ammoJS world which physics bodies are added to
  139518. */
  139519. world: any;
  139520. /**
  139521. * Name of the plugin
  139522. */
  139523. name: string;
  139524. private _timeStep;
  139525. private _fixedTimeStep;
  139526. private _maxSteps;
  139527. private _tmpQuaternion;
  139528. private _tmpAmmoTransform;
  139529. private _tmpAmmoQuaternion;
  139530. private _tmpAmmoConcreteContactResultCallback;
  139531. private _collisionConfiguration;
  139532. private _dispatcher;
  139533. private _overlappingPairCache;
  139534. private _solver;
  139535. private _softBodySolver;
  139536. private _tmpAmmoVectorA;
  139537. private _tmpAmmoVectorB;
  139538. private _tmpAmmoVectorC;
  139539. private _tmpAmmoVectorD;
  139540. private _tmpContactCallbackResult;
  139541. private _tmpAmmoVectorRCA;
  139542. private _tmpAmmoVectorRCB;
  139543. private _raycastResult;
  139544. private static readonly DISABLE_COLLISION_FLAG;
  139545. private static readonly KINEMATIC_FLAG;
  139546. private static readonly DISABLE_DEACTIVATION_FLAG;
  139547. /**
  139548. * Initializes the ammoJS plugin
  139549. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139550. * @param ammoInjection can be used to inject your own ammo reference
  139551. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139552. */
  139553. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139554. /**
  139555. * Sets the gravity of the physics world (m/(s^2))
  139556. * @param gravity Gravity to set
  139557. */
  139558. setGravity(gravity: Vector3): void;
  139559. /**
  139560. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139561. * @param timeStep timestep to use in seconds
  139562. */
  139563. setTimeStep(timeStep: number): void;
  139564. /**
  139565. * 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)
  139566. * @param fixedTimeStep fixedTimeStep to use in seconds
  139567. */
  139568. setFixedTimeStep(fixedTimeStep: number): void;
  139569. /**
  139570. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139571. * @param maxSteps the maximum number of steps by the physics engine per frame
  139572. */
  139573. setMaxSteps(maxSteps: number): void;
  139574. /**
  139575. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139576. * @returns the current timestep in seconds
  139577. */
  139578. getTimeStep(): number;
  139579. /**
  139580. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139581. */
  139582. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139583. private _isImpostorInContact;
  139584. private _isImpostorPairInContact;
  139585. private _stepSimulation;
  139586. /**
  139587. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139588. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139589. * After the step the babylon meshes are set to the position of the physics imposters
  139590. * @param delta amount of time to step forward
  139591. * @param impostors array of imposters to update before/after the step
  139592. */
  139593. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139594. /**
  139595. * Update babylon mesh to match physics world object
  139596. * @param impostor imposter to match
  139597. */
  139598. private _afterSoftStep;
  139599. /**
  139600. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139601. * @param impostor imposter to match
  139602. */
  139603. private _ropeStep;
  139604. /**
  139605. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139606. * @param impostor imposter to match
  139607. */
  139608. private _softbodyOrClothStep;
  139609. private _tmpMatrix;
  139610. /**
  139611. * Applies an impulse on the imposter
  139612. * @param impostor imposter to apply impulse to
  139613. * @param force amount of force to be applied to the imposter
  139614. * @param contactPoint the location to apply the impulse on the imposter
  139615. */
  139616. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139617. /**
  139618. * Applies a force on the imposter
  139619. * @param impostor imposter to apply force
  139620. * @param force amount of force to be applied to the imposter
  139621. * @param contactPoint the location to apply the force on the imposter
  139622. */
  139623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139624. /**
  139625. * Creates a physics body using the plugin
  139626. * @param impostor the imposter to create the physics body on
  139627. */
  139628. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139629. /**
  139630. * Removes the physics body from the imposter and disposes of the body's memory
  139631. * @param impostor imposter to remove the physics body from
  139632. */
  139633. removePhysicsBody(impostor: PhysicsImpostor): void;
  139634. /**
  139635. * Generates a joint
  139636. * @param impostorJoint the imposter joint to create the joint with
  139637. */
  139638. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139639. /**
  139640. * Removes a joint
  139641. * @param impostorJoint the imposter joint to remove the joint from
  139642. */
  139643. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139644. private _addMeshVerts;
  139645. /**
  139646. * Initialise the soft body vertices to match its object's (mesh) vertices
  139647. * Softbody vertices (nodes) are in world space and to match this
  139648. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139649. * @param impostor to create the softbody for
  139650. */
  139651. private _softVertexData;
  139652. /**
  139653. * Create an impostor's soft body
  139654. * @param impostor to create the softbody for
  139655. */
  139656. private _createSoftbody;
  139657. /**
  139658. * Create cloth for an impostor
  139659. * @param impostor to create the softbody for
  139660. */
  139661. private _createCloth;
  139662. /**
  139663. * Create rope for an impostor
  139664. * @param impostor to create the softbody for
  139665. */
  139666. private _createRope;
  139667. /**
  139668. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139669. * @param impostor to create the custom physics shape for
  139670. */
  139671. private _createCustom;
  139672. private _addHullVerts;
  139673. private _createShape;
  139674. /**
  139675. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139676. * @param impostor imposter containing the physics body and babylon object
  139677. */
  139678. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139679. /**
  139680. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139681. * @param impostor imposter containing the physics body and babylon object
  139682. * @param newPosition new position
  139683. * @param newRotation new rotation
  139684. */
  139685. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139686. /**
  139687. * If this plugin is supported
  139688. * @returns true if its supported
  139689. */
  139690. isSupported(): boolean;
  139691. /**
  139692. * Sets the linear velocity of the physics body
  139693. * @param impostor imposter to set the velocity on
  139694. * @param velocity velocity to set
  139695. */
  139696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139697. /**
  139698. * Sets the angular velocity of the physics body
  139699. * @param impostor imposter to set the velocity on
  139700. * @param velocity velocity to set
  139701. */
  139702. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139703. /**
  139704. * gets the linear velocity
  139705. * @param impostor imposter to get linear velocity from
  139706. * @returns linear velocity
  139707. */
  139708. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139709. /**
  139710. * gets the angular velocity
  139711. * @param impostor imposter to get angular velocity from
  139712. * @returns angular velocity
  139713. */
  139714. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139715. /**
  139716. * Sets the mass of physics body
  139717. * @param impostor imposter to set the mass on
  139718. * @param mass mass to set
  139719. */
  139720. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139721. /**
  139722. * Gets the mass of the physics body
  139723. * @param impostor imposter to get the mass from
  139724. * @returns mass
  139725. */
  139726. getBodyMass(impostor: PhysicsImpostor): number;
  139727. /**
  139728. * Gets friction of the impostor
  139729. * @param impostor impostor to get friction from
  139730. * @returns friction value
  139731. */
  139732. getBodyFriction(impostor: PhysicsImpostor): number;
  139733. /**
  139734. * Sets friction of the impostor
  139735. * @param impostor impostor to set friction on
  139736. * @param friction friction value
  139737. */
  139738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139739. /**
  139740. * Gets restitution of the impostor
  139741. * @param impostor impostor to get restitution from
  139742. * @returns restitution value
  139743. */
  139744. getBodyRestitution(impostor: PhysicsImpostor): number;
  139745. /**
  139746. * Sets resitution of the impostor
  139747. * @param impostor impostor to set resitution on
  139748. * @param restitution resitution value
  139749. */
  139750. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139751. /**
  139752. * Gets pressure inside the impostor
  139753. * @param impostor impostor to get pressure from
  139754. * @returns pressure value
  139755. */
  139756. getBodyPressure(impostor: PhysicsImpostor): number;
  139757. /**
  139758. * Sets pressure inside a soft body impostor
  139759. * Cloth and rope must remain 0 pressure
  139760. * @param impostor impostor to set pressure on
  139761. * @param pressure pressure value
  139762. */
  139763. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139764. /**
  139765. * Gets stiffness of the impostor
  139766. * @param impostor impostor to get stiffness from
  139767. * @returns pressure value
  139768. */
  139769. getBodyStiffness(impostor: PhysicsImpostor): number;
  139770. /**
  139771. * Sets stiffness of the impostor
  139772. * @param impostor impostor to set stiffness on
  139773. * @param stiffness stiffness value from 0 to 1
  139774. */
  139775. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139776. /**
  139777. * Gets velocityIterations of the impostor
  139778. * @param impostor impostor to get velocity iterations from
  139779. * @returns velocityIterations value
  139780. */
  139781. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139782. /**
  139783. * Sets velocityIterations of the impostor
  139784. * @param impostor impostor to set velocity iterations on
  139785. * @param velocityIterations velocityIterations value
  139786. */
  139787. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139788. /**
  139789. * Gets positionIterations of the impostor
  139790. * @param impostor impostor to get position iterations from
  139791. * @returns positionIterations value
  139792. */
  139793. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139794. /**
  139795. * Sets positionIterations of the impostor
  139796. * @param impostor impostor to set position on
  139797. * @param positionIterations positionIterations value
  139798. */
  139799. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139800. /**
  139801. * Append an anchor to a cloth object
  139802. * @param impostor is the cloth impostor to add anchor to
  139803. * @param otherImpostor is the rigid impostor to anchor to
  139804. * @param width ratio across width from 0 to 1
  139805. * @param height ratio up height from 0 to 1
  139806. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139807. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139808. */
  139809. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139810. /**
  139811. * Append an hook to a rope object
  139812. * @param impostor is the rope impostor to add hook to
  139813. * @param otherImpostor is the rigid impostor to hook to
  139814. * @param length ratio along the rope from 0 to 1
  139815. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139816. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139817. */
  139818. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139819. /**
  139820. * Sleeps the physics body and stops it from being active
  139821. * @param impostor impostor to sleep
  139822. */
  139823. sleepBody(impostor: PhysicsImpostor): void;
  139824. /**
  139825. * Activates the physics body
  139826. * @param impostor impostor to activate
  139827. */
  139828. wakeUpBody(impostor: PhysicsImpostor): void;
  139829. /**
  139830. * Updates the distance parameters of the joint
  139831. * @param joint joint to update
  139832. * @param maxDistance maximum distance of the joint
  139833. * @param minDistance minimum distance of the joint
  139834. */
  139835. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139836. /**
  139837. * Sets a motor on the joint
  139838. * @param joint joint to set motor on
  139839. * @param speed speed of the motor
  139840. * @param maxForce maximum force of the motor
  139841. * @param motorIndex index of the motor
  139842. */
  139843. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139844. /**
  139845. * Sets the motors limit
  139846. * @param joint joint to set limit on
  139847. * @param upperLimit upper limit
  139848. * @param lowerLimit lower limit
  139849. */
  139850. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139851. /**
  139852. * Syncs the position and rotation of a mesh with the impostor
  139853. * @param mesh mesh to sync
  139854. * @param impostor impostor to update the mesh with
  139855. */
  139856. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139857. /**
  139858. * Gets the radius of the impostor
  139859. * @param impostor impostor to get radius from
  139860. * @returns the radius
  139861. */
  139862. getRadius(impostor: PhysicsImpostor): number;
  139863. /**
  139864. * Gets the box size of the impostor
  139865. * @param impostor impostor to get box size from
  139866. * @param result the resulting box size
  139867. */
  139868. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139869. /**
  139870. * Disposes of the impostor
  139871. */
  139872. dispose(): void;
  139873. /**
  139874. * Does a raycast in the physics world
  139875. * @param from when should the ray start?
  139876. * @param to when should the ray end?
  139877. * @returns PhysicsRaycastResult
  139878. */
  139879. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139880. }
  139881. }
  139882. declare module BABYLON {
  139883. interface AbstractScene {
  139884. /**
  139885. * The list of reflection probes added to the scene
  139886. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139887. */
  139888. reflectionProbes: Array<ReflectionProbe>;
  139889. /**
  139890. * Removes the given reflection probe from this scene.
  139891. * @param toRemove The reflection probe to remove
  139892. * @returns The index of the removed reflection probe
  139893. */
  139894. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139895. /**
  139896. * Adds the given reflection probe to this scene.
  139897. * @param newReflectionProbe The reflection probe to add
  139898. */
  139899. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139900. }
  139901. /**
  139902. * Class used to generate realtime reflection / refraction cube textures
  139903. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139904. */
  139905. export class ReflectionProbe {
  139906. /** defines the name of the probe */
  139907. name: string;
  139908. private _scene;
  139909. private _renderTargetTexture;
  139910. private _projectionMatrix;
  139911. private _viewMatrix;
  139912. private _target;
  139913. private _add;
  139914. private _attachedMesh;
  139915. private _invertYAxis;
  139916. /** Gets or sets probe position (center of the cube map) */
  139917. position: Vector3;
  139918. /**
  139919. * Creates a new reflection probe
  139920. * @param name defines the name of the probe
  139921. * @param size defines the texture resolution (for each face)
  139922. * @param scene defines the hosting scene
  139923. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139924. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139925. */
  139926. constructor(
  139927. /** defines the name of the probe */
  139928. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139929. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139930. get samples(): number;
  139931. set samples(value: number);
  139932. /** Gets or sets the refresh rate to use (on every frame by default) */
  139933. get refreshRate(): number;
  139934. set refreshRate(value: number);
  139935. /**
  139936. * Gets the hosting scene
  139937. * @returns a Scene
  139938. */
  139939. getScene(): Scene;
  139940. /** Gets the internal CubeTexture used to render to */
  139941. get cubeTexture(): RenderTargetTexture;
  139942. /** Gets the list of meshes to render */
  139943. get renderList(): Nullable<AbstractMesh[]>;
  139944. /**
  139945. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139946. * @param mesh defines the mesh to attach to
  139947. */
  139948. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139949. /**
  139950. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139951. * @param renderingGroupId The rendering group id corresponding to its index
  139952. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139953. */
  139954. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139955. /**
  139956. * Clean all associated resources
  139957. */
  139958. dispose(): void;
  139959. /**
  139960. * Converts the reflection probe information to a readable string for debug purpose.
  139961. * @param fullDetails Supports for multiple levels of logging within scene loading
  139962. * @returns the human readable reflection probe info
  139963. */
  139964. toString(fullDetails?: boolean): string;
  139965. /**
  139966. * Get the class name of the relfection probe.
  139967. * @returns "ReflectionProbe"
  139968. */
  139969. getClassName(): string;
  139970. /**
  139971. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139972. * @returns The JSON representation of the texture
  139973. */
  139974. serialize(): any;
  139975. /**
  139976. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139977. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139978. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139979. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139980. * @returns The parsed reflection probe if successful
  139981. */
  139982. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139983. }
  139984. }
  139985. declare module BABYLON {
  139986. /** @hidden */
  139987. export var _BabylonLoaderRegistered: boolean;
  139988. /**
  139989. * Helps setting up some configuration for the babylon file loader.
  139990. */
  139991. export class BabylonFileLoaderConfiguration {
  139992. /**
  139993. * The loader does not allow injecting custom physix engine into the plugins.
  139994. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139995. * So you could set this variable to your engine import to make it work.
  139996. */
  139997. static LoaderInjectedPhysicsEngine: any;
  139998. }
  139999. }
  140000. declare module BABYLON {
  140001. /**
  140002. * The Physically based simple base material of BJS.
  140003. *
  140004. * This enables better naming and convention enforcements on top of the pbrMaterial.
  140005. * It is used as the base class for both the specGloss and metalRough conventions.
  140006. */
  140007. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  140008. /**
  140009. * Number of Simultaneous lights allowed on the material.
  140010. */
  140011. maxSimultaneousLights: number;
  140012. /**
  140013. * If sets to true, disables all the lights affecting the material.
  140014. */
  140015. disableLighting: boolean;
  140016. /**
  140017. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  140018. */
  140019. environmentTexture: BaseTexture;
  140020. /**
  140021. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  140022. */
  140023. invertNormalMapX: boolean;
  140024. /**
  140025. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  140026. */
  140027. invertNormalMapY: boolean;
  140028. /**
  140029. * Normal map used in the model.
  140030. */
  140031. normalTexture: BaseTexture;
  140032. /**
  140033. * Emissivie color used to self-illuminate the model.
  140034. */
  140035. emissiveColor: Color3;
  140036. /**
  140037. * Emissivie texture used to self-illuminate the model.
  140038. */
  140039. emissiveTexture: BaseTexture;
  140040. /**
  140041. * Occlusion Channel Strenght.
  140042. */
  140043. occlusionStrength: number;
  140044. /**
  140045. * Occlusion Texture of the material (adding extra occlusion effects).
  140046. */
  140047. occlusionTexture: BaseTexture;
  140048. /**
  140049. * Defines the alpha limits in alpha test mode.
  140050. */
  140051. alphaCutOff: number;
  140052. /**
  140053. * Gets the current double sided mode.
  140054. */
  140055. get doubleSided(): boolean;
  140056. /**
  140057. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  140058. */
  140059. set doubleSided(value: boolean);
  140060. /**
  140061. * Stores the pre-calculated light information of a mesh in a texture.
  140062. */
  140063. lightmapTexture: BaseTexture;
  140064. /**
  140065. * If true, the light map contains occlusion information instead of lighting info.
  140066. */
  140067. useLightmapAsShadowmap: boolean;
  140068. /**
  140069. * Instantiates a new PBRMaterial instance.
  140070. *
  140071. * @param name The material name
  140072. * @param scene The scene the material will be use in.
  140073. */
  140074. constructor(name: string, scene: Scene);
  140075. getClassName(): string;
  140076. }
  140077. }
  140078. declare module BABYLON {
  140079. /**
  140080. * The PBR material of BJS following the metal roughness convention.
  140081. *
  140082. * This fits to the PBR convention in the GLTF definition:
  140083. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  140084. */
  140085. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  140086. /**
  140087. * The base color has two different interpretations depending on the value of metalness.
  140088. * When the material is a metal, the base color is the specific measured reflectance value
  140089. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  140090. * of the material.
  140091. */
  140092. baseColor: Color3;
  140093. /**
  140094. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  140095. * well as opacity information in the alpha channel.
  140096. */
  140097. baseTexture: BaseTexture;
  140098. /**
  140099. * Specifies the metallic scalar value of the material.
  140100. * Can also be used to scale the metalness values of the metallic texture.
  140101. */
  140102. metallic: number;
  140103. /**
  140104. * Specifies the roughness scalar value of the material.
  140105. * Can also be used to scale the roughness values of the metallic texture.
  140106. */
  140107. roughness: number;
  140108. /**
  140109. * Texture containing both the metallic value in the B channel and the
  140110. * roughness value in the G channel to keep better precision.
  140111. */
  140112. metallicRoughnessTexture: BaseTexture;
  140113. /**
  140114. * Instantiates a new PBRMetalRoughnessMaterial instance.
  140115. *
  140116. * @param name The material name
  140117. * @param scene The scene the material will be use in.
  140118. */
  140119. constructor(name: string, scene: Scene);
  140120. /**
  140121. * Return the currrent class name of the material.
  140122. */
  140123. getClassName(): string;
  140124. /**
  140125. * Makes a duplicate of the current material.
  140126. * @param name - name to use for the new material.
  140127. */
  140128. clone(name: string): PBRMetallicRoughnessMaterial;
  140129. /**
  140130. * Serialize the material to a parsable JSON object.
  140131. */
  140132. serialize(): any;
  140133. /**
  140134. * Parses a JSON object correponding to the serialize function.
  140135. */
  140136. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  140137. }
  140138. }
  140139. declare module BABYLON {
  140140. /**
  140141. * The PBR material of BJS following the specular glossiness convention.
  140142. *
  140143. * This fits to the PBR convention in the GLTF definition:
  140144. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  140145. */
  140146. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  140147. /**
  140148. * Specifies the diffuse color of the material.
  140149. */
  140150. diffuseColor: Color3;
  140151. /**
  140152. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  140153. * channel.
  140154. */
  140155. diffuseTexture: BaseTexture;
  140156. /**
  140157. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  140158. */
  140159. specularColor: Color3;
  140160. /**
  140161. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  140162. */
  140163. glossiness: number;
  140164. /**
  140165. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  140166. */
  140167. specularGlossinessTexture: BaseTexture;
  140168. /**
  140169. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  140170. *
  140171. * @param name The material name
  140172. * @param scene The scene the material will be use in.
  140173. */
  140174. constructor(name: string, scene: Scene);
  140175. /**
  140176. * Return the currrent class name of the material.
  140177. */
  140178. getClassName(): string;
  140179. /**
  140180. * Makes a duplicate of the current material.
  140181. * @param name - name to use for the new material.
  140182. */
  140183. clone(name: string): PBRSpecularGlossinessMaterial;
  140184. /**
  140185. * Serialize the material to a parsable JSON object.
  140186. */
  140187. serialize(): any;
  140188. /**
  140189. * Parses a JSON object correponding to the serialize function.
  140190. */
  140191. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  140192. }
  140193. }
  140194. declare module BABYLON {
  140195. /**
  140196. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  140197. * It can help converting any input color in a desired output one. This can then be used to create effects
  140198. * from sepia, black and white to sixties or futuristic rendering...
  140199. *
  140200. * The only supported format is currently 3dl.
  140201. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  140202. */
  140203. export class ColorGradingTexture extends BaseTexture {
  140204. /**
  140205. * The texture URL.
  140206. */
  140207. url: string;
  140208. /**
  140209. * Empty line regex stored for GC.
  140210. */
  140211. private static _noneEmptyLineRegex;
  140212. private _textureMatrix;
  140213. private _onLoad;
  140214. /**
  140215. * Instantiates a ColorGradingTexture from the following parameters.
  140216. *
  140217. * @param url The location of the color gradind data (currently only supporting 3dl)
  140218. * @param sceneOrEngine The scene or engine the texture will be used in
  140219. * @param onLoad defines a callback triggered when the texture has been loaded
  140220. */
  140221. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  140222. /**
  140223. * Fires the onload event from the constructor if requested.
  140224. */
  140225. private _triggerOnLoad;
  140226. /**
  140227. * Returns the texture matrix used in most of the material.
  140228. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  140229. */
  140230. getTextureMatrix(): Matrix;
  140231. /**
  140232. * Occurs when the file being loaded is a .3dl LUT file.
  140233. */
  140234. private load3dlTexture;
  140235. /**
  140236. * Starts the loading process of the texture.
  140237. */
  140238. private loadTexture;
  140239. /**
  140240. * Clones the color gradind texture.
  140241. */
  140242. clone(): ColorGradingTexture;
  140243. /**
  140244. * Called during delayed load for textures.
  140245. */
  140246. delayLoad(): void;
  140247. /**
  140248. * Parses a color grading texture serialized by Babylon.
  140249. * @param parsedTexture The texture information being parsedTexture
  140250. * @param scene The scene to load the texture in
  140251. * @param rootUrl The root url of the data assets to load
  140252. * @return A color gradind texture
  140253. */
  140254. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140255. /**
  140256. * Serializes the LUT texture to json format.
  140257. */
  140258. serialize(): any;
  140259. }
  140260. }
  140261. declare module BABYLON {
  140262. /**
  140263. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140264. */
  140265. export class EquiRectangularCubeTexture extends BaseTexture {
  140266. /** The six faces of the cube. */
  140267. private static _FacesMapping;
  140268. private _noMipmap;
  140269. private _onLoad;
  140270. private _onError;
  140271. /** The size of the cubemap. */
  140272. private _size;
  140273. /** The buffer of the image. */
  140274. private _buffer;
  140275. /** The width of the input image. */
  140276. private _width;
  140277. /** The height of the input image. */
  140278. private _height;
  140279. /** The URL to the image. */
  140280. url: string;
  140281. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140282. coordinatesMode: number;
  140283. /**
  140284. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140285. * @param url The location of the image
  140286. * @param scene The scene the texture will be used in
  140287. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140288. * @param noMipmap Forces to not generate the mipmap if true
  140289. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140290. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140291. * @param onLoad — defines a callback called when texture is loaded
  140292. * @param onError — defines a callback called if there is an error
  140293. */
  140294. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140295. /**
  140296. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140297. */
  140298. private loadImage;
  140299. /**
  140300. * Convert the image buffer into a cubemap and create a CubeTexture.
  140301. */
  140302. private loadTexture;
  140303. /**
  140304. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140305. * @param buffer The ArrayBuffer that should be converted.
  140306. * @returns The buffer as Float32Array.
  140307. */
  140308. private getFloat32ArrayFromArrayBuffer;
  140309. /**
  140310. * Get the current class name of the texture useful for serialization or dynamic coding.
  140311. * @returns "EquiRectangularCubeTexture"
  140312. */
  140313. getClassName(): string;
  140314. /**
  140315. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140316. * @returns A clone of the current EquiRectangularCubeTexture.
  140317. */
  140318. clone(): EquiRectangularCubeTexture;
  140319. }
  140320. }
  140321. declare module BABYLON {
  140322. /**
  140323. * Defines the options related to the creation of an HtmlElementTexture
  140324. */
  140325. export interface IHtmlElementTextureOptions {
  140326. /**
  140327. * Defines wether mip maps should be created or not.
  140328. */
  140329. generateMipMaps?: boolean;
  140330. /**
  140331. * Defines the sampling mode of the texture.
  140332. */
  140333. samplingMode?: number;
  140334. /**
  140335. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  140336. */
  140337. engine: Nullable<ThinEngine>;
  140338. /**
  140339. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  140340. */
  140341. scene: Nullable<Scene>;
  140342. }
  140343. /**
  140344. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140345. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140346. * is automatically managed.
  140347. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140348. * in your application.
  140349. *
  140350. * As the update is not automatic, you need to call them manually.
  140351. */
  140352. export class HtmlElementTexture extends BaseTexture {
  140353. /**
  140354. * The texture URL.
  140355. */
  140356. element: HTMLVideoElement | HTMLCanvasElement;
  140357. private static readonly DefaultOptions;
  140358. private _textureMatrix;
  140359. private _isVideo;
  140360. private _generateMipMaps;
  140361. private _samplingMode;
  140362. /**
  140363. * Instantiates a HtmlElementTexture from the following parameters.
  140364. *
  140365. * @param name Defines the name of the texture
  140366. * @param element Defines the video or canvas the texture is filled with
  140367. * @param options Defines the other none mandatory texture creation options
  140368. */
  140369. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140370. private _createInternalTexture;
  140371. /**
  140372. * Returns the texture matrix used in most of the material.
  140373. */
  140374. getTextureMatrix(): Matrix;
  140375. /**
  140376. * Updates the content of the texture.
  140377. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140378. */
  140379. update(invertY?: Nullable<boolean>): void;
  140380. }
  140381. }
  140382. declare module BABYLON {
  140383. /**
  140384. * Based on jsTGALoader - Javascript loader for TGA file
  140385. * By Vincent Thibault
  140386. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140387. */
  140388. export class TGATools {
  140389. private static _TYPE_INDEXED;
  140390. private static _TYPE_RGB;
  140391. private static _TYPE_GREY;
  140392. private static _TYPE_RLE_INDEXED;
  140393. private static _TYPE_RLE_RGB;
  140394. private static _TYPE_RLE_GREY;
  140395. private static _ORIGIN_MASK;
  140396. private static _ORIGIN_SHIFT;
  140397. private static _ORIGIN_BL;
  140398. private static _ORIGIN_BR;
  140399. private static _ORIGIN_UL;
  140400. private static _ORIGIN_UR;
  140401. /**
  140402. * Gets the header of a TGA file
  140403. * @param data defines the TGA data
  140404. * @returns the header
  140405. */
  140406. static GetTGAHeader(data: Uint8Array): any;
  140407. /**
  140408. * Uploads TGA content to a Babylon Texture
  140409. * @hidden
  140410. */
  140411. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140412. /** @hidden */
  140413. 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;
  140414. /** @hidden */
  140415. 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;
  140416. /** @hidden */
  140417. 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;
  140418. /** @hidden */
  140419. 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;
  140420. /** @hidden */
  140421. 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;
  140422. /** @hidden */
  140423. 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;
  140424. }
  140425. }
  140426. declare module BABYLON {
  140427. /**
  140428. * Implementation of the TGA Texture Loader.
  140429. * @hidden
  140430. */
  140431. export class _TGATextureLoader implements IInternalTextureLoader {
  140432. /**
  140433. * Defines wether the loader supports cascade loading the different faces.
  140434. */
  140435. readonly supportCascades: boolean;
  140436. /**
  140437. * This returns if the loader support the current file information.
  140438. * @param extension defines the file extension of the file being loaded
  140439. * @returns true if the loader can load the specified file
  140440. */
  140441. canLoad(extension: string): boolean;
  140442. /**
  140443. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140444. * @param data contains the texture data
  140445. * @param texture defines the BabylonJS internal texture
  140446. * @param createPolynomials will be true if polynomials have been requested
  140447. * @param onLoad defines the callback to trigger once the texture is ready
  140448. * @param onError defines the callback to trigger in case of error
  140449. */
  140450. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140451. /**
  140452. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140453. * @param data contains the texture data
  140454. * @param texture defines the BabylonJS internal texture
  140455. * @param callback defines the method to call once ready to upload
  140456. */
  140457. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140458. }
  140459. }
  140460. declare module BABYLON {
  140461. /**
  140462. * Info about the .basis files
  140463. */
  140464. class BasisFileInfo {
  140465. /**
  140466. * If the file has alpha
  140467. */
  140468. hasAlpha: boolean;
  140469. /**
  140470. * Info about each image of the basis file
  140471. */
  140472. images: Array<{
  140473. levels: Array<{
  140474. width: number;
  140475. height: number;
  140476. transcodedPixels: ArrayBufferView;
  140477. }>;
  140478. }>;
  140479. }
  140480. /**
  140481. * Result of transcoding a basis file
  140482. */
  140483. class TranscodeResult {
  140484. /**
  140485. * Info about the .basis file
  140486. */
  140487. fileInfo: BasisFileInfo;
  140488. /**
  140489. * Format to use when loading the file
  140490. */
  140491. format: number;
  140492. }
  140493. /**
  140494. * Configuration options for the Basis transcoder
  140495. */
  140496. export class BasisTranscodeConfiguration {
  140497. /**
  140498. * Supported compression formats used to determine the supported output format of the transcoder
  140499. */
  140500. supportedCompressionFormats?: {
  140501. /**
  140502. * etc1 compression format
  140503. */
  140504. etc1?: boolean;
  140505. /**
  140506. * s3tc compression format
  140507. */
  140508. s3tc?: boolean;
  140509. /**
  140510. * pvrtc compression format
  140511. */
  140512. pvrtc?: boolean;
  140513. /**
  140514. * etc2 compression format
  140515. */
  140516. etc2?: boolean;
  140517. };
  140518. /**
  140519. * If mipmap levels should be loaded for transcoded images (Default: true)
  140520. */
  140521. loadMipmapLevels?: boolean;
  140522. /**
  140523. * Index of a single image to load (Default: all images)
  140524. */
  140525. loadSingleImage?: number;
  140526. }
  140527. /**
  140528. * Used to load .Basis files
  140529. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140530. */
  140531. export class BasisTools {
  140532. private static _IgnoreSupportedFormats;
  140533. /**
  140534. * URL to use when loading the basis transcoder
  140535. */
  140536. static JSModuleURL: string;
  140537. /**
  140538. * URL to use when loading the wasm module for the transcoder
  140539. */
  140540. static WasmModuleURL: string;
  140541. /**
  140542. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140543. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140544. * @returns internal format corresponding to the Basis format
  140545. */
  140546. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140547. private static _WorkerPromise;
  140548. private static _Worker;
  140549. private static _actionId;
  140550. private static _CreateWorkerAsync;
  140551. /**
  140552. * Transcodes a loaded image file to compressed pixel data
  140553. * @param data image data to transcode
  140554. * @param config configuration options for the transcoding
  140555. * @returns a promise resulting in the transcoded image
  140556. */
  140557. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140558. /**
  140559. * Loads a texture from the transcode result
  140560. * @param texture texture load to
  140561. * @param transcodeResult the result of transcoding the basis file to load from
  140562. */
  140563. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140564. }
  140565. }
  140566. declare module BABYLON {
  140567. /**
  140568. * Loader for .basis file format
  140569. */
  140570. export class _BasisTextureLoader implements IInternalTextureLoader {
  140571. /**
  140572. * Defines whether the loader supports cascade loading the different faces.
  140573. */
  140574. readonly supportCascades: boolean;
  140575. /**
  140576. * This returns if the loader support the current file information.
  140577. * @param extension defines the file extension of the file being loaded
  140578. * @returns true if the loader can load the specified file
  140579. */
  140580. canLoad(extension: string): boolean;
  140581. /**
  140582. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140583. * @param data contains the texture data
  140584. * @param texture defines the BabylonJS internal texture
  140585. * @param createPolynomials will be true if polynomials have been requested
  140586. * @param onLoad defines the callback to trigger once the texture is ready
  140587. * @param onError defines the callback to trigger in case of error
  140588. */
  140589. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140590. /**
  140591. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140592. * @param data contains the texture data
  140593. * @param texture defines the BabylonJS internal texture
  140594. * @param callback defines the method to call once ready to upload
  140595. */
  140596. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140597. }
  140598. }
  140599. declare module BABYLON {
  140600. /**
  140601. * Defines the basic options interface of a TexturePacker Frame
  140602. */
  140603. export interface ITexturePackerFrame {
  140604. /**
  140605. * The frame ID
  140606. */
  140607. id: number;
  140608. /**
  140609. * The frames Scale
  140610. */
  140611. scale: Vector2;
  140612. /**
  140613. * The Frames offset
  140614. */
  140615. offset: Vector2;
  140616. }
  140617. /**
  140618. * This is a support class for frame Data on texture packer sets.
  140619. */
  140620. export class TexturePackerFrame implements ITexturePackerFrame {
  140621. /**
  140622. * The frame ID
  140623. */
  140624. id: number;
  140625. /**
  140626. * The frames Scale
  140627. */
  140628. scale: Vector2;
  140629. /**
  140630. * The Frames offset
  140631. */
  140632. offset: Vector2;
  140633. /**
  140634. * Initializes a texture package frame.
  140635. * @param id The numerical frame identifier
  140636. * @param scale Scalar Vector2 for UV frame
  140637. * @param offset Vector2 for the frame position in UV units.
  140638. * @returns TexturePackerFrame
  140639. */
  140640. constructor(id: number, scale: Vector2, offset: Vector2);
  140641. }
  140642. }
  140643. declare module BABYLON {
  140644. /**
  140645. * Defines the basic options interface of a TexturePacker
  140646. */
  140647. export interface ITexturePackerOptions {
  140648. /**
  140649. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140650. */
  140651. map?: string[];
  140652. /**
  140653. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140654. */
  140655. uvsIn?: string;
  140656. /**
  140657. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140658. */
  140659. uvsOut?: string;
  140660. /**
  140661. * number representing the layout style. Defaults to LAYOUT_STRIP
  140662. */
  140663. layout?: number;
  140664. /**
  140665. * number of columns if using custom column count layout(2). This defaults to 4.
  140666. */
  140667. colnum?: number;
  140668. /**
  140669. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140670. */
  140671. updateInputMeshes?: boolean;
  140672. /**
  140673. * boolean flag to dispose all the source textures. Defaults to true.
  140674. */
  140675. disposeSources?: boolean;
  140676. /**
  140677. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140678. */
  140679. fillBlanks?: boolean;
  140680. /**
  140681. * string value representing the context fill style color. Defaults to 'black'.
  140682. */
  140683. customFillColor?: string;
  140684. /**
  140685. * Width and Height Value of each Frame in the TexturePacker Sets
  140686. */
  140687. frameSize?: number;
  140688. /**
  140689. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140690. */
  140691. paddingRatio?: number;
  140692. /**
  140693. * Number that declares the fill method for the padding gutter.
  140694. */
  140695. paddingMode?: number;
  140696. /**
  140697. * If in SUBUV_COLOR padding mode what color to use.
  140698. */
  140699. paddingColor?: Color3 | Color4;
  140700. }
  140701. /**
  140702. * Defines the basic interface of a TexturePacker JSON File
  140703. */
  140704. export interface ITexturePackerJSON {
  140705. /**
  140706. * The frame ID
  140707. */
  140708. name: string;
  140709. /**
  140710. * The base64 channel data
  140711. */
  140712. sets: any;
  140713. /**
  140714. * The options of the Packer
  140715. */
  140716. options: ITexturePackerOptions;
  140717. /**
  140718. * The frame data of the Packer
  140719. */
  140720. frames: Array<number>;
  140721. }
  140722. /**
  140723. * This is a support class that generates a series of packed texture sets.
  140724. * @see https://doc.babylonjs.com/babylon101/materials
  140725. */
  140726. export class TexturePacker {
  140727. /** Packer Layout Constant 0 */
  140728. static readonly LAYOUT_STRIP: number;
  140729. /** Packer Layout Constant 1 */
  140730. static readonly LAYOUT_POWER2: number;
  140731. /** Packer Layout Constant 2 */
  140732. static readonly LAYOUT_COLNUM: number;
  140733. /** Packer Layout Constant 0 */
  140734. static readonly SUBUV_WRAP: number;
  140735. /** Packer Layout Constant 1 */
  140736. static readonly SUBUV_EXTEND: number;
  140737. /** Packer Layout Constant 2 */
  140738. static readonly SUBUV_COLOR: number;
  140739. /** The Name of the Texture Package */
  140740. name: string;
  140741. /** The scene scope of the TexturePacker */
  140742. scene: Scene;
  140743. /** The Meshes to target */
  140744. meshes: AbstractMesh[];
  140745. /** Arguments passed with the Constructor */
  140746. options: ITexturePackerOptions;
  140747. /** The promise that is started upon initialization */
  140748. promise: Nullable<Promise<TexturePacker | string>>;
  140749. /** The Container object for the channel sets that are generated */
  140750. sets: object;
  140751. /** The Container array for the frames that are generated */
  140752. frames: TexturePackerFrame[];
  140753. /** The expected number of textures the system is parsing. */
  140754. private _expecting;
  140755. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140756. private _paddingValue;
  140757. /**
  140758. * Initializes a texture package series from an array of meshes or a single mesh.
  140759. * @param name The name of the package
  140760. * @param meshes The target meshes to compose the package from
  140761. * @param options The arguments that texture packer should follow while building.
  140762. * @param scene The scene which the textures are scoped to.
  140763. * @returns TexturePacker
  140764. */
  140765. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140766. /**
  140767. * Starts the package process
  140768. * @param resolve The promises resolution function
  140769. * @returns TexturePacker
  140770. */
  140771. private _createFrames;
  140772. /**
  140773. * Calculates the Size of the Channel Sets
  140774. * @returns Vector2
  140775. */
  140776. private _calculateSize;
  140777. /**
  140778. * Calculates the UV data for the frames.
  140779. * @param baseSize the base frameSize
  140780. * @param padding the base frame padding
  140781. * @param dtSize size of the Dynamic Texture for that channel
  140782. * @param dtUnits is 1/dtSize
  140783. * @param update flag to update the input meshes
  140784. */
  140785. private _calculateMeshUVFrames;
  140786. /**
  140787. * Calculates the frames Offset.
  140788. * @param index of the frame
  140789. * @returns Vector2
  140790. */
  140791. private _getFrameOffset;
  140792. /**
  140793. * Updates a Mesh to the frame data
  140794. * @param mesh that is the target
  140795. * @param frameID or the frame index
  140796. */
  140797. private _updateMeshUV;
  140798. /**
  140799. * Updates a Meshes materials to use the texture packer channels
  140800. * @param m is the mesh to target
  140801. * @param force all channels on the packer to be set.
  140802. */
  140803. private _updateTextureReferences;
  140804. /**
  140805. * Public method to set a Mesh to a frame
  140806. * @param m that is the target
  140807. * @param frameID or the frame index
  140808. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140809. */
  140810. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140811. /**
  140812. * Starts the async promise to compile the texture packer.
  140813. * @returns Promise<void>
  140814. */
  140815. processAsync(): Promise<void>;
  140816. /**
  140817. * Disposes all textures associated with this packer
  140818. */
  140819. dispose(): void;
  140820. /**
  140821. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140822. * @param imageType is the image type to use.
  140823. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140824. */
  140825. download(imageType?: string, quality?: number): void;
  140826. /**
  140827. * Public method to load a texturePacker JSON file.
  140828. * @param data of the JSON file in string format.
  140829. */
  140830. updateFromJSON(data: string): void;
  140831. }
  140832. }
  140833. declare module BABYLON {
  140834. /**
  140835. * 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.
  140836. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140837. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140838. */
  140839. export class CustomProceduralTexture extends ProceduralTexture {
  140840. private _animate;
  140841. private _time;
  140842. private _config;
  140843. private _texturePath;
  140844. /**
  140845. * Instantiates a new Custom Procedural Texture.
  140846. * 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.
  140847. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140848. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140849. * @param name Define the name of the texture
  140850. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140851. * @param size Define the size of the texture to create
  140852. * @param scene Define the scene the texture belongs to
  140853. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140854. * @param generateMipMaps Define if the texture should creates mip maps or not
  140855. */
  140856. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140857. private _loadJson;
  140858. /**
  140859. * Is the texture ready to be used ? (rendered at least once)
  140860. * @returns true if ready, otherwise, false.
  140861. */
  140862. isReady(): boolean;
  140863. /**
  140864. * Render the texture to its associated render target.
  140865. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140866. */
  140867. render(useCameraPostProcess?: boolean): void;
  140868. /**
  140869. * Update the list of dependant textures samplers in the shader.
  140870. */
  140871. updateTextures(): void;
  140872. /**
  140873. * Update the uniform values of the procedural texture in the shader.
  140874. */
  140875. updateShaderUniforms(): void;
  140876. /**
  140877. * Define if the texture animates or not.
  140878. */
  140879. get animate(): boolean;
  140880. set animate(value: boolean);
  140881. }
  140882. }
  140883. declare module BABYLON {
  140884. /** @hidden */
  140885. export var noisePixelShader: {
  140886. name: string;
  140887. shader: string;
  140888. };
  140889. }
  140890. declare module BABYLON {
  140891. /**
  140892. * Class used to generate noise procedural textures
  140893. */
  140894. export class NoiseProceduralTexture extends ProceduralTexture {
  140895. private _time;
  140896. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140897. brightness: number;
  140898. /** Defines the number of octaves to process */
  140899. octaves: number;
  140900. /** Defines the level of persistence (0.8 by default) */
  140901. persistence: number;
  140902. /** Gets or sets animation speed factor (default is 1) */
  140903. animationSpeedFactor: number;
  140904. /**
  140905. * Creates a new NoiseProceduralTexture
  140906. * @param name defines the name fo the texture
  140907. * @param size defines the size of the texture (default is 256)
  140908. * @param scene defines the hosting scene
  140909. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140910. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140911. */
  140912. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140913. private _updateShaderUniforms;
  140914. protected _getDefines(): string;
  140915. /** Generate the current state of the procedural texture */
  140916. render(useCameraPostProcess?: boolean): void;
  140917. /**
  140918. * Serializes this noise procedural texture
  140919. * @returns a serialized noise procedural texture object
  140920. */
  140921. serialize(): any;
  140922. /**
  140923. * Clone the texture.
  140924. * @returns the cloned texture
  140925. */
  140926. clone(): NoiseProceduralTexture;
  140927. /**
  140928. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140929. * @param parsedTexture defines parsed texture data
  140930. * @param scene defines the current scene
  140931. * @param rootUrl defines the root URL containing noise procedural texture information
  140932. * @returns a parsed NoiseProceduralTexture
  140933. */
  140934. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140935. }
  140936. }
  140937. declare module BABYLON {
  140938. /**
  140939. * Raw cube texture where the raw buffers are passed in
  140940. */
  140941. export class RawCubeTexture extends CubeTexture {
  140942. /**
  140943. * Creates a cube texture where the raw buffers are passed in.
  140944. * @param scene defines the scene the texture is attached to
  140945. * @param data defines the array of data to use to create each face
  140946. * @param size defines the size of the textures
  140947. * @param format defines the format of the data
  140948. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140949. * @param generateMipMaps defines if the engine should generate the mip levels
  140950. * @param invertY defines if data must be stored with Y axis inverted
  140951. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140952. * @param compression defines the compression used (null by default)
  140953. */
  140954. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140955. /**
  140956. * Updates the raw cube texture.
  140957. * @param data defines the data to store
  140958. * @param format defines the data format
  140959. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140960. * @param invertY defines if data must be stored with Y axis inverted
  140961. * @param compression defines the compression used (null by default)
  140962. * @param level defines which level of the texture to update
  140963. */
  140964. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140965. /**
  140966. * Updates a raw cube texture with RGBD encoded data.
  140967. * @param data defines the array of data [mipmap][face] to use to create each face
  140968. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140969. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140970. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140971. * @returns a promsie that resolves when the operation is complete
  140972. */
  140973. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140974. /**
  140975. * Clones the raw cube texture.
  140976. * @return a new cube texture
  140977. */
  140978. clone(): CubeTexture;
  140979. /** @hidden */
  140980. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140981. }
  140982. }
  140983. declare module BABYLON {
  140984. /**
  140985. * Class used to store 2D array textures containing user data
  140986. */
  140987. export class RawTexture2DArray extends Texture {
  140988. /** Gets or sets the texture format to use */
  140989. format: number;
  140990. /**
  140991. * Create a new RawTexture2DArray
  140992. * @param data defines the data of the texture
  140993. * @param width defines the width of the texture
  140994. * @param height defines the height of the texture
  140995. * @param depth defines the number of layers of the texture
  140996. * @param format defines the texture format to use
  140997. * @param scene defines the hosting scene
  140998. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140999. * @param invertY defines if texture must be stored with Y axis inverted
  141000. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141001. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141002. */
  141003. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141004. /** Gets or sets the texture format to use */
  141005. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141006. /**
  141007. * Update the texture with new data
  141008. * @param data defines the data to store in the texture
  141009. */
  141010. update(data: ArrayBufferView): void;
  141011. }
  141012. }
  141013. declare module BABYLON {
  141014. /**
  141015. * Class used to store 3D textures containing user data
  141016. */
  141017. export class RawTexture3D extends Texture {
  141018. /** Gets or sets the texture format to use */
  141019. format: number;
  141020. /**
  141021. * Create a new RawTexture3D
  141022. * @param data defines the data of the texture
  141023. * @param width defines the width of the texture
  141024. * @param height defines the height of the texture
  141025. * @param depth defines the depth of the texture
  141026. * @param format defines the texture format to use
  141027. * @param scene defines the hosting scene
  141028. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  141029. * @param invertY defines if texture must be stored with Y axis inverted
  141030. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141031. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  141032. */
  141033. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  141034. /** Gets or sets the texture format to use */
  141035. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  141036. /**
  141037. * Update the texture with new data
  141038. * @param data defines the data to store in the texture
  141039. */
  141040. update(data: ArrayBufferView): void;
  141041. }
  141042. }
  141043. declare module BABYLON {
  141044. /**
  141045. * Creates a refraction texture used by refraction channel of the standard material.
  141046. * It is like a mirror but to see through a material.
  141047. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141048. */
  141049. export class RefractionTexture extends RenderTargetTexture {
  141050. /**
  141051. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  141052. * 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.
  141053. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141054. */
  141055. refractionPlane: Plane;
  141056. /**
  141057. * Define how deep under the surface we should see.
  141058. */
  141059. depth: number;
  141060. /**
  141061. * Creates a refraction texture used by refraction channel of the standard material.
  141062. * It is like a mirror but to see through a material.
  141063. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  141064. * @param name Define the texture name
  141065. * @param size Define the size of the underlying texture
  141066. * @param scene Define the scene the refraction belongs to
  141067. * @param generateMipMaps Define if we need to generate mips level for the refraction
  141068. */
  141069. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  141070. /**
  141071. * Clone the refraction texture.
  141072. * @returns the cloned texture
  141073. */
  141074. clone(): RefractionTexture;
  141075. /**
  141076. * Serialize the texture to a JSON representation you could use in Parse later on
  141077. * @returns the serialized JSON representation
  141078. */
  141079. serialize(): any;
  141080. }
  141081. }
  141082. declare module BABYLON {
  141083. /**
  141084. * Block used to add support for vertex skinning (bones)
  141085. */
  141086. export class BonesBlock extends NodeMaterialBlock {
  141087. /**
  141088. * Creates a new BonesBlock
  141089. * @param name defines the block name
  141090. */
  141091. constructor(name: string);
  141092. /**
  141093. * Initialize the block and prepare the context for build
  141094. * @param state defines the state that will be used for the build
  141095. */
  141096. initialize(state: NodeMaterialBuildState): void;
  141097. /**
  141098. * Gets the current class name
  141099. * @returns the class name
  141100. */
  141101. getClassName(): string;
  141102. /**
  141103. * Gets the matrix indices input component
  141104. */
  141105. get matricesIndices(): NodeMaterialConnectionPoint;
  141106. /**
  141107. * Gets the matrix weights input component
  141108. */
  141109. get matricesWeights(): NodeMaterialConnectionPoint;
  141110. /**
  141111. * Gets the extra matrix indices input component
  141112. */
  141113. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  141114. /**
  141115. * Gets the extra matrix weights input component
  141116. */
  141117. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  141118. /**
  141119. * Gets the world input component
  141120. */
  141121. get world(): NodeMaterialConnectionPoint;
  141122. /**
  141123. * Gets the output component
  141124. */
  141125. get output(): NodeMaterialConnectionPoint;
  141126. autoConfigure(material: NodeMaterial): void;
  141127. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  141128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141130. protected _buildBlock(state: NodeMaterialBuildState): this;
  141131. }
  141132. }
  141133. declare module BABYLON {
  141134. /**
  141135. * Block used to add support for instances
  141136. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  141137. */
  141138. export class InstancesBlock extends NodeMaterialBlock {
  141139. /**
  141140. * Creates a new InstancesBlock
  141141. * @param name defines the block name
  141142. */
  141143. constructor(name: string);
  141144. /**
  141145. * Gets the current class name
  141146. * @returns the class name
  141147. */
  141148. getClassName(): string;
  141149. /**
  141150. * Gets the first world row input component
  141151. */
  141152. get world0(): NodeMaterialConnectionPoint;
  141153. /**
  141154. * Gets the second world row input component
  141155. */
  141156. get world1(): NodeMaterialConnectionPoint;
  141157. /**
  141158. * Gets the third world row input component
  141159. */
  141160. get world2(): NodeMaterialConnectionPoint;
  141161. /**
  141162. * Gets the forth world row input component
  141163. */
  141164. get world3(): NodeMaterialConnectionPoint;
  141165. /**
  141166. * Gets the world input component
  141167. */
  141168. get world(): NodeMaterialConnectionPoint;
  141169. /**
  141170. * Gets the output component
  141171. */
  141172. get output(): NodeMaterialConnectionPoint;
  141173. /**
  141174. * Gets the isntanceID component
  141175. */
  141176. get instanceID(): NodeMaterialConnectionPoint;
  141177. autoConfigure(material: NodeMaterial): void;
  141178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  141179. protected _buildBlock(state: NodeMaterialBuildState): this;
  141180. }
  141181. }
  141182. declare module BABYLON {
  141183. /**
  141184. * Block used to add morph targets support to vertex shader
  141185. */
  141186. export class MorphTargetsBlock extends NodeMaterialBlock {
  141187. private _repeatableContentAnchor;
  141188. /**
  141189. * Create a new MorphTargetsBlock
  141190. * @param name defines the block name
  141191. */
  141192. constructor(name: string);
  141193. /**
  141194. * Gets the current class name
  141195. * @returns the class name
  141196. */
  141197. getClassName(): string;
  141198. /**
  141199. * Gets the position input component
  141200. */
  141201. get position(): NodeMaterialConnectionPoint;
  141202. /**
  141203. * Gets the normal input component
  141204. */
  141205. get normal(): NodeMaterialConnectionPoint;
  141206. /**
  141207. * Gets the tangent input component
  141208. */
  141209. get tangent(): NodeMaterialConnectionPoint;
  141210. /**
  141211. * Gets the tangent input component
  141212. */
  141213. get uv(): NodeMaterialConnectionPoint;
  141214. /**
  141215. * Gets the position output component
  141216. */
  141217. get positionOutput(): NodeMaterialConnectionPoint;
  141218. /**
  141219. * Gets the normal output component
  141220. */
  141221. get normalOutput(): NodeMaterialConnectionPoint;
  141222. /**
  141223. * Gets the tangent output component
  141224. */
  141225. get tangentOutput(): NodeMaterialConnectionPoint;
  141226. /**
  141227. * Gets the tangent output component
  141228. */
  141229. get uvOutput(): NodeMaterialConnectionPoint;
  141230. initialize(state: NodeMaterialBuildState): void;
  141231. autoConfigure(material: NodeMaterial): void;
  141232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141234. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141235. protected _buildBlock(state: NodeMaterialBuildState): this;
  141236. }
  141237. }
  141238. declare module BABYLON {
  141239. /**
  141240. * Block used to get data information from a light
  141241. */
  141242. export class LightInformationBlock extends NodeMaterialBlock {
  141243. private _lightDataUniformName;
  141244. private _lightColorUniformName;
  141245. private _lightTypeDefineName;
  141246. /**
  141247. * Gets or sets the light associated with this block
  141248. */
  141249. light: Nullable<Light>;
  141250. /**
  141251. * Creates a new LightInformationBlock
  141252. * @param name defines the block name
  141253. */
  141254. constructor(name: string);
  141255. /**
  141256. * Gets the current class name
  141257. * @returns the class name
  141258. */
  141259. getClassName(): string;
  141260. /**
  141261. * Gets the world position input component
  141262. */
  141263. get worldPosition(): NodeMaterialConnectionPoint;
  141264. /**
  141265. * Gets the direction output component
  141266. */
  141267. get direction(): NodeMaterialConnectionPoint;
  141268. /**
  141269. * Gets the direction output component
  141270. */
  141271. get color(): NodeMaterialConnectionPoint;
  141272. /**
  141273. * Gets the direction output component
  141274. */
  141275. get intensity(): NodeMaterialConnectionPoint;
  141276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141278. protected _buildBlock(state: NodeMaterialBuildState): this;
  141279. serialize(): any;
  141280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141281. }
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * Block used to add image processing support to fragment shader
  141286. */
  141287. export class ImageProcessingBlock extends NodeMaterialBlock {
  141288. /**
  141289. * Create a new ImageProcessingBlock
  141290. * @param name defines the block name
  141291. */
  141292. constructor(name: string);
  141293. /**
  141294. * Gets the current class name
  141295. * @returns the class name
  141296. */
  141297. getClassName(): string;
  141298. /**
  141299. * Gets the color input component
  141300. */
  141301. get color(): NodeMaterialConnectionPoint;
  141302. /**
  141303. * Gets the output component
  141304. */
  141305. get output(): NodeMaterialConnectionPoint;
  141306. /**
  141307. * Initialize the block and prepare the context for build
  141308. * @param state defines the state that will be used for the build
  141309. */
  141310. initialize(state: NodeMaterialBuildState): void;
  141311. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141314. protected _buildBlock(state: NodeMaterialBuildState): this;
  141315. }
  141316. }
  141317. declare module BABYLON {
  141318. /**
  141319. * Block used to pertub normals based on a normal map
  141320. */
  141321. export class PerturbNormalBlock extends NodeMaterialBlock {
  141322. private _tangentSpaceParameterName;
  141323. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141324. invertX: boolean;
  141325. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  141326. invertY: boolean;
  141327. /**
  141328. * Create a new PerturbNormalBlock
  141329. * @param name defines the block name
  141330. */
  141331. constructor(name: string);
  141332. /**
  141333. * Gets the current class name
  141334. * @returns the class name
  141335. */
  141336. getClassName(): string;
  141337. /**
  141338. * Gets the world position input component
  141339. */
  141340. get worldPosition(): NodeMaterialConnectionPoint;
  141341. /**
  141342. * Gets the world normal input component
  141343. */
  141344. get worldNormal(): NodeMaterialConnectionPoint;
  141345. /**
  141346. * Gets the world tangent input component
  141347. */
  141348. get worldTangent(): NodeMaterialConnectionPoint;
  141349. /**
  141350. * Gets the uv input component
  141351. */
  141352. get uv(): NodeMaterialConnectionPoint;
  141353. /**
  141354. * Gets the normal map color input component
  141355. */
  141356. get normalMapColor(): NodeMaterialConnectionPoint;
  141357. /**
  141358. * Gets the strength input component
  141359. */
  141360. get strength(): NodeMaterialConnectionPoint;
  141361. /**
  141362. * Gets the output component
  141363. */
  141364. get output(): NodeMaterialConnectionPoint;
  141365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141367. autoConfigure(material: NodeMaterial): void;
  141368. protected _buildBlock(state: NodeMaterialBuildState): this;
  141369. protected _dumpPropertiesCode(): string;
  141370. serialize(): any;
  141371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141372. }
  141373. }
  141374. declare module BABYLON {
  141375. /**
  141376. * Block used to discard a pixel if a value is smaller than a cutoff
  141377. */
  141378. export class DiscardBlock extends NodeMaterialBlock {
  141379. /**
  141380. * Create a new DiscardBlock
  141381. * @param name defines the block name
  141382. */
  141383. constructor(name: string);
  141384. /**
  141385. * Gets the current class name
  141386. * @returns the class name
  141387. */
  141388. getClassName(): string;
  141389. /**
  141390. * Gets the color input component
  141391. */
  141392. get value(): NodeMaterialConnectionPoint;
  141393. /**
  141394. * Gets the cutoff input component
  141395. */
  141396. get cutoff(): NodeMaterialConnectionPoint;
  141397. protected _buildBlock(state: NodeMaterialBuildState): this;
  141398. }
  141399. }
  141400. declare module BABYLON {
  141401. /**
  141402. * Block used to test if the fragment shader is front facing
  141403. */
  141404. export class FrontFacingBlock extends NodeMaterialBlock {
  141405. /**
  141406. * Creates a new FrontFacingBlock
  141407. * @param name defines the block name
  141408. */
  141409. constructor(name: string);
  141410. /**
  141411. * Gets the current class name
  141412. * @returns the class name
  141413. */
  141414. getClassName(): string;
  141415. /**
  141416. * Gets the output component
  141417. */
  141418. get output(): NodeMaterialConnectionPoint;
  141419. protected _buildBlock(state: NodeMaterialBuildState): this;
  141420. }
  141421. }
  141422. declare module BABYLON {
  141423. /**
  141424. * Block used to get the derivative value on x and y of a given input
  141425. */
  141426. export class DerivativeBlock extends NodeMaterialBlock {
  141427. /**
  141428. * Create a new DerivativeBlock
  141429. * @param name defines the block name
  141430. */
  141431. constructor(name: string);
  141432. /**
  141433. * Gets the current class name
  141434. * @returns the class name
  141435. */
  141436. getClassName(): string;
  141437. /**
  141438. * Gets the input component
  141439. */
  141440. get input(): NodeMaterialConnectionPoint;
  141441. /**
  141442. * Gets the derivative output on x
  141443. */
  141444. get dx(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the derivative output on y
  141447. */
  141448. get dy(): NodeMaterialConnectionPoint;
  141449. protected _buildBlock(state: NodeMaterialBuildState): this;
  141450. }
  141451. }
  141452. declare module BABYLON {
  141453. /**
  141454. * Block used to make gl_FragCoord available
  141455. */
  141456. export class FragCoordBlock extends NodeMaterialBlock {
  141457. /**
  141458. * Creates a new FragCoordBlock
  141459. * @param name defines the block name
  141460. */
  141461. constructor(name: string);
  141462. /**
  141463. * Gets the current class name
  141464. * @returns the class name
  141465. */
  141466. getClassName(): string;
  141467. /**
  141468. * Gets the xy component
  141469. */
  141470. get xy(): NodeMaterialConnectionPoint;
  141471. /**
  141472. * Gets the xyz component
  141473. */
  141474. get xyz(): NodeMaterialConnectionPoint;
  141475. /**
  141476. * Gets the xyzw component
  141477. */
  141478. get xyzw(): NodeMaterialConnectionPoint;
  141479. /**
  141480. * Gets the x component
  141481. */
  141482. get x(): NodeMaterialConnectionPoint;
  141483. /**
  141484. * Gets the y component
  141485. */
  141486. get y(): NodeMaterialConnectionPoint;
  141487. /**
  141488. * Gets the z component
  141489. */
  141490. get z(): NodeMaterialConnectionPoint;
  141491. /**
  141492. * Gets the w component
  141493. */
  141494. get output(): NodeMaterialConnectionPoint;
  141495. protected writeOutputs(state: NodeMaterialBuildState): string;
  141496. protected _buildBlock(state: NodeMaterialBuildState): this;
  141497. }
  141498. }
  141499. declare module BABYLON {
  141500. /**
  141501. * Block used to get the screen sizes
  141502. */
  141503. export class ScreenSizeBlock extends NodeMaterialBlock {
  141504. private _varName;
  141505. private _scene;
  141506. /**
  141507. * Creates a new ScreenSizeBlock
  141508. * @param name defines the block name
  141509. */
  141510. constructor(name: string);
  141511. /**
  141512. * Gets the current class name
  141513. * @returns the class name
  141514. */
  141515. getClassName(): string;
  141516. /**
  141517. * Gets the xy component
  141518. */
  141519. get xy(): NodeMaterialConnectionPoint;
  141520. /**
  141521. * Gets the x component
  141522. */
  141523. get x(): NodeMaterialConnectionPoint;
  141524. /**
  141525. * Gets the y component
  141526. */
  141527. get y(): NodeMaterialConnectionPoint;
  141528. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141529. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141530. protected _buildBlock(state: NodeMaterialBuildState): this;
  141531. }
  141532. }
  141533. declare module BABYLON {
  141534. /**
  141535. * Block used to add support for scene fog
  141536. */
  141537. export class FogBlock extends NodeMaterialBlock {
  141538. private _fogDistanceName;
  141539. private _fogParameters;
  141540. /**
  141541. * Create a new FogBlock
  141542. * @param name defines the block name
  141543. */
  141544. constructor(name: string);
  141545. /**
  141546. * Gets the current class name
  141547. * @returns the class name
  141548. */
  141549. getClassName(): string;
  141550. /**
  141551. * Gets the world position input component
  141552. */
  141553. get worldPosition(): NodeMaterialConnectionPoint;
  141554. /**
  141555. * Gets the view input component
  141556. */
  141557. get view(): NodeMaterialConnectionPoint;
  141558. /**
  141559. * Gets the color input component
  141560. */
  141561. get input(): NodeMaterialConnectionPoint;
  141562. /**
  141563. * Gets the fog color input component
  141564. */
  141565. get fogColor(): NodeMaterialConnectionPoint;
  141566. /**
  141567. * Gets the output component
  141568. */
  141569. get output(): NodeMaterialConnectionPoint;
  141570. autoConfigure(material: NodeMaterial): void;
  141571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141573. protected _buildBlock(state: NodeMaterialBuildState): this;
  141574. }
  141575. }
  141576. declare module BABYLON {
  141577. /**
  141578. * Block used to add light in the fragment shader
  141579. */
  141580. export class LightBlock extends NodeMaterialBlock {
  141581. private _lightId;
  141582. /**
  141583. * Gets or sets the light associated with this block
  141584. */
  141585. light: Nullable<Light>;
  141586. /**
  141587. * Create a new LightBlock
  141588. * @param name defines the block name
  141589. */
  141590. constructor(name: string);
  141591. /**
  141592. * Gets the current class name
  141593. * @returns the class name
  141594. */
  141595. getClassName(): string;
  141596. /**
  141597. * Gets the world position input component
  141598. */
  141599. get worldPosition(): NodeMaterialConnectionPoint;
  141600. /**
  141601. * Gets the world normal input component
  141602. */
  141603. get worldNormal(): NodeMaterialConnectionPoint;
  141604. /**
  141605. * Gets the camera (or eye) position component
  141606. */
  141607. get cameraPosition(): NodeMaterialConnectionPoint;
  141608. /**
  141609. * Gets the glossiness component
  141610. */
  141611. get glossiness(): NodeMaterialConnectionPoint;
  141612. /**
  141613. * Gets the glossinness power component
  141614. */
  141615. get glossPower(): NodeMaterialConnectionPoint;
  141616. /**
  141617. * Gets the diffuse color component
  141618. */
  141619. get diffuseColor(): NodeMaterialConnectionPoint;
  141620. /**
  141621. * Gets the specular color component
  141622. */
  141623. get specularColor(): NodeMaterialConnectionPoint;
  141624. /**
  141625. * Gets the diffuse output component
  141626. */
  141627. get diffuseOutput(): NodeMaterialConnectionPoint;
  141628. /**
  141629. * Gets the specular output component
  141630. */
  141631. get specularOutput(): NodeMaterialConnectionPoint;
  141632. /**
  141633. * Gets the shadow output component
  141634. */
  141635. get shadow(): NodeMaterialConnectionPoint;
  141636. autoConfigure(material: NodeMaterial): void;
  141637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141638. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141640. private _injectVertexCode;
  141641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141642. serialize(): any;
  141643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141644. }
  141645. }
  141646. declare module BABYLON {
  141647. /**
  141648. * Block used to read a reflection texture from a sampler
  141649. */
  141650. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141651. /**
  141652. * Create a new ReflectionTextureBlock
  141653. * @param name defines the block name
  141654. */
  141655. constructor(name: string);
  141656. /**
  141657. * Gets the current class name
  141658. * @returns the class name
  141659. */
  141660. getClassName(): string;
  141661. /**
  141662. * Gets the world position input component
  141663. */
  141664. get position(): NodeMaterialConnectionPoint;
  141665. /**
  141666. * Gets the world position input component
  141667. */
  141668. get worldPosition(): NodeMaterialConnectionPoint;
  141669. /**
  141670. * Gets the world normal input component
  141671. */
  141672. get worldNormal(): NodeMaterialConnectionPoint;
  141673. /**
  141674. * Gets the world input component
  141675. */
  141676. get world(): NodeMaterialConnectionPoint;
  141677. /**
  141678. * Gets the camera (or eye) position component
  141679. */
  141680. get cameraPosition(): NodeMaterialConnectionPoint;
  141681. /**
  141682. * Gets the view input component
  141683. */
  141684. get view(): NodeMaterialConnectionPoint;
  141685. /**
  141686. * Gets the rgb output component
  141687. */
  141688. get rgb(): NodeMaterialConnectionPoint;
  141689. /**
  141690. * Gets the rgba output component
  141691. */
  141692. get rgba(): NodeMaterialConnectionPoint;
  141693. /**
  141694. * Gets the r output component
  141695. */
  141696. get r(): NodeMaterialConnectionPoint;
  141697. /**
  141698. * Gets the g output component
  141699. */
  141700. get g(): NodeMaterialConnectionPoint;
  141701. /**
  141702. * Gets the b output component
  141703. */
  141704. get b(): NodeMaterialConnectionPoint;
  141705. /**
  141706. * Gets the a output component
  141707. */
  141708. get a(): NodeMaterialConnectionPoint;
  141709. autoConfigure(material: NodeMaterial): void;
  141710. protected _buildBlock(state: NodeMaterialBuildState): this;
  141711. }
  141712. }
  141713. declare module BABYLON {
  141714. /**
  141715. * Block used to add 2 vectors
  141716. */
  141717. export class AddBlock extends NodeMaterialBlock {
  141718. /**
  141719. * Creates a new AddBlock
  141720. * @param name defines the block name
  141721. */
  141722. constructor(name: string);
  141723. /**
  141724. * Gets the current class name
  141725. * @returns the class name
  141726. */
  141727. getClassName(): string;
  141728. /**
  141729. * Gets the left operand input component
  141730. */
  141731. get left(): NodeMaterialConnectionPoint;
  141732. /**
  141733. * Gets the right operand input component
  141734. */
  141735. get right(): NodeMaterialConnectionPoint;
  141736. /**
  141737. * Gets the output component
  141738. */
  141739. get output(): NodeMaterialConnectionPoint;
  141740. protected _buildBlock(state: NodeMaterialBuildState): this;
  141741. }
  141742. }
  141743. declare module BABYLON {
  141744. /**
  141745. * Block used to scale a vector by a float
  141746. */
  141747. export class ScaleBlock extends NodeMaterialBlock {
  141748. /**
  141749. * Creates a new ScaleBlock
  141750. * @param name defines the block name
  141751. */
  141752. constructor(name: string);
  141753. /**
  141754. * Gets the current class name
  141755. * @returns the class name
  141756. */
  141757. getClassName(): string;
  141758. /**
  141759. * Gets the input component
  141760. */
  141761. get input(): NodeMaterialConnectionPoint;
  141762. /**
  141763. * Gets the factor input component
  141764. */
  141765. get factor(): NodeMaterialConnectionPoint;
  141766. /**
  141767. * Gets the output component
  141768. */
  141769. get output(): NodeMaterialConnectionPoint;
  141770. protected _buildBlock(state: NodeMaterialBuildState): this;
  141771. }
  141772. }
  141773. declare module BABYLON {
  141774. /**
  141775. * Block used to clamp a float
  141776. */
  141777. export class ClampBlock extends NodeMaterialBlock {
  141778. /** Gets or sets the minimum range */
  141779. minimum: number;
  141780. /** Gets or sets the maximum range */
  141781. maximum: number;
  141782. /**
  141783. * Creates a new ClampBlock
  141784. * @param name defines the block name
  141785. */
  141786. constructor(name: string);
  141787. /**
  141788. * Gets the current class name
  141789. * @returns the class name
  141790. */
  141791. getClassName(): string;
  141792. /**
  141793. * Gets the value input component
  141794. */
  141795. get value(): NodeMaterialConnectionPoint;
  141796. /**
  141797. * Gets the output component
  141798. */
  141799. get output(): NodeMaterialConnectionPoint;
  141800. protected _buildBlock(state: NodeMaterialBuildState): this;
  141801. protected _dumpPropertiesCode(): string;
  141802. serialize(): any;
  141803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141804. }
  141805. }
  141806. declare module BABYLON {
  141807. /**
  141808. * Block used to apply a cross product between 2 vectors
  141809. */
  141810. export class CrossBlock extends NodeMaterialBlock {
  141811. /**
  141812. * Creates a new CrossBlock
  141813. * @param name defines the block name
  141814. */
  141815. constructor(name: string);
  141816. /**
  141817. * Gets the current class name
  141818. * @returns the class name
  141819. */
  141820. getClassName(): string;
  141821. /**
  141822. * Gets the left operand input component
  141823. */
  141824. get left(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the right operand input component
  141827. */
  141828. get right(): NodeMaterialConnectionPoint;
  141829. /**
  141830. * Gets the output component
  141831. */
  141832. get output(): NodeMaterialConnectionPoint;
  141833. protected _buildBlock(state: NodeMaterialBuildState): this;
  141834. }
  141835. }
  141836. declare module BABYLON {
  141837. /**
  141838. * Block used to apply a dot product between 2 vectors
  141839. */
  141840. export class DotBlock extends NodeMaterialBlock {
  141841. /**
  141842. * Creates a new DotBlock
  141843. * @param name defines the block name
  141844. */
  141845. constructor(name: string);
  141846. /**
  141847. * Gets the current class name
  141848. * @returns the class name
  141849. */
  141850. getClassName(): string;
  141851. /**
  141852. * Gets the left operand input component
  141853. */
  141854. get left(): NodeMaterialConnectionPoint;
  141855. /**
  141856. * Gets the right operand input component
  141857. */
  141858. get right(): NodeMaterialConnectionPoint;
  141859. /**
  141860. * Gets the output component
  141861. */
  141862. get output(): NodeMaterialConnectionPoint;
  141863. protected _buildBlock(state: NodeMaterialBuildState): this;
  141864. }
  141865. }
  141866. declare module BABYLON {
  141867. /**
  141868. * Block used to normalize a vector
  141869. */
  141870. export class NormalizeBlock extends NodeMaterialBlock {
  141871. /**
  141872. * Creates a new NormalizeBlock
  141873. * @param name defines the block name
  141874. */
  141875. constructor(name: string);
  141876. /**
  141877. * Gets the current class name
  141878. * @returns the class name
  141879. */
  141880. getClassName(): string;
  141881. /**
  141882. * Gets the input component
  141883. */
  141884. get input(): NodeMaterialConnectionPoint;
  141885. /**
  141886. * Gets the output component
  141887. */
  141888. get output(): NodeMaterialConnectionPoint;
  141889. protected _buildBlock(state: NodeMaterialBuildState): this;
  141890. }
  141891. }
  141892. declare module BABYLON {
  141893. /**
  141894. * Operations supported by the Trigonometry block
  141895. */
  141896. export enum TrigonometryBlockOperations {
  141897. /** Cos */
  141898. Cos = 0,
  141899. /** Sin */
  141900. Sin = 1,
  141901. /** Abs */
  141902. Abs = 2,
  141903. /** Exp */
  141904. Exp = 3,
  141905. /** Exp2 */
  141906. Exp2 = 4,
  141907. /** Round */
  141908. Round = 5,
  141909. /** Floor */
  141910. Floor = 6,
  141911. /** Ceiling */
  141912. Ceiling = 7,
  141913. /** Square root */
  141914. Sqrt = 8,
  141915. /** Log */
  141916. Log = 9,
  141917. /** Tangent */
  141918. Tan = 10,
  141919. /** Arc tangent */
  141920. ArcTan = 11,
  141921. /** Arc cosinus */
  141922. ArcCos = 12,
  141923. /** Arc sinus */
  141924. ArcSin = 13,
  141925. /** Fraction */
  141926. Fract = 14,
  141927. /** Sign */
  141928. Sign = 15,
  141929. /** To radians (from degrees) */
  141930. Radians = 16,
  141931. /** To degrees (from radians) */
  141932. Degrees = 17
  141933. }
  141934. /**
  141935. * Block used to apply trigonometry operation to floats
  141936. */
  141937. export class TrigonometryBlock extends NodeMaterialBlock {
  141938. /**
  141939. * Gets or sets the operation applied by the block
  141940. */
  141941. operation: TrigonometryBlockOperations;
  141942. /**
  141943. * Creates a new TrigonometryBlock
  141944. * @param name defines the block name
  141945. */
  141946. constructor(name: string);
  141947. /**
  141948. * Gets the current class name
  141949. * @returns the class name
  141950. */
  141951. getClassName(): string;
  141952. /**
  141953. * Gets the input component
  141954. */
  141955. get input(): NodeMaterialConnectionPoint;
  141956. /**
  141957. * Gets the output component
  141958. */
  141959. get output(): NodeMaterialConnectionPoint;
  141960. protected _buildBlock(state: NodeMaterialBuildState): this;
  141961. serialize(): any;
  141962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141963. protected _dumpPropertiesCode(): string;
  141964. }
  141965. }
  141966. declare module BABYLON {
  141967. /**
  141968. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141969. */
  141970. export class ColorMergerBlock extends NodeMaterialBlock {
  141971. /**
  141972. * Create a new ColorMergerBlock
  141973. * @param name defines the block name
  141974. */
  141975. constructor(name: string);
  141976. /**
  141977. * Gets the current class name
  141978. * @returns the class name
  141979. */
  141980. getClassName(): string;
  141981. /**
  141982. * Gets the rgb component (input)
  141983. */
  141984. get rgbIn(): NodeMaterialConnectionPoint;
  141985. /**
  141986. * Gets the r component (input)
  141987. */
  141988. get r(): NodeMaterialConnectionPoint;
  141989. /**
  141990. * Gets the g component (input)
  141991. */
  141992. get g(): NodeMaterialConnectionPoint;
  141993. /**
  141994. * Gets the b component (input)
  141995. */
  141996. get b(): NodeMaterialConnectionPoint;
  141997. /**
  141998. * Gets the a component (input)
  141999. */
  142000. get a(): NodeMaterialConnectionPoint;
  142001. /**
  142002. * Gets the rgba component (output)
  142003. */
  142004. get rgba(): NodeMaterialConnectionPoint;
  142005. /**
  142006. * Gets the rgb component (output)
  142007. */
  142008. get rgbOut(): NodeMaterialConnectionPoint;
  142009. /**
  142010. * Gets the rgb component (output)
  142011. * @deprecated Please use rgbOut instead.
  142012. */
  142013. get rgb(): NodeMaterialConnectionPoint;
  142014. protected _buildBlock(state: NodeMaterialBuildState): this;
  142015. }
  142016. }
  142017. declare module BABYLON {
  142018. /**
  142019. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  142020. */
  142021. export class VectorSplitterBlock extends NodeMaterialBlock {
  142022. /**
  142023. * Create a new VectorSplitterBlock
  142024. * @param name defines the block name
  142025. */
  142026. constructor(name: string);
  142027. /**
  142028. * Gets the current class name
  142029. * @returns the class name
  142030. */
  142031. getClassName(): string;
  142032. /**
  142033. * Gets the xyzw component (input)
  142034. */
  142035. get xyzw(): NodeMaterialConnectionPoint;
  142036. /**
  142037. * Gets the xyz component (input)
  142038. */
  142039. get xyzIn(): NodeMaterialConnectionPoint;
  142040. /**
  142041. * Gets the xy component (input)
  142042. */
  142043. get xyIn(): NodeMaterialConnectionPoint;
  142044. /**
  142045. * Gets the xyz component (output)
  142046. */
  142047. get xyzOut(): NodeMaterialConnectionPoint;
  142048. /**
  142049. * Gets the xy component (output)
  142050. */
  142051. get xyOut(): NodeMaterialConnectionPoint;
  142052. /**
  142053. * Gets the x component (output)
  142054. */
  142055. get x(): NodeMaterialConnectionPoint;
  142056. /**
  142057. * Gets the y component (output)
  142058. */
  142059. get y(): NodeMaterialConnectionPoint;
  142060. /**
  142061. * Gets the z component (output)
  142062. */
  142063. get z(): NodeMaterialConnectionPoint;
  142064. /**
  142065. * Gets the w component (output)
  142066. */
  142067. get w(): NodeMaterialConnectionPoint;
  142068. protected _inputRename(name: string): string;
  142069. protected _outputRename(name: string): string;
  142070. protected _buildBlock(state: NodeMaterialBuildState): this;
  142071. }
  142072. }
  142073. declare module BABYLON {
  142074. /**
  142075. * Block used to lerp between 2 values
  142076. */
  142077. export class LerpBlock extends NodeMaterialBlock {
  142078. /**
  142079. * Creates a new LerpBlock
  142080. * @param name defines the block name
  142081. */
  142082. constructor(name: string);
  142083. /**
  142084. * Gets the current class name
  142085. * @returns the class name
  142086. */
  142087. getClassName(): string;
  142088. /**
  142089. * Gets the left operand input component
  142090. */
  142091. get left(): NodeMaterialConnectionPoint;
  142092. /**
  142093. * Gets the right operand input component
  142094. */
  142095. get right(): NodeMaterialConnectionPoint;
  142096. /**
  142097. * Gets the gradient operand input component
  142098. */
  142099. get gradient(): NodeMaterialConnectionPoint;
  142100. /**
  142101. * Gets the output component
  142102. */
  142103. get output(): NodeMaterialConnectionPoint;
  142104. protected _buildBlock(state: NodeMaterialBuildState): this;
  142105. }
  142106. }
  142107. declare module BABYLON {
  142108. /**
  142109. * Block used to divide 2 vectors
  142110. */
  142111. export class DivideBlock extends NodeMaterialBlock {
  142112. /**
  142113. * Creates a new DivideBlock
  142114. * @param name defines the block name
  142115. */
  142116. constructor(name: string);
  142117. /**
  142118. * Gets the current class name
  142119. * @returns the class name
  142120. */
  142121. getClassName(): string;
  142122. /**
  142123. * Gets the left operand input component
  142124. */
  142125. get left(): NodeMaterialConnectionPoint;
  142126. /**
  142127. * Gets the right operand input component
  142128. */
  142129. get right(): NodeMaterialConnectionPoint;
  142130. /**
  142131. * Gets the output component
  142132. */
  142133. get output(): NodeMaterialConnectionPoint;
  142134. protected _buildBlock(state: NodeMaterialBuildState): this;
  142135. }
  142136. }
  142137. declare module BABYLON {
  142138. /**
  142139. * Block used to subtract 2 vectors
  142140. */
  142141. export class SubtractBlock extends NodeMaterialBlock {
  142142. /**
  142143. * Creates a new SubtractBlock
  142144. * @param name defines the block name
  142145. */
  142146. constructor(name: string);
  142147. /**
  142148. * Gets the current class name
  142149. * @returns the class name
  142150. */
  142151. getClassName(): string;
  142152. /**
  142153. * Gets the left operand input component
  142154. */
  142155. get left(): NodeMaterialConnectionPoint;
  142156. /**
  142157. * Gets the right operand input component
  142158. */
  142159. get right(): NodeMaterialConnectionPoint;
  142160. /**
  142161. * Gets the output component
  142162. */
  142163. get output(): NodeMaterialConnectionPoint;
  142164. protected _buildBlock(state: NodeMaterialBuildState): this;
  142165. }
  142166. }
  142167. declare module BABYLON {
  142168. /**
  142169. * Block used to step a value
  142170. */
  142171. export class StepBlock extends NodeMaterialBlock {
  142172. /**
  142173. * Creates a new StepBlock
  142174. * @param name defines the block name
  142175. */
  142176. constructor(name: string);
  142177. /**
  142178. * Gets the current class name
  142179. * @returns the class name
  142180. */
  142181. getClassName(): string;
  142182. /**
  142183. * Gets the value operand input component
  142184. */
  142185. get value(): NodeMaterialConnectionPoint;
  142186. /**
  142187. * Gets the edge operand input component
  142188. */
  142189. get edge(): NodeMaterialConnectionPoint;
  142190. /**
  142191. * Gets the output component
  142192. */
  142193. get output(): NodeMaterialConnectionPoint;
  142194. protected _buildBlock(state: NodeMaterialBuildState): this;
  142195. }
  142196. }
  142197. declare module BABYLON {
  142198. /**
  142199. * Block used to get the opposite (1 - x) of a value
  142200. */
  142201. export class OneMinusBlock extends NodeMaterialBlock {
  142202. /**
  142203. * Creates a new OneMinusBlock
  142204. * @param name defines the block name
  142205. */
  142206. constructor(name: string);
  142207. /**
  142208. * Gets the current class name
  142209. * @returns the class name
  142210. */
  142211. getClassName(): string;
  142212. /**
  142213. * Gets the input component
  142214. */
  142215. get input(): NodeMaterialConnectionPoint;
  142216. /**
  142217. * Gets the output component
  142218. */
  142219. get output(): NodeMaterialConnectionPoint;
  142220. protected _buildBlock(state: NodeMaterialBuildState): this;
  142221. }
  142222. }
  142223. declare module BABYLON {
  142224. /**
  142225. * Block used to get the view direction
  142226. */
  142227. export class ViewDirectionBlock extends NodeMaterialBlock {
  142228. /**
  142229. * Creates a new ViewDirectionBlock
  142230. * @param name defines the block name
  142231. */
  142232. constructor(name: string);
  142233. /**
  142234. * Gets the current class name
  142235. * @returns the class name
  142236. */
  142237. getClassName(): string;
  142238. /**
  142239. * Gets the world position component
  142240. */
  142241. get worldPosition(): NodeMaterialConnectionPoint;
  142242. /**
  142243. * Gets the camera position component
  142244. */
  142245. get cameraPosition(): NodeMaterialConnectionPoint;
  142246. /**
  142247. * Gets the output component
  142248. */
  142249. get output(): NodeMaterialConnectionPoint;
  142250. autoConfigure(material: NodeMaterial): void;
  142251. protected _buildBlock(state: NodeMaterialBuildState): this;
  142252. }
  142253. }
  142254. declare module BABYLON {
  142255. /**
  142256. * Block used to compute fresnel value
  142257. */
  142258. export class FresnelBlock extends NodeMaterialBlock {
  142259. /**
  142260. * Create a new FresnelBlock
  142261. * @param name defines the block name
  142262. */
  142263. constructor(name: string);
  142264. /**
  142265. * Gets the current class name
  142266. * @returns the class name
  142267. */
  142268. getClassName(): string;
  142269. /**
  142270. * Gets the world normal input component
  142271. */
  142272. get worldNormal(): NodeMaterialConnectionPoint;
  142273. /**
  142274. * Gets the view direction input component
  142275. */
  142276. get viewDirection(): NodeMaterialConnectionPoint;
  142277. /**
  142278. * Gets the bias input component
  142279. */
  142280. get bias(): NodeMaterialConnectionPoint;
  142281. /**
  142282. * Gets the camera (or eye) position component
  142283. */
  142284. get power(): NodeMaterialConnectionPoint;
  142285. /**
  142286. * Gets the fresnel output component
  142287. */
  142288. get fresnel(): NodeMaterialConnectionPoint;
  142289. autoConfigure(material: NodeMaterial): void;
  142290. protected _buildBlock(state: NodeMaterialBuildState): this;
  142291. }
  142292. }
  142293. declare module BABYLON {
  142294. /**
  142295. * Block used to get the max of 2 values
  142296. */
  142297. export class MaxBlock extends NodeMaterialBlock {
  142298. /**
  142299. * Creates a new MaxBlock
  142300. * @param name defines the block name
  142301. */
  142302. constructor(name: string);
  142303. /**
  142304. * Gets the current class name
  142305. * @returns the class name
  142306. */
  142307. getClassName(): string;
  142308. /**
  142309. * Gets the left operand input component
  142310. */
  142311. get left(): NodeMaterialConnectionPoint;
  142312. /**
  142313. * Gets the right operand input component
  142314. */
  142315. get right(): NodeMaterialConnectionPoint;
  142316. /**
  142317. * Gets the output component
  142318. */
  142319. get output(): NodeMaterialConnectionPoint;
  142320. protected _buildBlock(state: NodeMaterialBuildState): this;
  142321. }
  142322. }
  142323. declare module BABYLON {
  142324. /**
  142325. * Block used to get the min of 2 values
  142326. */
  142327. export class MinBlock extends NodeMaterialBlock {
  142328. /**
  142329. * Creates a new MinBlock
  142330. * @param name defines the block name
  142331. */
  142332. constructor(name: string);
  142333. /**
  142334. * Gets the current class name
  142335. * @returns the class name
  142336. */
  142337. getClassName(): string;
  142338. /**
  142339. * Gets the left operand input component
  142340. */
  142341. get left(): NodeMaterialConnectionPoint;
  142342. /**
  142343. * Gets the right operand input component
  142344. */
  142345. get right(): NodeMaterialConnectionPoint;
  142346. /**
  142347. * Gets the output component
  142348. */
  142349. get output(): NodeMaterialConnectionPoint;
  142350. protected _buildBlock(state: NodeMaterialBuildState): this;
  142351. }
  142352. }
  142353. declare module BABYLON {
  142354. /**
  142355. * Block used to get the distance between 2 values
  142356. */
  142357. export class DistanceBlock extends NodeMaterialBlock {
  142358. /**
  142359. * Creates a new DistanceBlock
  142360. * @param name defines the block name
  142361. */
  142362. constructor(name: string);
  142363. /**
  142364. * Gets the current class name
  142365. * @returns the class name
  142366. */
  142367. getClassName(): string;
  142368. /**
  142369. * Gets the left operand input component
  142370. */
  142371. get left(): NodeMaterialConnectionPoint;
  142372. /**
  142373. * Gets the right operand input component
  142374. */
  142375. get right(): NodeMaterialConnectionPoint;
  142376. /**
  142377. * Gets the output component
  142378. */
  142379. get output(): NodeMaterialConnectionPoint;
  142380. protected _buildBlock(state: NodeMaterialBuildState): this;
  142381. }
  142382. }
  142383. declare module BABYLON {
  142384. /**
  142385. * Block used to get the length of a vector
  142386. */
  142387. export class LengthBlock extends NodeMaterialBlock {
  142388. /**
  142389. * Creates a new LengthBlock
  142390. * @param name defines the block name
  142391. */
  142392. constructor(name: string);
  142393. /**
  142394. * Gets the current class name
  142395. * @returns the class name
  142396. */
  142397. getClassName(): string;
  142398. /**
  142399. * Gets the value input component
  142400. */
  142401. get value(): NodeMaterialConnectionPoint;
  142402. /**
  142403. * Gets the output component
  142404. */
  142405. get output(): NodeMaterialConnectionPoint;
  142406. protected _buildBlock(state: NodeMaterialBuildState): this;
  142407. }
  142408. }
  142409. declare module BABYLON {
  142410. /**
  142411. * Block used to get negative version of a value (i.e. x * -1)
  142412. */
  142413. export class NegateBlock extends NodeMaterialBlock {
  142414. /**
  142415. * Creates a new NegateBlock
  142416. * @param name defines the block name
  142417. */
  142418. constructor(name: string);
  142419. /**
  142420. * Gets the current class name
  142421. * @returns the class name
  142422. */
  142423. getClassName(): string;
  142424. /**
  142425. * Gets the value input component
  142426. */
  142427. get value(): NodeMaterialConnectionPoint;
  142428. /**
  142429. * Gets the output component
  142430. */
  142431. get output(): NodeMaterialConnectionPoint;
  142432. protected _buildBlock(state: NodeMaterialBuildState): this;
  142433. }
  142434. }
  142435. declare module BABYLON {
  142436. /**
  142437. * Block used to get the value of the first parameter raised to the power of the second
  142438. */
  142439. export class PowBlock extends NodeMaterialBlock {
  142440. /**
  142441. * Creates a new PowBlock
  142442. * @param name defines the block name
  142443. */
  142444. constructor(name: string);
  142445. /**
  142446. * Gets the current class name
  142447. * @returns the class name
  142448. */
  142449. getClassName(): string;
  142450. /**
  142451. * Gets the value operand input component
  142452. */
  142453. get value(): NodeMaterialConnectionPoint;
  142454. /**
  142455. * Gets the power operand input component
  142456. */
  142457. get power(): NodeMaterialConnectionPoint;
  142458. /**
  142459. * Gets the output component
  142460. */
  142461. get output(): NodeMaterialConnectionPoint;
  142462. protected _buildBlock(state: NodeMaterialBuildState): this;
  142463. }
  142464. }
  142465. declare module BABYLON {
  142466. /**
  142467. * Block used to get a random number
  142468. */
  142469. export class RandomNumberBlock extends NodeMaterialBlock {
  142470. /**
  142471. * Creates a new RandomNumberBlock
  142472. * @param name defines the block name
  142473. */
  142474. constructor(name: string);
  142475. /**
  142476. * Gets the current class name
  142477. * @returns the class name
  142478. */
  142479. getClassName(): string;
  142480. /**
  142481. * Gets the seed input component
  142482. */
  142483. get seed(): NodeMaterialConnectionPoint;
  142484. /**
  142485. * Gets the output component
  142486. */
  142487. get output(): NodeMaterialConnectionPoint;
  142488. protected _buildBlock(state: NodeMaterialBuildState): this;
  142489. }
  142490. }
  142491. declare module BABYLON {
  142492. /**
  142493. * Block used to compute arc tangent of 2 values
  142494. */
  142495. export class ArcTan2Block extends NodeMaterialBlock {
  142496. /**
  142497. * Creates a new ArcTan2Block
  142498. * @param name defines the block name
  142499. */
  142500. constructor(name: string);
  142501. /**
  142502. * Gets the current class name
  142503. * @returns the class name
  142504. */
  142505. getClassName(): string;
  142506. /**
  142507. * Gets the x operand input component
  142508. */
  142509. get x(): NodeMaterialConnectionPoint;
  142510. /**
  142511. * Gets the y operand input component
  142512. */
  142513. get y(): NodeMaterialConnectionPoint;
  142514. /**
  142515. * Gets the output component
  142516. */
  142517. get output(): NodeMaterialConnectionPoint;
  142518. protected _buildBlock(state: NodeMaterialBuildState): this;
  142519. }
  142520. }
  142521. declare module BABYLON {
  142522. /**
  142523. * Block used to smooth step a value
  142524. */
  142525. export class SmoothStepBlock extends NodeMaterialBlock {
  142526. /**
  142527. * Creates a new SmoothStepBlock
  142528. * @param name defines the block name
  142529. */
  142530. constructor(name: string);
  142531. /**
  142532. * Gets the current class name
  142533. * @returns the class name
  142534. */
  142535. getClassName(): string;
  142536. /**
  142537. * Gets the value operand input component
  142538. */
  142539. get value(): NodeMaterialConnectionPoint;
  142540. /**
  142541. * Gets the first edge operand input component
  142542. */
  142543. get edge0(): NodeMaterialConnectionPoint;
  142544. /**
  142545. * Gets the second edge operand input component
  142546. */
  142547. get edge1(): NodeMaterialConnectionPoint;
  142548. /**
  142549. * Gets the output component
  142550. */
  142551. get output(): NodeMaterialConnectionPoint;
  142552. protected _buildBlock(state: NodeMaterialBuildState): this;
  142553. }
  142554. }
  142555. declare module BABYLON {
  142556. /**
  142557. * Block used to get the reciprocal (1 / x) of a value
  142558. */
  142559. export class ReciprocalBlock extends NodeMaterialBlock {
  142560. /**
  142561. * Creates a new ReciprocalBlock
  142562. * @param name defines the block name
  142563. */
  142564. constructor(name: string);
  142565. /**
  142566. * Gets the current class name
  142567. * @returns the class name
  142568. */
  142569. getClassName(): string;
  142570. /**
  142571. * Gets the input component
  142572. */
  142573. get input(): NodeMaterialConnectionPoint;
  142574. /**
  142575. * Gets the output component
  142576. */
  142577. get output(): NodeMaterialConnectionPoint;
  142578. protected _buildBlock(state: NodeMaterialBuildState): this;
  142579. }
  142580. }
  142581. declare module BABYLON {
  142582. /**
  142583. * Block used to replace a color by another one
  142584. */
  142585. export class ReplaceColorBlock extends NodeMaterialBlock {
  142586. /**
  142587. * Creates a new ReplaceColorBlock
  142588. * @param name defines the block name
  142589. */
  142590. constructor(name: string);
  142591. /**
  142592. * Gets the current class name
  142593. * @returns the class name
  142594. */
  142595. getClassName(): string;
  142596. /**
  142597. * Gets the value input component
  142598. */
  142599. get value(): NodeMaterialConnectionPoint;
  142600. /**
  142601. * Gets the reference input component
  142602. */
  142603. get reference(): NodeMaterialConnectionPoint;
  142604. /**
  142605. * Gets the distance input component
  142606. */
  142607. get distance(): NodeMaterialConnectionPoint;
  142608. /**
  142609. * Gets the replacement input component
  142610. */
  142611. get replacement(): NodeMaterialConnectionPoint;
  142612. /**
  142613. * Gets the output component
  142614. */
  142615. get output(): NodeMaterialConnectionPoint;
  142616. protected _buildBlock(state: NodeMaterialBuildState): this;
  142617. }
  142618. }
  142619. declare module BABYLON {
  142620. /**
  142621. * Block used to posterize a value
  142622. * @see https://en.wikipedia.org/wiki/Posterization
  142623. */
  142624. export class PosterizeBlock extends NodeMaterialBlock {
  142625. /**
  142626. * Creates a new PosterizeBlock
  142627. * @param name defines the block name
  142628. */
  142629. constructor(name: string);
  142630. /**
  142631. * Gets the current class name
  142632. * @returns the class name
  142633. */
  142634. getClassName(): string;
  142635. /**
  142636. * Gets the value input component
  142637. */
  142638. get value(): NodeMaterialConnectionPoint;
  142639. /**
  142640. * Gets the steps input component
  142641. */
  142642. get steps(): NodeMaterialConnectionPoint;
  142643. /**
  142644. * Gets the output component
  142645. */
  142646. get output(): NodeMaterialConnectionPoint;
  142647. protected _buildBlock(state: NodeMaterialBuildState): this;
  142648. }
  142649. }
  142650. declare module BABYLON {
  142651. /**
  142652. * Operations supported by the Wave block
  142653. */
  142654. export enum WaveBlockKind {
  142655. /** SawTooth */
  142656. SawTooth = 0,
  142657. /** Square */
  142658. Square = 1,
  142659. /** Triangle */
  142660. Triangle = 2
  142661. }
  142662. /**
  142663. * Block used to apply wave operation to floats
  142664. */
  142665. export class WaveBlock extends NodeMaterialBlock {
  142666. /**
  142667. * Gets or sets the kibnd of wave to be applied by the block
  142668. */
  142669. kind: WaveBlockKind;
  142670. /**
  142671. * Creates a new WaveBlock
  142672. * @param name defines the block name
  142673. */
  142674. constructor(name: string);
  142675. /**
  142676. * Gets the current class name
  142677. * @returns the class name
  142678. */
  142679. getClassName(): string;
  142680. /**
  142681. * Gets the input component
  142682. */
  142683. get input(): NodeMaterialConnectionPoint;
  142684. /**
  142685. * Gets the output component
  142686. */
  142687. get output(): NodeMaterialConnectionPoint;
  142688. protected _buildBlock(state: NodeMaterialBuildState): this;
  142689. serialize(): any;
  142690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142691. }
  142692. }
  142693. declare module BABYLON {
  142694. /**
  142695. * Class used to store a color step for the GradientBlock
  142696. */
  142697. export class GradientBlockColorStep {
  142698. /**
  142699. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142700. */
  142701. step: number;
  142702. /**
  142703. * Gets or sets the color associated with this step
  142704. */
  142705. color: Color3;
  142706. /**
  142707. * Creates a new GradientBlockColorStep
  142708. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142709. * @param color defines the color associated with this step
  142710. */
  142711. constructor(
  142712. /**
  142713. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142714. */
  142715. step: number,
  142716. /**
  142717. * Gets or sets the color associated with this step
  142718. */
  142719. color: Color3);
  142720. }
  142721. /**
  142722. * Block used to return a color from a gradient based on an input value between 0 and 1
  142723. */
  142724. export class GradientBlock extends NodeMaterialBlock {
  142725. /**
  142726. * Gets or sets the list of color steps
  142727. */
  142728. colorSteps: GradientBlockColorStep[];
  142729. /**
  142730. * Creates a new GradientBlock
  142731. * @param name defines the block name
  142732. */
  142733. constructor(name: string);
  142734. /**
  142735. * Gets the current class name
  142736. * @returns the class name
  142737. */
  142738. getClassName(): string;
  142739. /**
  142740. * Gets the gradient input component
  142741. */
  142742. get gradient(): NodeMaterialConnectionPoint;
  142743. /**
  142744. * Gets the output component
  142745. */
  142746. get output(): NodeMaterialConnectionPoint;
  142747. private _writeColorConstant;
  142748. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142749. serialize(): any;
  142750. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142751. protected _dumpPropertiesCode(): string;
  142752. }
  142753. }
  142754. declare module BABYLON {
  142755. /**
  142756. * Block used to normalize lerp between 2 values
  142757. */
  142758. export class NLerpBlock extends NodeMaterialBlock {
  142759. /**
  142760. * Creates a new NLerpBlock
  142761. * @param name defines the block name
  142762. */
  142763. constructor(name: string);
  142764. /**
  142765. * Gets the current class name
  142766. * @returns the class name
  142767. */
  142768. getClassName(): string;
  142769. /**
  142770. * Gets the left operand input component
  142771. */
  142772. get left(): NodeMaterialConnectionPoint;
  142773. /**
  142774. * Gets the right operand input component
  142775. */
  142776. get right(): NodeMaterialConnectionPoint;
  142777. /**
  142778. * Gets the gradient operand input component
  142779. */
  142780. get gradient(): NodeMaterialConnectionPoint;
  142781. /**
  142782. * Gets the output component
  142783. */
  142784. get output(): NodeMaterialConnectionPoint;
  142785. protected _buildBlock(state: NodeMaterialBuildState): this;
  142786. }
  142787. }
  142788. declare module BABYLON {
  142789. /**
  142790. * block used to Generate a Worley Noise 3D Noise Pattern
  142791. */
  142792. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142793. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142794. manhattanDistance: boolean;
  142795. /**
  142796. * Creates a new WorleyNoise3DBlock
  142797. * @param name defines the block name
  142798. */
  142799. constructor(name: string);
  142800. /**
  142801. * Gets the current class name
  142802. * @returns the class name
  142803. */
  142804. getClassName(): string;
  142805. /**
  142806. * Gets the seed input component
  142807. */
  142808. get seed(): NodeMaterialConnectionPoint;
  142809. /**
  142810. * Gets the jitter input component
  142811. */
  142812. get jitter(): NodeMaterialConnectionPoint;
  142813. /**
  142814. * Gets the output component
  142815. */
  142816. get output(): NodeMaterialConnectionPoint;
  142817. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142818. /**
  142819. * Exposes the properties to the UI?
  142820. */
  142821. protected _dumpPropertiesCode(): string;
  142822. /**
  142823. * Exposes the properties to the Seralize?
  142824. */
  142825. serialize(): any;
  142826. /**
  142827. * Exposes the properties to the deseralize?
  142828. */
  142829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142830. }
  142831. }
  142832. declare module BABYLON {
  142833. /**
  142834. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142835. */
  142836. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142837. /**
  142838. * Creates a new SimplexPerlin3DBlock
  142839. * @param name defines the block name
  142840. */
  142841. constructor(name: string);
  142842. /**
  142843. * Gets the current class name
  142844. * @returns the class name
  142845. */
  142846. getClassName(): string;
  142847. /**
  142848. * Gets the seed operand input component
  142849. */
  142850. get seed(): NodeMaterialConnectionPoint;
  142851. /**
  142852. * Gets the output component
  142853. */
  142854. get output(): NodeMaterialConnectionPoint;
  142855. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142856. }
  142857. }
  142858. declare module BABYLON {
  142859. /**
  142860. * Block used to blend normals
  142861. */
  142862. export class NormalBlendBlock extends NodeMaterialBlock {
  142863. /**
  142864. * Creates a new NormalBlendBlock
  142865. * @param name defines the block name
  142866. */
  142867. constructor(name: string);
  142868. /**
  142869. * Gets the current class name
  142870. * @returns the class name
  142871. */
  142872. getClassName(): string;
  142873. /**
  142874. * Gets the first input component
  142875. */
  142876. get normalMap0(): NodeMaterialConnectionPoint;
  142877. /**
  142878. * Gets the second input component
  142879. */
  142880. get normalMap1(): NodeMaterialConnectionPoint;
  142881. /**
  142882. * Gets the output component
  142883. */
  142884. get output(): NodeMaterialConnectionPoint;
  142885. protected _buildBlock(state: NodeMaterialBuildState): this;
  142886. }
  142887. }
  142888. declare module BABYLON {
  142889. /**
  142890. * Block used to rotate a 2d vector by a given angle
  142891. */
  142892. export class Rotate2dBlock extends NodeMaterialBlock {
  142893. /**
  142894. * Creates a new Rotate2dBlock
  142895. * @param name defines the block name
  142896. */
  142897. constructor(name: string);
  142898. /**
  142899. * Gets the current class name
  142900. * @returns the class name
  142901. */
  142902. getClassName(): string;
  142903. /**
  142904. * Gets the input vector
  142905. */
  142906. get input(): NodeMaterialConnectionPoint;
  142907. /**
  142908. * Gets the input angle
  142909. */
  142910. get angle(): NodeMaterialConnectionPoint;
  142911. /**
  142912. * Gets the output component
  142913. */
  142914. get output(): NodeMaterialConnectionPoint;
  142915. autoConfigure(material: NodeMaterial): void;
  142916. protected _buildBlock(state: NodeMaterialBuildState): this;
  142917. }
  142918. }
  142919. declare module BABYLON {
  142920. /**
  142921. * Block used to get the reflected vector from a direction and a normal
  142922. */
  142923. export class ReflectBlock extends NodeMaterialBlock {
  142924. /**
  142925. * Creates a new ReflectBlock
  142926. * @param name defines the block name
  142927. */
  142928. constructor(name: string);
  142929. /**
  142930. * Gets the current class name
  142931. * @returns the class name
  142932. */
  142933. getClassName(): string;
  142934. /**
  142935. * Gets the incident component
  142936. */
  142937. get incident(): NodeMaterialConnectionPoint;
  142938. /**
  142939. * Gets the normal component
  142940. */
  142941. get normal(): NodeMaterialConnectionPoint;
  142942. /**
  142943. * Gets the output component
  142944. */
  142945. get output(): NodeMaterialConnectionPoint;
  142946. protected _buildBlock(state: NodeMaterialBuildState): this;
  142947. }
  142948. }
  142949. declare module BABYLON {
  142950. /**
  142951. * Block used to get the refracted vector from a direction and a normal
  142952. */
  142953. export class RefractBlock extends NodeMaterialBlock {
  142954. /**
  142955. * Creates a new RefractBlock
  142956. * @param name defines the block name
  142957. */
  142958. constructor(name: string);
  142959. /**
  142960. * Gets the current class name
  142961. * @returns the class name
  142962. */
  142963. getClassName(): string;
  142964. /**
  142965. * Gets the incident component
  142966. */
  142967. get incident(): NodeMaterialConnectionPoint;
  142968. /**
  142969. * Gets the normal component
  142970. */
  142971. get normal(): NodeMaterialConnectionPoint;
  142972. /**
  142973. * Gets the index of refraction component
  142974. */
  142975. get ior(): NodeMaterialConnectionPoint;
  142976. /**
  142977. * Gets the output component
  142978. */
  142979. get output(): NodeMaterialConnectionPoint;
  142980. protected _buildBlock(state: NodeMaterialBuildState): this;
  142981. }
  142982. }
  142983. declare module BABYLON {
  142984. /**
  142985. * Block used to desaturate a color
  142986. */
  142987. export class DesaturateBlock extends NodeMaterialBlock {
  142988. /**
  142989. * Creates a new DesaturateBlock
  142990. * @param name defines the block name
  142991. */
  142992. constructor(name: string);
  142993. /**
  142994. * Gets the current class name
  142995. * @returns the class name
  142996. */
  142997. getClassName(): string;
  142998. /**
  142999. * Gets the color operand input component
  143000. */
  143001. get color(): NodeMaterialConnectionPoint;
  143002. /**
  143003. * Gets the level operand input component
  143004. */
  143005. get level(): NodeMaterialConnectionPoint;
  143006. /**
  143007. * Gets the output component
  143008. */
  143009. get output(): NodeMaterialConnectionPoint;
  143010. protected _buildBlock(state: NodeMaterialBuildState): this;
  143011. }
  143012. }
  143013. declare module BABYLON {
  143014. /**
  143015. * Block used to implement the ambient occlusion module of the PBR material
  143016. */
  143017. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  143018. /**
  143019. * Create a new AmbientOcclusionBlock
  143020. * @param name defines the block name
  143021. */
  143022. constructor(name: string);
  143023. /**
  143024. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  143025. */
  143026. useAmbientInGrayScale: boolean;
  143027. /**
  143028. * Initialize the block and prepare the context for build
  143029. * @param state defines the state that will be used for the build
  143030. */
  143031. initialize(state: NodeMaterialBuildState): void;
  143032. /**
  143033. * Gets the current class name
  143034. * @returns the class name
  143035. */
  143036. getClassName(): string;
  143037. /**
  143038. * Gets the texture input component
  143039. */
  143040. get texture(): NodeMaterialConnectionPoint;
  143041. /**
  143042. * Gets the texture intensity component
  143043. */
  143044. get intensity(): NodeMaterialConnectionPoint;
  143045. /**
  143046. * Gets the direct light intensity input component
  143047. */
  143048. get directLightIntensity(): NodeMaterialConnectionPoint;
  143049. /**
  143050. * Gets the ambient occlusion object output component
  143051. */
  143052. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143053. /**
  143054. * Gets the main code of the block (fragment side)
  143055. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  143056. * @returns the shader code
  143057. */
  143058. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  143059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143060. protected _buildBlock(state: NodeMaterialBuildState): this;
  143061. protected _dumpPropertiesCode(): string;
  143062. serialize(): any;
  143063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143064. }
  143065. }
  143066. declare module BABYLON {
  143067. /**
  143068. * Block used to implement the reflection module of the PBR material
  143069. */
  143070. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  143071. /** @hidden */
  143072. _defineLODReflectionAlpha: string;
  143073. /** @hidden */
  143074. _defineLinearSpecularReflection: string;
  143075. private _vEnvironmentIrradianceName;
  143076. /** @hidden */
  143077. _vReflectionMicrosurfaceInfosName: string;
  143078. /** @hidden */
  143079. _vReflectionInfosName: string;
  143080. /** @hidden */
  143081. _vReflectionFilteringInfoName: string;
  143082. private _scene;
  143083. /**
  143084. * The three properties below are set by the main PBR block prior to calling methods of this class.
  143085. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143086. * It's less burden on the user side in the editor part.
  143087. */
  143088. /** @hidden */
  143089. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143090. /** @hidden */
  143091. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143092. /** @hidden */
  143093. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  143094. /**
  143095. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  143096. * diffuse part of the IBL.
  143097. */
  143098. useSphericalHarmonics: boolean;
  143099. /**
  143100. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  143101. */
  143102. forceIrradianceInFragment: boolean;
  143103. /**
  143104. * Create a new ReflectionBlock
  143105. * @param name defines the block name
  143106. */
  143107. constructor(name: string);
  143108. /**
  143109. * Gets the current class name
  143110. * @returns the class name
  143111. */
  143112. getClassName(): string;
  143113. /**
  143114. * Gets the position input component
  143115. */
  143116. get position(): NodeMaterialConnectionPoint;
  143117. /**
  143118. * Gets the world position input component
  143119. */
  143120. get worldPosition(): NodeMaterialConnectionPoint;
  143121. /**
  143122. * Gets the world normal input component
  143123. */
  143124. get worldNormal(): NodeMaterialConnectionPoint;
  143125. /**
  143126. * Gets the world input component
  143127. */
  143128. get world(): NodeMaterialConnectionPoint;
  143129. /**
  143130. * Gets the camera (or eye) position component
  143131. */
  143132. get cameraPosition(): NodeMaterialConnectionPoint;
  143133. /**
  143134. * Gets the view input component
  143135. */
  143136. get view(): NodeMaterialConnectionPoint;
  143137. /**
  143138. * Gets the color input component
  143139. */
  143140. get color(): NodeMaterialConnectionPoint;
  143141. /**
  143142. * Gets the reflection object output component
  143143. */
  143144. get reflection(): NodeMaterialConnectionPoint;
  143145. /**
  143146. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  143147. */
  143148. get hasTexture(): boolean;
  143149. /**
  143150. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  143151. */
  143152. get reflectionColor(): string;
  143153. protected _getTexture(): Nullable<BaseTexture>;
  143154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143156. /**
  143157. * Gets the code to inject in the vertex shader
  143158. * @param state current state of the node material building
  143159. * @returns the shader code
  143160. */
  143161. handleVertexSide(state: NodeMaterialBuildState): string;
  143162. /**
  143163. * Gets the main code of the block (fragment side)
  143164. * @param state current state of the node material building
  143165. * @param normalVarName name of the existing variable corresponding to the normal
  143166. * @returns the shader code
  143167. */
  143168. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  143169. protected _buildBlock(state: NodeMaterialBuildState): this;
  143170. protected _dumpPropertiesCode(): string;
  143171. serialize(): any;
  143172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143173. }
  143174. }
  143175. declare module BABYLON {
  143176. /**
  143177. * Block used to implement the sheen module of the PBR material
  143178. */
  143179. export class SheenBlock extends NodeMaterialBlock {
  143180. /**
  143181. * Create a new SheenBlock
  143182. * @param name defines the block name
  143183. */
  143184. constructor(name: string);
  143185. /**
  143186. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  143187. * It allows the strength of the sheen effect to not depend on the base color of the material,
  143188. * making it easier to setup and tweak the effect
  143189. */
  143190. albedoScaling: boolean;
  143191. /**
  143192. * Defines if the sheen is linked to the sheen color.
  143193. */
  143194. linkSheenWithAlbedo: boolean;
  143195. /**
  143196. * Initialize the block and prepare the context for build
  143197. * @param state defines the state that will be used for the build
  143198. */
  143199. initialize(state: NodeMaterialBuildState): void;
  143200. /**
  143201. * Gets the current class name
  143202. * @returns the class name
  143203. */
  143204. getClassName(): string;
  143205. /**
  143206. * Gets the intensity input component
  143207. */
  143208. get intensity(): NodeMaterialConnectionPoint;
  143209. /**
  143210. * Gets the color input component
  143211. */
  143212. get color(): NodeMaterialConnectionPoint;
  143213. /**
  143214. * Gets the roughness input component
  143215. */
  143216. get roughness(): NodeMaterialConnectionPoint;
  143217. /**
  143218. * Gets the sheen object output component
  143219. */
  143220. get sheen(): NodeMaterialConnectionPoint;
  143221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143222. /**
  143223. * Gets the main code of the block (fragment side)
  143224. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143225. * @returns the shader code
  143226. */
  143227. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  143228. protected _buildBlock(state: NodeMaterialBuildState): this;
  143229. protected _dumpPropertiesCode(): string;
  143230. serialize(): any;
  143231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143232. }
  143233. }
  143234. declare module BABYLON {
  143235. /**
  143236. * Block used to implement the reflectivity module of the PBR material
  143237. */
  143238. export class ReflectivityBlock extends NodeMaterialBlock {
  143239. private _metallicReflectanceColor;
  143240. private _metallicF0Factor;
  143241. /** @hidden */
  143242. _vMetallicReflectanceFactorsName: string;
  143243. /**
  143244. * The property below is set by the main PBR block prior to calling methods of this class.
  143245. */
  143246. /** @hidden */
  143247. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143248. /**
  143249. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143250. */
  143251. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143252. /**
  143253. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143254. */
  143255. useMetallnessFromMetallicTextureBlue: boolean;
  143256. /**
  143257. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143258. */
  143259. useRoughnessFromMetallicTextureAlpha: boolean;
  143260. /**
  143261. * Specifies if the metallic texture contains the roughness information in its green channel.
  143262. */
  143263. useRoughnessFromMetallicTextureGreen: boolean;
  143264. /**
  143265. * Create a new ReflectivityBlock
  143266. * @param name defines the block name
  143267. */
  143268. constructor(name: string);
  143269. /**
  143270. * Initialize the block and prepare the context for build
  143271. * @param state defines the state that will be used for the build
  143272. */
  143273. initialize(state: NodeMaterialBuildState): void;
  143274. /**
  143275. * Gets the current class name
  143276. * @returns the class name
  143277. */
  143278. getClassName(): string;
  143279. /**
  143280. * Gets the metallic input component
  143281. */
  143282. get metallic(): NodeMaterialConnectionPoint;
  143283. /**
  143284. * Gets the roughness input component
  143285. */
  143286. get roughness(): NodeMaterialConnectionPoint;
  143287. /**
  143288. * Gets the texture input component
  143289. */
  143290. get texture(): NodeMaterialConnectionPoint;
  143291. /**
  143292. * Gets the reflectivity object output component
  143293. */
  143294. get reflectivity(): NodeMaterialConnectionPoint;
  143295. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143296. /**
  143297. * Gets the main code of the block (fragment side)
  143298. * @param state current state of the node material building
  143299. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143300. * @returns the shader code
  143301. */
  143302. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143304. protected _buildBlock(state: NodeMaterialBuildState): this;
  143305. protected _dumpPropertiesCode(): string;
  143306. serialize(): any;
  143307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143308. }
  143309. }
  143310. declare module BABYLON {
  143311. /**
  143312. * Block used to implement the anisotropy module of the PBR material
  143313. */
  143314. export class AnisotropyBlock extends NodeMaterialBlock {
  143315. /**
  143316. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143317. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143318. * It's less burden on the user side in the editor part.
  143319. */
  143320. /** @hidden */
  143321. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143322. /** @hidden */
  143323. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143324. /**
  143325. * Create a new AnisotropyBlock
  143326. * @param name defines the block name
  143327. */
  143328. constructor(name: string);
  143329. /**
  143330. * Initialize the block and prepare the context for build
  143331. * @param state defines the state that will be used for the build
  143332. */
  143333. initialize(state: NodeMaterialBuildState): void;
  143334. /**
  143335. * Gets the current class name
  143336. * @returns the class name
  143337. */
  143338. getClassName(): string;
  143339. /**
  143340. * Gets the intensity input component
  143341. */
  143342. get intensity(): NodeMaterialConnectionPoint;
  143343. /**
  143344. * Gets the direction input component
  143345. */
  143346. get direction(): NodeMaterialConnectionPoint;
  143347. /**
  143348. * Gets the texture input component
  143349. */
  143350. get texture(): NodeMaterialConnectionPoint;
  143351. /**
  143352. * Gets the uv input component
  143353. */
  143354. get uv(): NodeMaterialConnectionPoint;
  143355. /**
  143356. * Gets the worldTangent input component
  143357. */
  143358. get worldTangent(): NodeMaterialConnectionPoint;
  143359. /**
  143360. * Gets the anisotropy object output component
  143361. */
  143362. get anisotropy(): NodeMaterialConnectionPoint;
  143363. private _generateTBNSpace;
  143364. /**
  143365. * Gets the main code of the block (fragment side)
  143366. * @param state current state of the node material building
  143367. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143368. * @returns the shader code
  143369. */
  143370. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143372. protected _buildBlock(state: NodeMaterialBuildState): this;
  143373. }
  143374. }
  143375. declare module BABYLON {
  143376. /**
  143377. * Block used to implement the clear coat module of the PBR material
  143378. */
  143379. export class ClearCoatBlock extends NodeMaterialBlock {
  143380. private _scene;
  143381. /**
  143382. * Create a new ClearCoatBlock
  143383. * @param name defines the block name
  143384. */
  143385. constructor(name: string);
  143386. /**
  143387. * Initialize the block and prepare the context for build
  143388. * @param state defines the state that will be used for the build
  143389. */
  143390. initialize(state: NodeMaterialBuildState): void;
  143391. /**
  143392. * Gets the current class name
  143393. * @returns the class name
  143394. */
  143395. getClassName(): string;
  143396. /**
  143397. * Gets the intensity input component
  143398. */
  143399. get intensity(): NodeMaterialConnectionPoint;
  143400. /**
  143401. * Gets the roughness input component
  143402. */
  143403. get roughness(): NodeMaterialConnectionPoint;
  143404. /**
  143405. * Gets the ior input component
  143406. */
  143407. get ior(): NodeMaterialConnectionPoint;
  143408. /**
  143409. * Gets the texture input component
  143410. */
  143411. get texture(): NodeMaterialConnectionPoint;
  143412. /**
  143413. * Gets the bump texture input component
  143414. */
  143415. get bumpTexture(): NodeMaterialConnectionPoint;
  143416. /**
  143417. * Gets the uv input component
  143418. */
  143419. get uv(): NodeMaterialConnectionPoint;
  143420. /**
  143421. * Gets the tint color input component
  143422. */
  143423. get tintColor(): NodeMaterialConnectionPoint;
  143424. /**
  143425. * Gets the tint "at distance" input component
  143426. */
  143427. get tintAtDistance(): NodeMaterialConnectionPoint;
  143428. /**
  143429. * Gets the tint thickness input component
  143430. */
  143431. get tintThickness(): NodeMaterialConnectionPoint;
  143432. /**
  143433. * Gets the world tangent input component
  143434. */
  143435. get worldTangent(): NodeMaterialConnectionPoint;
  143436. /**
  143437. * Gets the clear coat object output component
  143438. */
  143439. get clearcoat(): NodeMaterialConnectionPoint;
  143440. autoConfigure(material: NodeMaterial): void;
  143441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143443. private _generateTBNSpace;
  143444. /**
  143445. * Gets the main code of the block (fragment side)
  143446. * @param state current state of the node material building
  143447. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143448. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143449. * @param worldPosVarName name of the variable holding the world position
  143450. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143451. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143452. * @param worldNormalVarName name of the variable holding the world normal
  143453. * @returns the shader code
  143454. */
  143455. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143456. protected _buildBlock(state: NodeMaterialBuildState): this;
  143457. }
  143458. }
  143459. declare module BABYLON {
  143460. /**
  143461. * Block used to implement the sub surface module of the PBR material
  143462. */
  143463. export class SubSurfaceBlock extends NodeMaterialBlock {
  143464. /**
  143465. * Create a new SubSurfaceBlock
  143466. * @param name defines the block name
  143467. */
  143468. constructor(name: string);
  143469. /**
  143470. * Stores the intensity of the different subsurface effects in the thickness texture.
  143471. * * the green channel is the translucency intensity.
  143472. * * the blue channel is the scattering intensity.
  143473. * * the alpha channel is the refraction intensity.
  143474. */
  143475. useMaskFromThicknessTexture: boolean;
  143476. /**
  143477. * Initialize the block and prepare the context for build
  143478. * @param state defines the state that will be used for the build
  143479. */
  143480. initialize(state: NodeMaterialBuildState): void;
  143481. /**
  143482. * Gets the current class name
  143483. * @returns the class name
  143484. */
  143485. getClassName(): string;
  143486. /**
  143487. * Gets the min thickness input component
  143488. */
  143489. get minThickness(): NodeMaterialConnectionPoint;
  143490. /**
  143491. * Gets the max thickness input component
  143492. */
  143493. get maxThickness(): NodeMaterialConnectionPoint;
  143494. /**
  143495. * Gets the thickness texture component
  143496. */
  143497. get thicknessTexture(): NodeMaterialConnectionPoint;
  143498. /**
  143499. * Gets the tint color input component
  143500. */
  143501. get tintColor(): NodeMaterialConnectionPoint;
  143502. /**
  143503. * Gets the translucency intensity input component
  143504. */
  143505. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143506. /**
  143507. * Gets the translucency diffusion distance input component
  143508. */
  143509. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143510. /**
  143511. * Gets the refraction object parameters
  143512. */
  143513. get refraction(): NodeMaterialConnectionPoint;
  143514. /**
  143515. * Gets the sub surface object output component
  143516. */
  143517. get subsurface(): NodeMaterialConnectionPoint;
  143518. autoConfigure(material: NodeMaterial): void;
  143519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143520. /**
  143521. * Gets the main code of the block (fragment side)
  143522. * @param state current state of the node material building
  143523. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143524. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143525. * @param worldPosVarName name of the variable holding the world position
  143526. * @returns the shader code
  143527. */
  143528. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143529. protected _buildBlock(state: NodeMaterialBuildState): this;
  143530. }
  143531. }
  143532. declare module BABYLON {
  143533. /**
  143534. * Block used to implement the PBR metallic/roughness model
  143535. */
  143536. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143537. /**
  143538. * Gets or sets the light associated with this block
  143539. */
  143540. light: Nullable<Light>;
  143541. private _lightId;
  143542. private _scene;
  143543. private _environmentBRDFTexture;
  143544. private _environmentBrdfSamplerName;
  143545. private _vNormalWName;
  143546. private _invertNormalName;
  143547. /**
  143548. * Create a new ReflectionBlock
  143549. * @param name defines the block name
  143550. */
  143551. constructor(name: string);
  143552. /**
  143553. * Intensity of the direct lights e.g. the four lights available in your scene.
  143554. * This impacts both the direct diffuse and specular highlights.
  143555. */
  143556. directIntensity: number;
  143557. /**
  143558. * Intensity of the environment e.g. how much the environment will light the object
  143559. * either through harmonics for rough material or through the refelction for shiny ones.
  143560. */
  143561. environmentIntensity: number;
  143562. /**
  143563. * This is a special control allowing the reduction of the specular highlights coming from the
  143564. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143565. */
  143566. specularIntensity: number;
  143567. /**
  143568. * Defines the falloff type used in this material.
  143569. * It by default is Physical.
  143570. */
  143571. lightFalloff: number;
  143572. /**
  143573. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143574. */
  143575. useAlphaFromAlbedoTexture: boolean;
  143576. /**
  143577. * Specifies that alpha test should be used
  143578. */
  143579. useAlphaTest: boolean;
  143580. /**
  143581. * Defines the alpha limits in alpha test mode.
  143582. */
  143583. alphaTestCutoff: number;
  143584. /**
  143585. * Specifies that alpha blending should be used
  143586. */
  143587. useAlphaBlending: boolean;
  143588. /**
  143589. * Defines if the alpha value should be determined via the rgb values.
  143590. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143591. */
  143592. opacityRGB: boolean;
  143593. /**
  143594. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143595. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143596. */
  143597. useRadianceOverAlpha: boolean;
  143598. /**
  143599. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143600. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143601. */
  143602. useSpecularOverAlpha: boolean;
  143603. /**
  143604. * Enables specular anti aliasing in the PBR shader.
  143605. * It will both interacts on the Geometry for analytical and IBL lighting.
  143606. * It also prefilter the roughness map based on the bump values.
  143607. */
  143608. enableSpecularAntiAliasing: boolean;
  143609. /**
  143610. * Enables realtime filtering on the texture.
  143611. */
  143612. realTimeFiltering: boolean;
  143613. /**
  143614. * Quality switch for realtime filtering
  143615. */
  143616. realTimeFilteringQuality: number;
  143617. /**
  143618. * Defines if the material uses energy conservation.
  143619. */
  143620. useEnergyConservation: boolean;
  143621. /**
  143622. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143623. * too much the area relying on ambient texture to define their ambient occlusion.
  143624. */
  143625. useRadianceOcclusion: boolean;
  143626. /**
  143627. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143628. * makes the reflect vector face the model (under horizon).
  143629. */
  143630. useHorizonOcclusion: boolean;
  143631. /**
  143632. * If set to true, no lighting calculations will be applied.
  143633. */
  143634. unlit: boolean;
  143635. /**
  143636. * Force normal to face away from face.
  143637. */
  143638. forceNormalForward: boolean;
  143639. /**
  143640. * Defines the material debug mode.
  143641. * It helps seeing only some components of the material while troubleshooting.
  143642. */
  143643. debugMode: number;
  143644. /**
  143645. * Specify from where on screen the debug mode should start.
  143646. * The value goes from -1 (full screen) to 1 (not visible)
  143647. * It helps with side by side comparison against the final render
  143648. * This defaults to 0
  143649. */
  143650. debugLimit: number;
  143651. /**
  143652. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143653. * You can use the factor to better multiply the final value.
  143654. */
  143655. debugFactor: number;
  143656. /**
  143657. * Initialize the block and prepare the context for build
  143658. * @param state defines the state that will be used for the build
  143659. */
  143660. initialize(state: NodeMaterialBuildState): void;
  143661. /**
  143662. * Gets the current class name
  143663. * @returns the class name
  143664. */
  143665. getClassName(): string;
  143666. /**
  143667. * Gets the world position input component
  143668. */
  143669. get worldPosition(): NodeMaterialConnectionPoint;
  143670. /**
  143671. * Gets the world normal input component
  143672. */
  143673. get worldNormal(): NodeMaterialConnectionPoint;
  143674. /**
  143675. * Gets the perturbed normal input component
  143676. */
  143677. get perturbedNormal(): NodeMaterialConnectionPoint;
  143678. /**
  143679. * Gets the camera position input component
  143680. */
  143681. get cameraPosition(): NodeMaterialConnectionPoint;
  143682. /**
  143683. * Gets the base color input component
  143684. */
  143685. get baseColor(): NodeMaterialConnectionPoint;
  143686. /**
  143687. * Gets the opacity texture input component
  143688. */
  143689. get opacityTexture(): NodeMaterialConnectionPoint;
  143690. /**
  143691. * Gets the ambient color input component
  143692. */
  143693. get ambientColor(): NodeMaterialConnectionPoint;
  143694. /**
  143695. * Gets the reflectivity object parameters
  143696. */
  143697. get reflectivity(): NodeMaterialConnectionPoint;
  143698. /**
  143699. * Gets the ambient occlusion object parameters
  143700. */
  143701. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143702. /**
  143703. * Gets the reflection object parameters
  143704. */
  143705. get reflection(): NodeMaterialConnectionPoint;
  143706. /**
  143707. * Gets the sheen object parameters
  143708. */
  143709. get sheen(): NodeMaterialConnectionPoint;
  143710. /**
  143711. * Gets the clear coat object parameters
  143712. */
  143713. get clearcoat(): NodeMaterialConnectionPoint;
  143714. /**
  143715. * Gets the sub surface object parameters
  143716. */
  143717. get subsurface(): NodeMaterialConnectionPoint;
  143718. /**
  143719. * Gets the anisotropy object parameters
  143720. */
  143721. get anisotropy(): NodeMaterialConnectionPoint;
  143722. /**
  143723. * Gets the ambient output component
  143724. */
  143725. get ambient(): NodeMaterialConnectionPoint;
  143726. /**
  143727. * Gets the diffuse output component
  143728. */
  143729. get diffuse(): NodeMaterialConnectionPoint;
  143730. /**
  143731. * Gets the specular output component
  143732. */
  143733. get specular(): NodeMaterialConnectionPoint;
  143734. /**
  143735. * Gets the sheen output component
  143736. */
  143737. get sheenDir(): NodeMaterialConnectionPoint;
  143738. /**
  143739. * Gets the clear coat output component
  143740. */
  143741. get clearcoatDir(): NodeMaterialConnectionPoint;
  143742. /**
  143743. * Gets the indirect diffuse output component
  143744. */
  143745. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143746. /**
  143747. * Gets the indirect specular output component
  143748. */
  143749. get specularIndirect(): NodeMaterialConnectionPoint;
  143750. /**
  143751. * Gets the indirect sheen output component
  143752. */
  143753. get sheenIndirect(): NodeMaterialConnectionPoint;
  143754. /**
  143755. * Gets the indirect clear coat output component
  143756. */
  143757. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143758. /**
  143759. * Gets the refraction output component
  143760. */
  143761. get refraction(): NodeMaterialConnectionPoint;
  143762. /**
  143763. * Gets the global lighting output component
  143764. */
  143765. get lighting(): NodeMaterialConnectionPoint;
  143766. /**
  143767. * Gets the shadow output component
  143768. */
  143769. get shadow(): NodeMaterialConnectionPoint;
  143770. /**
  143771. * Gets the alpha output component
  143772. */
  143773. get alpha(): NodeMaterialConnectionPoint;
  143774. autoConfigure(material: NodeMaterial): void;
  143775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143776. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143778. private _injectVertexCode;
  143779. /**
  143780. * Gets the code corresponding to the albedo/opacity module
  143781. * @returns the shader code
  143782. */
  143783. getAlbedoOpacityCode(): string;
  143784. protected _buildBlock(state: NodeMaterialBuildState): this;
  143785. protected _dumpPropertiesCode(): string;
  143786. serialize(): any;
  143787. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143788. }
  143789. }
  143790. declare module BABYLON {
  143791. /**
  143792. * Block used to compute value of one parameter modulo another
  143793. */
  143794. export class ModBlock extends NodeMaterialBlock {
  143795. /**
  143796. * Creates a new ModBlock
  143797. * @param name defines the block name
  143798. */
  143799. constructor(name: string);
  143800. /**
  143801. * Gets the current class name
  143802. * @returns the class name
  143803. */
  143804. getClassName(): string;
  143805. /**
  143806. * Gets the left operand input component
  143807. */
  143808. get left(): NodeMaterialConnectionPoint;
  143809. /**
  143810. * Gets the right operand input component
  143811. */
  143812. get right(): NodeMaterialConnectionPoint;
  143813. /**
  143814. * Gets the output component
  143815. */
  143816. get output(): NodeMaterialConnectionPoint;
  143817. protected _buildBlock(state: NodeMaterialBuildState): this;
  143818. }
  143819. }
  143820. declare module BABYLON {
  143821. /**
  143822. * Helper class to push actions to a pool of workers.
  143823. */
  143824. export class WorkerPool implements IDisposable {
  143825. private _workerInfos;
  143826. private _pendingActions;
  143827. /**
  143828. * Constructor
  143829. * @param workers Array of workers to use for actions
  143830. */
  143831. constructor(workers: Array<Worker>);
  143832. /**
  143833. * Terminates all workers and clears any pending actions.
  143834. */
  143835. dispose(): void;
  143836. /**
  143837. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143838. * pended until a worker has completed its action.
  143839. * @param action The action to perform. Call onComplete when the action is complete.
  143840. */
  143841. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143842. private _execute;
  143843. }
  143844. }
  143845. declare module BABYLON {
  143846. /**
  143847. * Configuration for Draco compression
  143848. */
  143849. export interface IDracoCompressionConfiguration {
  143850. /**
  143851. * Configuration for the decoder.
  143852. */
  143853. decoder: {
  143854. /**
  143855. * The url to the WebAssembly module.
  143856. */
  143857. wasmUrl?: string;
  143858. /**
  143859. * The url to the WebAssembly binary.
  143860. */
  143861. wasmBinaryUrl?: string;
  143862. /**
  143863. * The url to the fallback JavaScript module.
  143864. */
  143865. fallbackUrl?: string;
  143866. };
  143867. }
  143868. /**
  143869. * Draco compression (https://google.github.io/draco/)
  143870. *
  143871. * This class wraps the Draco module.
  143872. *
  143873. * **Encoder**
  143874. *
  143875. * The encoder is not currently implemented.
  143876. *
  143877. * **Decoder**
  143878. *
  143879. * 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.
  143880. *
  143881. * To update the configuration, use the following code:
  143882. * ```javascript
  143883. * DracoCompression.Configuration = {
  143884. * decoder: {
  143885. * wasmUrl: "<url to the WebAssembly library>",
  143886. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143887. * fallbackUrl: "<url to the fallback JavaScript library>",
  143888. * }
  143889. * };
  143890. * ```
  143891. *
  143892. * 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.
  143893. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143894. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143895. *
  143896. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143897. * ```javascript
  143898. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143899. * ```
  143900. *
  143901. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143902. */
  143903. export class DracoCompression implements IDisposable {
  143904. private _workerPoolPromise?;
  143905. private _decoderModulePromise?;
  143906. /**
  143907. * The configuration. Defaults to the following urls:
  143908. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143909. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143910. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143911. */
  143912. static Configuration: IDracoCompressionConfiguration;
  143913. /**
  143914. * Returns true if the decoder configuration is available.
  143915. */
  143916. static get DecoderAvailable(): boolean;
  143917. /**
  143918. * Default number of workers to create when creating the draco compression object.
  143919. */
  143920. static DefaultNumWorkers: number;
  143921. private static GetDefaultNumWorkers;
  143922. private static _Default;
  143923. /**
  143924. * Default instance for the draco compression object.
  143925. */
  143926. static get Default(): DracoCompression;
  143927. /**
  143928. * Constructor
  143929. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143930. */
  143931. constructor(numWorkers?: number);
  143932. /**
  143933. * Stop all async operations and release resources.
  143934. */
  143935. dispose(): void;
  143936. /**
  143937. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143938. * @returns a promise that resolves when ready
  143939. */
  143940. whenReadyAsync(): Promise<void>;
  143941. /**
  143942. * Decode Draco compressed mesh data to vertex data.
  143943. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143944. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143945. * @returns A promise that resolves with the decoded vertex data
  143946. */
  143947. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143948. [kind: string]: number;
  143949. }): Promise<VertexData>;
  143950. }
  143951. }
  143952. declare module BABYLON {
  143953. /**
  143954. * Class for building Constructive Solid Geometry
  143955. */
  143956. export class CSG {
  143957. private polygons;
  143958. /**
  143959. * The world matrix
  143960. */
  143961. matrix: Matrix;
  143962. /**
  143963. * Stores the position
  143964. */
  143965. position: Vector3;
  143966. /**
  143967. * Stores the rotation
  143968. */
  143969. rotation: Vector3;
  143970. /**
  143971. * Stores the rotation quaternion
  143972. */
  143973. rotationQuaternion: Nullable<Quaternion>;
  143974. /**
  143975. * Stores the scaling vector
  143976. */
  143977. scaling: Vector3;
  143978. /**
  143979. * Convert the Mesh to CSG
  143980. * @param mesh The Mesh to convert to CSG
  143981. * @returns A new CSG from the Mesh
  143982. */
  143983. static FromMesh(mesh: Mesh): CSG;
  143984. /**
  143985. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143986. * @param polygons Polygons used to construct a CSG solid
  143987. */
  143988. private static FromPolygons;
  143989. /**
  143990. * Clones, or makes a deep copy, of the CSG
  143991. * @returns A new CSG
  143992. */
  143993. clone(): CSG;
  143994. /**
  143995. * Unions this CSG with another CSG
  143996. * @param csg The CSG to union against this CSG
  143997. * @returns The unioned CSG
  143998. */
  143999. union(csg: CSG): CSG;
  144000. /**
  144001. * Unions this CSG with another CSG in place
  144002. * @param csg The CSG to union against this CSG
  144003. */
  144004. unionInPlace(csg: CSG): void;
  144005. /**
  144006. * Subtracts this CSG with another CSG
  144007. * @param csg The CSG to subtract against this CSG
  144008. * @returns A new CSG
  144009. */
  144010. subtract(csg: CSG): CSG;
  144011. /**
  144012. * Subtracts this CSG with another CSG in place
  144013. * @param csg The CSG to subtact against this CSG
  144014. */
  144015. subtractInPlace(csg: CSG): void;
  144016. /**
  144017. * Intersect this CSG with another CSG
  144018. * @param csg The CSG to intersect against this CSG
  144019. * @returns A new CSG
  144020. */
  144021. intersect(csg: CSG): CSG;
  144022. /**
  144023. * Intersects this CSG with another CSG in place
  144024. * @param csg The CSG to intersect against this CSG
  144025. */
  144026. intersectInPlace(csg: CSG): void;
  144027. /**
  144028. * Return a new CSG solid with solid and empty space switched. This solid is
  144029. * not modified.
  144030. * @returns A new CSG solid with solid and empty space switched
  144031. */
  144032. inverse(): CSG;
  144033. /**
  144034. * Inverses the CSG in place
  144035. */
  144036. inverseInPlace(): void;
  144037. /**
  144038. * This is used to keep meshes transformations so they can be restored
  144039. * when we build back a Babylon Mesh
  144040. * NB : All CSG operations are performed in world coordinates
  144041. * @param csg The CSG to copy the transform attributes from
  144042. * @returns This CSG
  144043. */
  144044. copyTransformAttributes(csg: CSG): CSG;
  144045. /**
  144046. * Build Raw mesh from CSG
  144047. * Coordinates here are in world space
  144048. * @param name The name of the mesh geometry
  144049. * @param scene The Scene
  144050. * @param keepSubMeshes Specifies if the submeshes should be kept
  144051. * @returns A new Mesh
  144052. */
  144053. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144054. /**
  144055. * Build Mesh from CSG taking material and transforms into account
  144056. * @param name The name of the Mesh
  144057. * @param material The material of the Mesh
  144058. * @param scene The Scene
  144059. * @param keepSubMeshes Specifies if submeshes should be kept
  144060. * @returns The new Mesh
  144061. */
  144062. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  144063. }
  144064. }
  144065. declare module BABYLON {
  144066. /**
  144067. * Class used to create a trail following a mesh
  144068. */
  144069. export class TrailMesh extends Mesh {
  144070. private _generator;
  144071. private _autoStart;
  144072. private _running;
  144073. private _diameter;
  144074. private _length;
  144075. private _sectionPolygonPointsCount;
  144076. private _sectionVectors;
  144077. private _sectionNormalVectors;
  144078. private _beforeRenderObserver;
  144079. /**
  144080. * @constructor
  144081. * @param name The value used by scene.getMeshByName() to do a lookup.
  144082. * @param generator The mesh or transform node to generate a trail.
  144083. * @param scene The scene to add this mesh to.
  144084. * @param diameter Diameter of trailing mesh. Default is 1.
  144085. * @param length Length of trailing mesh. Default is 60.
  144086. * @param autoStart Automatically start trailing mesh. Default true.
  144087. */
  144088. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  144089. /**
  144090. * "TrailMesh"
  144091. * @returns "TrailMesh"
  144092. */
  144093. getClassName(): string;
  144094. private _createMesh;
  144095. /**
  144096. * Start trailing mesh.
  144097. */
  144098. start(): void;
  144099. /**
  144100. * Stop trailing mesh.
  144101. */
  144102. stop(): void;
  144103. /**
  144104. * Update trailing mesh geometry.
  144105. */
  144106. update(): void;
  144107. /**
  144108. * Returns a new TrailMesh object.
  144109. * @param name is a string, the name given to the new mesh
  144110. * @param newGenerator use new generator object for cloned trail mesh
  144111. * @returns a new mesh
  144112. */
  144113. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  144114. /**
  144115. * Serializes this trail mesh
  144116. * @param serializationObject object to write serialization to
  144117. */
  144118. serialize(serializationObject: any): void;
  144119. /**
  144120. * Parses a serialized trail mesh
  144121. * @param parsedMesh the serialized mesh
  144122. * @param scene the scene to create the trail mesh in
  144123. * @returns the created trail mesh
  144124. */
  144125. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  144126. }
  144127. }
  144128. declare module BABYLON {
  144129. /**
  144130. * Class containing static functions to help procedurally build meshes
  144131. */
  144132. export class TiledBoxBuilder {
  144133. /**
  144134. * Creates a box mesh
  144135. * 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)
  144136. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144140. * @param name defines the name of the mesh
  144141. * @param options defines the options used to create the mesh
  144142. * @param scene defines the hosting scene
  144143. * @returns the box mesh
  144144. */
  144145. static CreateTiledBox(name: string, options: {
  144146. pattern?: number;
  144147. width?: number;
  144148. height?: number;
  144149. depth?: number;
  144150. tileSize?: number;
  144151. tileWidth?: number;
  144152. tileHeight?: number;
  144153. alignHorizontal?: number;
  144154. alignVertical?: number;
  144155. faceUV?: Vector4[];
  144156. faceColors?: Color4[];
  144157. sideOrientation?: number;
  144158. updatable?: boolean;
  144159. }, scene?: Nullable<Scene>): Mesh;
  144160. }
  144161. }
  144162. declare module BABYLON {
  144163. /**
  144164. * Class containing static functions to help procedurally build meshes
  144165. */
  144166. export class TorusKnotBuilder {
  144167. /**
  144168. * Creates a torus knot mesh
  144169. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144170. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144171. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144172. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144176. * @param name defines the name of the mesh
  144177. * @param options defines the options used to create the mesh
  144178. * @param scene defines the hosting scene
  144179. * @returns the torus knot mesh
  144180. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144181. */
  144182. static CreateTorusKnot(name: string, options: {
  144183. radius?: number;
  144184. tube?: number;
  144185. radialSegments?: number;
  144186. tubularSegments?: number;
  144187. p?: number;
  144188. q?: number;
  144189. updatable?: boolean;
  144190. sideOrientation?: number;
  144191. frontUVs?: Vector4;
  144192. backUVs?: Vector4;
  144193. }, scene: any): Mesh;
  144194. }
  144195. }
  144196. declare module BABYLON {
  144197. /**
  144198. * Polygon
  144199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  144200. */
  144201. export class Polygon {
  144202. /**
  144203. * Creates a rectangle
  144204. * @param xmin bottom X coord
  144205. * @param ymin bottom Y coord
  144206. * @param xmax top X coord
  144207. * @param ymax top Y coord
  144208. * @returns points that make the resulting rectation
  144209. */
  144210. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  144211. /**
  144212. * Creates a circle
  144213. * @param radius radius of circle
  144214. * @param cx scale in x
  144215. * @param cy scale in y
  144216. * @param numberOfSides number of sides that make up the circle
  144217. * @returns points that make the resulting circle
  144218. */
  144219. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  144220. /**
  144221. * Creates a polygon from input string
  144222. * @param input Input polygon data
  144223. * @returns the parsed points
  144224. */
  144225. static Parse(input: string): Vector2[];
  144226. /**
  144227. * Starts building a polygon from x and y coordinates
  144228. * @param x x coordinate
  144229. * @param y y coordinate
  144230. * @returns the started path2
  144231. */
  144232. static StartingAt(x: number, y: number): Path2;
  144233. }
  144234. /**
  144235. * Builds a polygon
  144236. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144237. */
  144238. export class PolygonMeshBuilder {
  144239. private _points;
  144240. private _outlinepoints;
  144241. private _holes;
  144242. private _name;
  144243. private _scene;
  144244. private _epoints;
  144245. private _eholes;
  144246. private _addToepoint;
  144247. /**
  144248. * Babylon reference to the earcut plugin.
  144249. */
  144250. bjsEarcut: any;
  144251. /**
  144252. * Creates a PolygonMeshBuilder
  144253. * @param name name of the builder
  144254. * @param contours Path of the polygon
  144255. * @param scene scene to add to when creating the mesh
  144256. * @param earcutInjection can be used to inject your own earcut reference
  144257. */
  144258. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144259. /**
  144260. * Adds a whole within the polygon
  144261. * @param hole Array of points defining the hole
  144262. * @returns this
  144263. */
  144264. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144265. /**
  144266. * Creates the polygon
  144267. * @param updatable If the mesh should be updatable
  144268. * @param depth The depth of the mesh created
  144269. * @returns the created mesh
  144270. */
  144271. build(updatable?: boolean, depth?: number): Mesh;
  144272. /**
  144273. * Creates the polygon
  144274. * @param depth The depth of the mesh created
  144275. * @returns the created VertexData
  144276. */
  144277. buildVertexData(depth?: number): VertexData;
  144278. /**
  144279. * Adds a side to the polygon
  144280. * @param positions points that make the polygon
  144281. * @param normals normals of the polygon
  144282. * @param uvs uvs of the polygon
  144283. * @param indices indices of the polygon
  144284. * @param bounds bounds of the polygon
  144285. * @param points points of the polygon
  144286. * @param depth depth of the polygon
  144287. * @param flip flip of the polygon
  144288. */
  144289. private addSide;
  144290. }
  144291. }
  144292. declare module BABYLON {
  144293. /**
  144294. * Class containing static functions to help procedurally build meshes
  144295. */
  144296. export class PolygonBuilder {
  144297. /**
  144298. * Creates a polygon mesh
  144299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144300. * * 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
  144301. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144304. * * Remember you can only change the shape positions, not their number when updating a polygon
  144305. * @param name defines the name of the mesh
  144306. * @param options defines the options used to create the mesh
  144307. * @param scene defines the hosting scene
  144308. * @param earcutInjection can be used to inject your own earcut reference
  144309. * @returns the polygon mesh
  144310. */
  144311. static CreatePolygon(name: string, options: {
  144312. shape: Vector3[];
  144313. holes?: Vector3[][];
  144314. depth?: number;
  144315. faceUV?: Vector4[];
  144316. faceColors?: Color4[];
  144317. updatable?: boolean;
  144318. sideOrientation?: number;
  144319. frontUVs?: Vector4;
  144320. backUVs?: Vector4;
  144321. wrap?: boolean;
  144322. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144323. /**
  144324. * Creates an extruded polygon mesh, with depth in the Y direction.
  144325. * * 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)
  144326. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144327. * @param name defines the name of the mesh
  144328. * @param options defines the options used to create the mesh
  144329. * @param scene defines the hosting scene
  144330. * @param earcutInjection can be used to inject your own earcut reference
  144331. * @returns the polygon mesh
  144332. */
  144333. static ExtrudePolygon(name: string, options: {
  144334. shape: Vector3[];
  144335. holes?: Vector3[][];
  144336. depth?: number;
  144337. faceUV?: Vector4[];
  144338. faceColors?: Color4[];
  144339. updatable?: boolean;
  144340. sideOrientation?: number;
  144341. frontUVs?: Vector4;
  144342. backUVs?: Vector4;
  144343. wrap?: boolean;
  144344. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144345. }
  144346. }
  144347. declare module BABYLON {
  144348. /**
  144349. * Class containing static functions to help procedurally build meshes
  144350. */
  144351. export class LatheBuilder {
  144352. /**
  144353. * Creates lathe mesh.
  144354. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144355. * * 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
  144356. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144357. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144358. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144359. * * 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
  144360. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144361. * * 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
  144362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144366. * @param name defines the name of the mesh
  144367. * @param options defines the options used to create the mesh
  144368. * @param scene defines the hosting scene
  144369. * @returns the lathe mesh
  144370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144371. */
  144372. static CreateLathe(name: string, options: {
  144373. shape: Vector3[];
  144374. radius?: number;
  144375. tessellation?: number;
  144376. clip?: number;
  144377. arc?: number;
  144378. closed?: boolean;
  144379. updatable?: boolean;
  144380. sideOrientation?: number;
  144381. frontUVs?: Vector4;
  144382. backUVs?: Vector4;
  144383. cap?: number;
  144384. invertUV?: boolean;
  144385. }, scene?: Nullable<Scene>): Mesh;
  144386. }
  144387. }
  144388. declare module BABYLON {
  144389. /**
  144390. * Class containing static functions to help procedurally build meshes
  144391. */
  144392. export class TiledPlaneBuilder {
  144393. /**
  144394. * Creates a tiled plane mesh
  144395. * * The parameter `pattern` will, depending on value, do nothing or
  144396. * * * flip (reflect about central vertical) alternate tiles across and up
  144397. * * * flip every tile on alternate rows
  144398. * * * rotate (180 degs) alternate tiles across and up
  144399. * * * rotate every tile on alternate rows
  144400. * * * flip and rotate alternate tiles across and up
  144401. * * * flip and rotate every tile on alternate rows
  144402. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144403. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144406. * * 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)
  144407. * * 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)
  144408. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144409. * @param name defines the name of the mesh
  144410. * @param options defines the options used to create the mesh
  144411. * @param scene defines the hosting scene
  144412. * @returns the box mesh
  144413. */
  144414. static CreateTiledPlane(name: string, options: {
  144415. pattern?: number;
  144416. tileSize?: number;
  144417. tileWidth?: number;
  144418. tileHeight?: number;
  144419. size?: number;
  144420. width?: number;
  144421. height?: number;
  144422. alignHorizontal?: number;
  144423. alignVertical?: number;
  144424. sideOrientation?: number;
  144425. frontUVs?: Vector4;
  144426. backUVs?: Vector4;
  144427. updatable?: boolean;
  144428. }, scene?: Nullable<Scene>): Mesh;
  144429. }
  144430. }
  144431. declare module BABYLON {
  144432. /**
  144433. * Class containing static functions to help procedurally build meshes
  144434. */
  144435. export class TubeBuilder {
  144436. /**
  144437. * Creates a tube mesh.
  144438. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144439. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144440. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144441. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144442. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144443. * * 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)
  144444. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144445. * * 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
  144446. * * 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
  144447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144451. * @param name defines the name of the mesh
  144452. * @param options defines the options used to create the mesh
  144453. * @param scene defines the hosting scene
  144454. * @returns the tube mesh
  144455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144456. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144457. */
  144458. static CreateTube(name: string, options: {
  144459. path: Vector3[];
  144460. radius?: number;
  144461. tessellation?: number;
  144462. radiusFunction?: {
  144463. (i: number, distance: number): number;
  144464. };
  144465. cap?: number;
  144466. arc?: number;
  144467. updatable?: boolean;
  144468. sideOrientation?: number;
  144469. frontUVs?: Vector4;
  144470. backUVs?: Vector4;
  144471. instance?: Mesh;
  144472. invertUV?: boolean;
  144473. }, scene?: Nullable<Scene>): Mesh;
  144474. }
  144475. }
  144476. declare module BABYLON {
  144477. /**
  144478. * Class containing static functions to help procedurally build meshes
  144479. */
  144480. export class IcoSphereBuilder {
  144481. /**
  144482. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144483. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144484. * * 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`)
  144485. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144486. * * 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
  144487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144490. * @param name defines the name of the mesh
  144491. * @param options defines the options used to create the mesh
  144492. * @param scene defines the hosting scene
  144493. * @returns the icosahedron mesh
  144494. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144495. */
  144496. static CreateIcoSphere(name: string, options: {
  144497. radius?: number;
  144498. radiusX?: number;
  144499. radiusY?: number;
  144500. radiusZ?: number;
  144501. flat?: boolean;
  144502. subdivisions?: number;
  144503. sideOrientation?: number;
  144504. frontUVs?: Vector4;
  144505. backUVs?: Vector4;
  144506. updatable?: boolean;
  144507. }, scene?: Nullable<Scene>): Mesh;
  144508. }
  144509. }
  144510. declare module BABYLON {
  144511. /**
  144512. * Class containing static functions to help procedurally build meshes
  144513. */
  144514. export class DecalBuilder {
  144515. /**
  144516. * Creates a decal mesh.
  144517. * 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
  144518. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144519. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144520. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144521. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144522. * @param name defines the name of the mesh
  144523. * @param sourceMesh defines the mesh where the decal must be applied
  144524. * @param options defines the options used to create the mesh
  144525. * @param scene defines the hosting scene
  144526. * @returns the decal mesh
  144527. * @see https://doc.babylonjs.com/how_to/decals
  144528. */
  144529. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144530. position?: Vector3;
  144531. normal?: Vector3;
  144532. size?: Vector3;
  144533. angle?: number;
  144534. }): Mesh;
  144535. }
  144536. }
  144537. declare module BABYLON {
  144538. /**
  144539. * Class containing static functions to help procedurally build meshes
  144540. */
  144541. export class MeshBuilder {
  144542. /**
  144543. * Creates a box mesh
  144544. * * The parameter `size` sets the size (float) of each box side (default 1)
  144545. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144546. * * 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)
  144547. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144551. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144552. * @param name defines the name of the mesh
  144553. * @param options defines the options used to create the mesh
  144554. * @param scene defines the hosting scene
  144555. * @returns the box mesh
  144556. */
  144557. static CreateBox(name: string, options: {
  144558. size?: number;
  144559. width?: number;
  144560. height?: number;
  144561. depth?: number;
  144562. faceUV?: Vector4[];
  144563. faceColors?: Color4[];
  144564. sideOrientation?: number;
  144565. frontUVs?: Vector4;
  144566. backUVs?: Vector4;
  144567. wrap?: boolean;
  144568. topBaseAt?: number;
  144569. bottomBaseAt?: number;
  144570. updatable?: boolean;
  144571. }, scene?: Nullable<Scene>): Mesh;
  144572. /**
  144573. * Creates a tiled box mesh
  144574. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144576. * @param name defines the name of the mesh
  144577. * @param options defines the options used to create the mesh
  144578. * @param scene defines the hosting scene
  144579. * @returns the tiled box mesh
  144580. */
  144581. static CreateTiledBox(name: string, options: {
  144582. pattern?: number;
  144583. size?: number;
  144584. width?: number;
  144585. height?: number;
  144586. depth: number;
  144587. tileSize?: number;
  144588. tileWidth?: number;
  144589. tileHeight?: number;
  144590. faceUV?: Vector4[];
  144591. faceColors?: Color4[];
  144592. alignHorizontal?: number;
  144593. alignVertical?: number;
  144594. sideOrientation?: number;
  144595. updatable?: boolean;
  144596. }, scene?: Nullable<Scene>): Mesh;
  144597. /**
  144598. * Creates a sphere mesh
  144599. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144600. * * 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`)
  144601. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144602. * * 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
  144603. * * 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)
  144604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144607. * @param name defines the name of the mesh
  144608. * @param options defines the options used to create the mesh
  144609. * @param scene defines the hosting scene
  144610. * @returns the sphere mesh
  144611. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144612. */
  144613. static CreateSphere(name: string, options: {
  144614. segments?: number;
  144615. diameter?: number;
  144616. diameterX?: number;
  144617. diameterY?: number;
  144618. diameterZ?: number;
  144619. arc?: number;
  144620. slice?: number;
  144621. sideOrientation?: number;
  144622. frontUVs?: Vector4;
  144623. backUVs?: Vector4;
  144624. updatable?: boolean;
  144625. }, scene?: Nullable<Scene>): Mesh;
  144626. /**
  144627. * Creates a plane polygonal mesh. By default, this is a disc
  144628. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144629. * * 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
  144630. * * 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
  144631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144634. * @param name defines the name of the mesh
  144635. * @param options defines the options used to create the mesh
  144636. * @param scene defines the hosting scene
  144637. * @returns the plane polygonal mesh
  144638. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144639. */
  144640. static CreateDisc(name: string, options: {
  144641. radius?: number;
  144642. tessellation?: number;
  144643. arc?: number;
  144644. updatable?: boolean;
  144645. sideOrientation?: number;
  144646. frontUVs?: Vector4;
  144647. backUVs?: Vector4;
  144648. }, scene?: Nullable<Scene>): Mesh;
  144649. /**
  144650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144652. * * 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`)
  144653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144654. * * 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
  144655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144658. * @param name defines the name of the mesh
  144659. * @param options defines the options used to create the mesh
  144660. * @param scene defines the hosting scene
  144661. * @returns the icosahedron mesh
  144662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144663. */
  144664. static CreateIcoSphere(name: string, options: {
  144665. radius?: number;
  144666. radiusX?: number;
  144667. radiusY?: number;
  144668. radiusZ?: number;
  144669. flat?: boolean;
  144670. subdivisions?: number;
  144671. sideOrientation?: number;
  144672. frontUVs?: Vector4;
  144673. backUVs?: Vector4;
  144674. updatable?: boolean;
  144675. }, scene?: Nullable<Scene>): Mesh;
  144676. /**
  144677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144681. * * 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
  144682. * * 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
  144683. * * 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
  144684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144687. * * 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
  144688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144689. * * 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
  144690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144692. * @param name defines the name of the mesh
  144693. * @param options defines the options used to create the mesh
  144694. * @param scene defines the hosting scene
  144695. * @returns the ribbon mesh
  144696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144698. */
  144699. static CreateRibbon(name: string, options: {
  144700. pathArray: Vector3[][];
  144701. closeArray?: boolean;
  144702. closePath?: boolean;
  144703. offset?: number;
  144704. updatable?: boolean;
  144705. sideOrientation?: number;
  144706. frontUVs?: Vector4;
  144707. backUVs?: Vector4;
  144708. instance?: Mesh;
  144709. invertUV?: boolean;
  144710. uvs?: Vector2[];
  144711. colors?: Color4[];
  144712. }, scene?: Nullable<Scene>): Mesh;
  144713. /**
  144714. * Creates a cylinder or a cone mesh
  144715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144717. * * 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.
  144718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144722. * * 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).
  144723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144724. * * 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).
  144725. * * 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
  144726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144727. * * 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
  144728. * * 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.
  144729. * * If `enclose` is false, a ring surface is one element.
  144730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144731. * * 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
  144732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144735. * @param name defines the name of the mesh
  144736. * @param options defines the options used to create the mesh
  144737. * @param scene defines the hosting scene
  144738. * @returns the cylinder mesh
  144739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144740. */
  144741. static CreateCylinder(name: string, options: {
  144742. height?: number;
  144743. diameterTop?: number;
  144744. diameterBottom?: number;
  144745. diameter?: number;
  144746. tessellation?: number;
  144747. subdivisions?: number;
  144748. arc?: number;
  144749. faceColors?: Color4[];
  144750. faceUV?: Vector4[];
  144751. updatable?: boolean;
  144752. hasRings?: boolean;
  144753. enclose?: boolean;
  144754. cap?: number;
  144755. sideOrientation?: number;
  144756. frontUVs?: Vector4;
  144757. backUVs?: Vector4;
  144758. }, scene?: Nullable<Scene>): Mesh;
  144759. /**
  144760. * Creates a torus mesh
  144761. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144762. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144763. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144767. * @param name defines the name of the mesh
  144768. * @param options defines the options used to create the mesh
  144769. * @param scene defines the hosting scene
  144770. * @returns the torus mesh
  144771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144772. */
  144773. static CreateTorus(name: string, options: {
  144774. diameter?: number;
  144775. thickness?: number;
  144776. tessellation?: number;
  144777. updatable?: boolean;
  144778. sideOrientation?: number;
  144779. frontUVs?: Vector4;
  144780. backUVs?: Vector4;
  144781. }, scene?: Nullable<Scene>): Mesh;
  144782. /**
  144783. * Creates a torus knot mesh
  144784. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144785. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144786. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144787. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144791. * @param name defines the name of the mesh
  144792. * @param options defines the options used to create the mesh
  144793. * @param scene defines the hosting scene
  144794. * @returns the torus knot mesh
  144795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144796. */
  144797. static CreateTorusKnot(name: string, options: {
  144798. radius?: number;
  144799. tube?: number;
  144800. radialSegments?: number;
  144801. tubularSegments?: number;
  144802. p?: number;
  144803. q?: number;
  144804. updatable?: boolean;
  144805. sideOrientation?: number;
  144806. frontUVs?: Vector4;
  144807. backUVs?: Vector4;
  144808. }, scene?: Nullable<Scene>): Mesh;
  144809. /**
  144810. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144811. * * 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
  144812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144813. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144814. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144815. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144817. * * 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
  144818. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144821. * @param name defines the name of the new line system
  144822. * @param options defines the options used to create the line system
  144823. * @param scene defines the hosting scene
  144824. * @returns a new line system mesh
  144825. */
  144826. static CreateLineSystem(name: string, options: {
  144827. lines: Vector3[][];
  144828. updatable?: boolean;
  144829. instance?: Nullable<LinesMesh>;
  144830. colors?: Nullable<Color4[][]>;
  144831. useVertexAlpha?: boolean;
  144832. }, scene: Nullable<Scene>): LinesMesh;
  144833. /**
  144834. * Creates a line mesh
  144835. * 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
  144836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144837. * * The parameter `points` is an array successive Vector3
  144838. * * 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
  144839. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144841. * * When updating an instance, remember that only point positions can change, not the number of points
  144842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144844. * @param name defines the name of the new line system
  144845. * @param options defines the options used to create the line system
  144846. * @param scene defines the hosting scene
  144847. * @returns a new line mesh
  144848. */
  144849. static CreateLines(name: string, options: {
  144850. points: Vector3[];
  144851. updatable?: boolean;
  144852. instance?: Nullable<LinesMesh>;
  144853. colors?: Color4[];
  144854. useVertexAlpha?: boolean;
  144855. }, scene?: Nullable<Scene>): LinesMesh;
  144856. /**
  144857. * Creates a dashed line mesh
  144858. * * 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
  144859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144860. * * The parameter `points` is an array successive Vector3
  144861. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144862. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144863. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144864. * * 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
  144865. * * When updating an instance, remember that only point positions can change, not the number of points
  144866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144867. * @param name defines the name of the mesh
  144868. * @param options defines the options used to create the mesh
  144869. * @param scene defines the hosting scene
  144870. * @returns the dashed line mesh
  144871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144872. */
  144873. static CreateDashedLines(name: string, options: {
  144874. points: Vector3[];
  144875. dashSize?: number;
  144876. gapSize?: number;
  144877. dashNb?: number;
  144878. updatable?: boolean;
  144879. instance?: LinesMesh;
  144880. }, scene?: Nullable<Scene>): LinesMesh;
  144881. /**
  144882. * 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.
  144883. * * 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.
  144884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144885. * * 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.
  144886. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144887. * * 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
  144888. * * 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
  144889. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144894. * @param name defines the name of the mesh
  144895. * @param options defines the options used to create the mesh
  144896. * @param scene defines the hosting scene
  144897. * @returns the extruded shape mesh
  144898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144900. */
  144901. static ExtrudeShape(name: string, options: {
  144902. shape: Vector3[];
  144903. path: Vector3[];
  144904. scale?: number;
  144905. rotation?: number;
  144906. cap?: number;
  144907. updatable?: boolean;
  144908. sideOrientation?: number;
  144909. frontUVs?: Vector4;
  144910. backUVs?: Vector4;
  144911. instance?: Mesh;
  144912. invertUV?: boolean;
  144913. }, scene?: Nullable<Scene>): Mesh;
  144914. /**
  144915. * Creates an custom extruded shape mesh.
  144916. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144917. * * 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.
  144918. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144919. * * 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
  144920. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144921. * * 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
  144922. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144923. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144924. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144925. * * 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
  144926. * * 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
  144927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144932. * @param name defines the name of the mesh
  144933. * @param options defines the options used to create the mesh
  144934. * @param scene defines the hosting scene
  144935. * @returns the custom extruded shape mesh
  144936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144939. */
  144940. static ExtrudeShapeCustom(name: string, options: {
  144941. shape: Vector3[];
  144942. path: Vector3[];
  144943. scaleFunction?: any;
  144944. rotationFunction?: any;
  144945. ribbonCloseArray?: boolean;
  144946. ribbonClosePath?: boolean;
  144947. cap?: number;
  144948. updatable?: boolean;
  144949. sideOrientation?: number;
  144950. frontUVs?: Vector4;
  144951. backUVs?: Vector4;
  144952. instance?: Mesh;
  144953. invertUV?: boolean;
  144954. }, scene?: Nullable<Scene>): Mesh;
  144955. /**
  144956. * Creates lathe mesh.
  144957. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144958. * * 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
  144959. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144960. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144961. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144962. * * 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
  144963. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144964. * * 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
  144965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144969. * @param name defines the name of the mesh
  144970. * @param options defines the options used to create the mesh
  144971. * @param scene defines the hosting scene
  144972. * @returns the lathe mesh
  144973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144974. */
  144975. static CreateLathe(name: string, options: {
  144976. shape: Vector3[];
  144977. radius?: number;
  144978. tessellation?: number;
  144979. clip?: number;
  144980. arc?: number;
  144981. closed?: boolean;
  144982. updatable?: boolean;
  144983. sideOrientation?: number;
  144984. frontUVs?: Vector4;
  144985. backUVs?: Vector4;
  144986. cap?: number;
  144987. invertUV?: boolean;
  144988. }, scene?: Nullable<Scene>): Mesh;
  144989. /**
  144990. * Creates a tiled plane mesh
  144991. * * You can set a limited pattern arrangement with the tiles
  144992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144995. * @param name defines the name of the mesh
  144996. * @param options defines the options used to create the mesh
  144997. * @param scene defines the hosting scene
  144998. * @returns the plane mesh
  144999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145000. */
  145001. static CreateTiledPlane(name: string, options: {
  145002. pattern?: number;
  145003. tileSize?: number;
  145004. tileWidth?: number;
  145005. tileHeight?: number;
  145006. size?: number;
  145007. width?: number;
  145008. height?: number;
  145009. alignHorizontal?: number;
  145010. alignVertical?: number;
  145011. sideOrientation?: number;
  145012. frontUVs?: Vector4;
  145013. backUVs?: Vector4;
  145014. updatable?: boolean;
  145015. }, scene?: Nullable<Scene>): Mesh;
  145016. /**
  145017. * Creates a plane mesh
  145018. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  145019. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  145020. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  145021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145024. * @param name defines the name of the mesh
  145025. * @param options defines the options used to create the mesh
  145026. * @param scene defines the hosting scene
  145027. * @returns the plane mesh
  145028. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  145029. */
  145030. static CreatePlane(name: string, options: {
  145031. size?: number;
  145032. width?: number;
  145033. height?: number;
  145034. sideOrientation?: number;
  145035. frontUVs?: Vector4;
  145036. backUVs?: Vector4;
  145037. updatable?: boolean;
  145038. sourcePlane?: Plane;
  145039. }, scene?: Nullable<Scene>): Mesh;
  145040. /**
  145041. * Creates a ground mesh
  145042. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  145043. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  145044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145045. * @param name defines the name of the mesh
  145046. * @param options defines the options used to create the mesh
  145047. * @param scene defines the hosting scene
  145048. * @returns the ground mesh
  145049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  145050. */
  145051. static CreateGround(name: string, options: {
  145052. width?: number;
  145053. height?: number;
  145054. subdivisions?: number;
  145055. subdivisionsX?: number;
  145056. subdivisionsY?: number;
  145057. updatable?: boolean;
  145058. }, scene?: Nullable<Scene>): Mesh;
  145059. /**
  145060. * Creates a tiled ground mesh
  145061. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  145062. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  145063. * * 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
  145064. * * 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
  145065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145066. * @param name defines the name of the mesh
  145067. * @param options defines the options used to create the mesh
  145068. * @param scene defines the hosting scene
  145069. * @returns the tiled ground mesh
  145070. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  145071. */
  145072. static CreateTiledGround(name: string, options: {
  145073. xmin: number;
  145074. zmin: number;
  145075. xmax: number;
  145076. zmax: number;
  145077. subdivisions?: {
  145078. w: number;
  145079. h: number;
  145080. };
  145081. precision?: {
  145082. w: number;
  145083. h: number;
  145084. };
  145085. updatable?: boolean;
  145086. }, scene?: Nullable<Scene>): Mesh;
  145087. /**
  145088. * Creates a ground mesh from a height map
  145089. * * The parameter `url` sets the URL of the height map image resource.
  145090. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  145091. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  145092. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  145093. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  145094. * * 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.
  145095. * * 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).
  145096. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  145097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145098. * @param name defines the name of the mesh
  145099. * @param url defines the url to the height map
  145100. * @param options defines the options used to create the mesh
  145101. * @param scene defines the hosting scene
  145102. * @returns the ground mesh
  145103. * @see https://doc.babylonjs.com/babylon101/height_map
  145104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  145105. */
  145106. static CreateGroundFromHeightMap(name: string, url: string, options: {
  145107. width?: number;
  145108. height?: number;
  145109. subdivisions?: number;
  145110. minHeight?: number;
  145111. maxHeight?: number;
  145112. colorFilter?: Color3;
  145113. alphaFilter?: number;
  145114. updatable?: boolean;
  145115. onReady?: (mesh: GroundMesh) => void;
  145116. }, scene?: Nullable<Scene>): GroundMesh;
  145117. /**
  145118. * Creates a polygon mesh
  145119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145120. * * 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
  145121. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145124. * * Remember you can only change the shape positions, not their number when updating a polygon
  145125. * @param name defines the name of the mesh
  145126. * @param options defines the options used to create the mesh
  145127. * @param scene defines the hosting scene
  145128. * @param earcutInjection can be used to inject your own earcut reference
  145129. * @returns the polygon mesh
  145130. */
  145131. static CreatePolygon(name: string, options: {
  145132. shape: Vector3[];
  145133. holes?: Vector3[][];
  145134. depth?: number;
  145135. faceUV?: Vector4[];
  145136. faceColors?: Color4[];
  145137. updatable?: boolean;
  145138. sideOrientation?: number;
  145139. frontUVs?: Vector4;
  145140. backUVs?: Vector4;
  145141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145142. /**
  145143. * Creates an extruded polygon mesh, with depth in the Y direction.
  145144. * * 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)
  145145. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145146. * @param name defines the name of the mesh
  145147. * @param options defines the options used to create the mesh
  145148. * @param scene defines the hosting scene
  145149. * @param earcutInjection can be used to inject your own earcut reference
  145150. * @returns the polygon mesh
  145151. */
  145152. static ExtrudePolygon(name: string, options: {
  145153. shape: Vector3[];
  145154. holes?: Vector3[][];
  145155. depth?: number;
  145156. faceUV?: Vector4[];
  145157. faceColors?: Color4[];
  145158. updatable?: boolean;
  145159. sideOrientation?: number;
  145160. frontUVs?: Vector4;
  145161. backUVs?: Vector4;
  145162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145163. /**
  145164. * Creates a tube mesh.
  145165. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145166. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145167. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145168. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145169. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145170. * * 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)
  145171. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145172. * * 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
  145173. * * 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
  145174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145178. * @param name defines the name of the mesh
  145179. * @param options defines the options used to create the mesh
  145180. * @param scene defines the hosting scene
  145181. * @returns the tube mesh
  145182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145183. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145184. */
  145185. static CreateTube(name: string, options: {
  145186. path: Vector3[];
  145187. radius?: number;
  145188. tessellation?: number;
  145189. radiusFunction?: {
  145190. (i: number, distance: number): number;
  145191. };
  145192. cap?: number;
  145193. arc?: number;
  145194. updatable?: boolean;
  145195. sideOrientation?: number;
  145196. frontUVs?: Vector4;
  145197. backUVs?: Vector4;
  145198. instance?: Mesh;
  145199. invertUV?: boolean;
  145200. }, scene?: Nullable<Scene>): Mesh;
  145201. /**
  145202. * Creates a polyhedron mesh
  145203. * * 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
  145204. * * The parameter `size` (positive float, default 1) sets the polygon size
  145205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  145206. * * 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`
  145207. * * 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
  145208. * * 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)`)
  145209. * * 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
  145210. * * 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
  145211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145214. * @param name defines the name of the mesh
  145215. * @param options defines the options used to create the mesh
  145216. * @param scene defines the hosting scene
  145217. * @returns the polyhedron mesh
  145218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  145219. */
  145220. static CreatePolyhedron(name: string, options: {
  145221. type?: number;
  145222. size?: number;
  145223. sizeX?: number;
  145224. sizeY?: number;
  145225. sizeZ?: number;
  145226. custom?: any;
  145227. faceUV?: Vector4[];
  145228. faceColors?: Color4[];
  145229. flat?: boolean;
  145230. updatable?: boolean;
  145231. sideOrientation?: number;
  145232. frontUVs?: Vector4;
  145233. backUVs?: Vector4;
  145234. }, scene?: Nullable<Scene>): Mesh;
  145235. /**
  145236. * Creates a decal mesh.
  145237. * 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
  145238. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145239. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145240. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145241. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145242. * @param name defines the name of the mesh
  145243. * @param sourceMesh defines the mesh where the decal must be applied
  145244. * @param options defines the options used to create the mesh
  145245. * @param scene defines the hosting scene
  145246. * @returns the decal mesh
  145247. * @see https://doc.babylonjs.com/how_to/decals
  145248. */
  145249. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145250. position?: Vector3;
  145251. normal?: Vector3;
  145252. size?: Vector3;
  145253. angle?: number;
  145254. }): Mesh;
  145255. }
  145256. }
  145257. declare module BABYLON {
  145258. /**
  145259. * A simplifier interface for future simplification implementations
  145260. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145261. */
  145262. export interface ISimplifier {
  145263. /**
  145264. * Simplification of a given mesh according to the given settings.
  145265. * Since this requires computation, it is assumed that the function runs async.
  145266. * @param settings The settings of the simplification, including quality and distance
  145267. * @param successCallback A callback that will be called after the mesh was simplified.
  145268. * @param errorCallback in case of an error, this callback will be called. optional.
  145269. */
  145270. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145271. }
  145272. /**
  145273. * Expected simplification settings.
  145274. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145275. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145276. */
  145277. export interface ISimplificationSettings {
  145278. /**
  145279. * Gets or sets the expected quality
  145280. */
  145281. quality: number;
  145282. /**
  145283. * Gets or sets the distance when this optimized version should be used
  145284. */
  145285. distance: number;
  145286. /**
  145287. * Gets an already optimized mesh
  145288. */
  145289. optimizeMesh?: boolean;
  145290. }
  145291. /**
  145292. * Class used to specify simplification options
  145293. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145294. */
  145295. export class SimplificationSettings implements ISimplificationSettings {
  145296. /** expected quality */
  145297. quality: number;
  145298. /** distance when this optimized version should be used */
  145299. distance: number;
  145300. /** already optimized mesh */
  145301. optimizeMesh?: boolean | undefined;
  145302. /**
  145303. * Creates a SimplificationSettings
  145304. * @param quality expected quality
  145305. * @param distance distance when this optimized version should be used
  145306. * @param optimizeMesh already optimized mesh
  145307. */
  145308. constructor(
  145309. /** expected quality */
  145310. quality: number,
  145311. /** distance when this optimized version should be used */
  145312. distance: number,
  145313. /** already optimized mesh */
  145314. optimizeMesh?: boolean | undefined);
  145315. }
  145316. /**
  145317. * Interface used to define a simplification task
  145318. */
  145319. export interface ISimplificationTask {
  145320. /**
  145321. * Array of settings
  145322. */
  145323. settings: Array<ISimplificationSettings>;
  145324. /**
  145325. * Simplification type
  145326. */
  145327. simplificationType: SimplificationType;
  145328. /**
  145329. * Mesh to simplify
  145330. */
  145331. mesh: Mesh;
  145332. /**
  145333. * Callback called on success
  145334. */
  145335. successCallback?: () => void;
  145336. /**
  145337. * Defines if parallel processing can be used
  145338. */
  145339. parallelProcessing: boolean;
  145340. }
  145341. /**
  145342. * Queue used to order the simplification tasks
  145343. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145344. */
  145345. export class SimplificationQueue {
  145346. private _simplificationArray;
  145347. /**
  145348. * Gets a boolean indicating that the process is still running
  145349. */
  145350. running: boolean;
  145351. /**
  145352. * Creates a new queue
  145353. */
  145354. constructor();
  145355. /**
  145356. * Adds a new simplification task
  145357. * @param task defines a task to add
  145358. */
  145359. addTask(task: ISimplificationTask): void;
  145360. /**
  145361. * Execute next task
  145362. */
  145363. executeNext(): void;
  145364. /**
  145365. * Execute a simplification task
  145366. * @param task defines the task to run
  145367. */
  145368. runSimplification(task: ISimplificationTask): void;
  145369. private getSimplifier;
  145370. }
  145371. /**
  145372. * The implemented types of simplification
  145373. * At the moment only Quadratic Error Decimation is implemented
  145374. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145375. */
  145376. export enum SimplificationType {
  145377. /** Quadratic error decimation */
  145378. QUADRATIC = 0
  145379. }
  145380. /**
  145381. * An implementation of the Quadratic Error simplification algorithm.
  145382. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145383. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145384. * @author RaananW
  145385. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145386. */
  145387. export class QuadraticErrorSimplification implements ISimplifier {
  145388. private _mesh;
  145389. private triangles;
  145390. private vertices;
  145391. private references;
  145392. private _reconstructedMesh;
  145393. /** Gets or sets the number pf sync interations */
  145394. syncIterations: number;
  145395. /** Gets or sets the aggressiveness of the simplifier */
  145396. aggressiveness: number;
  145397. /** Gets or sets the number of allowed iterations for decimation */
  145398. decimationIterations: number;
  145399. /** Gets or sets the espilon to use for bounding box computation */
  145400. boundingBoxEpsilon: number;
  145401. /**
  145402. * Creates a new QuadraticErrorSimplification
  145403. * @param _mesh defines the target mesh
  145404. */
  145405. constructor(_mesh: Mesh);
  145406. /**
  145407. * Simplification of a given mesh according to the given settings.
  145408. * Since this requires computation, it is assumed that the function runs async.
  145409. * @param settings The settings of the simplification, including quality and distance
  145410. * @param successCallback A callback that will be called after the mesh was simplified.
  145411. */
  145412. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145413. private runDecimation;
  145414. private initWithMesh;
  145415. private init;
  145416. private reconstructMesh;
  145417. private initDecimatedMesh;
  145418. private isFlipped;
  145419. private updateTriangles;
  145420. private identifyBorder;
  145421. private updateMesh;
  145422. private vertexError;
  145423. private calculateError;
  145424. }
  145425. }
  145426. declare module BABYLON {
  145427. interface Scene {
  145428. /** @hidden (Backing field) */
  145429. _simplificationQueue: SimplificationQueue;
  145430. /**
  145431. * Gets or sets the simplification queue attached to the scene
  145432. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145433. */
  145434. simplificationQueue: SimplificationQueue;
  145435. }
  145436. interface Mesh {
  145437. /**
  145438. * Simplify the mesh according to the given array of settings.
  145439. * Function will return immediately and will simplify async
  145440. * @param settings a collection of simplification settings
  145441. * @param parallelProcessing should all levels calculate parallel or one after the other
  145442. * @param simplificationType the type of simplification to run
  145443. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145444. * @returns the current mesh
  145445. */
  145446. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145447. }
  145448. /**
  145449. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145450. * created in a scene
  145451. */
  145452. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145453. /**
  145454. * The component name helpfull to identify the component in the list of scene components.
  145455. */
  145456. readonly name: string;
  145457. /**
  145458. * The scene the component belongs to.
  145459. */
  145460. scene: Scene;
  145461. /**
  145462. * Creates a new instance of the component for the given scene
  145463. * @param scene Defines the scene to register the component in
  145464. */
  145465. constructor(scene: Scene);
  145466. /**
  145467. * Registers the component in a given scene
  145468. */
  145469. register(): void;
  145470. /**
  145471. * Rebuilds the elements related to this component in case of
  145472. * context lost for instance.
  145473. */
  145474. rebuild(): void;
  145475. /**
  145476. * Disposes the component and the associated ressources
  145477. */
  145478. dispose(): void;
  145479. private _beforeCameraUpdate;
  145480. }
  145481. }
  145482. declare module BABYLON {
  145483. interface Mesh {
  145484. /**
  145485. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145486. */
  145487. thinInstanceEnablePicking: boolean;
  145488. /**
  145489. * Creates a new thin instance
  145490. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145491. * @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
  145492. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145493. */
  145494. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145495. /**
  145496. * Adds the transformation (matrix) of the current mesh as a thin instance
  145497. * @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
  145498. * @returns the thin instance index number
  145499. */
  145500. thinInstanceAddSelf(refresh: boolean): number;
  145501. /**
  145502. * Registers a custom attribute to be used with thin instances
  145503. * @param kind name of the attribute
  145504. * @param stride size in floats of the attribute
  145505. */
  145506. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145507. /**
  145508. * Sets the matrix of a thin instance
  145509. * @param index index of the thin instance
  145510. * @param matrix matrix to set
  145511. * @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
  145512. */
  145513. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145514. /**
  145515. * Sets the value of a custom attribute for a thin instance
  145516. * @param kind name of the attribute
  145517. * @param index index of the thin instance
  145518. * @param value value to set
  145519. * @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
  145520. */
  145521. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145522. /**
  145523. * 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.
  145524. */
  145525. thinInstanceCount: number;
  145526. /**
  145527. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145528. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145529. * @param buffer buffer to set
  145530. * @param stride size in floats of each value of the buffer
  145531. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145532. */
  145533. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145534. /**
  145535. * Gets the list of world matrices
  145536. * @return an array containing all the world matrices from the thin instances
  145537. */
  145538. thinInstanceGetWorldMatrices(): Matrix[];
  145539. /**
  145540. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145541. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145542. */
  145543. thinInstanceBufferUpdated(kind: string): void;
  145544. /**
  145545. * Refreshes the bounding info, taking into account all the thin instances defined
  145546. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145547. */
  145548. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145549. /** @hidden */
  145550. _thinInstanceInitializeUserStorage(): void;
  145551. /** @hidden */
  145552. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145553. /** @hidden */
  145554. _userThinInstanceBuffersStorage: {
  145555. data: {
  145556. [key: string]: Float32Array;
  145557. };
  145558. sizes: {
  145559. [key: string]: number;
  145560. };
  145561. vertexBuffers: {
  145562. [key: string]: Nullable<VertexBuffer>;
  145563. };
  145564. strides: {
  145565. [key: string]: number;
  145566. };
  145567. };
  145568. }
  145569. }
  145570. declare module BABYLON {
  145571. /**
  145572. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145573. */
  145574. export interface INavigationEnginePlugin {
  145575. /**
  145576. * plugin name
  145577. */
  145578. name: string;
  145579. /**
  145580. * Creates a navigation mesh
  145581. * @param meshes array of all the geometry used to compute the navigatio mesh
  145582. * @param parameters bunch of parameters used to filter geometry
  145583. */
  145584. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145585. /**
  145586. * Create a navigation mesh debug mesh
  145587. * @param scene is where the mesh will be added
  145588. * @returns debug display mesh
  145589. */
  145590. createDebugNavMesh(scene: Scene): Mesh;
  145591. /**
  145592. * Get a navigation mesh constrained position, closest to the parameter position
  145593. * @param position world position
  145594. * @returns the closest point to position constrained by the navigation mesh
  145595. */
  145596. getClosestPoint(position: Vector3): Vector3;
  145597. /**
  145598. * Get a navigation mesh constrained position, closest to the parameter position
  145599. * @param position world position
  145600. * @param result output the closest point to position constrained by the navigation mesh
  145601. */
  145602. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145603. /**
  145604. * Get a navigation mesh constrained position, within a particular radius
  145605. * @param position world position
  145606. * @param maxRadius the maximum distance to the constrained world position
  145607. * @returns the closest point to position constrained by the navigation mesh
  145608. */
  145609. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145610. /**
  145611. * Get a navigation mesh constrained position, within a particular radius
  145612. * @param position world position
  145613. * @param maxRadius the maximum distance to the constrained world position
  145614. * @param result output the closest point to position constrained by the navigation mesh
  145615. */
  145616. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145617. /**
  145618. * Compute the final position from a segment made of destination-position
  145619. * @param position world position
  145620. * @param destination world position
  145621. * @returns the resulting point along the navmesh
  145622. */
  145623. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145624. /**
  145625. * Compute the final position from a segment made of destination-position
  145626. * @param position world position
  145627. * @param destination world position
  145628. * @param result output the resulting point along the navmesh
  145629. */
  145630. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145631. /**
  145632. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145633. * @param start world position
  145634. * @param end world position
  145635. * @returns array containing world position composing the path
  145636. */
  145637. computePath(start: Vector3, end: Vector3): Vector3[];
  145638. /**
  145639. * If this plugin is supported
  145640. * @returns true if plugin is supported
  145641. */
  145642. isSupported(): boolean;
  145643. /**
  145644. * Create a new Crowd so you can add agents
  145645. * @param maxAgents the maximum agent count in the crowd
  145646. * @param maxAgentRadius the maximum radius an agent can have
  145647. * @param scene to attach the crowd to
  145648. * @returns the crowd you can add agents to
  145649. */
  145650. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145651. /**
  145652. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145653. * The queries will try to find a solution within those bounds
  145654. * default is (1,1,1)
  145655. * @param extent x,y,z value that define the extent around the queries point of reference
  145656. */
  145657. setDefaultQueryExtent(extent: Vector3): void;
  145658. /**
  145659. * Get the Bounding box extent specified by setDefaultQueryExtent
  145660. * @returns the box extent values
  145661. */
  145662. getDefaultQueryExtent(): Vector3;
  145663. /**
  145664. * build the navmesh from a previously saved state using getNavmeshData
  145665. * @param data the Uint8Array returned by getNavmeshData
  145666. */
  145667. buildFromNavmeshData(data: Uint8Array): void;
  145668. /**
  145669. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145670. * @returns data the Uint8Array that can be saved and reused
  145671. */
  145672. getNavmeshData(): Uint8Array;
  145673. /**
  145674. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145675. * @param result output the box extent values
  145676. */
  145677. getDefaultQueryExtentToRef(result: Vector3): void;
  145678. /**
  145679. * Release all resources
  145680. */
  145681. dispose(): void;
  145682. }
  145683. /**
  145684. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145685. */
  145686. export interface ICrowd {
  145687. /**
  145688. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145689. * You can attach anything to that node. The node position is updated in the scene update tick.
  145690. * @param pos world position that will be constrained by the navigation mesh
  145691. * @param parameters agent parameters
  145692. * @param transform hooked to the agent that will be update by the scene
  145693. * @returns agent index
  145694. */
  145695. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145696. /**
  145697. * Returns the agent position in world space
  145698. * @param index agent index returned by addAgent
  145699. * @returns world space position
  145700. */
  145701. getAgentPosition(index: number): Vector3;
  145702. /**
  145703. * Gets the agent position result in world space
  145704. * @param index agent index returned by addAgent
  145705. * @param result output world space position
  145706. */
  145707. getAgentPositionToRef(index: number, result: Vector3): void;
  145708. /**
  145709. * Gets the agent velocity in world space
  145710. * @param index agent index returned by addAgent
  145711. * @returns world space velocity
  145712. */
  145713. getAgentVelocity(index: number): Vector3;
  145714. /**
  145715. * Gets the agent velocity result in world space
  145716. * @param index agent index returned by addAgent
  145717. * @param result output world space velocity
  145718. */
  145719. getAgentVelocityToRef(index: number, result: Vector3): void;
  145720. /**
  145721. * remove a particular agent previously created
  145722. * @param index agent index returned by addAgent
  145723. */
  145724. removeAgent(index: number): void;
  145725. /**
  145726. * get the list of all agents attached to this crowd
  145727. * @returns list of agent indices
  145728. */
  145729. getAgents(): number[];
  145730. /**
  145731. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145732. * @param deltaTime in seconds
  145733. */
  145734. update(deltaTime: number): void;
  145735. /**
  145736. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145737. * @param index agent index returned by addAgent
  145738. * @param destination targeted world position
  145739. */
  145740. agentGoto(index: number, destination: Vector3): void;
  145741. /**
  145742. * Teleport the agent to a new position
  145743. * @param index agent index returned by addAgent
  145744. * @param destination targeted world position
  145745. */
  145746. agentTeleport(index: number, destination: Vector3): void;
  145747. /**
  145748. * Update agent parameters
  145749. * @param index agent index returned by addAgent
  145750. * @param parameters agent parameters
  145751. */
  145752. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145753. /**
  145754. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145755. * The queries will try to find a solution within those bounds
  145756. * default is (1,1,1)
  145757. * @param extent x,y,z value that define the extent around the queries point of reference
  145758. */
  145759. setDefaultQueryExtent(extent: Vector3): void;
  145760. /**
  145761. * Get the Bounding box extent specified by setDefaultQueryExtent
  145762. * @returns the box extent values
  145763. */
  145764. getDefaultQueryExtent(): Vector3;
  145765. /**
  145766. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145767. * @param result output the box extent values
  145768. */
  145769. getDefaultQueryExtentToRef(result: Vector3): void;
  145770. /**
  145771. * Release all resources
  145772. */
  145773. dispose(): void;
  145774. }
  145775. /**
  145776. * Configures an agent
  145777. */
  145778. export interface IAgentParameters {
  145779. /**
  145780. * Agent radius. [Limit: >= 0]
  145781. */
  145782. radius: number;
  145783. /**
  145784. * Agent height. [Limit: > 0]
  145785. */
  145786. height: number;
  145787. /**
  145788. * Maximum allowed acceleration. [Limit: >= 0]
  145789. */
  145790. maxAcceleration: number;
  145791. /**
  145792. * Maximum allowed speed. [Limit: >= 0]
  145793. */
  145794. maxSpeed: number;
  145795. /**
  145796. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145797. */
  145798. collisionQueryRange: number;
  145799. /**
  145800. * The path visibility optimization range. [Limit: > 0]
  145801. */
  145802. pathOptimizationRange: number;
  145803. /**
  145804. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145805. */
  145806. separationWeight: number;
  145807. }
  145808. /**
  145809. * Configures the navigation mesh creation
  145810. */
  145811. export interface INavMeshParameters {
  145812. /**
  145813. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145814. */
  145815. cs: number;
  145816. /**
  145817. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145818. */
  145819. ch: number;
  145820. /**
  145821. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145822. */
  145823. walkableSlopeAngle: number;
  145824. /**
  145825. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145826. * be considered walkable. [Limit: >= 3] [Units: vx]
  145827. */
  145828. walkableHeight: number;
  145829. /**
  145830. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145831. */
  145832. walkableClimb: number;
  145833. /**
  145834. * The distance to erode/shrink the walkable area of the heightfield away from
  145835. * obstructions. [Limit: >=0] [Units: vx]
  145836. */
  145837. walkableRadius: number;
  145838. /**
  145839. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145840. */
  145841. maxEdgeLen: number;
  145842. /**
  145843. * The maximum distance a simplfied contour's border edges should deviate
  145844. * the original raw contour. [Limit: >=0] [Units: vx]
  145845. */
  145846. maxSimplificationError: number;
  145847. /**
  145848. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145849. */
  145850. minRegionArea: number;
  145851. /**
  145852. * Any regions with a span count smaller than this value will, if possible,
  145853. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145854. */
  145855. mergeRegionArea: number;
  145856. /**
  145857. * The maximum number of vertices allowed for polygons generated during the
  145858. * contour to polygon conversion process. [Limit: >= 3]
  145859. */
  145860. maxVertsPerPoly: number;
  145861. /**
  145862. * Sets the sampling distance to use when generating the detail mesh.
  145863. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145864. */
  145865. detailSampleDist: number;
  145866. /**
  145867. * The maximum distance the detail mesh surface should deviate from heightfield
  145868. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145869. */
  145870. detailSampleMaxError: number;
  145871. }
  145872. }
  145873. declare module BABYLON {
  145874. /**
  145875. * RecastJS navigation plugin
  145876. */
  145877. export class RecastJSPlugin implements INavigationEnginePlugin {
  145878. /**
  145879. * Reference to the Recast library
  145880. */
  145881. bjsRECAST: any;
  145882. /**
  145883. * plugin name
  145884. */
  145885. name: string;
  145886. /**
  145887. * the first navmesh created. We might extend this to support multiple navmeshes
  145888. */
  145889. navMesh: any;
  145890. /**
  145891. * Initializes the recastJS plugin
  145892. * @param recastInjection can be used to inject your own recast reference
  145893. */
  145894. constructor(recastInjection?: any);
  145895. /**
  145896. * Creates a navigation mesh
  145897. * @param meshes array of all the geometry used to compute the navigatio mesh
  145898. * @param parameters bunch of parameters used to filter geometry
  145899. */
  145900. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145901. /**
  145902. * Create a navigation mesh debug mesh
  145903. * @param scene is where the mesh will be added
  145904. * @returns debug display mesh
  145905. */
  145906. createDebugNavMesh(scene: Scene): Mesh;
  145907. /**
  145908. * Get a navigation mesh constrained position, closest to the parameter position
  145909. * @param position world position
  145910. * @returns the closest point to position constrained by the navigation mesh
  145911. */
  145912. getClosestPoint(position: Vector3): Vector3;
  145913. /**
  145914. * Get a navigation mesh constrained position, closest to the parameter position
  145915. * @param position world position
  145916. * @param result output the closest point to position constrained by the navigation mesh
  145917. */
  145918. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145919. /**
  145920. * Get a navigation mesh constrained position, within a particular radius
  145921. * @param position world position
  145922. * @param maxRadius the maximum distance to the constrained world position
  145923. * @returns the closest point to position constrained by the navigation mesh
  145924. */
  145925. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145926. /**
  145927. * Get a navigation mesh constrained position, within a particular radius
  145928. * @param position world position
  145929. * @param maxRadius the maximum distance to the constrained world position
  145930. * @param result output the closest point to position constrained by the navigation mesh
  145931. */
  145932. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145933. /**
  145934. * Compute the final position from a segment made of destination-position
  145935. * @param position world position
  145936. * @param destination world position
  145937. * @returns the resulting point along the navmesh
  145938. */
  145939. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145940. /**
  145941. * Compute the final position from a segment made of destination-position
  145942. * @param position world position
  145943. * @param destination world position
  145944. * @param result output the resulting point along the navmesh
  145945. */
  145946. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145947. /**
  145948. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145949. * @param start world position
  145950. * @param end world position
  145951. * @returns array containing world position composing the path
  145952. */
  145953. computePath(start: Vector3, end: Vector3): Vector3[];
  145954. /**
  145955. * Create a new Crowd so you can add agents
  145956. * @param maxAgents the maximum agent count in the crowd
  145957. * @param maxAgentRadius the maximum radius an agent can have
  145958. * @param scene to attach the crowd to
  145959. * @returns the crowd you can add agents to
  145960. */
  145961. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145962. /**
  145963. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145964. * The queries will try to find a solution within those bounds
  145965. * default is (1,1,1)
  145966. * @param extent x,y,z value that define the extent around the queries point of reference
  145967. */
  145968. setDefaultQueryExtent(extent: Vector3): void;
  145969. /**
  145970. * Get the Bounding box extent specified by setDefaultQueryExtent
  145971. * @returns the box extent values
  145972. */
  145973. getDefaultQueryExtent(): Vector3;
  145974. /**
  145975. * build the navmesh from a previously saved state using getNavmeshData
  145976. * @param data the Uint8Array returned by getNavmeshData
  145977. */
  145978. buildFromNavmeshData(data: Uint8Array): void;
  145979. /**
  145980. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145981. * @returns data the Uint8Array that can be saved and reused
  145982. */
  145983. getNavmeshData(): Uint8Array;
  145984. /**
  145985. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145986. * @param result output the box extent values
  145987. */
  145988. getDefaultQueryExtentToRef(result: Vector3): void;
  145989. /**
  145990. * Disposes
  145991. */
  145992. dispose(): void;
  145993. /**
  145994. * If this plugin is supported
  145995. * @returns true if plugin is supported
  145996. */
  145997. isSupported(): boolean;
  145998. }
  145999. /**
  146000. * Recast detour crowd implementation
  146001. */
  146002. export class RecastJSCrowd implements ICrowd {
  146003. /**
  146004. * Recast/detour plugin
  146005. */
  146006. bjsRECASTPlugin: RecastJSPlugin;
  146007. /**
  146008. * Link to the detour crowd
  146009. */
  146010. recastCrowd: any;
  146011. /**
  146012. * One transform per agent
  146013. */
  146014. transforms: TransformNode[];
  146015. /**
  146016. * All agents created
  146017. */
  146018. agents: number[];
  146019. /**
  146020. * Link to the scene is kept to unregister the crowd from the scene
  146021. */
  146022. private _scene;
  146023. /**
  146024. * Observer for crowd updates
  146025. */
  146026. private _onBeforeAnimationsObserver;
  146027. /**
  146028. * Constructor
  146029. * @param plugin recastJS plugin
  146030. * @param maxAgents the maximum agent count in the crowd
  146031. * @param maxAgentRadius the maximum radius an agent can have
  146032. * @param scene to attach the crowd to
  146033. * @returns the crowd you can add agents to
  146034. */
  146035. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  146036. /**
  146037. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146038. * You can attach anything to that node. The node position is updated in the scene update tick.
  146039. * @param pos world position that will be constrained by the navigation mesh
  146040. * @param parameters agent parameters
  146041. * @param transform hooked to the agent that will be update by the scene
  146042. * @returns agent index
  146043. */
  146044. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146045. /**
  146046. * Returns the agent position in world space
  146047. * @param index agent index returned by addAgent
  146048. * @returns world space position
  146049. */
  146050. getAgentPosition(index: number): Vector3;
  146051. /**
  146052. * Returns the agent position result in world space
  146053. * @param index agent index returned by addAgent
  146054. * @param result output world space position
  146055. */
  146056. getAgentPositionToRef(index: number, result: Vector3): void;
  146057. /**
  146058. * Returns the agent velocity in world space
  146059. * @param index agent index returned by addAgent
  146060. * @returns world space velocity
  146061. */
  146062. getAgentVelocity(index: number): Vector3;
  146063. /**
  146064. * Returns the agent velocity result in world space
  146065. * @param index agent index returned by addAgent
  146066. * @param result output world space velocity
  146067. */
  146068. getAgentVelocityToRef(index: number, result: Vector3): void;
  146069. /**
  146070. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146071. * @param index agent index returned by addAgent
  146072. * @param destination targeted world position
  146073. */
  146074. agentGoto(index: number, destination: Vector3): void;
  146075. /**
  146076. * Teleport the agent to a new position
  146077. * @param index agent index returned by addAgent
  146078. * @param destination targeted world position
  146079. */
  146080. agentTeleport(index: number, destination: Vector3): void;
  146081. /**
  146082. * Update agent parameters
  146083. * @param index agent index returned by addAgent
  146084. * @param parameters agent parameters
  146085. */
  146086. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146087. /**
  146088. * remove a particular agent previously created
  146089. * @param index agent index returned by addAgent
  146090. */
  146091. removeAgent(index: number): void;
  146092. /**
  146093. * get the list of all agents attached to this crowd
  146094. * @returns list of agent indices
  146095. */
  146096. getAgents(): number[];
  146097. /**
  146098. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146099. * @param deltaTime in seconds
  146100. */
  146101. update(deltaTime: number): void;
  146102. /**
  146103. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146104. * The queries will try to find a solution within those bounds
  146105. * default is (1,1,1)
  146106. * @param extent x,y,z value that define the extent around the queries point of reference
  146107. */
  146108. setDefaultQueryExtent(extent: Vector3): void;
  146109. /**
  146110. * Get the Bounding box extent specified by setDefaultQueryExtent
  146111. * @returns the box extent values
  146112. */
  146113. getDefaultQueryExtent(): Vector3;
  146114. /**
  146115. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146116. * @param result output the box extent values
  146117. */
  146118. getDefaultQueryExtentToRef(result: Vector3): void;
  146119. /**
  146120. * Release all resources
  146121. */
  146122. dispose(): void;
  146123. }
  146124. }
  146125. declare module BABYLON {
  146126. /**
  146127. * Class used to enable access to IndexedDB
  146128. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  146129. */
  146130. export class Database implements IOfflineProvider {
  146131. private _callbackManifestChecked;
  146132. private _currentSceneUrl;
  146133. private _db;
  146134. private _enableSceneOffline;
  146135. private _enableTexturesOffline;
  146136. private _manifestVersionFound;
  146137. private _mustUpdateRessources;
  146138. private _hasReachedQuota;
  146139. private _isSupported;
  146140. private _idbFactory;
  146141. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  146142. private static IsUASupportingBlobStorage;
  146143. /**
  146144. * Gets a boolean indicating if Database storate is enabled (off by default)
  146145. */
  146146. static IDBStorageEnabled: boolean;
  146147. /**
  146148. * Gets a boolean indicating if scene must be saved in the database
  146149. */
  146150. get enableSceneOffline(): boolean;
  146151. /**
  146152. * Gets a boolean indicating if textures must be saved in the database
  146153. */
  146154. get enableTexturesOffline(): boolean;
  146155. /**
  146156. * Creates a new Database
  146157. * @param urlToScene defines the url to load the scene
  146158. * @param callbackManifestChecked defines the callback to use when manifest is checked
  146159. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  146160. */
  146161. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  146162. private static _ParseURL;
  146163. private static _ReturnFullUrlLocation;
  146164. private _checkManifestFile;
  146165. /**
  146166. * Open the database and make it available
  146167. * @param successCallback defines the callback to call on success
  146168. * @param errorCallback defines the callback to call on error
  146169. */
  146170. open(successCallback: () => void, errorCallback: () => void): void;
  146171. /**
  146172. * Loads an image from the database
  146173. * @param url defines the url to load from
  146174. * @param image defines the target DOM image
  146175. */
  146176. loadImage(url: string, image: HTMLImageElement): void;
  146177. private _loadImageFromDBAsync;
  146178. private _saveImageIntoDBAsync;
  146179. private _checkVersionFromDB;
  146180. private _loadVersionFromDBAsync;
  146181. private _saveVersionIntoDBAsync;
  146182. /**
  146183. * Loads a file from database
  146184. * @param url defines the URL to load from
  146185. * @param sceneLoaded defines a callback to call on success
  146186. * @param progressCallBack defines a callback to call when progress changed
  146187. * @param errorCallback defines a callback to call on error
  146188. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  146189. */
  146190. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  146191. private _loadFileAsync;
  146192. private _saveFileAsync;
  146193. /**
  146194. * Validates if xhr data is correct
  146195. * @param xhr defines the request to validate
  146196. * @param dataType defines the expected data type
  146197. * @returns true if data is correct
  146198. */
  146199. private static _ValidateXHRData;
  146200. }
  146201. }
  146202. declare module BABYLON {
  146203. /** @hidden */
  146204. export var gpuUpdateParticlesPixelShader: {
  146205. name: string;
  146206. shader: string;
  146207. };
  146208. }
  146209. declare module BABYLON {
  146210. /** @hidden */
  146211. export var gpuUpdateParticlesVertexShader: {
  146212. name: string;
  146213. shader: string;
  146214. };
  146215. }
  146216. declare module BABYLON {
  146217. /** @hidden */
  146218. export var clipPlaneFragmentDeclaration2: {
  146219. name: string;
  146220. shader: string;
  146221. };
  146222. }
  146223. declare module BABYLON {
  146224. /** @hidden */
  146225. export var gpuRenderParticlesPixelShader: {
  146226. name: string;
  146227. shader: string;
  146228. };
  146229. }
  146230. declare module BABYLON {
  146231. /** @hidden */
  146232. export var clipPlaneVertexDeclaration2: {
  146233. name: string;
  146234. shader: string;
  146235. };
  146236. }
  146237. declare module BABYLON {
  146238. /** @hidden */
  146239. export var gpuRenderParticlesVertexShader: {
  146240. name: string;
  146241. shader: string;
  146242. };
  146243. }
  146244. declare module BABYLON {
  146245. /**
  146246. * This represents a GPU particle system in Babylon
  146247. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146248. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146249. */
  146250. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146251. /**
  146252. * The layer mask we are rendering the particles through.
  146253. */
  146254. layerMask: number;
  146255. private _capacity;
  146256. private _activeCount;
  146257. private _currentActiveCount;
  146258. private _accumulatedCount;
  146259. private _renderEffect;
  146260. private _updateEffect;
  146261. private _buffer0;
  146262. private _buffer1;
  146263. private _spriteBuffer;
  146264. private _updateVAO;
  146265. private _renderVAO;
  146266. private _targetIndex;
  146267. private _sourceBuffer;
  146268. private _targetBuffer;
  146269. private _currentRenderId;
  146270. private _started;
  146271. private _stopped;
  146272. private _timeDelta;
  146273. private _randomTexture;
  146274. private _randomTexture2;
  146275. private _attributesStrideSize;
  146276. private _updateEffectOptions;
  146277. private _randomTextureSize;
  146278. private _actualFrame;
  146279. private _customEffect;
  146280. private readonly _rawTextureWidth;
  146281. /**
  146282. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146283. */
  146284. static get IsSupported(): boolean;
  146285. /**
  146286. * An event triggered when the system is disposed.
  146287. */
  146288. onDisposeObservable: Observable<IParticleSystem>;
  146289. /**
  146290. * Gets the maximum number of particles active at the same time.
  146291. * @returns The max number of active particles.
  146292. */
  146293. getCapacity(): number;
  146294. /**
  146295. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146296. * to override the particles.
  146297. */
  146298. forceDepthWrite: boolean;
  146299. /**
  146300. * Gets or set the number of active particles
  146301. */
  146302. get activeParticleCount(): number;
  146303. set activeParticleCount(value: number);
  146304. private _preWarmDone;
  146305. /**
  146306. * Specifies if the particles are updated in emitter local space or world space.
  146307. */
  146308. isLocal: boolean;
  146309. /** Gets or sets a matrix to use to compute projection */
  146310. defaultProjectionMatrix: Matrix;
  146311. /**
  146312. * Is this system ready to be used/rendered
  146313. * @return true if the system is ready
  146314. */
  146315. isReady(): boolean;
  146316. /**
  146317. * Gets if the system has been started. (Note: this will still be true after stop is called)
  146318. * @returns True if it has been started, otherwise false.
  146319. */
  146320. isStarted(): boolean;
  146321. /**
  146322. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  146323. * @returns True if it has been stopped, otherwise false.
  146324. */
  146325. isStopped(): boolean;
  146326. /**
  146327. * Gets a boolean indicating that the system is stopping
  146328. * @returns true if the system is currently stopping
  146329. */
  146330. isStopping(): boolean;
  146331. /**
  146332. * Gets the number of particles active at the same time.
  146333. * @returns The number of active particles.
  146334. */
  146335. getActiveCount(): number;
  146336. /**
  146337. * Starts the particle system and begins to emit
  146338. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  146339. */
  146340. start(delay?: number): void;
  146341. /**
  146342. * Stops the particle system.
  146343. */
  146344. stop(): void;
  146345. /**
  146346. * Remove all active particles
  146347. */
  146348. reset(): void;
  146349. /**
  146350. * Returns the string "GPUParticleSystem"
  146351. * @returns a string containing the class name
  146352. */
  146353. getClassName(): string;
  146354. /**
  146355. * Gets the custom effect used to render the particles
  146356. * @param blendMode Blend mode for which the effect should be retrieved
  146357. * @returns The effect
  146358. */
  146359. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146360. /**
  146361. * Sets the custom effect used to render the particles
  146362. * @param effect The effect to set
  146363. * @param blendMode Blend mode for which the effect should be set
  146364. */
  146365. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146366. /** @hidden */
  146367. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146368. /**
  146369. * Observable that will be called just before the particles are drawn
  146370. */
  146371. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146372. /**
  146373. * Gets the name of the particle vertex shader
  146374. */
  146375. get vertexShaderName(): string;
  146376. private _colorGradientsTexture;
  146377. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146378. /**
  146379. * Adds a new color gradient
  146380. * @param gradient defines the gradient to use (between 0 and 1)
  146381. * @param color1 defines the color to affect to the specified gradient
  146382. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146383. * @returns the current particle system
  146384. */
  146385. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146386. private _refreshColorGradient;
  146387. /** Force the system to rebuild all gradients that need to be resync */
  146388. forceRefreshGradients(): void;
  146389. /**
  146390. * Remove a specific color gradient
  146391. * @param gradient defines the gradient to remove
  146392. * @returns the current particle system
  146393. */
  146394. removeColorGradient(gradient: number): GPUParticleSystem;
  146395. private _angularSpeedGradientsTexture;
  146396. private _sizeGradientsTexture;
  146397. private _velocityGradientsTexture;
  146398. private _limitVelocityGradientsTexture;
  146399. private _dragGradientsTexture;
  146400. private _addFactorGradient;
  146401. /**
  146402. * Adds a new size gradient
  146403. * @param gradient defines the gradient to use (between 0 and 1)
  146404. * @param factor defines the size factor to affect to the specified gradient
  146405. * @returns the current particle system
  146406. */
  146407. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146408. /**
  146409. * Remove a specific size gradient
  146410. * @param gradient defines the gradient to remove
  146411. * @returns the current particle system
  146412. */
  146413. removeSizeGradient(gradient: number): GPUParticleSystem;
  146414. private _refreshFactorGradient;
  146415. /**
  146416. * Adds a new angular speed gradient
  146417. * @param gradient defines the gradient to use (between 0 and 1)
  146418. * @param factor defines the angular speed to affect to the specified gradient
  146419. * @returns the current particle system
  146420. */
  146421. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146422. /**
  146423. * Remove a specific angular speed gradient
  146424. * @param gradient defines the gradient to remove
  146425. * @returns the current particle system
  146426. */
  146427. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146428. /**
  146429. * Adds a new velocity gradient
  146430. * @param gradient defines the gradient to use (between 0 and 1)
  146431. * @param factor defines the velocity to affect to the specified gradient
  146432. * @returns the current particle system
  146433. */
  146434. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146435. /**
  146436. * Remove a specific velocity gradient
  146437. * @param gradient defines the gradient to remove
  146438. * @returns the current particle system
  146439. */
  146440. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146441. /**
  146442. * Adds a new limit velocity gradient
  146443. * @param gradient defines the gradient to use (between 0 and 1)
  146444. * @param factor defines the limit velocity value to affect to the specified gradient
  146445. * @returns the current particle system
  146446. */
  146447. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146448. /**
  146449. * Remove a specific limit velocity gradient
  146450. * @param gradient defines the gradient to remove
  146451. * @returns the current particle system
  146452. */
  146453. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146454. /**
  146455. * Adds a new drag gradient
  146456. * @param gradient defines the gradient to use (between 0 and 1)
  146457. * @param factor defines the drag value to affect to the specified gradient
  146458. * @returns the current particle system
  146459. */
  146460. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146461. /**
  146462. * Remove a specific drag gradient
  146463. * @param gradient defines the gradient to remove
  146464. * @returns the current particle system
  146465. */
  146466. removeDragGradient(gradient: number): GPUParticleSystem;
  146467. /**
  146468. * Not supported by GPUParticleSystem
  146469. * @param gradient defines the gradient to use (between 0 and 1)
  146470. * @param factor defines the emit rate value to affect to the specified gradient
  146471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146472. * @returns the current particle system
  146473. */
  146474. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146475. /**
  146476. * Not supported by GPUParticleSystem
  146477. * @param gradient defines the gradient to remove
  146478. * @returns the current particle system
  146479. */
  146480. removeEmitRateGradient(gradient: number): IParticleSystem;
  146481. /**
  146482. * Not supported by GPUParticleSystem
  146483. * @param gradient defines the gradient to use (between 0 and 1)
  146484. * @param factor defines the start size value to affect to the specified gradient
  146485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146486. * @returns the current particle system
  146487. */
  146488. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146489. /**
  146490. * Not supported by GPUParticleSystem
  146491. * @param gradient defines the gradient to remove
  146492. * @returns the current particle system
  146493. */
  146494. removeStartSizeGradient(gradient: number): IParticleSystem;
  146495. /**
  146496. * Not supported by GPUParticleSystem
  146497. * @param gradient defines the gradient to use (between 0 and 1)
  146498. * @param min defines the color remap minimal range
  146499. * @param max defines the color remap maximal range
  146500. * @returns the current particle system
  146501. */
  146502. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146503. /**
  146504. * Not supported by GPUParticleSystem
  146505. * @param gradient defines the gradient to remove
  146506. * @returns the current particle system
  146507. */
  146508. removeColorRemapGradient(): IParticleSystem;
  146509. /**
  146510. * Not supported by GPUParticleSystem
  146511. * @param gradient defines the gradient to use (between 0 and 1)
  146512. * @param min defines the alpha remap minimal range
  146513. * @param max defines the alpha remap maximal range
  146514. * @returns the current particle system
  146515. */
  146516. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146517. /**
  146518. * Not supported by GPUParticleSystem
  146519. * @param gradient defines the gradient to remove
  146520. * @returns the current particle system
  146521. */
  146522. removeAlphaRemapGradient(): IParticleSystem;
  146523. /**
  146524. * Not supported by GPUParticleSystem
  146525. * @param gradient defines the gradient to use (between 0 and 1)
  146526. * @param color defines the color to affect to the specified gradient
  146527. * @returns the current particle system
  146528. */
  146529. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146530. /**
  146531. * Not supported by GPUParticleSystem
  146532. * @param gradient defines the gradient to remove
  146533. * @returns the current particle system
  146534. */
  146535. removeRampGradient(): IParticleSystem;
  146536. /**
  146537. * Not supported by GPUParticleSystem
  146538. * @returns the list of ramp gradients
  146539. */
  146540. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146541. /**
  146542. * Not supported by GPUParticleSystem
  146543. * Gets or sets a boolean indicating that ramp gradients must be used
  146544. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146545. */
  146546. get useRampGradients(): boolean;
  146547. set useRampGradients(value: boolean);
  146548. /**
  146549. * Not supported by GPUParticleSystem
  146550. * @param gradient defines the gradient to use (between 0 and 1)
  146551. * @param factor defines the life time factor to affect to the specified gradient
  146552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146553. * @returns the current particle system
  146554. */
  146555. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146556. /**
  146557. * Not supported by GPUParticleSystem
  146558. * @param gradient defines the gradient to remove
  146559. * @returns the current particle system
  146560. */
  146561. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146562. /**
  146563. * Instantiates a GPU particle system.
  146564. * 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.
  146565. * @param name The name of the particle system
  146566. * @param options The options used to create the system
  146567. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  146568. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146569. * @param customEffect a custom effect used to change the way particles are rendered by default
  146570. */
  146571. constructor(name: string, options: Partial<{
  146572. capacity: number;
  146573. randomTextureSize: number;
  146574. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146575. protected _reset(): void;
  146576. private _createUpdateVAO;
  146577. private _createRenderVAO;
  146578. private _initialize;
  146579. /** @hidden */
  146580. _recreateUpdateEffect(): void;
  146581. private _getEffect;
  146582. /**
  146583. * Fill the defines array according to the current settings of the particle system
  146584. * @param defines Array to be updated
  146585. * @param blendMode blend mode to take into account when updating the array
  146586. */
  146587. fillDefines(defines: Array<string>, blendMode?: number): void;
  146588. /**
  146589. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146590. * @param uniforms Uniforms array to fill
  146591. * @param attributes Attributes array to fill
  146592. * @param samplers Samplers array to fill
  146593. */
  146594. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146595. /** @hidden */
  146596. _recreateRenderEffect(): Effect;
  146597. /**
  146598. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146599. * @param preWarm defines if we are in the pre-warmimg phase
  146600. */
  146601. animate(preWarm?: boolean): void;
  146602. private _createFactorGradientTexture;
  146603. private _createSizeGradientTexture;
  146604. private _createAngularSpeedGradientTexture;
  146605. private _createVelocityGradientTexture;
  146606. private _createLimitVelocityGradientTexture;
  146607. private _createDragGradientTexture;
  146608. private _createColorGradientTexture;
  146609. /**
  146610. * Renders the particle system in its current state
  146611. * @param preWarm defines if the system should only update the particles but not render them
  146612. * @returns the current number of particles
  146613. */
  146614. render(preWarm?: boolean): number;
  146615. /**
  146616. * Rebuilds the particle system
  146617. */
  146618. rebuild(): void;
  146619. private _releaseBuffers;
  146620. private _releaseVAOs;
  146621. /**
  146622. * Disposes the particle system and free the associated resources
  146623. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146624. */
  146625. dispose(disposeTexture?: boolean): void;
  146626. /**
  146627. * Clones the particle system.
  146628. * @param name The name of the cloned object
  146629. * @param newEmitter The new emitter to use
  146630. * @returns the cloned particle system
  146631. */
  146632. clone(name: string, newEmitter: any): GPUParticleSystem;
  146633. /**
  146634. * Serializes the particle system to a JSON object
  146635. * @param serializeTexture defines if the texture must be serialized as well
  146636. * @returns the JSON object
  146637. */
  146638. serialize(serializeTexture?: boolean): any;
  146639. /**
  146640. * Parses a JSON object to create a GPU particle system.
  146641. * @param parsedParticleSystem The JSON object to parse
  146642. * @param sceneOrEngine The scene or the engine to create the particle system in
  146643. * @param rootUrl The root url to use to load external dependencies like texture
  146644. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146645. * @returns the parsed GPU particle system
  146646. */
  146647. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146648. }
  146649. }
  146650. declare module BABYLON {
  146651. /**
  146652. * Represents a set of particle systems working together to create a specific effect
  146653. */
  146654. export class ParticleSystemSet implements IDisposable {
  146655. /**
  146656. * Gets or sets base Assets URL
  146657. */
  146658. static BaseAssetsUrl: string;
  146659. private _emitterCreationOptions;
  146660. private _emitterNode;
  146661. /**
  146662. * Gets the particle system list
  146663. */
  146664. systems: IParticleSystem[];
  146665. /**
  146666. * Gets the emitter node used with this set
  146667. */
  146668. get emitterNode(): Nullable<TransformNode>;
  146669. /**
  146670. * Creates a new emitter mesh as a sphere
  146671. * @param options defines the options used to create the sphere
  146672. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146673. * @param scene defines the hosting scene
  146674. */
  146675. setEmitterAsSphere(options: {
  146676. diameter: number;
  146677. segments: number;
  146678. color: Color3;
  146679. }, renderingGroupId: number, scene: Scene): void;
  146680. /**
  146681. * Starts all particle systems of the set
  146682. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146683. */
  146684. start(emitter?: AbstractMesh): void;
  146685. /**
  146686. * Release all associated resources
  146687. */
  146688. dispose(): void;
  146689. /**
  146690. * Serialize the set into a JSON compatible object
  146691. * @param serializeTexture defines if the texture must be serialized as well
  146692. * @returns a JSON compatible representation of the set
  146693. */
  146694. serialize(serializeTexture?: boolean): any;
  146695. /**
  146696. * Parse a new ParticleSystemSet from a serialized source
  146697. * @param data defines a JSON compatible representation of the set
  146698. * @param scene defines the hosting scene
  146699. * @param gpu defines if we want GPU particles or CPU particles
  146700. * @returns a new ParticleSystemSet
  146701. */
  146702. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146703. }
  146704. }
  146705. declare module BABYLON {
  146706. /**
  146707. * This class is made for on one-liner static method to help creating particle system set.
  146708. */
  146709. export class ParticleHelper {
  146710. /**
  146711. * Gets or sets base Assets URL
  146712. */
  146713. static BaseAssetsUrl: string;
  146714. /** Define the Url to load snippets */
  146715. static SnippetUrl: string;
  146716. /**
  146717. * Create a default particle system that you can tweak
  146718. * @param emitter defines the emitter to use
  146719. * @param capacity defines the system capacity (default is 500 particles)
  146720. * @param scene defines the hosting scene
  146721. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146722. * @returns the new Particle system
  146723. */
  146724. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146725. /**
  146726. * This is the main static method (one-liner) of this helper to create different particle systems
  146727. * @param type This string represents the type to the particle system to create
  146728. * @param scene The scene where the particle system should live
  146729. * @param gpu If the system will use gpu
  146730. * @returns the ParticleSystemSet created
  146731. */
  146732. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146733. /**
  146734. * Static function used to export a particle system to a ParticleSystemSet variable.
  146735. * Please note that the emitter shape is not exported
  146736. * @param systems defines the particle systems to export
  146737. * @returns the created particle system set
  146738. */
  146739. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146740. /**
  146741. * Creates a particle system from a snippet saved in a remote file
  146742. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146743. * @param url defines the url to load from
  146744. * @param scene defines the hosting scene
  146745. * @param gpu If the system will use gpu
  146746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146747. * @returns a promise that will resolve to the new particle system
  146748. */
  146749. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146750. /**
  146751. * Creates a particle system from a snippet saved by the particle system editor
  146752. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146753. * @param scene defines the hosting scene
  146754. * @param gpu If the system will use gpu
  146755. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146756. * @returns a promise that will resolve to the new particle system
  146757. */
  146758. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146759. }
  146760. }
  146761. declare module BABYLON {
  146762. interface Engine {
  146763. /**
  146764. * Create an effect to use with particle systems.
  146765. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146766. * the particle system for which you want to create a custom effect in the last parameter
  146767. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146768. * @param uniformsNames defines a list of attribute names
  146769. * @param samplers defines an array of string used to represent textures
  146770. * @param defines defines the string containing the defines to use to compile the shaders
  146771. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146772. * @param onCompiled defines a function to call when the effect creation is successful
  146773. * @param onError defines a function to call when the effect creation has failed
  146774. * @param particleSystem the particle system you want to create the effect for
  146775. * @returns the new Effect
  146776. */
  146777. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146778. }
  146779. interface Mesh {
  146780. /**
  146781. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146782. * @returns an array of IParticleSystem
  146783. */
  146784. getEmittedParticleSystems(): IParticleSystem[];
  146785. /**
  146786. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146787. * @returns an array of IParticleSystem
  146788. */
  146789. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146790. }
  146791. }
  146792. declare module BABYLON {
  146793. /** Defines the 4 color options */
  146794. export enum PointColor {
  146795. /** color value */
  146796. Color = 2,
  146797. /** uv value */
  146798. UV = 1,
  146799. /** random value */
  146800. Random = 0,
  146801. /** stated value */
  146802. Stated = 3
  146803. }
  146804. /**
  146805. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146806. * 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.
  146807. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146808. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146809. *
  146810. * Full documentation here : TO BE ENTERED
  146811. */
  146812. export class PointsCloudSystem implements IDisposable {
  146813. /**
  146814. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146815. * Example : var p = SPS.particles[i];
  146816. */
  146817. particles: CloudPoint[];
  146818. /**
  146819. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146820. */
  146821. nbParticles: number;
  146822. /**
  146823. * This a counter for your own usage. It's not set by any SPS functions.
  146824. */
  146825. counter: number;
  146826. /**
  146827. * The PCS name. This name is also given to the underlying mesh.
  146828. */
  146829. name: string;
  146830. /**
  146831. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146832. */
  146833. mesh: Mesh;
  146834. /**
  146835. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146836. * Please read :
  146837. */
  146838. vars: any;
  146839. /**
  146840. * @hidden
  146841. */
  146842. _size: number;
  146843. private _scene;
  146844. private _promises;
  146845. private _positions;
  146846. private _indices;
  146847. private _normals;
  146848. private _colors;
  146849. private _uvs;
  146850. private _indices32;
  146851. private _positions32;
  146852. private _colors32;
  146853. private _uvs32;
  146854. private _updatable;
  146855. private _isVisibilityBoxLocked;
  146856. private _alwaysVisible;
  146857. private _groups;
  146858. private _groupCounter;
  146859. private _computeParticleColor;
  146860. private _computeParticleTexture;
  146861. private _computeParticleRotation;
  146862. private _computeBoundingBox;
  146863. private _isReady;
  146864. /**
  146865. * Creates a PCS (Points Cloud System) object
  146866. * @param name (String) is the PCS name, this will be the underlying mesh name
  146867. * @param pointSize (number) is the size for each point
  146868. * @param scene (Scene) is the scene in which the PCS is added
  146869. * @param options defines the options of the PCS e.g.
  146870. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146871. */
  146872. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146873. updatable?: boolean;
  146874. });
  146875. /**
  146876. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146877. * If no points were added to the PCS, the returned mesh is just a single point.
  146878. * @returns a promise for the created mesh
  146879. */
  146880. buildMeshAsync(): Promise<Mesh>;
  146881. /**
  146882. * @hidden
  146883. */
  146884. private _buildMesh;
  146885. private _addParticle;
  146886. private _randomUnitVector;
  146887. private _getColorIndicesForCoord;
  146888. private _setPointsColorOrUV;
  146889. private _colorFromTexture;
  146890. private _calculateDensity;
  146891. /**
  146892. * Adds points to the PCS in random positions within a unit sphere
  146893. * @param nb (positive integer) the number of particles to be created from this model
  146894. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146895. * @returns the number of groups in the system
  146896. */
  146897. addPoints(nb: number, pointFunction?: any): number;
  146898. /**
  146899. * Adds points to the PCS from the surface of the model shape
  146900. * @param mesh is any Mesh object that will be used as a surface model for the points
  146901. * @param nb (positive integer) the number of particles to be created from this model
  146902. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146903. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146904. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146905. * @returns the number of groups in the system
  146906. */
  146907. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146908. /**
  146909. * Adds points to the PCS inside the model shape
  146910. * @param mesh is any Mesh object that will be used as a surface model for the points
  146911. * @param nb (positive integer) the number of particles to be created from this model
  146912. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146913. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146914. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146915. * @returns the number of groups in the system
  146916. */
  146917. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146918. /**
  146919. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146920. * This method calls `updateParticle()` for each particle of the SPS.
  146921. * For an animated SPS, it is usually called within the render loop.
  146922. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146923. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146924. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146925. * @returns the PCS.
  146926. */
  146927. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146928. /**
  146929. * Disposes the PCS.
  146930. */
  146931. dispose(): void;
  146932. /**
  146933. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146934. * doc :
  146935. * @returns the PCS.
  146936. */
  146937. refreshVisibleSize(): PointsCloudSystem;
  146938. /**
  146939. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146940. * @param size the size (float) of the visibility box
  146941. * note : this doesn't lock the PCS mesh bounding box.
  146942. * doc :
  146943. */
  146944. setVisibilityBox(size: number): void;
  146945. /**
  146946. * Gets whether the PCS is always visible or not
  146947. * doc :
  146948. */
  146949. get isAlwaysVisible(): boolean;
  146950. /**
  146951. * Sets the PCS as always visible or not
  146952. * doc :
  146953. */
  146954. set isAlwaysVisible(val: boolean);
  146955. /**
  146956. * Tells to `setParticles()` to compute the particle rotations or not
  146957. * Default value : false. The PCS is faster when it's set to false
  146958. * Note : particle rotations are only applied to parent particles
  146959. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146960. */
  146961. set computeParticleRotation(val: boolean);
  146962. /**
  146963. * Tells to `setParticles()` to compute the particle colors or not.
  146964. * Default value : true. The PCS is faster when it's set to false.
  146965. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146966. */
  146967. set computeParticleColor(val: boolean);
  146968. set computeParticleTexture(val: boolean);
  146969. /**
  146970. * Gets if `setParticles()` computes the particle colors or not.
  146971. * Default value : false. The PCS is faster when it's set to false.
  146972. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146973. */
  146974. get computeParticleColor(): boolean;
  146975. /**
  146976. * Gets if `setParticles()` computes the particle textures or not.
  146977. * Default value : false. The PCS is faster when it's set to false.
  146978. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146979. */
  146980. get computeParticleTexture(): boolean;
  146981. /**
  146982. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146983. */
  146984. set computeBoundingBox(val: boolean);
  146985. /**
  146986. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146987. */
  146988. get computeBoundingBox(): boolean;
  146989. /**
  146990. * This function does nothing. It may be overwritten to set all the particle first values.
  146991. * The PCS doesn't call this function, you may have to call it by your own.
  146992. * doc :
  146993. */
  146994. initParticles(): void;
  146995. /**
  146996. * This function does nothing. It may be overwritten to recycle a particle
  146997. * The PCS doesn't call this function, you can to call it
  146998. * doc :
  146999. * @param particle The particle to recycle
  147000. * @returns the recycled particle
  147001. */
  147002. recycleParticle(particle: CloudPoint): CloudPoint;
  147003. /**
  147004. * Updates a particle : this function should be overwritten by the user.
  147005. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  147006. * doc :
  147007. * @example : just set a particle position or velocity and recycle conditions
  147008. * @param particle The particle to update
  147009. * @returns the updated particle
  147010. */
  147011. updateParticle(particle: CloudPoint): CloudPoint;
  147012. /**
  147013. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  147014. * This does nothing and may be overwritten by the user.
  147015. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147016. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147017. * @param update the boolean update value actually passed to setParticles()
  147018. */
  147019. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147020. /**
  147021. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  147022. * This will be passed three parameters.
  147023. * This does nothing and may be overwritten by the user.
  147024. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  147025. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  147026. * @param update the boolean update value actually passed to setParticles()
  147027. */
  147028. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  147029. }
  147030. }
  147031. declare module BABYLON {
  147032. /**
  147033. * Represents one particle of a points cloud system.
  147034. */
  147035. export class CloudPoint {
  147036. /**
  147037. * particle global index
  147038. */
  147039. idx: number;
  147040. /**
  147041. * The color of the particle
  147042. */
  147043. color: Nullable<Color4>;
  147044. /**
  147045. * The world space position of the particle.
  147046. */
  147047. position: Vector3;
  147048. /**
  147049. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  147050. */
  147051. rotation: Vector3;
  147052. /**
  147053. * The world space rotation quaternion of the particle.
  147054. */
  147055. rotationQuaternion: Nullable<Quaternion>;
  147056. /**
  147057. * The uv of the particle.
  147058. */
  147059. uv: Nullable<Vector2>;
  147060. /**
  147061. * The current speed of the particle.
  147062. */
  147063. velocity: Vector3;
  147064. /**
  147065. * The pivot point in the particle local space.
  147066. */
  147067. pivot: Vector3;
  147068. /**
  147069. * Must the particle be translated from its pivot point in its local space ?
  147070. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  147071. * Default : false
  147072. */
  147073. translateFromPivot: boolean;
  147074. /**
  147075. * Index of this particle in the global "positions" array (Internal use)
  147076. * @hidden
  147077. */
  147078. _pos: number;
  147079. /**
  147080. * @hidden Index of this particle in the global "indices" array (Internal use)
  147081. */
  147082. _ind: number;
  147083. /**
  147084. * Group this particle belongs to
  147085. */
  147086. _group: PointsGroup;
  147087. /**
  147088. * Group id of this particle
  147089. */
  147090. groupId: number;
  147091. /**
  147092. * Index of the particle in its group id (Internal use)
  147093. */
  147094. idxInGroup: number;
  147095. /**
  147096. * @hidden Particle BoundingInfo object (Internal use)
  147097. */
  147098. _boundingInfo: BoundingInfo;
  147099. /**
  147100. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  147101. */
  147102. _pcs: PointsCloudSystem;
  147103. /**
  147104. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  147105. */
  147106. _stillInvisible: boolean;
  147107. /**
  147108. * @hidden Last computed particle rotation matrix
  147109. */
  147110. _rotationMatrix: number[];
  147111. /**
  147112. * Parent particle Id, if any.
  147113. * Default null.
  147114. */
  147115. parentId: Nullable<number>;
  147116. /**
  147117. * @hidden Internal global position in the PCS.
  147118. */
  147119. _globalPosition: Vector3;
  147120. /**
  147121. * Creates a Point Cloud object.
  147122. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  147123. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  147124. * @param group (PointsGroup) is the group the particle belongs to
  147125. * @param groupId (integer) is the group identifier in the PCS.
  147126. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  147127. * @param pcs defines the PCS it is associated to
  147128. */
  147129. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  147130. /**
  147131. * get point size
  147132. */
  147133. get size(): Vector3;
  147134. /**
  147135. * Set point size
  147136. */
  147137. set size(scale: Vector3);
  147138. /**
  147139. * Legacy support, changed quaternion to rotationQuaternion
  147140. */
  147141. get quaternion(): Nullable<Quaternion>;
  147142. /**
  147143. * Legacy support, changed quaternion to rotationQuaternion
  147144. */
  147145. set quaternion(q: Nullable<Quaternion>);
  147146. /**
  147147. * Returns a boolean. True if the particle intersects a mesh, else false
  147148. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  147149. * @param target is the object (point or mesh) what the intersection is computed against
  147150. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  147151. * @returns true if it intersects
  147152. */
  147153. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  147154. /**
  147155. * get the rotation matrix of the particle
  147156. * @hidden
  147157. */
  147158. getRotationMatrix(m: Matrix): void;
  147159. }
  147160. /**
  147161. * Represents a group of points in a points cloud system
  147162. * * PCS internal tool, don't use it manually.
  147163. */
  147164. export class PointsGroup {
  147165. /**
  147166. * The group id
  147167. * @hidden
  147168. */
  147169. groupID: number;
  147170. /**
  147171. * image data for group (internal use)
  147172. * @hidden
  147173. */
  147174. _groupImageData: Nullable<ArrayBufferView>;
  147175. /**
  147176. * Image Width (internal use)
  147177. * @hidden
  147178. */
  147179. _groupImgWidth: number;
  147180. /**
  147181. * Image Height (internal use)
  147182. * @hidden
  147183. */
  147184. _groupImgHeight: number;
  147185. /**
  147186. * Custom position function (internal use)
  147187. * @hidden
  147188. */
  147189. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  147190. /**
  147191. * density per facet for surface points
  147192. * @hidden
  147193. */
  147194. _groupDensity: number[];
  147195. /**
  147196. * Only when points are colored by texture carries pointer to texture list array
  147197. * @hidden
  147198. */
  147199. _textureNb: number;
  147200. /**
  147201. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  147202. * PCS internal tool, don't use it manually.
  147203. * @hidden
  147204. */
  147205. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  147206. }
  147207. }
  147208. declare module BABYLON {
  147209. interface Scene {
  147210. /** @hidden (Backing field) */
  147211. _physicsEngine: Nullable<IPhysicsEngine>;
  147212. /** @hidden */
  147213. _physicsTimeAccumulator: number;
  147214. /**
  147215. * Gets the current physics engine
  147216. * @returns a IPhysicsEngine or null if none attached
  147217. */
  147218. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  147219. /**
  147220. * Enables physics to the current scene
  147221. * @param gravity defines the scene's gravity for the physics engine
  147222. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  147223. * @return a boolean indicating if the physics engine was initialized
  147224. */
  147225. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  147226. /**
  147227. * Disables and disposes the physics engine associated with the scene
  147228. */
  147229. disablePhysicsEngine(): void;
  147230. /**
  147231. * Gets a boolean indicating if there is an active physics engine
  147232. * @returns a boolean indicating if there is an active physics engine
  147233. */
  147234. isPhysicsEnabled(): boolean;
  147235. /**
  147236. * Deletes a physics compound impostor
  147237. * @param compound defines the compound to delete
  147238. */
  147239. deleteCompoundImpostor(compound: any): void;
  147240. /**
  147241. * An event triggered when physic simulation is about to be run
  147242. */
  147243. onBeforePhysicsObservable: Observable<Scene>;
  147244. /**
  147245. * An event triggered when physic simulation has been done
  147246. */
  147247. onAfterPhysicsObservable: Observable<Scene>;
  147248. }
  147249. interface AbstractMesh {
  147250. /** @hidden */
  147251. _physicsImpostor: Nullable<PhysicsImpostor>;
  147252. /**
  147253. * Gets or sets impostor used for physic simulation
  147254. * @see https://doc.babylonjs.com/features/physics_engine
  147255. */
  147256. physicsImpostor: Nullable<PhysicsImpostor>;
  147257. /**
  147258. * Gets the current physics impostor
  147259. * @see https://doc.babylonjs.com/features/physics_engine
  147260. * @returns a physics impostor or null
  147261. */
  147262. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147263. /** Apply a physic impulse to the mesh
  147264. * @param force defines the force to apply
  147265. * @param contactPoint defines where to apply the force
  147266. * @returns the current mesh
  147267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147268. */
  147269. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147270. /**
  147271. * Creates a physic joint between two meshes
  147272. * @param otherMesh defines the other mesh to use
  147273. * @param pivot1 defines the pivot to use on this mesh
  147274. * @param pivot2 defines the pivot to use on the other mesh
  147275. * @param options defines additional options (can be plugin dependent)
  147276. * @returns the current mesh
  147277. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147278. */
  147279. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147280. /** @hidden */
  147281. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147282. }
  147283. /**
  147284. * Defines the physics engine scene component responsible to manage a physics engine
  147285. */
  147286. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147287. /**
  147288. * The component name helpful to identify the component in the list of scene components.
  147289. */
  147290. readonly name: string;
  147291. /**
  147292. * The scene the component belongs to.
  147293. */
  147294. scene: Scene;
  147295. /**
  147296. * Creates a new instance of the component for the given scene
  147297. * @param scene Defines the scene to register the component in
  147298. */
  147299. constructor(scene: Scene);
  147300. /**
  147301. * Registers the component in a given scene
  147302. */
  147303. register(): void;
  147304. /**
  147305. * Rebuilds the elements related to this component in case of
  147306. * context lost for instance.
  147307. */
  147308. rebuild(): void;
  147309. /**
  147310. * Disposes the component and the associated ressources
  147311. */
  147312. dispose(): void;
  147313. }
  147314. }
  147315. declare module BABYLON {
  147316. /**
  147317. * A helper for physics simulations
  147318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147319. */
  147320. export class PhysicsHelper {
  147321. private _scene;
  147322. private _physicsEngine;
  147323. /**
  147324. * Initializes the Physics helper
  147325. * @param scene Babylon.js scene
  147326. */
  147327. constructor(scene: Scene);
  147328. /**
  147329. * Applies a radial explosion impulse
  147330. * @param origin the origin of the explosion
  147331. * @param radiusOrEventOptions the radius or the options of radial explosion
  147332. * @param strength the explosion strength
  147333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147334. * @returns A physics radial explosion event, or null
  147335. */
  147336. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147337. /**
  147338. * Applies a radial explosion force
  147339. * @param origin the origin of the explosion
  147340. * @param radiusOrEventOptions the radius or the options of radial explosion
  147341. * @param strength the explosion strength
  147342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147343. * @returns A physics radial explosion event, or null
  147344. */
  147345. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147346. /**
  147347. * Creates a gravitational field
  147348. * @param origin the origin of the explosion
  147349. * @param radiusOrEventOptions the radius or the options of radial explosion
  147350. * @param strength the explosion strength
  147351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147352. * @returns A physics gravitational field event, or null
  147353. */
  147354. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147355. /**
  147356. * Creates a physics updraft event
  147357. * @param origin the origin of the updraft
  147358. * @param radiusOrEventOptions the radius or the options of the updraft
  147359. * @param strength the strength of the updraft
  147360. * @param height the height of the updraft
  147361. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147362. * @returns A physics updraft event, or null
  147363. */
  147364. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147365. /**
  147366. * Creates a physics vortex event
  147367. * @param origin the of the vortex
  147368. * @param radiusOrEventOptions the radius or the options of the vortex
  147369. * @param strength the strength of the vortex
  147370. * @param height the height of the vortex
  147371. * @returns a Physics vortex event, or null
  147372. * A physics vortex event or null
  147373. */
  147374. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147375. }
  147376. /**
  147377. * Represents a physics radial explosion event
  147378. */
  147379. class PhysicsRadialExplosionEvent {
  147380. private _scene;
  147381. private _options;
  147382. private _sphere;
  147383. private _dataFetched;
  147384. /**
  147385. * Initializes a radial explosioin event
  147386. * @param _scene BabylonJS scene
  147387. * @param _options The options for the vortex event
  147388. */
  147389. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147390. /**
  147391. * Returns the data related to the radial explosion event (sphere).
  147392. * @returns The radial explosion event data
  147393. */
  147394. getData(): PhysicsRadialExplosionEventData;
  147395. /**
  147396. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147397. * @param impostor A physics imposter
  147398. * @param origin the origin of the explosion
  147399. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147400. */
  147401. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147402. /**
  147403. * Triggers affecterd impostors callbacks
  147404. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147405. */
  147406. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147407. /**
  147408. * Disposes the sphere.
  147409. * @param force Specifies if the sphere should be disposed by force
  147410. */
  147411. dispose(force?: boolean): void;
  147412. /*** Helpers ***/
  147413. private _prepareSphere;
  147414. private _intersectsWithSphere;
  147415. }
  147416. /**
  147417. * Represents a gravitational field event
  147418. */
  147419. class PhysicsGravitationalFieldEvent {
  147420. private _physicsHelper;
  147421. private _scene;
  147422. private _origin;
  147423. private _options;
  147424. private _tickCallback;
  147425. private _sphere;
  147426. private _dataFetched;
  147427. /**
  147428. * Initializes the physics gravitational field event
  147429. * @param _physicsHelper A physics helper
  147430. * @param _scene BabylonJS scene
  147431. * @param _origin The origin position of the gravitational field event
  147432. * @param _options The options for the vortex event
  147433. */
  147434. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147435. /**
  147436. * Returns the data related to the gravitational field event (sphere).
  147437. * @returns A gravitational field event
  147438. */
  147439. getData(): PhysicsGravitationalFieldEventData;
  147440. /**
  147441. * Enables the gravitational field.
  147442. */
  147443. enable(): void;
  147444. /**
  147445. * Disables the gravitational field.
  147446. */
  147447. disable(): void;
  147448. /**
  147449. * Disposes the sphere.
  147450. * @param force The force to dispose from the gravitational field event
  147451. */
  147452. dispose(force?: boolean): void;
  147453. private _tick;
  147454. }
  147455. /**
  147456. * Represents a physics updraft event
  147457. */
  147458. class PhysicsUpdraftEvent {
  147459. private _scene;
  147460. private _origin;
  147461. private _options;
  147462. private _physicsEngine;
  147463. private _originTop;
  147464. private _originDirection;
  147465. private _tickCallback;
  147466. private _cylinder;
  147467. private _cylinderPosition;
  147468. private _dataFetched;
  147469. /**
  147470. * Initializes the physics updraft event
  147471. * @param _scene BabylonJS scene
  147472. * @param _origin The origin position of the updraft
  147473. * @param _options The options for the updraft event
  147474. */
  147475. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147476. /**
  147477. * Returns the data related to the updraft event (cylinder).
  147478. * @returns A physics updraft event
  147479. */
  147480. getData(): PhysicsUpdraftEventData;
  147481. /**
  147482. * Enables the updraft.
  147483. */
  147484. enable(): void;
  147485. /**
  147486. * Disables the updraft.
  147487. */
  147488. disable(): void;
  147489. /**
  147490. * Disposes the cylinder.
  147491. * @param force Specifies if the updraft should be disposed by force
  147492. */
  147493. dispose(force?: boolean): void;
  147494. private getImpostorHitData;
  147495. private _tick;
  147496. /*** Helpers ***/
  147497. private _prepareCylinder;
  147498. private _intersectsWithCylinder;
  147499. }
  147500. /**
  147501. * Represents a physics vortex event
  147502. */
  147503. class PhysicsVortexEvent {
  147504. private _scene;
  147505. private _origin;
  147506. private _options;
  147507. private _physicsEngine;
  147508. private _originTop;
  147509. private _tickCallback;
  147510. private _cylinder;
  147511. private _cylinderPosition;
  147512. private _dataFetched;
  147513. /**
  147514. * Initializes the physics vortex event
  147515. * @param _scene The BabylonJS scene
  147516. * @param _origin The origin position of the vortex
  147517. * @param _options The options for the vortex event
  147518. */
  147519. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147520. /**
  147521. * Returns the data related to the vortex event (cylinder).
  147522. * @returns The physics vortex event data
  147523. */
  147524. getData(): PhysicsVortexEventData;
  147525. /**
  147526. * Enables the vortex.
  147527. */
  147528. enable(): void;
  147529. /**
  147530. * Disables the cortex.
  147531. */
  147532. disable(): void;
  147533. /**
  147534. * Disposes the sphere.
  147535. * @param force
  147536. */
  147537. dispose(force?: boolean): void;
  147538. private getImpostorHitData;
  147539. private _tick;
  147540. /*** Helpers ***/
  147541. private _prepareCylinder;
  147542. private _intersectsWithCylinder;
  147543. }
  147544. /**
  147545. * Options fot the radial explosion event
  147546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147547. */
  147548. export class PhysicsRadialExplosionEventOptions {
  147549. /**
  147550. * The radius of the sphere for the radial explosion.
  147551. */
  147552. radius: number;
  147553. /**
  147554. * The strenth of the explosion.
  147555. */
  147556. strength: number;
  147557. /**
  147558. * The strenght of the force in correspondence to the distance of the affected object
  147559. */
  147560. falloff: PhysicsRadialImpulseFalloff;
  147561. /**
  147562. * Sphere options for the radial explosion.
  147563. */
  147564. sphere: {
  147565. segments: number;
  147566. diameter: number;
  147567. };
  147568. /**
  147569. * Sphere options for the radial explosion.
  147570. */
  147571. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147572. }
  147573. /**
  147574. * Options fot the updraft event
  147575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147576. */
  147577. export class PhysicsUpdraftEventOptions {
  147578. /**
  147579. * The radius of the cylinder for the vortex
  147580. */
  147581. radius: number;
  147582. /**
  147583. * The strenth of the updraft.
  147584. */
  147585. strength: number;
  147586. /**
  147587. * The height of the cylinder for the updraft.
  147588. */
  147589. height: number;
  147590. /**
  147591. * The mode for the the updraft.
  147592. */
  147593. updraftMode: PhysicsUpdraftMode;
  147594. }
  147595. /**
  147596. * Options fot the vortex event
  147597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147598. */
  147599. export class PhysicsVortexEventOptions {
  147600. /**
  147601. * The radius of the cylinder for the vortex
  147602. */
  147603. radius: number;
  147604. /**
  147605. * The strenth of the vortex.
  147606. */
  147607. strength: number;
  147608. /**
  147609. * The height of the cylinder for the vortex.
  147610. */
  147611. height: number;
  147612. /**
  147613. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147614. */
  147615. centripetalForceThreshold: number;
  147616. /**
  147617. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147618. */
  147619. centripetalForceMultiplier: number;
  147620. /**
  147621. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147622. */
  147623. centrifugalForceMultiplier: number;
  147624. /**
  147625. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147626. */
  147627. updraftForceMultiplier: number;
  147628. }
  147629. /**
  147630. * The strenght of the force in correspondence to the distance of the affected object
  147631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147632. */
  147633. export enum PhysicsRadialImpulseFalloff {
  147634. /** Defines that impulse is constant in strength across it's whole radius */
  147635. Constant = 0,
  147636. /** Defines that impulse gets weaker if it's further from the origin */
  147637. Linear = 1
  147638. }
  147639. /**
  147640. * The strength of the force in correspondence to the distance of the affected object
  147641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147642. */
  147643. export enum PhysicsUpdraftMode {
  147644. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147645. Center = 0,
  147646. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147647. Perpendicular = 1
  147648. }
  147649. /**
  147650. * Interface for a physics hit data
  147651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147652. */
  147653. export interface PhysicsHitData {
  147654. /**
  147655. * The force applied at the contact point
  147656. */
  147657. force: Vector3;
  147658. /**
  147659. * The contact point
  147660. */
  147661. contactPoint: Vector3;
  147662. /**
  147663. * The distance from the origin to the contact point
  147664. */
  147665. distanceFromOrigin: number;
  147666. }
  147667. /**
  147668. * Interface for radial explosion event data
  147669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147670. */
  147671. export interface PhysicsRadialExplosionEventData {
  147672. /**
  147673. * A sphere used for the radial explosion event
  147674. */
  147675. sphere: Mesh;
  147676. }
  147677. /**
  147678. * Interface for gravitational field event data
  147679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147680. */
  147681. export interface PhysicsGravitationalFieldEventData {
  147682. /**
  147683. * A sphere mesh used for the gravitational field event
  147684. */
  147685. sphere: Mesh;
  147686. }
  147687. /**
  147688. * Interface for updraft event data
  147689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147690. */
  147691. export interface PhysicsUpdraftEventData {
  147692. /**
  147693. * A cylinder used for the updraft event
  147694. */
  147695. cylinder: Mesh;
  147696. }
  147697. /**
  147698. * Interface for vortex event data
  147699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147700. */
  147701. export interface PhysicsVortexEventData {
  147702. /**
  147703. * A cylinder used for the vortex event
  147704. */
  147705. cylinder: Mesh;
  147706. }
  147707. /**
  147708. * Interface for an affected physics impostor
  147709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147710. */
  147711. export interface PhysicsAffectedImpostorWithData {
  147712. /**
  147713. * The impostor affected by the effect
  147714. */
  147715. impostor: PhysicsImpostor;
  147716. /**
  147717. * The data about the hit/horce from the explosion
  147718. */
  147719. hitData: PhysicsHitData;
  147720. }
  147721. }
  147722. declare module BABYLON {
  147723. /** @hidden */
  147724. export var blackAndWhitePixelShader: {
  147725. name: string;
  147726. shader: string;
  147727. };
  147728. }
  147729. declare module BABYLON {
  147730. /**
  147731. * Post process used to render in black and white
  147732. */
  147733. export class BlackAndWhitePostProcess extends PostProcess {
  147734. /**
  147735. * Linear about to convert he result to black and white (default: 1)
  147736. */
  147737. degree: number;
  147738. /**
  147739. * Creates a black and white post process
  147740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147741. * @param name The name of the effect.
  147742. * @param options The required width/height ratio to downsize to before computing the render pass.
  147743. * @param camera The camera to apply the render pass to.
  147744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147745. * @param engine The engine which the post process will be applied. (default: current engine)
  147746. * @param reusable If the post process can be reused on the same frame. (default: false)
  147747. */
  147748. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147749. }
  147750. }
  147751. declare module BABYLON {
  147752. /**
  147753. * This represents a set of one or more post processes in Babylon.
  147754. * A post process can be used to apply a shader to a texture after it is rendered.
  147755. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147756. */
  147757. export class PostProcessRenderEffect {
  147758. private _postProcesses;
  147759. private _getPostProcesses;
  147760. private _singleInstance;
  147761. private _cameras;
  147762. private _indicesForCamera;
  147763. /**
  147764. * Name of the effect
  147765. * @hidden
  147766. */
  147767. _name: string;
  147768. /**
  147769. * Instantiates a post process render effect.
  147770. * A post process can be used to apply a shader to a texture after it is rendered.
  147771. * @param engine The engine the effect is tied to
  147772. * @param name The name of the effect
  147773. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147774. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147775. */
  147776. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147777. /**
  147778. * Checks if all the post processes in the effect are supported.
  147779. */
  147780. get isSupported(): boolean;
  147781. /**
  147782. * Updates the current state of the effect
  147783. * @hidden
  147784. */
  147785. _update(): void;
  147786. /**
  147787. * Attaches the effect on cameras
  147788. * @param cameras The camera to attach to.
  147789. * @hidden
  147790. */
  147791. _attachCameras(cameras: Camera): void;
  147792. /**
  147793. * Attaches the effect on cameras
  147794. * @param cameras The camera to attach to.
  147795. * @hidden
  147796. */
  147797. _attachCameras(cameras: Camera[]): void;
  147798. /**
  147799. * Detaches the effect on cameras
  147800. * @param cameras The camera to detatch from.
  147801. * @hidden
  147802. */
  147803. _detachCameras(cameras: Camera): void;
  147804. /**
  147805. * Detatches the effect on cameras
  147806. * @param cameras The camera to detatch from.
  147807. * @hidden
  147808. */
  147809. _detachCameras(cameras: Camera[]): void;
  147810. /**
  147811. * Enables the effect on given cameras
  147812. * @param cameras The camera to enable.
  147813. * @hidden
  147814. */
  147815. _enable(cameras: Camera): void;
  147816. /**
  147817. * Enables the effect on given cameras
  147818. * @param cameras The camera to enable.
  147819. * @hidden
  147820. */
  147821. _enable(cameras: Nullable<Camera[]>): void;
  147822. /**
  147823. * Disables the effect on the given cameras
  147824. * @param cameras The camera to disable.
  147825. * @hidden
  147826. */
  147827. _disable(cameras: Camera): void;
  147828. /**
  147829. * Disables the effect on the given cameras
  147830. * @param cameras The camera to disable.
  147831. * @hidden
  147832. */
  147833. _disable(cameras: Nullable<Camera[]>): void;
  147834. /**
  147835. * Gets a list of the post processes contained in the effect.
  147836. * @param camera The camera to get the post processes on.
  147837. * @returns The list of the post processes in the effect.
  147838. */
  147839. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147840. }
  147841. }
  147842. declare module BABYLON {
  147843. /** @hidden */
  147844. export var extractHighlightsPixelShader: {
  147845. name: string;
  147846. shader: string;
  147847. };
  147848. }
  147849. declare module BABYLON {
  147850. /**
  147851. * 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.
  147852. */
  147853. export class ExtractHighlightsPostProcess extends PostProcess {
  147854. /**
  147855. * The luminance threshold, pixels below this value will be set to black.
  147856. */
  147857. threshold: number;
  147858. /** @hidden */
  147859. _exposure: number;
  147860. /**
  147861. * Post process which has the input texture to be used when performing highlight extraction
  147862. * @hidden
  147863. */
  147864. _inputPostProcess: Nullable<PostProcess>;
  147865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147866. }
  147867. }
  147868. declare module BABYLON {
  147869. /** @hidden */
  147870. export var bloomMergePixelShader: {
  147871. name: string;
  147872. shader: string;
  147873. };
  147874. }
  147875. declare module BABYLON {
  147876. /**
  147877. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147878. */
  147879. export class BloomMergePostProcess extends PostProcess {
  147880. /** Weight of the bloom to be added to the original input. */
  147881. weight: number;
  147882. /**
  147883. * Creates a new instance of @see BloomMergePostProcess
  147884. * @param name The name of the effect.
  147885. * @param originalFromInput Post process which's input will be used for the merge.
  147886. * @param blurred Blurred highlights post process which's output will be used.
  147887. * @param weight Weight of the bloom to be added to the original input.
  147888. * @param options The required width/height ratio to downsize to before computing the render pass.
  147889. * @param camera The camera to apply the render pass to.
  147890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147891. * @param engine The engine which the post process will be applied. (default: current engine)
  147892. * @param reusable If the post process can be reused on the same frame. (default: false)
  147893. * @param textureType Type of textures used when performing the post process. (default: 0)
  147894. * @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)
  147895. */
  147896. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147897. /** Weight of the bloom to be added to the original input. */
  147898. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147899. }
  147900. }
  147901. declare module BABYLON {
  147902. /**
  147903. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147904. */
  147905. export class BloomEffect extends PostProcessRenderEffect {
  147906. private bloomScale;
  147907. /**
  147908. * @hidden Internal
  147909. */
  147910. _effects: Array<PostProcess>;
  147911. /**
  147912. * @hidden Internal
  147913. */
  147914. _downscale: ExtractHighlightsPostProcess;
  147915. private _blurX;
  147916. private _blurY;
  147917. private _merge;
  147918. /**
  147919. * The luminance threshold to find bright areas of the image to bloom.
  147920. */
  147921. get threshold(): number;
  147922. set threshold(value: number);
  147923. /**
  147924. * The strength of the bloom.
  147925. */
  147926. get weight(): number;
  147927. set weight(value: number);
  147928. /**
  147929. * Specifies the size of the bloom blur kernel, relative to the final output size
  147930. */
  147931. get kernel(): number;
  147932. set kernel(value: number);
  147933. /**
  147934. * Creates a new instance of @see BloomEffect
  147935. * @param scene The scene the effect belongs to.
  147936. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147937. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147938. * @param bloomWeight The the strength of bloom.
  147939. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147940. * @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)
  147941. */
  147942. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147943. /**
  147944. * Disposes each of the internal effects for a given camera.
  147945. * @param camera The camera to dispose the effect on.
  147946. */
  147947. disposeEffects(camera: Camera): void;
  147948. /**
  147949. * @hidden Internal
  147950. */
  147951. _updateEffects(): void;
  147952. /**
  147953. * Internal
  147954. * @returns if all the contained post processes are ready.
  147955. * @hidden
  147956. */
  147957. _isReady(): boolean;
  147958. }
  147959. }
  147960. declare module BABYLON {
  147961. /** @hidden */
  147962. export var chromaticAberrationPixelShader: {
  147963. name: string;
  147964. shader: string;
  147965. };
  147966. }
  147967. declare module BABYLON {
  147968. /**
  147969. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147970. */
  147971. export class ChromaticAberrationPostProcess extends PostProcess {
  147972. /**
  147973. * The amount of seperation of rgb channels (default: 30)
  147974. */
  147975. aberrationAmount: number;
  147976. /**
  147977. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147978. */
  147979. radialIntensity: number;
  147980. /**
  147981. * 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))
  147982. */
  147983. direction: Vector2;
  147984. /**
  147985. * 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))
  147986. */
  147987. centerPosition: Vector2;
  147988. /**
  147989. * Creates a new instance ChromaticAberrationPostProcess
  147990. * @param name The name of the effect.
  147991. * @param screenWidth The width of the screen to apply the effect on.
  147992. * @param screenHeight The height of the screen to apply the effect on.
  147993. * @param options The required width/height ratio to downsize to before computing the render pass.
  147994. * @param camera The camera to apply the render pass to.
  147995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147996. * @param engine The engine which the post process will be applied. (default: current engine)
  147997. * @param reusable If the post process can be reused on the same frame. (default: false)
  147998. * @param textureType Type of textures used when performing the post process. (default: 0)
  147999. * @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)
  148000. */
  148001. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148002. }
  148003. }
  148004. declare module BABYLON {
  148005. /** @hidden */
  148006. export var circleOfConfusionPixelShader: {
  148007. name: string;
  148008. shader: string;
  148009. };
  148010. }
  148011. declare module BABYLON {
  148012. /**
  148013. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  148014. */
  148015. export class CircleOfConfusionPostProcess extends PostProcess {
  148016. /**
  148017. * 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.
  148018. */
  148019. lensSize: number;
  148020. /**
  148021. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148022. */
  148023. fStop: number;
  148024. /**
  148025. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148026. */
  148027. focusDistance: number;
  148028. /**
  148029. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  148030. */
  148031. focalLength: number;
  148032. private _depthTexture;
  148033. /**
  148034. * Creates a new instance CircleOfConfusionPostProcess
  148035. * @param name The name of the effect.
  148036. * @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.
  148037. * @param options The required width/height ratio to downsize to before computing the render pass.
  148038. * @param camera The camera to apply the render pass to.
  148039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148040. * @param engine The engine which the post process will be applied. (default: current engine)
  148041. * @param reusable If the post process can be reused on the same frame. (default: false)
  148042. * @param textureType Type of textures used when performing the post process. (default: 0)
  148043. * @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)
  148044. */
  148045. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148046. /**
  148047. * 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.
  148048. */
  148049. set depthTexture(value: RenderTargetTexture);
  148050. }
  148051. }
  148052. declare module BABYLON {
  148053. /** @hidden */
  148054. export var colorCorrectionPixelShader: {
  148055. name: string;
  148056. shader: string;
  148057. };
  148058. }
  148059. declare module BABYLON {
  148060. /**
  148061. *
  148062. * This post-process allows the modification of rendered colors by using
  148063. * a 'look-up table' (LUT). This effect is also called Color Grading.
  148064. *
  148065. * The object needs to be provided an url to a texture containing the color
  148066. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  148067. * Use an image editing software to tweak the LUT to match your needs.
  148068. *
  148069. * For an example of a color LUT, see here:
  148070. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  148071. * For explanations on color grading, see here:
  148072. * @see http://udn.epicgames.com/Three/ColorGrading.html
  148073. *
  148074. */
  148075. export class ColorCorrectionPostProcess extends PostProcess {
  148076. private _colorTableTexture;
  148077. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148078. }
  148079. }
  148080. declare module BABYLON {
  148081. /** @hidden */
  148082. export var convolutionPixelShader: {
  148083. name: string;
  148084. shader: string;
  148085. };
  148086. }
  148087. declare module BABYLON {
  148088. /**
  148089. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  148090. * input texture to perform effects such as edge detection or sharpening
  148091. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148092. */
  148093. export class ConvolutionPostProcess extends PostProcess {
  148094. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148095. kernel: number[];
  148096. /**
  148097. * Creates a new instance ConvolutionPostProcess
  148098. * @param name The name of the effect.
  148099. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  148100. * @param options The required width/height ratio to downsize to before computing the render pass.
  148101. * @param camera The camera to apply the render pass to.
  148102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148103. * @param engine The engine which the post process will be applied. (default: current engine)
  148104. * @param reusable If the post process can be reused on the same frame. (default: false)
  148105. * @param textureType Type of textures used when performing the post process. (default: 0)
  148106. */
  148107. constructor(name: string,
  148108. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  148109. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148110. /**
  148111. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148112. */
  148113. static EdgeDetect0Kernel: number[];
  148114. /**
  148115. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148116. */
  148117. static EdgeDetect1Kernel: number[];
  148118. /**
  148119. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148120. */
  148121. static EdgeDetect2Kernel: number[];
  148122. /**
  148123. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148124. */
  148125. static SharpenKernel: number[];
  148126. /**
  148127. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148128. */
  148129. static EmbossKernel: number[];
  148130. /**
  148131. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  148132. */
  148133. static GaussianKernel: number[];
  148134. }
  148135. }
  148136. declare module BABYLON {
  148137. /**
  148138. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  148139. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  148140. * based on samples that have a large difference in distance than the center pixel.
  148141. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  148142. */
  148143. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  148144. direction: Vector2;
  148145. /**
  148146. * Creates a new instance CircleOfConfusionPostProcess
  148147. * @param name The name of the effect.
  148148. * @param scene The scene the effect belongs to.
  148149. * @param direction The direction the blur should be applied.
  148150. * @param kernel The size of the kernel used to blur.
  148151. * @param options The required width/height ratio to downsize to before computing the render pass.
  148152. * @param camera The camera to apply the render pass to.
  148153. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  148154. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  148155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148156. * @param engine The engine which the post process will be applied. (default: current engine)
  148157. * @param reusable If the post process can be reused on the same frame. (default: false)
  148158. * @param textureType Type of textures used when performing the post process. (default: 0)
  148159. * @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)
  148160. */
  148161. 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);
  148162. }
  148163. }
  148164. declare module BABYLON {
  148165. /** @hidden */
  148166. export var depthOfFieldMergePixelShader: {
  148167. name: string;
  148168. shader: string;
  148169. };
  148170. }
  148171. declare module BABYLON {
  148172. /**
  148173. * Options to be set when merging outputs from the default pipeline.
  148174. */
  148175. export class DepthOfFieldMergePostProcessOptions {
  148176. /**
  148177. * The original image to merge on top of
  148178. */
  148179. originalFromInput: PostProcess;
  148180. /**
  148181. * Parameters to perform the merge of the depth of field effect
  148182. */
  148183. depthOfField?: {
  148184. circleOfConfusion: PostProcess;
  148185. blurSteps: Array<PostProcess>;
  148186. };
  148187. /**
  148188. * Parameters to perform the merge of bloom effect
  148189. */
  148190. bloom?: {
  148191. blurred: PostProcess;
  148192. weight: number;
  148193. };
  148194. }
  148195. /**
  148196. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148197. */
  148198. export class DepthOfFieldMergePostProcess extends PostProcess {
  148199. private blurSteps;
  148200. /**
  148201. * Creates a new instance of DepthOfFieldMergePostProcess
  148202. * @param name The name of the effect.
  148203. * @param originalFromInput Post process which's input will be used for the merge.
  148204. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  148205. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  148206. * @param options The required width/height ratio to downsize to before computing the render pass.
  148207. * @param camera The camera to apply the render pass to.
  148208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148209. * @param engine The engine which the post process will be applied. (default: current engine)
  148210. * @param reusable If the post process can be reused on the same frame. (default: false)
  148211. * @param textureType Type of textures used when performing the post process. (default: 0)
  148212. * @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)
  148213. */
  148214. 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);
  148215. /**
  148216. * Updates the effect with the current post process compile time values and recompiles the shader.
  148217. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  148218. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  148219. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  148220. * @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
  148221. * @param onCompiled Called when the shader has been compiled.
  148222. * @param onError Called if there is an error when compiling a shader.
  148223. */
  148224. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  148225. }
  148226. }
  148227. declare module BABYLON {
  148228. /**
  148229. * Specifies the level of max blur that should be applied when using the depth of field effect
  148230. */
  148231. export enum DepthOfFieldEffectBlurLevel {
  148232. /**
  148233. * Subtle blur
  148234. */
  148235. Low = 0,
  148236. /**
  148237. * Medium blur
  148238. */
  148239. Medium = 1,
  148240. /**
  148241. * Large blur
  148242. */
  148243. High = 2
  148244. }
  148245. /**
  148246. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148247. */
  148248. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148249. private _circleOfConfusion;
  148250. /**
  148251. * @hidden Internal, blurs from high to low
  148252. */
  148253. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148254. private _depthOfFieldBlurY;
  148255. private _dofMerge;
  148256. /**
  148257. * @hidden Internal post processes in depth of field effect
  148258. */
  148259. _effects: Array<PostProcess>;
  148260. /**
  148261. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  148262. */
  148263. set focalLength(value: number);
  148264. get focalLength(): number;
  148265. /**
  148266. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148267. */
  148268. set fStop(value: number);
  148269. get fStop(): number;
  148270. /**
  148271. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148272. */
  148273. set focusDistance(value: number);
  148274. get focusDistance(): number;
  148275. /**
  148276. * 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.
  148277. */
  148278. set lensSize(value: number);
  148279. get lensSize(): number;
  148280. /**
  148281. * Creates a new instance DepthOfFieldEffect
  148282. * @param scene The scene the effect belongs to.
  148283. * @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.
  148284. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148285. * @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)
  148286. */
  148287. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  148288. /**
  148289. * Get the current class name of the current effet
  148290. * @returns "DepthOfFieldEffect"
  148291. */
  148292. getClassName(): string;
  148293. /**
  148294. * 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.
  148295. */
  148296. set depthTexture(value: RenderTargetTexture);
  148297. /**
  148298. * Disposes each of the internal effects for a given camera.
  148299. * @param camera The camera to dispose the effect on.
  148300. */
  148301. disposeEffects(camera: Camera): void;
  148302. /**
  148303. * @hidden Internal
  148304. */
  148305. _updateEffects(): void;
  148306. /**
  148307. * Internal
  148308. * @returns if all the contained post processes are ready.
  148309. * @hidden
  148310. */
  148311. _isReady(): boolean;
  148312. }
  148313. }
  148314. declare module BABYLON {
  148315. /** @hidden */
  148316. export var displayPassPixelShader: {
  148317. name: string;
  148318. shader: string;
  148319. };
  148320. }
  148321. declare module BABYLON {
  148322. /**
  148323. * DisplayPassPostProcess which produces an output the same as it's input
  148324. */
  148325. export class DisplayPassPostProcess extends PostProcess {
  148326. /**
  148327. * Creates the DisplayPassPostProcess
  148328. * @param name The name of the effect.
  148329. * @param options The required width/height ratio to downsize to before computing the render pass.
  148330. * @param camera The camera to apply the render pass to.
  148331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148332. * @param engine The engine which the post process will be applied. (default: current engine)
  148333. * @param reusable If the post process can be reused on the same frame. (default: false)
  148334. */
  148335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148336. }
  148337. }
  148338. declare module BABYLON {
  148339. /** @hidden */
  148340. export var filterPixelShader: {
  148341. name: string;
  148342. shader: string;
  148343. };
  148344. }
  148345. declare module BABYLON {
  148346. /**
  148347. * Applies a kernel filter to the image
  148348. */
  148349. export class FilterPostProcess extends PostProcess {
  148350. /** The matrix to be applied to the image */
  148351. kernelMatrix: Matrix;
  148352. /**
  148353. *
  148354. * @param name The name of the effect.
  148355. * @param kernelMatrix The matrix to be applied to the image
  148356. * @param options The required width/height ratio to downsize to before computing the render pass.
  148357. * @param camera The camera to apply the render pass to.
  148358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148359. * @param engine The engine which the post process will be applied. (default: current engine)
  148360. * @param reusable If the post process can be reused on the same frame. (default: false)
  148361. */
  148362. constructor(name: string,
  148363. /** The matrix to be applied to the image */
  148364. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148365. }
  148366. }
  148367. declare module BABYLON {
  148368. /** @hidden */
  148369. export var fxaaPixelShader: {
  148370. name: string;
  148371. shader: string;
  148372. };
  148373. }
  148374. declare module BABYLON {
  148375. /** @hidden */
  148376. export var fxaaVertexShader: {
  148377. name: string;
  148378. shader: string;
  148379. };
  148380. }
  148381. declare module BABYLON {
  148382. /**
  148383. * Fxaa post process
  148384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148385. */
  148386. export class FxaaPostProcess extends PostProcess {
  148387. /** @hidden */
  148388. texelWidth: number;
  148389. /** @hidden */
  148390. texelHeight: number;
  148391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148392. private _getDefines;
  148393. }
  148394. }
  148395. declare module BABYLON {
  148396. /** @hidden */
  148397. export var grainPixelShader: {
  148398. name: string;
  148399. shader: string;
  148400. };
  148401. }
  148402. declare module BABYLON {
  148403. /**
  148404. * The GrainPostProcess adds noise to the image at mid luminance levels
  148405. */
  148406. export class GrainPostProcess extends PostProcess {
  148407. /**
  148408. * The intensity of the grain added (default: 30)
  148409. */
  148410. intensity: number;
  148411. /**
  148412. * If the grain should be randomized on every frame
  148413. */
  148414. animated: boolean;
  148415. /**
  148416. * Creates a new instance of @see GrainPostProcess
  148417. * @param name The name of the effect.
  148418. * @param options The required width/height ratio to downsize to before computing the render pass.
  148419. * @param camera The camera to apply the render pass to.
  148420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148421. * @param engine The engine which the post process will be applied. (default: current engine)
  148422. * @param reusable If the post process can be reused on the same frame. (default: false)
  148423. * @param textureType Type of textures used when performing the post process. (default: 0)
  148424. * @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)
  148425. */
  148426. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148427. }
  148428. }
  148429. declare module BABYLON {
  148430. /** @hidden */
  148431. export var highlightsPixelShader: {
  148432. name: string;
  148433. shader: string;
  148434. };
  148435. }
  148436. declare module BABYLON {
  148437. /**
  148438. * Extracts highlights from the image
  148439. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148440. */
  148441. export class HighlightsPostProcess extends PostProcess {
  148442. /**
  148443. * Extracts highlights from the image
  148444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148445. * @param name The name of the effect.
  148446. * @param options The required width/height ratio to downsize to before computing the render pass.
  148447. * @param camera The camera to apply the render pass to.
  148448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148449. * @param engine The engine which the post process will be applied. (default: current engine)
  148450. * @param reusable If the post process can be reused on the same frame. (default: false)
  148451. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148452. */
  148453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148454. }
  148455. }
  148456. declare module BABYLON {
  148457. /** @hidden */
  148458. export var mrtFragmentDeclaration: {
  148459. name: string;
  148460. shader: string;
  148461. };
  148462. }
  148463. declare module BABYLON {
  148464. /** @hidden */
  148465. export var geometryPixelShader: {
  148466. name: string;
  148467. shader: string;
  148468. };
  148469. }
  148470. declare module BABYLON {
  148471. /** @hidden */
  148472. export var geometryVertexShader: {
  148473. name: string;
  148474. shader: string;
  148475. };
  148476. }
  148477. declare module BABYLON {
  148478. /** @hidden */
  148479. interface ISavedTransformationMatrix {
  148480. world: Matrix;
  148481. viewProjection: Matrix;
  148482. }
  148483. /**
  148484. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148485. */
  148486. export class GeometryBufferRenderer {
  148487. /**
  148488. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148489. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148490. */
  148491. static readonly POSITION_TEXTURE_TYPE: number;
  148492. /**
  148493. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148494. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148495. */
  148496. static readonly VELOCITY_TEXTURE_TYPE: number;
  148497. /**
  148498. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148499. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148500. */
  148501. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148502. /**
  148503. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148504. * in order to compute objects velocities when enableVelocity is set to "true"
  148505. * @hidden
  148506. */
  148507. _previousTransformationMatrices: {
  148508. [index: number]: ISavedTransformationMatrix;
  148509. };
  148510. /**
  148511. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148512. * in order to compute objects velocities when enableVelocity is set to "true"
  148513. * @hidden
  148514. */
  148515. _previousBonesTransformationMatrices: {
  148516. [index: number]: Float32Array;
  148517. };
  148518. /**
  148519. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148520. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148521. */
  148522. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148523. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148524. renderTransparentMeshes: boolean;
  148525. private _scene;
  148526. private _resizeObserver;
  148527. private _multiRenderTarget;
  148528. private _ratio;
  148529. private _enablePosition;
  148530. private _enableVelocity;
  148531. private _enableReflectivity;
  148532. private _positionIndex;
  148533. private _velocityIndex;
  148534. private _reflectivityIndex;
  148535. protected _effect: Effect;
  148536. protected _cachedDefines: string;
  148537. /**
  148538. * Set the render list (meshes to be rendered) used in the G buffer.
  148539. */
  148540. set renderList(meshes: Mesh[]);
  148541. /**
  148542. * Gets wether or not G buffer are supported by the running hardware.
  148543. * This requires draw buffer supports
  148544. */
  148545. get isSupported(): boolean;
  148546. /**
  148547. * Returns the index of the given texture type in the G-Buffer textures array
  148548. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148549. * @returns the index of the given texture type in the G-Buffer textures array
  148550. */
  148551. getTextureIndex(textureType: number): number;
  148552. /**
  148553. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148554. */
  148555. get enablePosition(): boolean;
  148556. /**
  148557. * Sets whether or not objects positions are enabled for the G buffer.
  148558. */
  148559. set enablePosition(enable: boolean);
  148560. /**
  148561. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148562. */
  148563. get enableVelocity(): boolean;
  148564. /**
  148565. * Sets wether or not objects velocities are enabled for the G buffer.
  148566. */
  148567. set enableVelocity(enable: boolean);
  148568. /**
  148569. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148570. */
  148571. get enableReflectivity(): boolean;
  148572. /**
  148573. * Sets wether or not objects roughness are enabled for the G buffer.
  148574. */
  148575. set enableReflectivity(enable: boolean);
  148576. /**
  148577. * Gets the scene associated with the buffer.
  148578. */
  148579. get scene(): Scene;
  148580. /**
  148581. * Gets the ratio used by the buffer during its creation.
  148582. * How big is the buffer related to the main canvas.
  148583. */
  148584. get ratio(): number;
  148585. /** @hidden */
  148586. static _SceneComponentInitialization: (scene: Scene) => void;
  148587. /**
  148588. * Creates a new G Buffer for the scene
  148589. * @param scene The scene the buffer belongs to
  148590. * @param ratio How big is the buffer related to the main canvas.
  148591. */
  148592. constructor(scene: Scene, ratio?: number);
  148593. /**
  148594. * Checks wether everything is ready to render a submesh to the G buffer.
  148595. * @param subMesh the submesh to check readiness for
  148596. * @param useInstances is the mesh drawn using instance or not
  148597. * @returns true if ready otherwise false
  148598. */
  148599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148600. /**
  148601. * Gets the current underlying G Buffer.
  148602. * @returns the buffer
  148603. */
  148604. getGBuffer(): MultiRenderTarget;
  148605. /**
  148606. * Gets the number of samples used to render the buffer (anti aliasing).
  148607. */
  148608. get samples(): number;
  148609. /**
  148610. * Sets the number of samples used to render the buffer (anti aliasing).
  148611. */
  148612. set samples(value: number);
  148613. /**
  148614. * Disposes the renderer and frees up associated resources.
  148615. */
  148616. dispose(): void;
  148617. protected _createRenderTargets(): void;
  148618. private _copyBonesTransformationMatrices;
  148619. }
  148620. }
  148621. declare module BABYLON {
  148622. interface Scene {
  148623. /** @hidden (Backing field) */
  148624. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148625. /**
  148626. * Gets or Sets the current geometry buffer associated to the scene.
  148627. */
  148628. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148629. /**
  148630. * Enables a GeometryBufferRender and associates it with the scene
  148631. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148632. * @returns the GeometryBufferRenderer
  148633. */
  148634. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148635. /**
  148636. * Disables the GeometryBufferRender associated with the scene
  148637. */
  148638. disableGeometryBufferRenderer(): void;
  148639. }
  148640. /**
  148641. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148642. * in several rendering techniques.
  148643. */
  148644. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148645. /**
  148646. * The component name helpful to identify the component in the list of scene components.
  148647. */
  148648. readonly name: string;
  148649. /**
  148650. * The scene the component belongs to.
  148651. */
  148652. scene: Scene;
  148653. /**
  148654. * Creates a new instance of the component for the given scene
  148655. * @param scene Defines the scene to register the component in
  148656. */
  148657. constructor(scene: Scene);
  148658. /**
  148659. * Registers the component in a given scene
  148660. */
  148661. register(): void;
  148662. /**
  148663. * Rebuilds the elements related to this component in case of
  148664. * context lost for instance.
  148665. */
  148666. rebuild(): void;
  148667. /**
  148668. * Disposes the component and the associated ressources
  148669. */
  148670. dispose(): void;
  148671. private _gatherRenderTargets;
  148672. }
  148673. }
  148674. declare module BABYLON {
  148675. /** @hidden */
  148676. export var motionBlurPixelShader: {
  148677. name: string;
  148678. shader: string;
  148679. };
  148680. }
  148681. declare module BABYLON {
  148682. /**
  148683. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148684. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148685. * As an example, all you have to do is to create the post-process:
  148686. * var mb = new BABYLON.MotionBlurPostProcess(
  148687. * 'mb', // The name of the effect.
  148688. * scene, // The scene containing the objects to blur according to their velocity.
  148689. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148690. * camera // The camera to apply the render pass to.
  148691. * );
  148692. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148693. */
  148694. export class MotionBlurPostProcess extends PostProcess {
  148695. /**
  148696. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148697. */
  148698. motionStrength: number;
  148699. /**
  148700. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148701. */
  148702. get motionBlurSamples(): number;
  148703. /**
  148704. * Sets the number of iterations to be used for motion blur quality
  148705. */
  148706. set motionBlurSamples(samples: number);
  148707. private _motionBlurSamples;
  148708. private _geometryBufferRenderer;
  148709. /**
  148710. * Creates a new instance MotionBlurPostProcess
  148711. * @param name The name of the effect.
  148712. * @param scene The scene containing the objects to blur according to their velocity.
  148713. * @param options The required width/height ratio to downsize to before computing the render pass.
  148714. * @param camera The camera to apply the render pass to.
  148715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148716. * @param engine The engine which the post process will be applied. (default: current engine)
  148717. * @param reusable If the post process can be reused on the same frame. (default: false)
  148718. * @param textureType Type of textures used when performing the post process. (default: 0)
  148719. * @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)
  148720. */
  148721. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148722. /**
  148723. * Excludes the given skinned mesh from computing bones velocities.
  148724. * 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.
  148725. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148726. */
  148727. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148728. /**
  148729. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148730. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148731. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148732. */
  148733. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148734. /**
  148735. * Disposes the post process.
  148736. * @param camera The camera to dispose the post process on.
  148737. */
  148738. dispose(camera?: Camera): void;
  148739. }
  148740. }
  148741. declare module BABYLON {
  148742. /** @hidden */
  148743. export var refractionPixelShader: {
  148744. name: string;
  148745. shader: string;
  148746. };
  148747. }
  148748. declare module BABYLON {
  148749. /**
  148750. * Post process which applies a refractin texture
  148751. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148752. */
  148753. export class RefractionPostProcess extends PostProcess {
  148754. /** the base color of the refraction (used to taint the rendering) */
  148755. color: Color3;
  148756. /** simulated refraction depth */
  148757. depth: number;
  148758. /** the coefficient of the base color (0 to remove base color tainting) */
  148759. colorLevel: number;
  148760. private _refTexture;
  148761. private _ownRefractionTexture;
  148762. /**
  148763. * Gets or sets the refraction texture
  148764. * Please note that you are responsible for disposing the texture if you set it manually
  148765. */
  148766. get refractionTexture(): Texture;
  148767. set refractionTexture(value: Texture);
  148768. /**
  148769. * Initializes the RefractionPostProcess
  148770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148771. * @param name The name of the effect.
  148772. * @param refractionTextureUrl Url of the refraction texture to use
  148773. * @param color the base color of the refraction (used to taint the rendering)
  148774. * @param depth simulated refraction depth
  148775. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148776. * @param camera The camera to apply the render pass to.
  148777. * @param options The required width/height ratio to downsize to before computing the render pass.
  148778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148779. * @param engine The engine which the post process will be applied. (default: current engine)
  148780. * @param reusable If the post process can be reused on the same frame. (default: false)
  148781. */
  148782. constructor(name: string, refractionTextureUrl: string,
  148783. /** the base color of the refraction (used to taint the rendering) */
  148784. color: Color3,
  148785. /** simulated refraction depth */
  148786. depth: number,
  148787. /** the coefficient of the base color (0 to remove base color tainting) */
  148788. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148789. /**
  148790. * Disposes of the post process
  148791. * @param camera Camera to dispose post process on
  148792. */
  148793. dispose(camera: Camera): void;
  148794. }
  148795. }
  148796. declare module BABYLON {
  148797. /** @hidden */
  148798. export var sharpenPixelShader: {
  148799. name: string;
  148800. shader: string;
  148801. };
  148802. }
  148803. declare module BABYLON {
  148804. /**
  148805. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148806. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148807. */
  148808. export class SharpenPostProcess extends PostProcess {
  148809. /**
  148810. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148811. */
  148812. colorAmount: number;
  148813. /**
  148814. * How much sharpness should be applied (default: 0.3)
  148815. */
  148816. edgeAmount: number;
  148817. /**
  148818. * Creates a new instance ConvolutionPostProcess
  148819. * @param name The name of the effect.
  148820. * @param options The required width/height ratio to downsize to before computing the render pass.
  148821. * @param camera The camera to apply the render pass to.
  148822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148823. * @param engine The engine which the post process will be applied. (default: current engine)
  148824. * @param reusable If the post process can be reused on the same frame. (default: false)
  148825. * @param textureType Type of textures used when performing the post process. (default: 0)
  148826. * @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)
  148827. */
  148828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148829. }
  148830. }
  148831. declare module BABYLON {
  148832. /**
  148833. * PostProcessRenderPipeline
  148834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148835. */
  148836. export class PostProcessRenderPipeline {
  148837. private engine;
  148838. private _renderEffects;
  148839. private _renderEffectsForIsolatedPass;
  148840. /**
  148841. * List of inspectable custom properties (used by the Inspector)
  148842. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148843. */
  148844. inspectableCustomProperties: IInspectable[];
  148845. /**
  148846. * @hidden
  148847. */
  148848. protected _cameras: Camera[];
  148849. /** @hidden */
  148850. _name: string;
  148851. /**
  148852. * Gets pipeline name
  148853. */
  148854. get name(): string;
  148855. /** Gets the list of attached cameras */
  148856. get cameras(): Camera[];
  148857. /**
  148858. * Initializes a PostProcessRenderPipeline
  148859. * @param engine engine to add the pipeline to
  148860. * @param name name of the pipeline
  148861. */
  148862. constructor(engine: Engine, name: string);
  148863. /**
  148864. * Gets the class name
  148865. * @returns "PostProcessRenderPipeline"
  148866. */
  148867. getClassName(): string;
  148868. /**
  148869. * If all the render effects in the pipeline are supported
  148870. */
  148871. get isSupported(): boolean;
  148872. /**
  148873. * Adds an effect to the pipeline
  148874. * @param renderEffect the effect to add
  148875. */
  148876. addEffect(renderEffect: PostProcessRenderEffect): void;
  148877. /** @hidden */
  148878. _rebuild(): void;
  148879. /** @hidden */
  148880. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148881. /** @hidden */
  148882. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148883. /** @hidden */
  148884. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148885. /** @hidden */
  148886. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148887. /** @hidden */
  148888. _attachCameras(cameras: Camera, unique: boolean): void;
  148889. /** @hidden */
  148890. _attachCameras(cameras: Camera[], unique: boolean): void;
  148891. /** @hidden */
  148892. _detachCameras(cameras: Camera): void;
  148893. /** @hidden */
  148894. _detachCameras(cameras: Nullable<Camera[]>): void;
  148895. /** @hidden */
  148896. _update(): void;
  148897. /** @hidden */
  148898. _reset(): void;
  148899. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148900. /**
  148901. * Sets the required values to the prepass renderer.
  148902. * @param prePassRenderer defines the prepass renderer to setup.
  148903. * @returns true if the pre pass is needed.
  148904. */
  148905. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148906. /**
  148907. * Disposes of the pipeline
  148908. */
  148909. dispose(): void;
  148910. }
  148911. }
  148912. declare module BABYLON {
  148913. /**
  148914. * PostProcessRenderPipelineManager class
  148915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148916. */
  148917. export class PostProcessRenderPipelineManager {
  148918. private _renderPipelines;
  148919. /**
  148920. * Initializes a PostProcessRenderPipelineManager
  148921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148922. */
  148923. constructor();
  148924. /**
  148925. * Gets the list of supported render pipelines
  148926. */
  148927. get supportedPipelines(): PostProcessRenderPipeline[];
  148928. /**
  148929. * Adds a pipeline to the manager
  148930. * @param renderPipeline The pipeline to add
  148931. */
  148932. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148933. /**
  148934. * Attaches a camera to the pipeline
  148935. * @param renderPipelineName The name of the pipeline to attach to
  148936. * @param cameras the camera to attach
  148937. * @param unique if the camera can be attached multiple times to the pipeline
  148938. */
  148939. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148940. /**
  148941. * Detaches a camera from the pipeline
  148942. * @param renderPipelineName The name of the pipeline to detach from
  148943. * @param cameras the camera to detach
  148944. */
  148945. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148946. /**
  148947. * Enables an effect by name on a pipeline
  148948. * @param renderPipelineName the name of the pipeline to enable the effect in
  148949. * @param renderEffectName the name of the effect to enable
  148950. * @param cameras the cameras that the effect should be enabled on
  148951. */
  148952. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148953. /**
  148954. * Disables an effect by name on a pipeline
  148955. * @param renderPipelineName the name of the pipeline to disable the effect in
  148956. * @param renderEffectName the name of the effect to disable
  148957. * @param cameras the cameras that the effect should be disabled on
  148958. */
  148959. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148960. /**
  148961. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148962. */
  148963. update(): void;
  148964. /** @hidden */
  148965. _rebuild(): void;
  148966. /**
  148967. * Disposes of the manager and pipelines
  148968. */
  148969. dispose(): void;
  148970. }
  148971. }
  148972. declare module BABYLON {
  148973. interface Scene {
  148974. /** @hidden (Backing field) */
  148975. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148976. /**
  148977. * Gets the postprocess render pipeline manager
  148978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148979. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148980. */
  148981. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148982. }
  148983. /**
  148984. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148985. */
  148986. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148987. /**
  148988. * The component name helpfull to identify the component in the list of scene components.
  148989. */
  148990. readonly name: string;
  148991. /**
  148992. * The scene the component belongs to.
  148993. */
  148994. scene: Scene;
  148995. /**
  148996. * Creates a new instance of the component for the given scene
  148997. * @param scene Defines the scene to register the component in
  148998. */
  148999. constructor(scene: Scene);
  149000. /**
  149001. * Registers the component in a given scene
  149002. */
  149003. register(): void;
  149004. /**
  149005. * Rebuilds the elements related to this component in case of
  149006. * context lost for instance.
  149007. */
  149008. rebuild(): void;
  149009. /**
  149010. * Disposes the component and the associated ressources
  149011. */
  149012. dispose(): void;
  149013. private _gatherRenderTargets;
  149014. }
  149015. }
  149016. declare module BABYLON {
  149017. /**
  149018. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  149019. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  149020. */
  149021. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149022. private _scene;
  149023. private _camerasToBeAttached;
  149024. /**
  149025. * ID of the sharpen post process,
  149026. */
  149027. private readonly SharpenPostProcessId;
  149028. /**
  149029. * @ignore
  149030. * ID of the image processing post process;
  149031. */
  149032. readonly ImageProcessingPostProcessId: string;
  149033. /**
  149034. * @ignore
  149035. * ID of the Fast Approximate Anti-Aliasing post process;
  149036. */
  149037. readonly FxaaPostProcessId: string;
  149038. /**
  149039. * ID of the chromatic aberration post process,
  149040. */
  149041. private readonly ChromaticAberrationPostProcessId;
  149042. /**
  149043. * ID of the grain post process
  149044. */
  149045. private readonly GrainPostProcessId;
  149046. /**
  149047. * Sharpen post process which will apply a sharpen convolution to enhance edges
  149048. */
  149049. sharpen: SharpenPostProcess;
  149050. private _sharpenEffect;
  149051. private bloom;
  149052. /**
  149053. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  149054. */
  149055. depthOfField: DepthOfFieldEffect;
  149056. /**
  149057. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149058. */
  149059. fxaa: FxaaPostProcess;
  149060. /**
  149061. * Image post processing pass used to perform operations such as tone mapping or color grading.
  149062. */
  149063. imageProcessing: ImageProcessingPostProcess;
  149064. /**
  149065. * Chromatic aberration post process which will shift rgb colors in the image
  149066. */
  149067. chromaticAberration: ChromaticAberrationPostProcess;
  149068. private _chromaticAberrationEffect;
  149069. /**
  149070. * Grain post process which add noise to the image
  149071. */
  149072. grain: GrainPostProcess;
  149073. private _grainEffect;
  149074. /**
  149075. * Glow post process which adds a glow to emissive areas of the image
  149076. */
  149077. private _glowLayer;
  149078. /**
  149079. * Animations which can be used to tweak settings over a period of time
  149080. */
  149081. animations: Animation[];
  149082. private _imageProcessingConfigurationObserver;
  149083. private _sharpenEnabled;
  149084. private _bloomEnabled;
  149085. private _depthOfFieldEnabled;
  149086. private _depthOfFieldBlurLevel;
  149087. private _fxaaEnabled;
  149088. private _imageProcessingEnabled;
  149089. private _defaultPipelineTextureType;
  149090. private _bloomScale;
  149091. private _chromaticAberrationEnabled;
  149092. private _grainEnabled;
  149093. private _buildAllowed;
  149094. /**
  149095. * Gets active scene
  149096. */
  149097. get scene(): Scene;
  149098. /**
  149099. * Enable or disable the sharpen process from the pipeline
  149100. */
  149101. set sharpenEnabled(enabled: boolean);
  149102. get sharpenEnabled(): boolean;
  149103. private _resizeObserver;
  149104. private _hardwareScaleLevel;
  149105. private _bloomKernel;
  149106. /**
  149107. * Specifies the size of the bloom blur kernel, relative to the final output size
  149108. */
  149109. get bloomKernel(): number;
  149110. set bloomKernel(value: number);
  149111. /**
  149112. * Specifies the weight of the bloom in the final rendering
  149113. */
  149114. private _bloomWeight;
  149115. /**
  149116. * Specifies the luma threshold for the area that will be blurred by the bloom
  149117. */
  149118. private _bloomThreshold;
  149119. private _hdr;
  149120. /**
  149121. * The strength of the bloom.
  149122. */
  149123. set bloomWeight(value: number);
  149124. get bloomWeight(): number;
  149125. /**
  149126. * The strength of the bloom.
  149127. */
  149128. set bloomThreshold(value: number);
  149129. get bloomThreshold(): number;
  149130. /**
  149131. * The scale of the bloom, lower value will provide better performance.
  149132. */
  149133. set bloomScale(value: number);
  149134. get bloomScale(): number;
  149135. /**
  149136. * Enable or disable the bloom from the pipeline
  149137. */
  149138. set bloomEnabled(enabled: boolean);
  149139. get bloomEnabled(): boolean;
  149140. private _rebuildBloom;
  149141. /**
  149142. * If the depth of field is enabled.
  149143. */
  149144. get depthOfFieldEnabled(): boolean;
  149145. set depthOfFieldEnabled(enabled: boolean);
  149146. /**
  149147. * Blur level of the depth of field effect. (Higher blur will effect performance)
  149148. */
  149149. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  149150. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  149151. /**
  149152. * If the anti aliasing is enabled.
  149153. */
  149154. set fxaaEnabled(enabled: boolean);
  149155. get fxaaEnabled(): boolean;
  149156. private _samples;
  149157. /**
  149158. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149159. */
  149160. set samples(sampleCount: number);
  149161. get samples(): number;
  149162. /**
  149163. * If image processing is enabled.
  149164. */
  149165. set imageProcessingEnabled(enabled: boolean);
  149166. get imageProcessingEnabled(): boolean;
  149167. /**
  149168. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  149169. */
  149170. set glowLayerEnabled(enabled: boolean);
  149171. get glowLayerEnabled(): boolean;
  149172. /**
  149173. * Gets the glow layer (or null if not defined)
  149174. */
  149175. get glowLayer(): Nullable<GlowLayer>;
  149176. /**
  149177. * Enable or disable the chromaticAberration process from the pipeline
  149178. */
  149179. set chromaticAberrationEnabled(enabled: boolean);
  149180. get chromaticAberrationEnabled(): boolean;
  149181. /**
  149182. * Enable or disable the grain process from the pipeline
  149183. */
  149184. set grainEnabled(enabled: boolean);
  149185. get grainEnabled(): boolean;
  149186. /**
  149187. * @constructor
  149188. * @param name - The rendering pipeline name (default: "")
  149189. * @param hdr - If high dynamic range textures should be used (default: true)
  149190. * @param scene - The scene linked to this pipeline (default: the last created scene)
  149191. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  149192. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  149193. */
  149194. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  149195. /**
  149196. * Get the class name
  149197. * @returns "DefaultRenderingPipeline"
  149198. */
  149199. getClassName(): string;
  149200. /**
  149201. * Force the compilation of the entire pipeline.
  149202. */
  149203. prepare(): void;
  149204. private _hasCleared;
  149205. private _prevPostProcess;
  149206. private _prevPrevPostProcess;
  149207. private _setAutoClearAndTextureSharing;
  149208. private _depthOfFieldSceneObserver;
  149209. private _buildPipeline;
  149210. private _disposePostProcesses;
  149211. /**
  149212. * Adds a camera to the pipeline
  149213. * @param camera the camera to be added
  149214. */
  149215. addCamera(camera: Camera): void;
  149216. /**
  149217. * Removes a camera from the pipeline
  149218. * @param camera the camera to remove
  149219. */
  149220. removeCamera(camera: Camera): void;
  149221. /**
  149222. * Dispose of the pipeline and stop all post processes
  149223. */
  149224. dispose(): void;
  149225. /**
  149226. * Serialize the rendering pipeline (Used when exporting)
  149227. * @returns the serialized object
  149228. */
  149229. serialize(): any;
  149230. /**
  149231. * Parse the serialized pipeline
  149232. * @param source Source pipeline.
  149233. * @param scene The scene to load the pipeline to.
  149234. * @param rootUrl The URL of the serialized pipeline.
  149235. * @returns An instantiated pipeline from the serialized object.
  149236. */
  149237. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  149238. }
  149239. }
  149240. declare module BABYLON {
  149241. /** @hidden */
  149242. export var lensHighlightsPixelShader: {
  149243. name: string;
  149244. shader: string;
  149245. };
  149246. }
  149247. declare module BABYLON {
  149248. /** @hidden */
  149249. export var depthOfFieldPixelShader: {
  149250. name: string;
  149251. shader: string;
  149252. };
  149253. }
  149254. declare module BABYLON {
  149255. /**
  149256. * BABYLON.JS Chromatic Aberration GLSL Shader
  149257. * Author: Olivier Guyot
  149258. * Separates very slightly R, G and B colors on the edges of the screen
  149259. * Inspired by Francois Tarlier & Martins Upitis
  149260. */
  149261. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  149262. /**
  149263. * @ignore
  149264. * The chromatic aberration PostProcess id in the pipeline
  149265. */
  149266. LensChromaticAberrationEffect: string;
  149267. /**
  149268. * @ignore
  149269. * The highlights enhancing PostProcess id in the pipeline
  149270. */
  149271. HighlightsEnhancingEffect: string;
  149272. /**
  149273. * @ignore
  149274. * The depth-of-field PostProcess id in the pipeline
  149275. */
  149276. LensDepthOfFieldEffect: string;
  149277. private _scene;
  149278. private _depthTexture;
  149279. private _grainTexture;
  149280. private _chromaticAberrationPostProcess;
  149281. private _highlightsPostProcess;
  149282. private _depthOfFieldPostProcess;
  149283. private _edgeBlur;
  149284. private _grainAmount;
  149285. private _chromaticAberration;
  149286. private _distortion;
  149287. private _highlightsGain;
  149288. private _highlightsThreshold;
  149289. private _dofDistance;
  149290. private _dofAperture;
  149291. private _dofDarken;
  149292. private _dofPentagon;
  149293. private _blurNoise;
  149294. /**
  149295. * @constructor
  149296. *
  149297. * Effect parameters are as follow:
  149298. * {
  149299. * chromatic_aberration: number; // from 0 to x (1 for realism)
  149300. * edge_blur: number; // from 0 to x (1 for realism)
  149301. * distortion: number; // from 0 to x (1 for realism)
  149302. * grain_amount: number; // from 0 to 1
  149303. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  149304. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  149305. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  149306. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  149307. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  149308. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  149309. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  149310. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  149311. * }
  149312. * Note: if an effect parameter is unset, effect is disabled
  149313. *
  149314. * @param name The rendering pipeline name
  149315. * @param parameters - An object containing all parameters (see above)
  149316. * @param scene The scene linked to this pipeline
  149317. * @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)
  149318. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149319. */
  149320. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  149321. /**
  149322. * Get the class name
  149323. * @returns "LensRenderingPipeline"
  149324. */
  149325. getClassName(): string;
  149326. /**
  149327. * Gets associated scene
  149328. */
  149329. get scene(): Scene;
  149330. /**
  149331. * Gets or sets the edge blur
  149332. */
  149333. get edgeBlur(): number;
  149334. set edgeBlur(value: number);
  149335. /**
  149336. * Gets or sets the grain amount
  149337. */
  149338. get grainAmount(): number;
  149339. set grainAmount(value: number);
  149340. /**
  149341. * Gets or sets the chromatic aberration amount
  149342. */
  149343. get chromaticAberration(): number;
  149344. set chromaticAberration(value: number);
  149345. /**
  149346. * Gets or sets the depth of field aperture
  149347. */
  149348. get dofAperture(): number;
  149349. set dofAperture(value: number);
  149350. /**
  149351. * Gets or sets the edge distortion
  149352. */
  149353. get edgeDistortion(): number;
  149354. set edgeDistortion(value: number);
  149355. /**
  149356. * Gets or sets the depth of field distortion
  149357. */
  149358. get dofDistortion(): number;
  149359. set dofDistortion(value: number);
  149360. /**
  149361. * Gets or sets the darken out of focus amount
  149362. */
  149363. get darkenOutOfFocus(): number;
  149364. set darkenOutOfFocus(value: number);
  149365. /**
  149366. * Gets or sets a boolean indicating if blur noise is enabled
  149367. */
  149368. get blurNoise(): boolean;
  149369. set blurNoise(value: boolean);
  149370. /**
  149371. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149372. */
  149373. get pentagonBokeh(): boolean;
  149374. set pentagonBokeh(value: boolean);
  149375. /**
  149376. * Gets or sets the highlight grain amount
  149377. */
  149378. get highlightsGain(): number;
  149379. set highlightsGain(value: number);
  149380. /**
  149381. * Gets or sets the highlight threshold
  149382. */
  149383. get highlightsThreshold(): number;
  149384. set highlightsThreshold(value: number);
  149385. /**
  149386. * Sets the amount of blur at the edges
  149387. * @param amount blur amount
  149388. */
  149389. setEdgeBlur(amount: number): void;
  149390. /**
  149391. * Sets edge blur to 0
  149392. */
  149393. disableEdgeBlur(): void;
  149394. /**
  149395. * Sets the amout of grain
  149396. * @param amount Amount of grain
  149397. */
  149398. setGrainAmount(amount: number): void;
  149399. /**
  149400. * Set grain amount to 0
  149401. */
  149402. disableGrain(): void;
  149403. /**
  149404. * Sets the chromatic aberration amount
  149405. * @param amount amount of chromatic aberration
  149406. */
  149407. setChromaticAberration(amount: number): void;
  149408. /**
  149409. * Sets chromatic aberration amount to 0
  149410. */
  149411. disableChromaticAberration(): void;
  149412. /**
  149413. * Sets the EdgeDistortion amount
  149414. * @param amount amount of EdgeDistortion
  149415. */
  149416. setEdgeDistortion(amount: number): void;
  149417. /**
  149418. * Sets edge distortion to 0
  149419. */
  149420. disableEdgeDistortion(): void;
  149421. /**
  149422. * Sets the FocusDistance amount
  149423. * @param amount amount of FocusDistance
  149424. */
  149425. setFocusDistance(amount: number): void;
  149426. /**
  149427. * Disables depth of field
  149428. */
  149429. disableDepthOfField(): void;
  149430. /**
  149431. * Sets the Aperture amount
  149432. * @param amount amount of Aperture
  149433. */
  149434. setAperture(amount: number): void;
  149435. /**
  149436. * Sets the DarkenOutOfFocus amount
  149437. * @param amount amount of DarkenOutOfFocus
  149438. */
  149439. setDarkenOutOfFocus(amount: number): void;
  149440. private _pentagonBokehIsEnabled;
  149441. /**
  149442. * Creates a pentagon bokeh effect
  149443. */
  149444. enablePentagonBokeh(): void;
  149445. /**
  149446. * Disables the pentagon bokeh effect
  149447. */
  149448. disablePentagonBokeh(): void;
  149449. /**
  149450. * Enables noise blur
  149451. */
  149452. enableNoiseBlur(): void;
  149453. /**
  149454. * Disables noise blur
  149455. */
  149456. disableNoiseBlur(): void;
  149457. /**
  149458. * Sets the HighlightsGain amount
  149459. * @param amount amount of HighlightsGain
  149460. */
  149461. setHighlightsGain(amount: number): void;
  149462. /**
  149463. * Sets the HighlightsThreshold amount
  149464. * @param amount amount of HighlightsThreshold
  149465. */
  149466. setHighlightsThreshold(amount: number): void;
  149467. /**
  149468. * Disables highlights
  149469. */
  149470. disableHighlights(): void;
  149471. /**
  149472. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149473. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149474. */
  149475. dispose(disableDepthRender?: boolean): void;
  149476. private _createChromaticAberrationPostProcess;
  149477. private _createHighlightsPostProcess;
  149478. private _createDepthOfFieldPostProcess;
  149479. private _createGrainTexture;
  149480. }
  149481. }
  149482. declare module BABYLON {
  149483. /** @hidden */
  149484. export var ssao2PixelShader: {
  149485. name: string;
  149486. shader: string;
  149487. };
  149488. }
  149489. declare module BABYLON {
  149490. /** @hidden */
  149491. export var ssaoCombinePixelShader: {
  149492. name: string;
  149493. shader: string;
  149494. };
  149495. }
  149496. declare module BABYLON {
  149497. /**
  149498. * Render pipeline to produce ssao effect
  149499. */
  149500. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149501. /**
  149502. * @ignore
  149503. * The PassPostProcess id in the pipeline that contains the original scene color
  149504. */
  149505. SSAOOriginalSceneColorEffect: string;
  149506. /**
  149507. * @ignore
  149508. * The SSAO PostProcess id in the pipeline
  149509. */
  149510. SSAORenderEffect: string;
  149511. /**
  149512. * @ignore
  149513. * The horizontal blur PostProcess id in the pipeline
  149514. */
  149515. SSAOBlurHRenderEffect: string;
  149516. /**
  149517. * @ignore
  149518. * The vertical blur PostProcess id in the pipeline
  149519. */
  149520. SSAOBlurVRenderEffect: string;
  149521. /**
  149522. * @ignore
  149523. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149524. */
  149525. SSAOCombineRenderEffect: string;
  149526. /**
  149527. * The output strength of the SSAO post-process. Default value is 1.0.
  149528. */
  149529. totalStrength: number;
  149530. /**
  149531. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149532. */
  149533. maxZ: number;
  149534. /**
  149535. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149536. */
  149537. minZAspect: number;
  149538. private _samples;
  149539. /**
  149540. * Number of samples used for the SSAO calculations. Default value is 8
  149541. */
  149542. set samples(n: number);
  149543. get samples(): number;
  149544. private _textureSamples;
  149545. /**
  149546. * Number of samples to use for antialiasing
  149547. */
  149548. set textureSamples(n: number);
  149549. get textureSamples(): number;
  149550. /**
  149551. * Force rendering the geometry through geometry buffer
  149552. */
  149553. private _forceGeometryBuffer;
  149554. /**
  149555. * Ratio object used for SSAO ratio and blur ratio
  149556. */
  149557. private _ratio;
  149558. /**
  149559. * Dynamically generated sphere sampler.
  149560. */
  149561. private _sampleSphere;
  149562. /**
  149563. * Blur filter offsets
  149564. */
  149565. private _samplerOffsets;
  149566. private _expensiveBlur;
  149567. /**
  149568. * If bilateral blur should be used
  149569. */
  149570. set expensiveBlur(b: boolean);
  149571. get expensiveBlur(): boolean;
  149572. /**
  149573. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149574. */
  149575. radius: number;
  149576. /**
  149577. * The base color of the SSAO post-process
  149578. * The final result is "base + ssao" between [0, 1]
  149579. */
  149580. base: number;
  149581. /**
  149582. * Support test.
  149583. */
  149584. static get IsSupported(): boolean;
  149585. private _scene;
  149586. private _randomTexture;
  149587. private _originalColorPostProcess;
  149588. private _ssaoPostProcess;
  149589. private _blurHPostProcess;
  149590. private _blurVPostProcess;
  149591. private _ssaoCombinePostProcess;
  149592. private _prePassRenderer;
  149593. /**
  149594. * Gets active scene
  149595. */
  149596. get scene(): Scene;
  149597. /**
  149598. * @constructor
  149599. * @param name The rendering pipeline name
  149600. * @param scene The scene linked to this pipeline
  149601. * @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 }
  149602. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149603. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149604. */
  149605. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149606. /**
  149607. * Get the class name
  149608. * @returns "SSAO2RenderingPipeline"
  149609. */
  149610. getClassName(): string;
  149611. /**
  149612. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149613. */
  149614. dispose(disableGeometryBufferRenderer?: boolean): void;
  149615. private _createBlurPostProcess;
  149616. /** @hidden */
  149617. _rebuild(): void;
  149618. private _bits;
  149619. private _radicalInverse_VdC;
  149620. private _hammersley;
  149621. private _hemisphereSample_uniform;
  149622. private _generateHemisphere;
  149623. private _getDefinesForSSAO;
  149624. private _createSSAOPostProcess;
  149625. private _createSSAOCombinePostProcess;
  149626. private _createRandomTexture;
  149627. /**
  149628. * Serialize the rendering pipeline (Used when exporting)
  149629. * @returns the serialized object
  149630. */
  149631. serialize(): any;
  149632. /**
  149633. * Parse the serialized pipeline
  149634. * @param source Source pipeline.
  149635. * @param scene The scene to load the pipeline to.
  149636. * @param rootUrl The URL of the serialized pipeline.
  149637. * @returns An instantiated pipeline from the serialized object.
  149638. */
  149639. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149640. /**
  149641. * Sets the required values to the prepass renderer.
  149642. * @param prePassRenderer defines the prepass renderer to setup
  149643. * @returns true if the pre pass is needed.
  149644. */
  149645. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149646. }
  149647. }
  149648. declare module BABYLON {
  149649. /** @hidden */
  149650. export var ssaoPixelShader: {
  149651. name: string;
  149652. shader: string;
  149653. };
  149654. }
  149655. declare module BABYLON {
  149656. /**
  149657. * Render pipeline to produce ssao effect
  149658. */
  149659. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149660. /**
  149661. * @ignore
  149662. * The PassPostProcess id in the pipeline that contains the original scene color
  149663. */
  149664. SSAOOriginalSceneColorEffect: string;
  149665. /**
  149666. * @ignore
  149667. * The SSAO PostProcess id in the pipeline
  149668. */
  149669. SSAORenderEffect: string;
  149670. /**
  149671. * @ignore
  149672. * The horizontal blur PostProcess id in the pipeline
  149673. */
  149674. SSAOBlurHRenderEffect: string;
  149675. /**
  149676. * @ignore
  149677. * The vertical blur PostProcess id in the pipeline
  149678. */
  149679. SSAOBlurVRenderEffect: string;
  149680. /**
  149681. * @ignore
  149682. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149683. */
  149684. SSAOCombineRenderEffect: string;
  149685. /**
  149686. * The output strength of the SSAO post-process. Default value is 1.0.
  149687. */
  149688. totalStrength: number;
  149689. /**
  149690. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149691. */
  149692. radius: number;
  149693. /**
  149694. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149695. * Must not be equal to fallOff and superior to fallOff.
  149696. * Default value is 0.0075
  149697. */
  149698. area: number;
  149699. /**
  149700. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149701. * Must not be equal to area and inferior to area.
  149702. * Default value is 0.000001
  149703. */
  149704. fallOff: number;
  149705. /**
  149706. * The base color of the SSAO post-process
  149707. * The final result is "base + ssao" between [0, 1]
  149708. */
  149709. base: number;
  149710. private _scene;
  149711. private _depthTexture;
  149712. private _randomTexture;
  149713. private _originalColorPostProcess;
  149714. private _ssaoPostProcess;
  149715. private _blurHPostProcess;
  149716. private _blurVPostProcess;
  149717. private _ssaoCombinePostProcess;
  149718. private _firstUpdate;
  149719. /**
  149720. * Gets active scene
  149721. */
  149722. get scene(): Scene;
  149723. /**
  149724. * @constructor
  149725. * @param name - The rendering pipeline name
  149726. * @param scene - The scene linked to this pipeline
  149727. * @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 }
  149728. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149729. */
  149730. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149731. /**
  149732. * Get the class name
  149733. * @returns "SSAORenderingPipeline"
  149734. */
  149735. getClassName(): string;
  149736. /**
  149737. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149738. */
  149739. dispose(disableDepthRender?: boolean): void;
  149740. private _createBlurPostProcess;
  149741. /** @hidden */
  149742. _rebuild(): void;
  149743. private _createSSAOPostProcess;
  149744. private _createSSAOCombinePostProcess;
  149745. private _createRandomTexture;
  149746. }
  149747. }
  149748. declare module BABYLON {
  149749. /** @hidden */
  149750. export var screenSpaceReflectionPixelShader: {
  149751. name: string;
  149752. shader: string;
  149753. };
  149754. }
  149755. declare module BABYLON {
  149756. /**
  149757. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149758. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149759. */
  149760. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149761. /**
  149762. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149763. */
  149764. threshold: number;
  149765. /**
  149766. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149767. */
  149768. strength: number;
  149769. /**
  149770. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149771. */
  149772. reflectionSpecularFalloffExponent: number;
  149773. /**
  149774. * 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]
  149775. */
  149776. step: number;
  149777. /**
  149778. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149779. */
  149780. roughnessFactor: number;
  149781. private _geometryBufferRenderer;
  149782. private _enableSmoothReflections;
  149783. private _reflectionSamples;
  149784. private _smoothSteps;
  149785. /**
  149786. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149787. * @param name The name of the effect.
  149788. * @param scene The scene containing the objects to calculate reflections.
  149789. * @param options The required width/height ratio to downsize to before computing the render pass.
  149790. * @param camera The camera to apply the render pass to.
  149791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149792. * @param engine The engine which the post process will be applied. (default: current engine)
  149793. * @param reusable If the post process can be reused on the same frame. (default: false)
  149794. * @param textureType Type of textures used when performing the post process. (default: 0)
  149795. * @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)
  149796. */
  149797. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149798. /**
  149799. * Gets wether or not smoothing reflections is enabled.
  149800. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149801. */
  149802. get enableSmoothReflections(): boolean;
  149803. /**
  149804. * Sets wether or not smoothing reflections is enabled.
  149805. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149806. */
  149807. set enableSmoothReflections(enabled: boolean);
  149808. /**
  149809. * Gets the number of samples taken while computing reflections. More samples count is high,
  149810. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149811. */
  149812. get reflectionSamples(): number;
  149813. /**
  149814. * Sets the number of samples taken while computing reflections. More samples count is high,
  149815. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149816. */
  149817. set reflectionSamples(samples: number);
  149818. /**
  149819. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149820. * more the post-process will require GPU power and can generate a drop in FPS.
  149821. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149822. */
  149823. get smoothSteps(): number;
  149824. set smoothSteps(steps: number);
  149825. private _updateEffectDefines;
  149826. }
  149827. }
  149828. declare module BABYLON {
  149829. /** @hidden */
  149830. export var standardPixelShader: {
  149831. name: string;
  149832. shader: string;
  149833. };
  149834. }
  149835. declare module BABYLON {
  149836. /**
  149837. * Standard rendering pipeline
  149838. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149839. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149840. */
  149841. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149842. /**
  149843. * Public members
  149844. */
  149845. /**
  149846. * Post-process which contains the original scene color before the pipeline applies all the effects
  149847. */
  149848. originalPostProcess: Nullable<PostProcess>;
  149849. /**
  149850. * Post-process used to down scale an image x4
  149851. */
  149852. downSampleX4PostProcess: Nullable<PostProcess>;
  149853. /**
  149854. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149855. */
  149856. brightPassPostProcess: Nullable<PostProcess>;
  149857. /**
  149858. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149859. */
  149860. blurHPostProcesses: PostProcess[];
  149861. /**
  149862. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149863. */
  149864. blurVPostProcesses: PostProcess[];
  149865. /**
  149866. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149867. */
  149868. textureAdderPostProcess: Nullable<PostProcess>;
  149869. /**
  149870. * Post-process used to create volumetric lighting effect
  149871. */
  149872. volumetricLightPostProcess: Nullable<PostProcess>;
  149873. /**
  149874. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149875. */
  149876. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149877. /**
  149878. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149879. */
  149880. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149881. /**
  149882. * Post-process used to merge the volumetric light effect and the real scene color
  149883. */
  149884. volumetricLightMergePostProces: Nullable<PostProcess>;
  149885. /**
  149886. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149887. */
  149888. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149889. /**
  149890. * Base post-process used to calculate the average luminance of the final image for HDR
  149891. */
  149892. luminancePostProcess: Nullable<PostProcess>;
  149893. /**
  149894. * Post-processes used to create down sample post-processes in order to get
  149895. * the average luminance of the final image for HDR
  149896. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149897. */
  149898. luminanceDownSamplePostProcesses: PostProcess[];
  149899. /**
  149900. * Post-process used to create a HDR effect (light adaptation)
  149901. */
  149902. hdrPostProcess: Nullable<PostProcess>;
  149903. /**
  149904. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149905. */
  149906. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149907. /**
  149908. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149909. */
  149910. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149911. /**
  149912. * Post-process used to merge the final HDR post-process and the real scene color
  149913. */
  149914. hdrFinalPostProcess: Nullable<PostProcess>;
  149915. /**
  149916. * Post-process used to create a lens flare effect
  149917. */
  149918. lensFlarePostProcess: Nullable<PostProcess>;
  149919. /**
  149920. * Post-process that merges the result of the lens flare post-process and the real scene color
  149921. */
  149922. lensFlareComposePostProcess: Nullable<PostProcess>;
  149923. /**
  149924. * Post-process used to create a motion blur effect
  149925. */
  149926. motionBlurPostProcess: Nullable<PostProcess>;
  149927. /**
  149928. * Post-process used to create a depth of field effect
  149929. */
  149930. depthOfFieldPostProcess: Nullable<PostProcess>;
  149931. /**
  149932. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149933. */
  149934. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149935. /**
  149936. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149937. */
  149938. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149939. /**
  149940. * Represents the brightness threshold in order to configure the illuminated surfaces
  149941. */
  149942. brightThreshold: number;
  149943. /**
  149944. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149945. */
  149946. blurWidth: number;
  149947. /**
  149948. * Sets if the blur for highlighted surfaces must be only horizontal
  149949. */
  149950. horizontalBlur: boolean;
  149951. /**
  149952. * Gets the overall exposure used by the pipeline
  149953. */
  149954. get exposure(): number;
  149955. /**
  149956. * Sets the overall exposure used by the pipeline
  149957. */
  149958. set exposure(value: number);
  149959. /**
  149960. * Texture used typically to simulate "dirty" on camera lens
  149961. */
  149962. lensTexture: Nullable<Texture>;
  149963. /**
  149964. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149965. */
  149966. volumetricLightCoefficient: number;
  149967. /**
  149968. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149969. */
  149970. volumetricLightPower: number;
  149971. /**
  149972. * Used the set the blur intensity to smooth the volumetric lights
  149973. */
  149974. volumetricLightBlurScale: number;
  149975. /**
  149976. * Light (spot or directional) used to generate the volumetric lights rays
  149977. * The source light must have a shadow generate so the pipeline can get its
  149978. * depth map
  149979. */
  149980. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149981. /**
  149982. * For eye adaptation, represents the minimum luminance the eye can see
  149983. */
  149984. hdrMinimumLuminance: number;
  149985. /**
  149986. * For eye adaptation, represents the decrease luminance speed
  149987. */
  149988. hdrDecreaseRate: number;
  149989. /**
  149990. * For eye adaptation, represents the increase luminance speed
  149991. */
  149992. hdrIncreaseRate: number;
  149993. /**
  149994. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149995. */
  149996. get hdrAutoExposure(): boolean;
  149997. /**
  149998. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149999. */
  150000. set hdrAutoExposure(value: boolean);
  150001. /**
  150002. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  150003. */
  150004. lensColorTexture: Nullable<Texture>;
  150005. /**
  150006. * The overall strengh for the lens flare effect
  150007. */
  150008. lensFlareStrength: number;
  150009. /**
  150010. * Dispersion coefficient for lens flare ghosts
  150011. */
  150012. lensFlareGhostDispersal: number;
  150013. /**
  150014. * Main lens flare halo width
  150015. */
  150016. lensFlareHaloWidth: number;
  150017. /**
  150018. * Based on the lens distortion effect, defines how much the lens flare result
  150019. * is distorted
  150020. */
  150021. lensFlareDistortionStrength: number;
  150022. /**
  150023. * Configures the blur intensity used for for lens flare (halo)
  150024. */
  150025. lensFlareBlurWidth: number;
  150026. /**
  150027. * Lens star texture must be used to simulate rays on the flares and is available
  150028. * in the documentation
  150029. */
  150030. lensStarTexture: Nullable<Texture>;
  150031. /**
  150032. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  150033. * flare effect by taking account of the dirt texture
  150034. */
  150035. lensFlareDirtTexture: Nullable<Texture>;
  150036. /**
  150037. * Represents the focal length for the depth of field effect
  150038. */
  150039. depthOfFieldDistance: number;
  150040. /**
  150041. * Represents the blur intensity for the blurred part of the depth of field effect
  150042. */
  150043. depthOfFieldBlurWidth: number;
  150044. /**
  150045. * Gets how much the image is blurred by the movement while using the motion blur post-process
  150046. */
  150047. get motionStrength(): number;
  150048. /**
  150049. * Sets how much the image is blurred by the movement while using the motion blur post-process
  150050. */
  150051. set motionStrength(strength: number);
  150052. /**
  150053. * Gets wether or not the motion blur post-process is object based or screen based.
  150054. */
  150055. get objectBasedMotionBlur(): boolean;
  150056. /**
  150057. * Sets wether or not the motion blur post-process should be object based or screen based
  150058. */
  150059. set objectBasedMotionBlur(value: boolean);
  150060. /**
  150061. * List of animations for the pipeline (IAnimatable implementation)
  150062. */
  150063. animations: Animation[];
  150064. /**
  150065. * Private members
  150066. */
  150067. private _scene;
  150068. private _currentDepthOfFieldSource;
  150069. private _basePostProcess;
  150070. private _fixedExposure;
  150071. private _currentExposure;
  150072. private _hdrAutoExposure;
  150073. private _hdrCurrentLuminance;
  150074. private _motionStrength;
  150075. private _isObjectBasedMotionBlur;
  150076. private _floatTextureType;
  150077. private _camerasToBeAttached;
  150078. private _ratio;
  150079. private _bloomEnabled;
  150080. private _depthOfFieldEnabled;
  150081. private _vlsEnabled;
  150082. private _lensFlareEnabled;
  150083. private _hdrEnabled;
  150084. private _motionBlurEnabled;
  150085. private _fxaaEnabled;
  150086. private _screenSpaceReflectionsEnabled;
  150087. private _motionBlurSamples;
  150088. private _volumetricLightStepsCount;
  150089. private _samples;
  150090. /**
  150091. * @ignore
  150092. * Specifies if the bloom pipeline is enabled
  150093. */
  150094. get BloomEnabled(): boolean;
  150095. set BloomEnabled(enabled: boolean);
  150096. /**
  150097. * @ignore
  150098. * Specifies if the depth of field pipeline is enabed
  150099. */
  150100. get DepthOfFieldEnabled(): boolean;
  150101. set DepthOfFieldEnabled(enabled: boolean);
  150102. /**
  150103. * @ignore
  150104. * Specifies if the lens flare pipeline is enabed
  150105. */
  150106. get LensFlareEnabled(): boolean;
  150107. set LensFlareEnabled(enabled: boolean);
  150108. /**
  150109. * @ignore
  150110. * Specifies if the HDR pipeline is enabled
  150111. */
  150112. get HDREnabled(): boolean;
  150113. set HDREnabled(enabled: boolean);
  150114. /**
  150115. * @ignore
  150116. * Specifies if the volumetric lights scattering effect is enabled
  150117. */
  150118. get VLSEnabled(): boolean;
  150119. set VLSEnabled(enabled: boolean);
  150120. /**
  150121. * @ignore
  150122. * Specifies if the motion blur effect is enabled
  150123. */
  150124. get MotionBlurEnabled(): boolean;
  150125. set MotionBlurEnabled(enabled: boolean);
  150126. /**
  150127. * Specifies if anti-aliasing is enabled
  150128. */
  150129. get fxaaEnabled(): boolean;
  150130. set fxaaEnabled(enabled: boolean);
  150131. /**
  150132. * Specifies if screen space reflections are enabled.
  150133. */
  150134. get screenSpaceReflectionsEnabled(): boolean;
  150135. set screenSpaceReflectionsEnabled(enabled: boolean);
  150136. /**
  150137. * Specifies the number of steps used to calculate the volumetric lights
  150138. * Typically in interval [50, 200]
  150139. */
  150140. get volumetricLightStepsCount(): number;
  150141. set volumetricLightStepsCount(count: number);
  150142. /**
  150143. * Specifies the number of samples used for the motion blur effect
  150144. * Typically in interval [16, 64]
  150145. */
  150146. get motionBlurSamples(): number;
  150147. set motionBlurSamples(samples: number);
  150148. /**
  150149. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150150. */
  150151. get samples(): number;
  150152. set samples(sampleCount: number);
  150153. /**
  150154. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150155. * @constructor
  150156. * @param name The rendering pipeline name
  150157. * @param scene The scene linked to this pipeline
  150158. * @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)
  150159. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  150160. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150161. */
  150162. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  150163. private _buildPipeline;
  150164. private _createDownSampleX4PostProcess;
  150165. private _createBrightPassPostProcess;
  150166. private _createBlurPostProcesses;
  150167. private _createTextureAdderPostProcess;
  150168. private _createVolumetricLightPostProcess;
  150169. private _createLuminancePostProcesses;
  150170. private _createHdrPostProcess;
  150171. private _createLensFlarePostProcess;
  150172. private _createDepthOfFieldPostProcess;
  150173. private _createMotionBlurPostProcess;
  150174. private _getDepthTexture;
  150175. private _disposePostProcesses;
  150176. /**
  150177. * Dispose of the pipeline and stop all post processes
  150178. */
  150179. dispose(): void;
  150180. /**
  150181. * Serialize the rendering pipeline (Used when exporting)
  150182. * @returns the serialized object
  150183. */
  150184. serialize(): any;
  150185. /**
  150186. * Parse the serialized pipeline
  150187. * @param source Source pipeline.
  150188. * @param scene The scene to load the pipeline to.
  150189. * @param rootUrl The URL of the serialized pipeline.
  150190. * @returns An instantiated pipeline from the serialized object.
  150191. */
  150192. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  150193. /**
  150194. * Luminance steps
  150195. */
  150196. static LuminanceSteps: number;
  150197. }
  150198. }
  150199. declare module BABYLON {
  150200. /** @hidden */
  150201. export var stereoscopicInterlacePixelShader: {
  150202. name: string;
  150203. shader: string;
  150204. };
  150205. }
  150206. declare module BABYLON {
  150207. /**
  150208. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  150209. */
  150210. export class StereoscopicInterlacePostProcessI extends PostProcess {
  150211. private _stepSize;
  150212. private _passedProcess;
  150213. /**
  150214. * Initializes a StereoscopicInterlacePostProcessI
  150215. * @param name The name of the effect.
  150216. * @param rigCameras The rig cameras to be appled to the post process
  150217. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  150218. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  150219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150220. * @param engine The engine which the post process will be applied. (default: current engine)
  150221. * @param reusable If the post process can be reused on the same frame. (default: false)
  150222. */
  150223. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150224. }
  150225. /**
  150226. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  150227. */
  150228. export class StereoscopicInterlacePostProcess extends PostProcess {
  150229. private _stepSize;
  150230. private _passedProcess;
  150231. /**
  150232. * Initializes a StereoscopicInterlacePostProcess
  150233. * @param name The name of the effect.
  150234. * @param rigCameras The rig cameras to be appled to the post process
  150235. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  150236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150237. * @param engine The engine which the post process will be applied. (default: current engine)
  150238. * @param reusable If the post process can be reused on the same frame. (default: false)
  150239. */
  150240. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150241. }
  150242. }
  150243. declare module BABYLON {
  150244. /** @hidden */
  150245. export var tonemapPixelShader: {
  150246. name: string;
  150247. shader: string;
  150248. };
  150249. }
  150250. declare module BABYLON {
  150251. /** Defines operator used for tonemapping */
  150252. export enum TonemappingOperator {
  150253. /** Hable */
  150254. Hable = 0,
  150255. /** Reinhard */
  150256. Reinhard = 1,
  150257. /** HejiDawson */
  150258. HejiDawson = 2,
  150259. /** Photographic */
  150260. Photographic = 3
  150261. }
  150262. /**
  150263. * Defines a post process to apply tone mapping
  150264. */
  150265. export class TonemapPostProcess extends PostProcess {
  150266. private _operator;
  150267. /** Defines the required exposure adjustement */
  150268. exposureAdjustment: number;
  150269. /**
  150270. * Creates a new TonemapPostProcess
  150271. * @param name defines the name of the postprocess
  150272. * @param _operator defines the operator to use
  150273. * @param exposureAdjustment defines the required exposure adjustement
  150274. * @param camera defines the camera to use (can be null)
  150275. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  150276. * @param engine defines the hosting engine (can be ignore if camera is set)
  150277. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150278. */
  150279. constructor(name: string, _operator: TonemappingOperator,
  150280. /** Defines the required exposure adjustement */
  150281. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  150282. }
  150283. }
  150284. declare module BABYLON {
  150285. /** @hidden */
  150286. export var volumetricLightScatteringPixelShader: {
  150287. name: string;
  150288. shader: string;
  150289. };
  150290. }
  150291. declare module BABYLON {
  150292. /** @hidden */
  150293. export var volumetricLightScatteringPassVertexShader: {
  150294. name: string;
  150295. shader: string;
  150296. };
  150297. }
  150298. declare module BABYLON {
  150299. /** @hidden */
  150300. export var volumetricLightScatteringPassPixelShader: {
  150301. name: string;
  150302. shader: string;
  150303. };
  150304. }
  150305. declare module BABYLON {
  150306. /**
  150307. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  150308. */
  150309. export class VolumetricLightScatteringPostProcess extends PostProcess {
  150310. private _volumetricLightScatteringPass;
  150311. private _volumetricLightScatteringRTT;
  150312. private _viewPort;
  150313. private _screenCoordinates;
  150314. private _cachedDefines;
  150315. /**
  150316. * If not undefined, the mesh position is computed from the attached node position
  150317. */
  150318. attachedNode: {
  150319. position: Vector3;
  150320. };
  150321. /**
  150322. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  150323. */
  150324. customMeshPosition: Vector3;
  150325. /**
  150326. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  150327. */
  150328. useCustomMeshPosition: boolean;
  150329. /**
  150330. * If the post-process should inverse the light scattering direction
  150331. */
  150332. invert: boolean;
  150333. /**
  150334. * The internal mesh used by the post-process
  150335. */
  150336. mesh: Mesh;
  150337. /**
  150338. * @hidden
  150339. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  150340. */
  150341. get useDiffuseColor(): boolean;
  150342. set useDiffuseColor(useDiffuseColor: boolean);
  150343. /**
  150344. * Array containing the excluded meshes not rendered in the internal pass
  150345. */
  150346. excludedMeshes: AbstractMesh[];
  150347. /**
  150348. * Controls the overall intensity of the post-process
  150349. */
  150350. exposure: number;
  150351. /**
  150352. * Dissipates each sample's contribution in range [0, 1]
  150353. */
  150354. decay: number;
  150355. /**
  150356. * Controls the overall intensity of each sample
  150357. */
  150358. weight: number;
  150359. /**
  150360. * Controls the density of each sample
  150361. */
  150362. density: number;
  150363. /**
  150364. * @constructor
  150365. * @param name The post-process name
  150366. * @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)
  150367. * @param camera The camera that the post-process will be attached to
  150368. * @param mesh The mesh used to create the light scattering
  150369. * @param samples The post-process quality, default 100
  150370. * @param samplingModeThe post-process filtering mode
  150371. * @param engine The babylon engine
  150372. * @param reusable If the post-process is reusable
  150373. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150374. */
  150375. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150376. /**
  150377. * Returns the string "VolumetricLightScatteringPostProcess"
  150378. * @returns "VolumetricLightScatteringPostProcess"
  150379. */
  150380. getClassName(): string;
  150381. private _isReady;
  150382. /**
  150383. * Sets the new light position for light scattering effect
  150384. * @param position The new custom light position
  150385. */
  150386. setCustomMeshPosition(position: Vector3): void;
  150387. /**
  150388. * Returns the light position for light scattering effect
  150389. * @return Vector3 The custom light position
  150390. */
  150391. getCustomMeshPosition(): Vector3;
  150392. /**
  150393. * Disposes the internal assets and detaches the post-process from the camera
  150394. */
  150395. dispose(camera: Camera): void;
  150396. /**
  150397. * Returns the render target texture used by the post-process
  150398. * @return the render target texture used by the post-process
  150399. */
  150400. getPass(): RenderTargetTexture;
  150401. private _meshExcluded;
  150402. private _createPass;
  150403. private _updateMeshScreenCoordinates;
  150404. /**
  150405. * Creates a default mesh for the Volumeric Light Scattering post-process
  150406. * @param name The mesh name
  150407. * @param scene The scene where to create the mesh
  150408. * @return the default mesh
  150409. */
  150410. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150411. }
  150412. }
  150413. declare module BABYLON {
  150414. /** @hidden */
  150415. export var screenSpaceCurvaturePixelShader: {
  150416. name: string;
  150417. shader: string;
  150418. };
  150419. }
  150420. declare module BABYLON {
  150421. /**
  150422. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150423. */
  150424. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150425. /**
  150426. * Defines how much ridge the curvature effect displays.
  150427. */
  150428. ridge: number;
  150429. /**
  150430. * Defines how much valley the curvature effect displays.
  150431. */
  150432. valley: number;
  150433. private _geometryBufferRenderer;
  150434. /**
  150435. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150436. * @param name The name of the effect.
  150437. * @param scene The scene containing the objects to blur according to their velocity.
  150438. * @param options The required width/height ratio to downsize to before computing the render pass.
  150439. * @param camera The camera to apply the render pass to.
  150440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150441. * @param engine The engine which the post process will be applied. (default: current engine)
  150442. * @param reusable If the post process can be reused on the same frame. (default: false)
  150443. * @param textureType Type of textures used when performing the post process. (default: 0)
  150444. * @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)
  150445. */
  150446. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150447. /**
  150448. * Support test.
  150449. */
  150450. static get IsSupported(): boolean;
  150451. }
  150452. }
  150453. declare module BABYLON {
  150454. interface Scene {
  150455. /** @hidden (Backing field) */
  150456. _boundingBoxRenderer: BoundingBoxRenderer;
  150457. /** @hidden (Backing field) */
  150458. _forceShowBoundingBoxes: boolean;
  150459. /**
  150460. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150461. */
  150462. forceShowBoundingBoxes: boolean;
  150463. /**
  150464. * Gets the bounding box renderer associated with the scene
  150465. * @returns a BoundingBoxRenderer
  150466. */
  150467. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150468. }
  150469. interface AbstractMesh {
  150470. /** @hidden (Backing field) */
  150471. _showBoundingBox: boolean;
  150472. /**
  150473. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150474. */
  150475. showBoundingBox: boolean;
  150476. }
  150477. /**
  150478. * Component responsible of rendering the bounding box of the meshes in a scene.
  150479. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150480. */
  150481. export class BoundingBoxRenderer implements ISceneComponent {
  150482. /**
  150483. * The component name helpfull to identify the component in the list of scene components.
  150484. */
  150485. readonly name: string;
  150486. /**
  150487. * The scene the component belongs to.
  150488. */
  150489. scene: Scene;
  150490. /**
  150491. * Color of the bounding box lines placed in front of an object
  150492. */
  150493. frontColor: Color3;
  150494. /**
  150495. * Color of the bounding box lines placed behind an object
  150496. */
  150497. backColor: Color3;
  150498. /**
  150499. * Defines if the renderer should show the back lines or not
  150500. */
  150501. showBackLines: boolean;
  150502. /**
  150503. * Observable raised before rendering a bounding box
  150504. */
  150505. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150506. /**
  150507. * Observable raised after rendering a bounding box
  150508. */
  150509. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150510. /**
  150511. * @hidden
  150512. */
  150513. renderList: SmartArray<BoundingBox>;
  150514. private _colorShader;
  150515. private _vertexBuffers;
  150516. private _indexBuffer;
  150517. private _fillIndexBuffer;
  150518. private _fillIndexData;
  150519. /**
  150520. * Instantiates a new bounding box renderer in a scene.
  150521. * @param scene the scene the renderer renders in
  150522. */
  150523. constructor(scene: Scene);
  150524. /**
  150525. * Registers the component in a given scene
  150526. */
  150527. register(): void;
  150528. private _evaluateSubMesh;
  150529. private _activeMesh;
  150530. private _prepareRessources;
  150531. private _createIndexBuffer;
  150532. /**
  150533. * Rebuilds the elements related to this component in case of
  150534. * context lost for instance.
  150535. */
  150536. rebuild(): void;
  150537. /**
  150538. * @hidden
  150539. */
  150540. reset(): void;
  150541. /**
  150542. * Render the bounding boxes of a specific rendering group
  150543. * @param renderingGroupId defines the rendering group to render
  150544. */
  150545. render(renderingGroupId: number): void;
  150546. /**
  150547. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150548. * @param mesh Define the mesh to render the occlusion bounding box for
  150549. */
  150550. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150551. /**
  150552. * Dispose and release the resources attached to this renderer.
  150553. */
  150554. dispose(): void;
  150555. }
  150556. }
  150557. declare module BABYLON {
  150558. interface Scene {
  150559. /** @hidden (Backing field) */
  150560. _depthRenderer: {
  150561. [id: string]: DepthRenderer;
  150562. };
  150563. /**
  150564. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150565. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150566. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150567. * @returns the created depth renderer
  150568. */
  150569. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150570. /**
  150571. * Disables a depth renderer for a given camera
  150572. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150573. */
  150574. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150575. }
  150576. /**
  150577. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150578. * in several rendering techniques.
  150579. */
  150580. export class DepthRendererSceneComponent implements ISceneComponent {
  150581. /**
  150582. * The component name helpfull to identify the component in the list of scene components.
  150583. */
  150584. readonly name: string;
  150585. /**
  150586. * The scene the component belongs to.
  150587. */
  150588. scene: Scene;
  150589. /**
  150590. * Creates a new instance of the component for the given scene
  150591. * @param scene Defines the scene to register the component in
  150592. */
  150593. constructor(scene: Scene);
  150594. /**
  150595. * Registers the component in a given scene
  150596. */
  150597. register(): void;
  150598. /**
  150599. * Rebuilds the elements related to this component in case of
  150600. * context lost for instance.
  150601. */
  150602. rebuild(): void;
  150603. /**
  150604. * Disposes the component and the associated ressources
  150605. */
  150606. dispose(): void;
  150607. private _gatherRenderTargets;
  150608. private _gatherActiveCameraRenderTargets;
  150609. }
  150610. }
  150611. declare module BABYLON {
  150612. interface AbstractScene {
  150613. /** @hidden (Backing field) */
  150614. _prePassRenderer: Nullable<PrePassRenderer>;
  150615. /**
  150616. * Gets or Sets the current prepass renderer associated to the scene.
  150617. */
  150618. prePassRenderer: Nullable<PrePassRenderer>;
  150619. /**
  150620. * Enables the prepass and associates it with the scene
  150621. * @returns the PrePassRenderer
  150622. */
  150623. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150624. /**
  150625. * Disables the prepass associated with the scene
  150626. */
  150627. disablePrePassRenderer(): void;
  150628. }
  150629. /**
  150630. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150631. * in several rendering techniques.
  150632. */
  150633. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150634. /**
  150635. * The component name helpful to identify the component in the list of scene components.
  150636. */
  150637. readonly name: string;
  150638. /**
  150639. * The scene the component belongs to.
  150640. */
  150641. scene: Scene;
  150642. /**
  150643. * Creates a new instance of the component for the given scene
  150644. * @param scene Defines the scene to register the component in
  150645. */
  150646. constructor(scene: Scene);
  150647. /**
  150648. * Registers the component in a given scene
  150649. */
  150650. register(): void;
  150651. private _beforeCameraDraw;
  150652. private _afterCameraDraw;
  150653. private _beforeClearStage;
  150654. /**
  150655. * Serializes the component data to the specified json object
  150656. * @param serializationObject The object to serialize to
  150657. */
  150658. serialize(serializationObject: any): void;
  150659. /**
  150660. * Adds all the elements from the container to the scene
  150661. * @param container the container holding the elements
  150662. */
  150663. addFromContainer(container: AbstractScene): void;
  150664. /**
  150665. * Removes all the elements in the container from the scene
  150666. * @param container contains the elements to remove
  150667. * @param dispose if the removed element should be disposed (default: false)
  150668. */
  150669. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150670. /**
  150671. * Rebuilds the elements related to this component in case of
  150672. * context lost for instance.
  150673. */
  150674. rebuild(): void;
  150675. /**
  150676. * Disposes the component and the associated ressources
  150677. */
  150678. dispose(): void;
  150679. }
  150680. }
  150681. declare module BABYLON {
  150682. /** @hidden */
  150683. export var outlinePixelShader: {
  150684. name: string;
  150685. shader: string;
  150686. };
  150687. }
  150688. declare module BABYLON {
  150689. /** @hidden */
  150690. export var outlineVertexShader: {
  150691. name: string;
  150692. shader: string;
  150693. };
  150694. }
  150695. declare module BABYLON {
  150696. interface Scene {
  150697. /** @hidden */
  150698. _outlineRenderer: OutlineRenderer;
  150699. /**
  150700. * Gets the outline renderer associated with the scene
  150701. * @returns a OutlineRenderer
  150702. */
  150703. getOutlineRenderer(): OutlineRenderer;
  150704. }
  150705. interface AbstractMesh {
  150706. /** @hidden (Backing field) */
  150707. _renderOutline: boolean;
  150708. /**
  150709. * Gets or sets a boolean indicating if the outline must be rendered as well
  150710. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150711. */
  150712. renderOutline: boolean;
  150713. /** @hidden (Backing field) */
  150714. _renderOverlay: boolean;
  150715. /**
  150716. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150717. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150718. */
  150719. renderOverlay: boolean;
  150720. }
  150721. /**
  150722. * This class is responsible to draw bothe outline/overlay of meshes.
  150723. * It should not be used directly but through the available method on mesh.
  150724. */
  150725. export class OutlineRenderer implements ISceneComponent {
  150726. /**
  150727. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150728. */
  150729. private static _StencilReference;
  150730. /**
  150731. * The name of the component. Each component must have a unique name.
  150732. */
  150733. name: string;
  150734. /**
  150735. * The scene the component belongs to.
  150736. */
  150737. scene: Scene;
  150738. /**
  150739. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150740. */
  150741. zOffset: number;
  150742. private _engine;
  150743. private _effect;
  150744. private _cachedDefines;
  150745. private _savedDepthWrite;
  150746. /**
  150747. * Instantiates a new outline renderer. (There could be only one per scene).
  150748. * @param scene Defines the scene it belongs to
  150749. */
  150750. constructor(scene: Scene);
  150751. /**
  150752. * Register the component to one instance of a scene.
  150753. */
  150754. register(): void;
  150755. /**
  150756. * Rebuilds the elements related to this component in case of
  150757. * context lost for instance.
  150758. */
  150759. rebuild(): void;
  150760. /**
  150761. * Disposes the component and the associated ressources.
  150762. */
  150763. dispose(): void;
  150764. /**
  150765. * Renders the outline in the canvas.
  150766. * @param subMesh Defines the sumesh to render
  150767. * @param batch Defines the batch of meshes in case of instances
  150768. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150769. */
  150770. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150771. /**
  150772. * Returns whether or not the outline renderer is ready for a given submesh.
  150773. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150774. * @param subMesh Defines the submesh to check readyness for
  150775. * @param useInstances Defines wheter wee are trying to render instances or not
  150776. * @returns true if ready otherwise false
  150777. */
  150778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150779. private _beforeRenderingMesh;
  150780. private _afterRenderingMesh;
  150781. }
  150782. }
  150783. declare module BABYLON {
  150784. /**
  150785. * Defines the basic options interface of a Sprite Frame Source Size.
  150786. */
  150787. export interface ISpriteJSONSpriteSourceSize {
  150788. /**
  150789. * number of the original width of the Frame
  150790. */
  150791. w: number;
  150792. /**
  150793. * number of the original height of the Frame
  150794. */
  150795. h: number;
  150796. }
  150797. /**
  150798. * Defines the basic options interface of a Sprite Frame Data.
  150799. */
  150800. export interface ISpriteJSONSpriteFrameData {
  150801. /**
  150802. * number of the x offset of the Frame
  150803. */
  150804. x: number;
  150805. /**
  150806. * number of the y offset of the Frame
  150807. */
  150808. y: number;
  150809. /**
  150810. * number of the width of the Frame
  150811. */
  150812. w: number;
  150813. /**
  150814. * number of the height of the Frame
  150815. */
  150816. h: number;
  150817. }
  150818. /**
  150819. * Defines the basic options interface of a JSON Sprite.
  150820. */
  150821. export interface ISpriteJSONSprite {
  150822. /**
  150823. * string name of the Frame
  150824. */
  150825. filename: string;
  150826. /**
  150827. * ISpriteJSONSpriteFrame basic object of the frame data
  150828. */
  150829. frame: ISpriteJSONSpriteFrameData;
  150830. /**
  150831. * boolean to flag is the frame was rotated.
  150832. */
  150833. rotated: boolean;
  150834. /**
  150835. * boolean to flag is the frame was trimmed.
  150836. */
  150837. trimmed: boolean;
  150838. /**
  150839. * ISpriteJSONSpriteFrame basic object of the source data
  150840. */
  150841. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150842. /**
  150843. * ISpriteJSONSpriteFrame basic object of the source data
  150844. */
  150845. sourceSize: ISpriteJSONSpriteSourceSize;
  150846. }
  150847. /**
  150848. * Defines the basic options interface of a JSON atlas.
  150849. */
  150850. export interface ISpriteJSONAtlas {
  150851. /**
  150852. * Array of objects that contain the frame data.
  150853. */
  150854. frames: Array<ISpriteJSONSprite>;
  150855. /**
  150856. * object basic object containing the sprite meta data.
  150857. */
  150858. meta?: object;
  150859. }
  150860. }
  150861. declare module BABYLON {
  150862. /** @hidden */
  150863. export var spriteMapPixelShader: {
  150864. name: string;
  150865. shader: string;
  150866. };
  150867. }
  150868. declare module BABYLON {
  150869. /** @hidden */
  150870. export var spriteMapVertexShader: {
  150871. name: string;
  150872. shader: string;
  150873. };
  150874. }
  150875. declare module BABYLON {
  150876. /**
  150877. * Defines the basic options interface of a SpriteMap
  150878. */
  150879. export interface ISpriteMapOptions {
  150880. /**
  150881. * Vector2 of the number of cells in the grid.
  150882. */
  150883. stageSize?: Vector2;
  150884. /**
  150885. * Vector2 of the size of the output plane in World Units.
  150886. */
  150887. outputSize?: Vector2;
  150888. /**
  150889. * Vector3 of the position of the output plane in World Units.
  150890. */
  150891. outputPosition?: Vector3;
  150892. /**
  150893. * Vector3 of the rotation of the output plane.
  150894. */
  150895. outputRotation?: Vector3;
  150896. /**
  150897. * number of layers that the system will reserve in resources.
  150898. */
  150899. layerCount?: number;
  150900. /**
  150901. * number of max animation frames a single cell will reserve in resources.
  150902. */
  150903. maxAnimationFrames?: number;
  150904. /**
  150905. * number cell index of the base tile when the system compiles.
  150906. */
  150907. baseTile?: number;
  150908. /**
  150909. * boolean flip the sprite after its been repositioned by the framing data.
  150910. */
  150911. flipU?: boolean;
  150912. /**
  150913. * Vector3 scalar of the global RGB values of the SpriteMap.
  150914. */
  150915. colorMultiply?: Vector3;
  150916. }
  150917. /**
  150918. * Defines the IDisposable interface in order to be cleanable from resources.
  150919. */
  150920. export interface ISpriteMap extends IDisposable {
  150921. /**
  150922. * String name of the SpriteMap.
  150923. */
  150924. name: string;
  150925. /**
  150926. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150927. */
  150928. atlasJSON: ISpriteJSONAtlas;
  150929. /**
  150930. * Texture of the SpriteMap.
  150931. */
  150932. spriteSheet: Texture;
  150933. /**
  150934. * The parameters to initialize the SpriteMap with.
  150935. */
  150936. options: ISpriteMapOptions;
  150937. }
  150938. /**
  150939. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150940. */
  150941. export class SpriteMap implements ISpriteMap {
  150942. /** The Name of the spriteMap */
  150943. name: string;
  150944. /** The JSON file with the frame and meta data */
  150945. atlasJSON: ISpriteJSONAtlas;
  150946. /** The systems Sprite Sheet Texture */
  150947. spriteSheet: Texture;
  150948. /** Arguments passed with the Constructor */
  150949. options: ISpriteMapOptions;
  150950. /** Public Sprite Storage array, parsed from atlasJSON */
  150951. sprites: Array<ISpriteJSONSprite>;
  150952. /** Returns the Number of Sprites in the System */
  150953. get spriteCount(): number;
  150954. /** Returns the Position of Output Plane*/
  150955. get position(): Vector3;
  150956. /** Returns the Position of Output Plane*/
  150957. set position(v: Vector3);
  150958. /** Returns the Rotation of Output Plane*/
  150959. get rotation(): Vector3;
  150960. /** Returns the Rotation of Output Plane*/
  150961. set rotation(v: Vector3);
  150962. /** Sets the AnimationMap*/
  150963. get animationMap(): RawTexture;
  150964. /** Sets the AnimationMap*/
  150965. set animationMap(v: RawTexture);
  150966. /** Scene that the SpriteMap was created in */
  150967. private _scene;
  150968. /** Texture Buffer of Float32 that holds tile frame data*/
  150969. private _frameMap;
  150970. /** Texture Buffers of Float32 that holds tileMap data*/
  150971. private _tileMaps;
  150972. /** Texture Buffer of Float32 that holds Animation Data*/
  150973. private _animationMap;
  150974. /** Custom ShaderMaterial Central to the System*/
  150975. private _material;
  150976. /** Custom ShaderMaterial Central to the System*/
  150977. private _output;
  150978. /** Systems Time Ticker*/
  150979. private _time;
  150980. /**
  150981. * Creates a new SpriteMap
  150982. * @param name defines the SpriteMaps Name
  150983. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150984. * @param spriteSheet is the Texture that the Sprites are on.
  150985. * @param options a basic deployment configuration
  150986. * @param scene The Scene that the map is deployed on
  150987. */
  150988. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150989. /**
  150990. * Returns tileID location
  150991. * @returns Vector2 the cell position ID
  150992. */
  150993. getTileID(): Vector2;
  150994. /**
  150995. * Gets the UV location of the mouse over the SpriteMap.
  150996. * @returns Vector2 the UV position of the mouse interaction
  150997. */
  150998. getMousePosition(): Vector2;
  150999. /**
  151000. * Creates the "frame" texture Buffer
  151001. * -------------------------------------
  151002. * Structure of frames
  151003. * "filename": "Falling-Water-2.png",
  151004. * "frame": {"x":69,"y":103,"w":24,"h":32},
  151005. * "rotated": true,
  151006. * "trimmed": true,
  151007. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  151008. * "sourceSize": {"w":32,"h":32}
  151009. * @returns RawTexture of the frameMap
  151010. */
  151011. private _createFrameBuffer;
  151012. /**
  151013. * Creates the tileMap texture Buffer
  151014. * @param buffer normally and array of numbers, or a false to generate from scratch
  151015. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  151016. * @returns RawTexture of the tileMap
  151017. */
  151018. private _createTileBuffer;
  151019. /**
  151020. * Modifies the data of the tileMaps
  151021. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  151022. * @param pos is the iVector2 Coordinates of the Tile
  151023. * @param tile The SpriteIndex of the new Tile
  151024. */
  151025. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  151026. /**
  151027. * Creates the animationMap texture Buffer
  151028. * @param buffer normally and array of numbers, or a false to generate from scratch
  151029. * @returns RawTexture of the animationMap
  151030. */
  151031. private _createTileAnimationBuffer;
  151032. /**
  151033. * Modifies the data of the animationMap
  151034. * @param cellID is the Index of the Sprite
  151035. * @param _frame is the target Animation frame
  151036. * @param toCell is the Target Index of the next frame of the animation
  151037. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  151038. * @param speed is a global scalar of the time variable on the map.
  151039. */
  151040. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  151041. /**
  151042. * Exports the .tilemaps file
  151043. */
  151044. saveTileMaps(): void;
  151045. /**
  151046. * Imports the .tilemaps file
  151047. * @param url of the .tilemaps file
  151048. */
  151049. loadTileMaps(url: string): void;
  151050. /**
  151051. * Release associated resources
  151052. */
  151053. dispose(): void;
  151054. }
  151055. }
  151056. declare module BABYLON {
  151057. /**
  151058. * Class used to manage multiple sprites of different sizes on the same spritesheet
  151059. * @see https://doc.babylonjs.com/babylon101/sprites
  151060. */
  151061. export class SpritePackedManager extends SpriteManager {
  151062. /** defines the packed manager's name */
  151063. name: string;
  151064. /**
  151065. * Creates a new sprite manager from a packed sprite sheet
  151066. * @param name defines the manager's name
  151067. * @param imgUrl defines the sprite sheet url
  151068. * @param capacity defines the maximum allowed number of sprites
  151069. * @param scene defines the hosting scene
  151070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  151071. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  151072. * @param samplingMode defines the smapling mode to use with spritesheet
  151073. * @param fromPacked set to true; do not alter
  151074. */
  151075. constructor(
  151076. /** defines the packed manager's name */
  151077. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  151078. }
  151079. }
  151080. declare module BABYLON {
  151081. /**
  151082. * Defines the list of states available for a task inside a AssetsManager
  151083. */
  151084. export enum AssetTaskState {
  151085. /**
  151086. * Initialization
  151087. */
  151088. INIT = 0,
  151089. /**
  151090. * Running
  151091. */
  151092. RUNNING = 1,
  151093. /**
  151094. * Done
  151095. */
  151096. DONE = 2,
  151097. /**
  151098. * Error
  151099. */
  151100. ERROR = 3
  151101. }
  151102. /**
  151103. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  151104. */
  151105. export abstract class AbstractAssetTask {
  151106. /**
  151107. * Task name
  151108. */ name: string;
  151109. /**
  151110. * Callback called when the task is successful
  151111. */
  151112. onSuccess: (task: any) => void;
  151113. /**
  151114. * Callback called when the task is not successful
  151115. */
  151116. onError: (task: any, message?: string, exception?: any) => void;
  151117. /**
  151118. * Creates a new AssetsManager
  151119. * @param name defines the name of the task
  151120. */
  151121. constructor(
  151122. /**
  151123. * Task name
  151124. */ name: string);
  151125. private _isCompleted;
  151126. private _taskState;
  151127. private _errorObject;
  151128. /**
  151129. * Get if the task is completed
  151130. */
  151131. get isCompleted(): boolean;
  151132. /**
  151133. * Gets the current state of the task
  151134. */
  151135. get taskState(): AssetTaskState;
  151136. /**
  151137. * Gets the current error object (if task is in error)
  151138. */
  151139. get errorObject(): {
  151140. message?: string;
  151141. exception?: any;
  151142. };
  151143. /**
  151144. * Internal only
  151145. * @hidden
  151146. */
  151147. _setErrorObject(message?: string, exception?: any): void;
  151148. /**
  151149. * Execute the current task
  151150. * @param scene defines the scene where you want your assets to be loaded
  151151. * @param onSuccess is a callback called when the task is successfully executed
  151152. * @param onError is a callback called if an error occurs
  151153. */
  151154. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151155. /**
  151156. * Execute the current task
  151157. * @param scene defines the scene where you want your assets to be loaded
  151158. * @param onSuccess is a callback called when the task is successfully executed
  151159. * @param onError is a callback called if an error occurs
  151160. */
  151161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151162. /**
  151163. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  151164. * This can be used with failed tasks that have the reason for failure fixed.
  151165. */
  151166. reset(): void;
  151167. private onErrorCallback;
  151168. private onDoneCallback;
  151169. }
  151170. /**
  151171. * Define the interface used by progress events raised during assets loading
  151172. */
  151173. export interface IAssetsProgressEvent {
  151174. /**
  151175. * Defines the number of remaining tasks to process
  151176. */
  151177. remainingCount: number;
  151178. /**
  151179. * Defines the total number of tasks
  151180. */
  151181. totalCount: number;
  151182. /**
  151183. * Defines the task that was just processed
  151184. */
  151185. task: AbstractAssetTask;
  151186. }
  151187. /**
  151188. * Class used to share progress information about assets loading
  151189. */
  151190. export class AssetsProgressEvent implements IAssetsProgressEvent {
  151191. /**
  151192. * Defines the number of remaining tasks to process
  151193. */
  151194. remainingCount: number;
  151195. /**
  151196. * Defines the total number of tasks
  151197. */
  151198. totalCount: number;
  151199. /**
  151200. * Defines the task that was just processed
  151201. */
  151202. task: AbstractAssetTask;
  151203. /**
  151204. * Creates a AssetsProgressEvent
  151205. * @param remainingCount defines the number of remaining tasks to process
  151206. * @param totalCount defines the total number of tasks
  151207. * @param task defines the task that was just processed
  151208. */
  151209. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  151210. }
  151211. /**
  151212. * Define a task used by AssetsManager to load assets into a container
  151213. */
  151214. export class ContainerAssetTask extends AbstractAssetTask {
  151215. /**
  151216. * Defines the name of the task
  151217. */
  151218. name: string;
  151219. /**
  151220. * Defines the list of mesh's names you want to load
  151221. */
  151222. meshesNames: any;
  151223. /**
  151224. * Defines the root url to use as a base to load your meshes and associated resources
  151225. */
  151226. rootUrl: string;
  151227. /**
  151228. * Defines the filename or File of the scene to load from
  151229. */
  151230. sceneFilename: string | File;
  151231. /**
  151232. * Get the loaded asset container
  151233. */
  151234. loadedContainer: AssetContainer;
  151235. /**
  151236. * Gets the list of loaded meshes
  151237. */
  151238. loadedMeshes: Array<AbstractMesh>;
  151239. /**
  151240. * Gets the list of loaded particle systems
  151241. */
  151242. loadedParticleSystems: Array<IParticleSystem>;
  151243. /**
  151244. * Gets the list of loaded skeletons
  151245. */
  151246. loadedSkeletons: Array<Skeleton>;
  151247. /**
  151248. * Gets the list of loaded animation groups
  151249. */
  151250. loadedAnimationGroups: Array<AnimationGroup>;
  151251. /**
  151252. * Callback called when the task is successful
  151253. */
  151254. onSuccess: (task: ContainerAssetTask) => void;
  151255. /**
  151256. * Callback called when the task is successful
  151257. */
  151258. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  151259. /**
  151260. * Creates a new ContainerAssetTask
  151261. * @param name defines the name of the task
  151262. * @param meshesNames defines the list of mesh's names you want to load
  151263. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151264. * @param sceneFilename defines the filename or File of the scene to load from
  151265. */
  151266. constructor(
  151267. /**
  151268. * Defines the name of the task
  151269. */
  151270. name: string,
  151271. /**
  151272. * Defines the list of mesh's names you want to load
  151273. */
  151274. meshesNames: any,
  151275. /**
  151276. * Defines the root url to use as a base to load your meshes and associated resources
  151277. */
  151278. rootUrl: string,
  151279. /**
  151280. * Defines the filename or File of the scene to load from
  151281. */
  151282. sceneFilename: string | File);
  151283. /**
  151284. * Execute the current task
  151285. * @param scene defines the scene where you want your assets to be loaded
  151286. * @param onSuccess is a callback called when the task is successfully executed
  151287. * @param onError is a callback called if an error occurs
  151288. */
  151289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151290. }
  151291. /**
  151292. * Define a task used by AssetsManager to load meshes
  151293. */
  151294. export class MeshAssetTask extends AbstractAssetTask {
  151295. /**
  151296. * Defines the name of the task
  151297. */
  151298. name: string;
  151299. /**
  151300. * Defines the list of mesh's names you want to load
  151301. */
  151302. meshesNames: any;
  151303. /**
  151304. * Defines the root url to use as a base to load your meshes and associated resources
  151305. */
  151306. rootUrl: string;
  151307. /**
  151308. * Defines the filename or File of the scene to load from
  151309. */
  151310. sceneFilename: string | File;
  151311. /**
  151312. * Gets the list of loaded meshes
  151313. */
  151314. loadedMeshes: Array<AbstractMesh>;
  151315. /**
  151316. * Gets the list of loaded particle systems
  151317. */
  151318. loadedParticleSystems: Array<IParticleSystem>;
  151319. /**
  151320. * Gets the list of loaded skeletons
  151321. */
  151322. loadedSkeletons: Array<Skeleton>;
  151323. /**
  151324. * Gets the list of loaded animation groups
  151325. */
  151326. loadedAnimationGroups: Array<AnimationGroup>;
  151327. /**
  151328. * Callback called when the task is successful
  151329. */
  151330. onSuccess: (task: MeshAssetTask) => void;
  151331. /**
  151332. * Callback called when the task is successful
  151333. */
  151334. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  151335. /**
  151336. * Creates a new MeshAssetTask
  151337. * @param name defines the name of the task
  151338. * @param meshesNames defines the list of mesh's names you want to load
  151339. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151340. * @param sceneFilename defines the filename or File of the scene to load from
  151341. */
  151342. constructor(
  151343. /**
  151344. * Defines the name of the task
  151345. */
  151346. name: string,
  151347. /**
  151348. * Defines the list of mesh's names you want to load
  151349. */
  151350. meshesNames: any,
  151351. /**
  151352. * Defines the root url to use as a base to load your meshes and associated resources
  151353. */
  151354. rootUrl: string,
  151355. /**
  151356. * Defines the filename or File of the scene to load from
  151357. */
  151358. sceneFilename: string | File);
  151359. /**
  151360. * Execute the current task
  151361. * @param scene defines the scene where you want your assets to be loaded
  151362. * @param onSuccess is a callback called when the task is successfully executed
  151363. * @param onError is a callback called if an error occurs
  151364. */
  151365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151366. }
  151367. /**
  151368. * Define a task used by AssetsManager to load text content
  151369. */
  151370. export class TextFileAssetTask extends AbstractAssetTask {
  151371. /**
  151372. * Defines the name of the task
  151373. */
  151374. name: string;
  151375. /**
  151376. * Defines the location of the file to load
  151377. */
  151378. url: string;
  151379. /**
  151380. * Gets the loaded text string
  151381. */
  151382. text: string;
  151383. /**
  151384. * Callback called when the task is successful
  151385. */
  151386. onSuccess: (task: TextFileAssetTask) => void;
  151387. /**
  151388. * Callback called when the task is successful
  151389. */
  151390. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151391. /**
  151392. * Creates a new TextFileAssetTask object
  151393. * @param name defines the name of the task
  151394. * @param url defines the location of the file to load
  151395. */
  151396. constructor(
  151397. /**
  151398. * Defines the name of the task
  151399. */
  151400. name: string,
  151401. /**
  151402. * Defines the location of the file to load
  151403. */
  151404. url: string);
  151405. /**
  151406. * Execute the current task
  151407. * @param scene defines the scene where you want your assets to be loaded
  151408. * @param onSuccess is a callback called when the task is successfully executed
  151409. * @param onError is a callback called if an error occurs
  151410. */
  151411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151412. }
  151413. /**
  151414. * Define a task used by AssetsManager to load binary data
  151415. */
  151416. export class BinaryFileAssetTask extends AbstractAssetTask {
  151417. /**
  151418. * Defines the name of the task
  151419. */
  151420. name: string;
  151421. /**
  151422. * Defines the location of the file to load
  151423. */
  151424. url: string;
  151425. /**
  151426. * Gets the lodaded data (as an array buffer)
  151427. */
  151428. data: ArrayBuffer;
  151429. /**
  151430. * Callback called when the task is successful
  151431. */
  151432. onSuccess: (task: BinaryFileAssetTask) => void;
  151433. /**
  151434. * Callback called when the task is successful
  151435. */
  151436. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151437. /**
  151438. * Creates a new BinaryFileAssetTask object
  151439. * @param name defines the name of the new task
  151440. * @param url defines the location of the file to load
  151441. */
  151442. constructor(
  151443. /**
  151444. * Defines the name of the task
  151445. */
  151446. name: string,
  151447. /**
  151448. * Defines the location of the file to load
  151449. */
  151450. url: string);
  151451. /**
  151452. * Execute the current task
  151453. * @param scene defines the scene where you want your assets to be loaded
  151454. * @param onSuccess is a callback called when the task is successfully executed
  151455. * @param onError is a callback called if an error occurs
  151456. */
  151457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151458. }
  151459. /**
  151460. * Define a task used by AssetsManager to load images
  151461. */
  151462. export class ImageAssetTask extends AbstractAssetTask {
  151463. /**
  151464. * Defines the name of the task
  151465. */
  151466. name: string;
  151467. /**
  151468. * Defines the location of the image to load
  151469. */
  151470. url: string;
  151471. /**
  151472. * Gets the loaded images
  151473. */
  151474. image: HTMLImageElement;
  151475. /**
  151476. * Callback called when the task is successful
  151477. */
  151478. onSuccess: (task: ImageAssetTask) => void;
  151479. /**
  151480. * Callback called when the task is successful
  151481. */
  151482. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151483. /**
  151484. * Creates a new ImageAssetTask
  151485. * @param name defines the name of the task
  151486. * @param url defines the location of the image to load
  151487. */
  151488. constructor(
  151489. /**
  151490. * Defines the name of the task
  151491. */
  151492. name: string,
  151493. /**
  151494. * Defines the location of the image to load
  151495. */
  151496. url: string);
  151497. /**
  151498. * Execute the current task
  151499. * @param scene defines the scene where you want your assets to be loaded
  151500. * @param onSuccess is a callback called when the task is successfully executed
  151501. * @param onError is a callback called if an error occurs
  151502. */
  151503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151504. }
  151505. /**
  151506. * Defines the interface used by texture loading tasks
  151507. */
  151508. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151509. /**
  151510. * Gets the loaded texture
  151511. */
  151512. texture: TEX;
  151513. }
  151514. /**
  151515. * Define a task used by AssetsManager to load 2D textures
  151516. */
  151517. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151518. /**
  151519. * Defines the name of the task
  151520. */
  151521. name: string;
  151522. /**
  151523. * Defines the location of the file to load
  151524. */
  151525. url: string;
  151526. /**
  151527. * Defines if mipmap should not be generated (default is false)
  151528. */
  151529. noMipmap?: boolean | undefined;
  151530. /**
  151531. * Defines if texture must be inverted on Y axis (default is true)
  151532. */
  151533. invertY: boolean;
  151534. /**
  151535. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151536. */
  151537. samplingMode: number;
  151538. /**
  151539. * Gets the loaded texture
  151540. */
  151541. texture: Texture;
  151542. /**
  151543. * Callback called when the task is successful
  151544. */
  151545. onSuccess: (task: TextureAssetTask) => void;
  151546. /**
  151547. * Callback called when the task is successful
  151548. */
  151549. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151550. /**
  151551. * Creates a new TextureAssetTask object
  151552. * @param name defines the name of the task
  151553. * @param url defines the location of the file to load
  151554. * @param noMipmap defines if mipmap should not be generated (default is false)
  151555. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151556. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151557. */
  151558. constructor(
  151559. /**
  151560. * Defines the name of the task
  151561. */
  151562. name: string,
  151563. /**
  151564. * Defines the location of the file to load
  151565. */
  151566. url: string,
  151567. /**
  151568. * Defines if mipmap should not be generated (default is false)
  151569. */
  151570. noMipmap?: boolean | undefined,
  151571. /**
  151572. * Defines if texture must be inverted on Y axis (default is true)
  151573. */
  151574. invertY?: boolean,
  151575. /**
  151576. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151577. */
  151578. samplingMode?: number);
  151579. /**
  151580. * Execute the current task
  151581. * @param scene defines the scene where you want your assets to be loaded
  151582. * @param onSuccess is a callback called when the task is successfully executed
  151583. * @param onError is a callback called if an error occurs
  151584. */
  151585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151586. }
  151587. /**
  151588. * Define a task used by AssetsManager to load cube textures
  151589. */
  151590. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151591. /**
  151592. * Defines the name of the task
  151593. */
  151594. name: string;
  151595. /**
  151596. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151597. */
  151598. url: string;
  151599. /**
  151600. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151601. */
  151602. extensions?: string[] | undefined;
  151603. /**
  151604. * Defines if mipmaps should not be generated (default is false)
  151605. */
  151606. noMipmap?: boolean | undefined;
  151607. /**
  151608. * Defines the explicit list of files (undefined by default)
  151609. */
  151610. files?: string[] | undefined;
  151611. /**
  151612. * Gets the loaded texture
  151613. */
  151614. texture: CubeTexture;
  151615. /**
  151616. * Callback called when the task is successful
  151617. */
  151618. onSuccess: (task: CubeTextureAssetTask) => void;
  151619. /**
  151620. * Callback called when the task is successful
  151621. */
  151622. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151623. /**
  151624. * Creates a new CubeTextureAssetTask
  151625. * @param name defines the name of the task
  151626. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151627. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151628. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151629. * @param files defines the explicit list of files (undefined by default)
  151630. */
  151631. constructor(
  151632. /**
  151633. * Defines the name of the task
  151634. */
  151635. name: string,
  151636. /**
  151637. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151638. */
  151639. url: string,
  151640. /**
  151641. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151642. */
  151643. extensions?: string[] | undefined,
  151644. /**
  151645. * Defines if mipmaps should not be generated (default is false)
  151646. */
  151647. noMipmap?: boolean | undefined,
  151648. /**
  151649. * Defines the explicit list of files (undefined by default)
  151650. */
  151651. files?: string[] | undefined);
  151652. /**
  151653. * Execute the current task
  151654. * @param scene defines the scene where you want your assets to be loaded
  151655. * @param onSuccess is a callback called when the task is successfully executed
  151656. * @param onError is a callback called if an error occurs
  151657. */
  151658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151659. }
  151660. /**
  151661. * Define a task used by AssetsManager to load HDR cube textures
  151662. */
  151663. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151664. /**
  151665. * Defines the name of the task
  151666. */
  151667. name: string;
  151668. /**
  151669. * Defines the location of the file to load
  151670. */
  151671. url: string;
  151672. /**
  151673. * Defines the desired size (the more it increases the longer the generation will be)
  151674. */
  151675. size: number;
  151676. /**
  151677. * Defines if mipmaps should not be generated (default is false)
  151678. */
  151679. noMipmap: boolean;
  151680. /**
  151681. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151682. */
  151683. generateHarmonics: boolean;
  151684. /**
  151685. * 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)
  151686. */
  151687. gammaSpace: boolean;
  151688. /**
  151689. * Internal Use Only
  151690. */
  151691. reserved: boolean;
  151692. /**
  151693. * Gets the loaded texture
  151694. */
  151695. texture: HDRCubeTexture;
  151696. /**
  151697. * Callback called when the task is successful
  151698. */
  151699. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151700. /**
  151701. * Callback called when the task is successful
  151702. */
  151703. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151704. /**
  151705. * Creates a new HDRCubeTextureAssetTask object
  151706. * @param name defines the name of the task
  151707. * @param url defines the location of the file to load
  151708. * @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.
  151709. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151710. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151711. * @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)
  151712. * @param reserved Internal use only
  151713. */
  151714. constructor(
  151715. /**
  151716. * Defines the name of the task
  151717. */
  151718. name: string,
  151719. /**
  151720. * Defines the location of the file to load
  151721. */
  151722. url: string,
  151723. /**
  151724. * Defines the desired size (the more it increases the longer the generation will be)
  151725. */
  151726. size: number,
  151727. /**
  151728. * Defines if mipmaps should not be generated (default is false)
  151729. */
  151730. noMipmap?: boolean,
  151731. /**
  151732. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151733. */
  151734. generateHarmonics?: boolean,
  151735. /**
  151736. * 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)
  151737. */
  151738. gammaSpace?: boolean,
  151739. /**
  151740. * Internal Use Only
  151741. */
  151742. reserved?: boolean);
  151743. /**
  151744. * Execute the current task
  151745. * @param scene defines the scene where you want your assets to be loaded
  151746. * @param onSuccess is a callback called when the task is successfully executed
  151747. * @param onError is a callback called if an error occurs
  151748. */
  151749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151750. }
  151751. /**
  151752. * Define a task used by AssetsManager to load Equirectangular cube textures
  151753. */
  151754. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151755. /**
  151756. * Defines the name of the task
  151757. */
  151758. name: string;
  151759. /**
  151760. * Defines the location of the file to load
  151761. */
  151762. url: string;
  151763. /**
  151764. * Defines the desired size (the more it increases the longer the generation will be)
  151765. */
  151766. size: number;
  151767. /**
  151768. * Defines if mipmaps should not be generated (default is false)
  151769. */
  151770. noMipmap: boolean;
  151771. /**
  151772. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151773. * but the standard material would require them in Gamma space) (default is true)
  151774. */
  151775. gammaSpace: boolean;
  151776. /**
  151777. * Gets the loaded texture
  151778. */
  151779. texture: EquiRectangularCubeTexture;
  151780. /**
  151781. * Callback called when the task is successful
  151782. */
  151783. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151784. /**
  151785. * Callback called when the task is successful
  151786. */
  151787. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151788. /**
  151789. * Creates a new EquiRectangularCubeTextureAssetTask object
  151790. * @param name defines the name of the task
  151791. * @param url defines the location of the file to load
  151792. * @param size defines the desired size (the more it increases the longer the generation will be)
  151793. * If the size is omitted this implies you are using a preprocessed cubemap.
  151794. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151795. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151796. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151797. * (default is true)
  151798. */
  151799. constructor(
  151800. /**
  151801. * Defines the name of the task
  151802. */
  151803. name: string,
  151804. /**
  151805. * Defines the location of the file to load
  151806. */
  151807. url: string,
  151808. /**
  151809. * Defines the desired size (the more it increases the longer the generation will be)
  151810. */
  151811. size: number,
  151812. /**
  151813. * Defines if mipmaps should not be generated (default is false)
  151814. */
  151815. noMipmap?: boolean,
  151816. /**
  151817. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151818. * but the standard material would require them in Gamma space) (default is true)
  151819. */
  151820. gammaSpace?: boolean);
  151821. /**
  151822. * Execute the current task
  151823. * @param scene defines the scene where you want your assets to be loaded
  151824. * @param onSuccess is a callback called when the task is successfully executed
  151825. * @param onError is a callback called if an error occurs
  151826. */
  151827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151828. }
  151829. /**
  151830. * This class can be used to easily import assets into a scene
  151831. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151832. */
  151833. export class AssetsManager {
  151834. private _scene;
  151835. private _isLoading;
  151836. protected _tasks: AbstractAssetTask[];
  151837. protected _waitingTasksCount: number;
  151838. protected _totalTasksCount: number;
  151839. /**
  151840. * Callback called when all tasks are processed
  151841. */
  151842. onFinish: (tasks: AbstractAssetTask[]) => void;
  151843. /**
  151844. * Callback called when a task is successful
  151845. */
  151846. onTaskSuccess: (task: AbstractAssetTask) => void;
  151847. /**
  151848. * Callback called when a task had an error
  151849. */
  151850. onTaskError: (task: AbstractAssetTask) => void;
  151851. /**
  151852. * Callback called when a task is done (whatever the result is)
  151853. */
  151854. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151855. /**
  151856. * Observable called when all tasks are processed
  151857. */
  151858. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151859. /**
  151860. * Observable called when a task had an error
  151861. */
  151862. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151863. /**
  151864. * Observable called when all tasks were executed
  151865. */
  151866. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151867. /**
  151868. * Observable called when a task is done (whatever the result is)
  151869. */
  151870. onProgressObservable: Observable<IAssetsProgressEvent>;
  151871. /**
  151872. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151873. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151874. */
  151875. useDefaultLoadingScreen: boolean;
  151876. /**
  151877. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151878. * when all assets have been downloaded.
  151879. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151880. */
  151881. autoHideLoadingUI: boolean;
  151882. /**
  151883. * Creates a new AssetsManager
  151884. * @param scene defines the scene to work on
  151885. */
  151886. constructor(scene: Scene);
  151887. /**
  151888. * Add a ContainerAssetTask to the list of active tasks
  151889. * @param taskName defines the name of the new task
  151890. * @param meshesNames defines the name of meshes to load
  151891. * @param rootUrl defines the root url to use to locate files
  151892. * @param sceneFilename defines the filename of the scene file
  151893. * @returns a new ContainerAssetTask object
  151894. */
  151895. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151896. /**
  151897. * Add a MeshAssetTask to the list of active tasks
  151898. * @param taskName defines the name of the new task
  151899. * @param meshesNames defines the name of meshes to load
  151900. * @param rootUrl defines the root url to use to locate files
  151901. * @param sceneFilename defines the filename of the scene file
  151902. * @returns a new MeshAssetTask object
  151903. */
  151904. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151905. /**
  151906. * Add a TextFileAssetTask to the list of active tasks
  151907. * @param taskName defines the name of the new task
  151908. * @param url defines the url of the file to load
  151909. * @returns a new TextFileAssetTask object
  151910. */
  151911. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151912. /**
  151913. * Add a BinaryFileAssetTask to the list of active tasks
  151914. * @param taskName defines the name of the new task
  151915. * @param url defines the url of the file to load
  151916. * @returns a new BinaryFileAssetTask object
  151917. */
  151918. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151919. /**
  151920. * Add a ImageAssetTask to the list of active tasks
  151921. * @param taskName defines the name of the new task
  151922. * @param url defines the url of the file to load
  151923. * @returns a new ImageAssetTask object
  151924. */
  151925. addImageTask(taskName: string, url: string): ImageAssetTask;
  151926. /**
  151927. * Add a TextureAssetTask to the list of active tasks
  151928. * @param taskName defines the name of the new task
  151929. * @param url defines the url of the file to load
  151930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151931. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151932. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151933. * @returns a new TextureAssetTask object
  151934. */
  151935. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151936. /**
  151937. * Add a CubeTextureAssetTask to the list of active tasks
  151938. * @param taskName defines the name of the new task
  151939. * @param url defines the url of the file to load
  151940. * @param extensions defines the extension to use to load the cube map (can be null)
  151941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151942. * @param files defines the list of files to load (can be null)
  151943. * @returns a new CubeTextureAssetTask object
  151944. */
  151945. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151946. /**
  151947. *
  151948. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151949. * @param taskName defines the name of the new task
  151950. * @param url defines the url of the file to load
  151951. * @param size defines the size you want for the cubemap (can be null)
  151952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151953. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151954. * @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)
  151955. * @param reserved Internal use only
  151956. * @returns a new HDRCubeTextureAssetTask object
  151957. */
  151958. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151959. /**
  151960. *
  151961. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151962. * @param taskName defines the name of the new task
  151963. * @param url defines the url of the file to load
  151964. * @param size defines the size you want for the cubemap (can be null)
  151965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151966. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151967. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151968. * @returns a new EquiRectangularCubeTextureAssetTask object
  151969. */
  151970. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151971. /**
  151972. * Remove a task from the assets manager.
  151973. * @param task the task to remove
  151974. */
  151975. removeTask(task: AbstractAssetTask): void;
  151976. private _decreaseWaitingTasksCount;
  151977. private _runTask;
  151978. /**
  151979. * Reset the AssetsManager and remove all tasks
  151980. * @return the current instance of the AssetsManager
  151981. */
  151982. reset(): AssetsManager;
  151983. /**
  151984. * Start the loading process
  151985. * @return the current instance of the AssetsManager
  151986. */
  151987. load(): AssetsManager;
  151988. /**
  151989. * Start the loading process as an async operation
  151990. * @return a promise returning the list of failed tasks
  151991. */
  151992. loadAsync(): Promise<void>;
  151993. }
  151994. }
  151995. declare module BABYLON {
  151996. /**
  151997. * Wrapper class for promise with external resolve and reject.
  151998. */
  151999. export class Deferred<T> {
  152000. /**
  152001. * The promise associated with this deferred object.
  152002. */
  152003. readonly promise: Promise<T>;
  152004. private _resolve;
  152005. private _reject;
  152006. /**
  152007. * The resolve method of the promise associated with this deferred object.
  152008. */
  152009. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  152010. /**
  152011. * The reject method of the promise associated with this deferred object.
  152012. */
  152013. get reject(): (reason?: any) => void;
  152014. /**
  152015. * Constructor for this deferred object.
  152016. */
  152017. constructor();
  152018. }
  152019. }
  152020. declare module BABYLON {
  152021. /**
  152022. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  152023. */
  152024. export class MeshExploder {
  152025. private _centerMesh;
  152026. private _meshes;
  152027. private _meshesOrigins;
  152028. private _toCenterVectors;
  152029. private _scaledDirection;
  152030. private _newPosition;
  152031. private _centerPosition;
  152032. /**
  152033. * Explodes meshes from a center mesh.
  152034. * @param meshes The meshes to explode.
  152035. * @param centerMesh The mesh to be center of explosion.
  152036. */
  152037. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  152038. private _setCenterMesh;
  152039. /**
  152040. * Get class name
  152041. * @returns "MeshExploder"
  152042. */
  152043. getClassName(): string;
  152044. /**
  152045. * "Exploded meshes"
  152046. * @returns Array of meshes with the centerMesh at index 0.
  152047. */
  152048. getMeshes(): Array<Mesh>;
  152049. /**
  152050. * Explodes meshes giving a specific direction
  152051. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  152052. */
  152053. explode(direction?: number): void;
  152054. }
  152055. }
  152056. declare module BABYLON {
  152057. /**
  152058. * Class used to help managing file picking and drag'n'drop
  152059. */
  152060. export class FilesInput {
  152061. /**
  152062. * List of files ready to be loaded
  152063. */
  152064. static get FilesToLoad(): {
  152065. [key: string]: File;
  152066. };
  152067. /**
  152068. * Callback called when a file is processed
  152069. */
  152070. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  152071. private _engine;
  152072. private _currentScene;
  152073. private _sceneLoadedCallback;
  152074. private _progressCallback;
  152075. private _additionalRenderLoopLogicCallback;
  152076. private _textureLoadingCallback;
  152077. private _startingProcessingFilesCallback;
  152078. private _onReloadCallback;
  152079. private _errorCallback;
  152080. private _elementToMonitor;
  152081. private _sceneFileToLoad;
  152082. private _filesToLoad;
  152083. /**
  152084. * Creates a new FilesInput
  152085. * @param engine defines the rendering engine
  152086. * @param scene defines the hosting scene
  152087. * @param sceneLoadedCallback callback called when scene is loaded
  152088. * @param progressCallback callback called to track progress
  152089. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  152090. * @param textureLoadingCallback callback called when a texture is loading
  152091. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  152092. * @param onReloadCallback callback called when a reload is requested
  152093. * @param errorCallback callback call if an error occurs
  152094. */
  152095. 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>);
  152096. private _dragEnterHandler;
  152097. private _dragOverHandler;
  152098. private _dropHandler;
  152099. /**
  152100. * Calls this function to listen to drag'n'drop events on a specific DOM element
  152101. * @param elementToMonitor defines the DOM element to track
  152102. */
  152103. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  152104. /** Gets the current list of files to load */
  152105. get filesToLoad(): File[];
  152106. /**
  152107. * Release all associated resources
  152108. */
  152109. dispose(): void;
  152110. private renderFunction;
  152111. private drag;
  152112. private drop;
  152113. private _traverseFolder;
  152114. private _processFiles;
  152115. /**
  152116. * Load files from a drop event
  152117. * @param event defines the drop event to use as source
  152118. */
  152119. loadFiles(event: any): void;
  152120. private _processReload;
  152121. /**
  152122. * Reload the current scene from the loaded files
  152123. */
  152124. reload(): void;
  152125. }
  152126. }
  152127. declare module BABYLON {
  152128. /**
  152129. * Defines the root class used to create scene optimization to use with SceneOptimizer
  152130. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152131. */
  152132. export class SceneOptimization {
  152133. /**
  152134. * Defines the priority of this optimization (0 by default which means first in the list)
  152135. */
  152136. priority: number;
  152137. /**
  152138. * Gets a string describing the action executed by the current optimization
  152139. * @returns description string
  152140. */
  152141. getDescription(): string;
  152142. /**
  152143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152144. * @param scene defines the current scene where to apply this optimization
  152145. * @param optimizer defines the current optimizer
  152146. * @returns true if everything that can be done was applied
  152147. */
  152148. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152149. /**
  152150. * Creates the SceneOptimization object
  152151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152152. * @param desc defines the description associated with the optimization
  152153. */
  152154. constructor(
  152155. /**
  152156. * Defines the priority of this optimization (0 by default which means first in the list)
  152157. */
  152158. priority?: number);
  152159. }
  152160. /**
  152161. * Defines an optimization used to reduce the size of render target textures
  152162. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152163. */
  152164. export class TextureOptimization extends SceneOptimization {
  152165. /**
  152166. * Defines the priority of this optimization (0 by default which means first in the list)
  152167. */
  152168. priority: number;
  152169. /**
  152170. * 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
  152171. */
  152172. maximumSize: number;
  152173. /**
  152174. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152175. */
  152176. step: number;
  152177. /**
  152178. * Gets a string describing the action executed by the current optimization
  152179. * @returns description string
  152180. */
  152181. getDescription(): string;
  152182. /**
  152183. * Creates the TextureOptimization object
  152184. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152185. * @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
  152186. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152187. */
  152188. constructor(
  152189. /**
  152190. * Defines the priority of this optimization (0 by default which means first in the list)
  152191. */
  152192. priority?: number,
  152193. /**
  152194. * 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
  152195. */
  152196. maximumSize?: number,
  152197. /**
  152198. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  152199. */
  152200. step?: number);
  152201. /**
  152202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152203. * @param scene defines the current scene where to apply this optimization
  152204. * @param optimizer defines the current optimizer
  152205. * @returns true if everything that can be done was applied
  152206. */
  152207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152208. }
  152209. /**
  152210. * Defines an optimization used to increase or decrease the rendering resolution
  152211. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152212. */
  152213. export class HardwareScalingOptimization extends SceneOptimization {
  152214. /**
  152215. * Defines the priority of this optimization (0 by default which means first in the list)
  152216. */
  152217. priority: number;
  152218. /**
  152219. * Defines the maximum scale to use (2 by default)
  152220. */
  152221. maximumScale: number;
  152222. /**
  152223. * Defines the step to use between two passes (0.5 by default)
  152224. */
  152225. step: number;
  152226. private _currentScale;
  152227. private _directionOffset;
  152228. /**
  152229. * Gets a string describing the action executed by the current optimization
  152230. * @return description string
  152231. */
  152232. getDescription(): string;
  152233. /**
  152234. * Creates the HardwareScalingOptimization object
  152235. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152236. * @param maximumScale defines the maximum scale to use (2 by default)
  152237. * @param step defines the step to use between two passes (0.5 by default)
  152238. */
  152239. constructor(
  152240. /**
  152241. * Defines the priority of this optimization (0 by default which means first in the list)
  152242. */
  152243. priority?: number,
  152244. /**
  152245. * Defines the maximum scale to use (2 by default)
  152246. */
  152247. maximumScale?: number,
  152248. /**
  152249. * Defines the step to use between two passes (0.5 by default)
  152250. */
  152251. step?: number);
  152252. /**
  152253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152254. * @param scene defines the current scene where to apply this optimization
  152255. * @param optimizer defines the current optimizer
  152256. * @returns true if everything that can be done was applied
  152257. */
  152258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152259. }
  152260. /**
  152261. * Defines an optimization used to remove shadows
  152262. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152263. */
  152264. export class ShadowsOptimization extends SceneOptimization {
  152265. /**
  152266. * Gets a string describing the action executed by the current optimization
  152267. * @return description string
  152268. */
  152269. getDescription(): string;
  152270. /**
  152271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152272. * @param scene defines the current scene where to apply this optimization
  152273. * @param optimizer defines the current optimizer
  152274. * @returns true if everything that can be done was applied
  152275. */
  152276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152277. }
  152278. /**
  152279. * Defines an optimization used to turn post-processes off
  152280. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152281. */
  152282. export class PostProcessesOptimization extends SceneOptimization {
  152283. /**
  152284. * Gets a string describing the action executed by the current optimization
  152285. * @return description string
  152286. */
  152287. getDescription(): string;
  152288. /**
  152289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152290. * @param scene defines the current scene where to apply this optimization
  152291. * @param optimizer defines the current optimizer
  152292. * @returns true if everything that can be done was applied
  152293. */
  152294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152295. }
  152296. /**
  152297. * Defines an optimization used to turn lens flares off
  152298. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152299. */
  152300. export class LensFlaresOptimization extends SceneOptimization {
  152301. /**
  152302. * Gets a string describing the action executed by the current optimization
  152303. * @return description string
  152304. */
  152305. getDescription(): string;
  152306. /**
  152307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152308. * @param scene defines the current scene where to apply this optimization
  152309. * @param optimizer defines the current optimizer
  152310. * @returns true if everything that can be done was applied
  152311. */
  152312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152313. }
  152314. /**
  152315. * Defines an optimization based on user defined callback.
  152316. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152317. */
  152318. export class CustomOptimization extends SceneOptimization {
  152319. /**
  152320. * Callback called to apply the custom optimization.
  152321. */
  152322. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  152323. /**
  152324. * Callback called to get custom description
  152325. */
  152326. onGetDescription: () => string;
  152327. /**
  152328. * Gets a string describing the action executed by the current optimization
  152329. * @returns description string
  152330. */
  152331. getDescription(): string;
  152332. /**
  152333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152334. * @param scene defines the current scene where to apply this optimization
  152335. * @param optimizer defines the current optimizer
  152336. * @returns true if everything that can be done was applied
  152337. */
  152338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152339. }
  152340. /**
  152341. * Defines an optimization used to turn particles off
  152342. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152343. */
  152344. export class ParticlesOptimization extends SceneOptimization {
  152345. /**
  152346. * Gets a string describing the action executed by the current optimization
  152347. * @return description string
  152348. */
  152349. getDescription(): string;
  152350. /**
  152351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152352. * @param scene defines the current scene where to apply this optimization
  152353. * @param optimizer defines the current optimizer
  152354. * @returns true if everything that can be done was applied
  152355. */
  152356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152357. }
  152358. /**
  152359. * Defines an optimization used to turn render targets off
  152360. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152361. */
  152362. export class RenderTargetsOptimization extends SceneOptimization {
  152363. /**
  152364. * Gets a string describing the action executed by the current optimization
  152365. * @return description string
  152366. */
  152367. getDescription(): string;
  152368. /**
  152369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152370. * @param scene defines the current scene where to apply this optimization
  152371. * @param optimizer defines the current optimizer
  152372. * @returns true if everything that can be done was applied
  152373. */
  152374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152375. }
  152376. /**
  152377. * Defines an optimization used to merge meshes with compatible materials
  152378. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152379. */
  152380. export class MergeMeshesOptimization extends SceneOptimization {
  152381. private static _UpdateSelectionTree;
  152382. /**
  152383. * Gets or sets a boolean which defines if optimization octree has to be updated
  152384. */
  152385. static get UpdateSelectionTree(): boolean;
  152386. /**
  152387. * Gets or sets a boolean which defines if optimization octree has to be updated
  152388. */
  152389. static set UpdateSelectionTree(value: boolean);
  152390. /**
  152391. * Gets a string describing the action executed by the current optimization
  152392. * @return description string
  152393. */
  152394. getDescription(): string;
  152395. private _canBeMerged;
  152396. /**
  152397. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152398. * @param scene defines the current scene where to apply this optimization
  152399. * @param optimizer defines the current optimizer
  152400. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152401. * @returns true if everything that can be done was applied
  152402. */
  152403. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152404. }
  152405. /**
  152406. * Defines a list of options used by SceneOptimizer
  152407. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152408. */
  152409. export class SceneOptimizerOptions {
  152410. /**
  152411. * Defines the target frame rate to reach (60 by default)
  152412. */
  152413. targetFrameRate: number;
  152414. /**
  152415. * Defines the interval between two checkes (2000ms by default)
  152416. */
  152417. trackerDuration: number;
  152418. /**
  152419. * Gets the list of optimizations to apply
  152420. */
  152421. optimizations: SceneOptimization[];
  152422. /**
  152423. * Creates a new list of options used by SceneOptimizer
  152424. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152425. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152426. */
  152427. constructor(
  152428. /**
  152429. * Defines the target frame rate to reach (60 by default)
  152430. */
  152431. targetFrameRate?: number,
  152432. /**
  152433. * Defines the interval between two checkes (2000ms by default)
  152434. */
  152435. trackerDuration?: number);
  152436. /**
  152437. * Add a new optimization
  152438. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152439. * @returns the current SceneOptimizerOptions
  152440. */
  152441. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152442. /**
  152443. * Add a new custom optimization
  152444. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152445. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152446. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152447. * @returns the current SceneOptimizerOptions
  152448. */
  152449. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152450. /**
  152451. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152452. * @param targetFrameRate defines the target frame rate (60 by default)
  152453. * @returns a SceneOptimizerOptions object
  152454. */
  152455. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152456. /**
  152457. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152458. * @param targetFrameRate defines the target frame rate (60 by default)
  152459. * @returns a SceneOptimizerOptions object
  152460. */
  152461. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152462. /**
  152463. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152464. * @param targetFrameRate defines the target frame rate (60 by default)
  152465. * @returns a SceneOptimizerOptions object
  152466. */
  152467. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152468. }
  152469. /**
  152470. * Class used to run optimizations in order to reach a target frame rate
  152471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152472. */
  152473. export class SceneOptimizer implements IDisposable {
  152474. private _isRunning;
  152475. private _options;
  152476. private _scene;
  152477. private _currentPriorityLevel;
  152478. private _targetFrameRate;
  152479. private _trackerDuration;
  152480. private _currentFrameRate;
  152481. private _sceneDisposeObserver;
  152482. private _improvementMode;
  152483. /**
  152484. * Defines an observable called when the optimizer reaches the target frame rate
  152485. */
  152486. onSuccessObservable: Observable<SceneOptimizer>;
  152487. /**
  152488. * Defines an observable called when the optimizer enables an optimization
  152489. */
  152490. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152491. /**
  152492. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152493. */
  152494. onFailureObservable: Observable<SceneOptimizer>;
  152495. /**
  152496. * Gets a boolean indicating if the optimizer is in improvement mode
  152497. */
  152498. get isInImprovementMode(): boolean;
  152499. /**
  152500. * Gets the current priority level (0 at start)
  152501. */
  152502. get currentPriorityLevel(): number;
  152503. /**
  152504. * Gets the current frame rate checked by the SceneOptimizer
  152505. */
  152506. get currentFrameRate(): number;
  152507. /**
  152508. * Gets or sets the current target frame rate (60 by default)
  152509. */
  152510. get targetFrameRate(): number;
  152511. /**
  152512. * Gets or sets the current target frame rate (60 by default)
  152513. */
  152514. set targetFrameRate(value: number);
  152515. /**
  152516. * Gets or sets the current interval between two checks (every 2000ms by default)
  152517. */
  152518. get trackerDuration(): number;
  152519. /**
  152520. * Gets or sets the current interval between two checks (every 2000ms by default)
  152521. */
  152522. set trackerDuration(value: number);
  152523. /**
  152524. * Gets the list of active optimizations
  152525. */
  152526. get optimizations(): SceneOptimization[];
  152527. /**
  152528. * Creates a new SceneOptimizer
  152529. * @param scene defines the scene to work on
  152530. * @param options defines the options to use with the SceneOptimizer
  152531. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152532. * @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)
  152533. */
  152534. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152535. /**
  152536. * Stops the current optimizer
  152537. */
  152538. stop(): void;
  152539. /**
  152540. * Reset the optimizer to initial step (current priority level = 0)
  152541. */
  152542. reset(): void;
  152543. /**
  152544. * Start the optimizer. By default it will try to reach a specific framerate
  152545. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152546. */
  152547. start(): void;
  152548. private _checkCurrentState;
  152549. /**
  152550. * Release all resources
  152551. */
  152552. dispose(): void;
  152553. /**
  152554. * Helper function to create a SceneOptimizer with one single line of code
  152555. * @param scene defines the scene to work on
  152556. * @param options defines the options to use with the SceneOptimizer
  152557. * @param onSuccess defines a callback to call on success
  152558. * @param onFailure defines a callback to call on failure
  152559. * @returns the new SceneOptimizer object
  152560. */
  152561. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152562. }
  152563. }
  152564. declare module BABYLON {
  152565. /**
  152566. * Class used to serialize a scene into a string
  152567. */
  152568. export class SceneSerializer {
  152569. /**
  152570. * Clear cache used by a previous serialization
  152571. */
  152572. static ClearCache(): void;
  152573. /**
  152574. * Serialize a scene into a JSON compatible object
  152575. * @param scene defines the scene to serialize
  152576. * @returns a JSON compatible object
  152577. */
  152578. static Serialize(scene: Scene): any;
  152579. /**
  152580. * Serialize a mesh into a JSON compatible object
  152581. * @param toSerialize defines the mesh to serialize
  152582. * @param withParents defines if parents must be serialized as well
  152583. * @param withChildren defines if children must be serialized as well
  152584. * @returns a JSON compatible object
  152585. */
  152586. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152587. }
  152588. }
  152589. declare module BABYLON {
  152590. /**
  152591. * Class used to host texture specific utilities
  152592. */
  152593. export class TextureTools {
  152594. /**
  152595. * Uses the GPU to create a copy texture rescaled at a given size
  152596. * @param texture Texture to copy from
  152597. * @param width defines the desired width
  152598. * @param height defines the desired height
  152599. * @param useBilinearMode defines if bilinear mode has to be used
  152600. * @return the generated texture
  152601. */
  152602. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152603. }
  152604. }
  152605. declare module BABYLON {
  152606. /**
  152607. * This represents the different options available for the video capture.
  152608. */
  152609. export interface VideoRecorderOptions {
  152610. /** Defines the mime type of the video. */
  152611. mimeType: string;
  152612. /** Defines the FPS the video should be recorded at. */
  152613. fps: number;
  152614. /** Defines the chunk size for the recording data. */
  152615. recordChunckSize: number;
  152616. /** The audio tracks to attach to the recording. */
  152617. audioTracks?: MediaStreamTrack[];
  152618. }
  152619. /**
  152620. * This can help with recording videos from BabylonJS.
  152621. * This is based on the available WebRTC functionalities of the browser.
  152622. *
  152623. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152624. */
  152625. export class VideoRecorder {
  152626. private static readonly _defaultOptions;
  152627. /**
  152628. * Returns whether or not the VideoRecorder is available in your browser.
  152629. * @param engine Defines the Babylon Engine.
  152630. * @returns true if supported otherwise false.
  152631. */
  152632. static IsSupported(engine: Engine): boolean;
  152633. private readonly _options;
  152634. private _canvas;
  152635. private _mediaRecorder;
  152636. private _recordedChunks;
  152637. private _fileName;
  152638. private _resolve;
  152639. private _reject;
  152640. /**
  152641. * True when a recording is already in progress.
  152642. */
  152643. get isRecording(): boolean;
  152644. /**
  152645. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152646. * @param engine Defines the BabylonJS Engine you wish to record.
  152647. * @param options Defines options that can be used to customize the capture.
  152648. */
  152649. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152650. /**
  152651. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152652. */
  152653. stopRecording(): void;
  152654. /**
  152655. * Starts recording the canvas for a max duration specified in parameters.
  152656. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152657. * If null no automatic download will start and you can rely on the promise to get the data back.
  152658. * @param maxDuration Defines the maximum recording time in seconds.
  152659. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152660. * @return A promise callback at the end of the recording with the video data in Blob.
  152661. */
  152662. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152663. /**
  152664. * Releases internal resources used during the recording.
  152665. */
  152666. dispose(): void;
  152667. private _handleDataAvailable;
  152668. private _handleError;
  152669. private _handleStop;
  152670. }
  152671. }
  152672. declare module BABYLON {
  152673. /**
  152674. * Class containing a set of static utilities functions for screenshots
  152675. */
  152676. export class ScreenshotTools {
  152677. /**
  152678. * Captures a screenshot of the current rendering
  152679. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152680. * @param engine defines the rendering engine
  152681. * @param camera defines the source camera
  152682. * @param size This parameter can be set to a single number or to an object with the
  152683. * following (optional) properties: precision, width, height. If a single number is passed,
  152684. * it will be used for both width and height. If an object is passed, the screenshot size
  152685. * will be derived from the parameters. The precision property is a multiplier allowing
  152686. * rendering at a higher or lower resolution
  152687. * @param successCallback defines the callback receives a single parameter which contains the
  152688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152689. * src parameter of an <img> to display it
  152690. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152691. * Check your browser for supported MIME types
  152692. */
  152693. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152694. /**
  152695. * Captures a screenshot of the current rendering
  152696. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152697. * @param engine defines the rendering engine
  152698. * @param camera defines the source camera
  152699. * @param size This parameter can be set to a single number or to an object with the
  152700. * following (optional) properties: precision, width, height. If a single number is passed,
  152701. * it will be used for both width and height. If an object is passed, the screenshot size
  152702. * will be derived from the parameters. The precision property is a multiplier allowing
  152703. * rendering at a higher or lower resolution
  152704. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152705. * Check your browser for supported MIME types
  152706. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152707. * to the src parameter of an <img> to display it
  152708. */
  152709. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152710. /**
  152711. * Generates an image screenshot from the specified camera.
  152712. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152713. * @param engine The engine to use for rendering
  152714. * @param camera The camera to use for rendering
  152715. * @param size This parameter can be set to a single number or to an object with the
  152716. * following (optional) properties: precision, width, height. If a single number is passed,
  152717. * it will be used for both width and height. If an object is passed, the screenshot size
  152718. * will be derived from the parameters. The precision property is a multiplier allowing
  152719. * rendering at a higher or lower resolution
  152720. * @param successCallback The callback receives a single parameter which contains the
  152721. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152722. * src parameter of an <img> to display it
  152723. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152724. * Check your browser for supported MIME types
  152725. * @param samples Texture samples (default: 1)
  152726. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152727. * @param fileName A name for for the downloaded file.
  152728. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152729. */
  152730. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152731. /**
  152732. * Generates an image screenshot from the specified camera.
  152733. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152734. * @param engine The engine to use for rendering
  152735. * @param camera The camera to use for rendering
  152736. * @param size This parameter can be set to a single number or to an object with the
  152737. * following (optional) properties: precision, width, height. If a single number is passed,
  152738. * it will be used for both width and height. If an object is passed, the screenshot size
  152739. * will be derived from the parameters. The precision property is a multiplier allowing
  152740. * rendering at a higher or lower resolution
  152741. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152742. * Check your browser for supported MIME types
  152743. * @param samples Texture samples (default: 1)
  152744. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152745. * @param fileName A name for for the downloaded file.
  152746. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152747. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152748. * to the src parameter of an <img> to display it
  152749. */
  152750. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152751. /**
  152752. * Gets height and width for screenshot size
  152753. * @private
  152754. */
  152755. private static _getScreenshotSize;
  152756. }
  152757. }
  152758. declare module BABYLON {
  152759. /**
  152760. * Interface for a data buffer
  152761. */
  152762. export interface IDataBuffer {
  152763. /**
  152764. * Reads bytes from the data buffer.
  152765. * @param byteOffset The byte offset to read
  152766. * @param byteLength The byte length to read
  152767. * @returns A promise that resolves when the bytes are read
  152768. */
  152769. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152770. /**
  152771. * The byte length of the buffer.
  152772. */
  152773. readonly byteLength: number;
  152774. }
  152775. /**
  152776. * Utility class for reading from a data buffer
  152777. */
  152778. export class DataReader {
  152779. /**
  152780. * The data buffer associated with this data reader.
  152781. */
  152782. readonly buffer: IDataBuffer;
  152783. /**
  152784. * The current byte offset from the beginning of the data buffer.
  152785. */
  152786. byteOffset: number;
  152787. private _dataView;
  152788. private _dataByteOffset;
  152789. /**
  152790. * Constructor
  152791. * @param buffer The buffer to read
  152792. */
  152793. constructor(buffer: IDataBuffer);
  152794. /**
  152795. * Loads the given byte length.
  152796. * @param byteLength The byte length to load
  152797. * @returns A promise that resolves when the load is complete
  152798. */
  152799. loadAsync(byteLength: number): Promise<void>;
  152800. /**
  152801. * Read a unsigned 32-bit integer from the currently loaded data range.
  152802. * @returns The 32-bit integer read
  152803. */
  152804. readUint32(): number;
  152805. /**
  152806. * Read a byte array from the currently loaded data range.
  152807. * @param byteLength The byte length to read
  152808. * @returns The byte array read
  152809. */
  152810. readUint8Array(byteLength: number): Uint8Array;
  152811. /**
  152812. * Read a string from the currently loaded data range.
  152813. * @param byteLength The byte length to read
  152814. * @returns The string read
  152815. */
  152816. readString(byteLength: number): string;
  152817. /**
  152818. * Skips the given byte length the currently loaded data range.
  152819. * @param byteLength The byte length to skip
  152820. */
  152821. skipBytes(byteLength: number): void;
  152822. }
  152823. }
  152824. declare module BABYLON {
  152825. /**
  152826. * Class for storing data to local storage if available or in-memory storage otherwise
  152827. */
  152828. export class DataStorage {
  152829. private static _Storage;
  152830. private static _GetStorage;
  152831. /**
  152832. * Reads a string from the data storage
  152833. * @param key The key to read
  152834. * @param defaultValue The value if the key doesn't exist
  152835. * @returns The string value
  152836. */
  152837. static ReadString(key: string, defaultValue: string): string;
  152838. /**
  152839. * Writes a string to the data storage
  152840. * @param key The key to write
  152841. * @param value The value to write
  152842. */
  152843. static WriteString(key: string, value: string): void;
  152844. /**
  152845. * Reads a boolean from the data storage
  152846. * @param key The key to read
  152847. * @param defaultValue The value if the key doesn't exist
  152848. * @returns The boolean value
  152849. */
  152850. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152851. /**
  152852. * Writes a boolean to the data storage
  152853. * @param key The key to write
  152854. * @param value The value to write
  152855. */
  152856. static WriteBoolean(key: string, value: boolean): void;
  152857. /**
  152858. * Reads a number from the data storage
  152859. * @param key The key to read
  152860. * @param defaultValue The value if the key doesn't exist
  152861. * @returns The number value
  152862. */
  152863. static ReadNumber(key: string, defaultValue: number): number;
  152864. /**
  152865. * Writes a number to the data storage
  152866. * @param key The key to write
  152867. * @param value The value to write
  152868. */
  152869. static WriteNumber(key: string, value: number): void;
  152870. }
  152871. }
  152872. declare module BABYLON {
  152873. /**
  152874. * Class used to record delta files between 2 scene states
  152875. */
  152876. export class SceneRecorder {
  152877. private _trackedScene;
  152878. private _savedJSON;
  152879. /**
  152880. * Track a given scene. This means the current scene state will be considered the original state
  152881. * @param scene defines the scene to track
  152882. */
  152883. track(scene: Scene): void;
  152884. /**
  152885. * Get the delta between current state and original state
  152886. * @returns a string containing the delta
  152887. */
  152888. getDelta(): any;
  152889. private _compareArray;
  152890. private _compareObjects;
  152891. private _compareCollections;
  152892. private static GetShadowGeneratorById;
  152893. /**
  152894. * Apply a given delta to a given scene
  152895. * @param deltaJSON defines the JSON containing the delta
  152896. * @param scene defines the scene to apply the delta to
  152897. */
  152898. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152899. private static _ApplyPropertiesToEntity;
  152900. private static _ApplyDeltaForEntity;
  152901. }
  152902. }
  152903. declare module BABYLON {
  152904. /**
  152905. * An interface for all Hit test features
  152906. */
  152907. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152908. /**
  152909. * Triggered when new babylon (transformed) hit test results are available
  152910. */
  152911. onHitTestResultObservable: Observable<T[]>;
  152912. }
  152913. /**
  152914. * Options used for hit testing
  152915. */
  152916. export interface IWebXRLegacyHitTestOptions {
  152917. /**
  152918. * Only test when user interacted with the scene. Default - hit test every frame
  152919. */
  152920. testOnPointerDownOnly?: boolean;
  152921. /**
  152922. * The node to use to transform the local results to world coordinates
  152923. */
  152924. worldParentNode?: TransformNode;
  152925. }
  152926. /**
  152927. * Interface defining the babylon result of raycasting/hit-test
  152928. */
  152929. export interface IWebXRLegacyHitResult {
  152930. /**
  152931. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152932. */
  152933. transformationMatrix: Matrix;
  152934. /**
  152935. * The native hit test result
  152936. */
  152937. xrHitResult: XRHitResult | XRHitTestResult;
  152938. }
  152939. /**
  152940. * The currently-working hit-test module.
  152941. * Hit test (or Ray-casting) is used to interact with the real world.
  152942. * For further information read here - https://github.com/immersive-web/hit-test
  152943. */
  152944. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152945. /**
  152946. * options to use when constructing this feature
  152947. */
  152948. readonly options: IWebXRLegacyHitTestOptions;
  152949. private _direction;
  152950. private _mat;
  152951. private _onSelectEnabled;
  152952. private _origin;
  152953. /**
  152954. * The module's name
  152955. */
  152956. static readonly Name: string;
  152957. /**
  152958. * The (Babylon) version of this module.
  152959. * This is an integer representing the implementation version.
  152960. * This number does not correspond to the WebXR specs version
  152961. */
  152962. static readonly Version: number;
  152963. /**
  152964. * Populated with the last native XR Hit Results
  152965. */
  152966. lastNativeXRHitResults: XRHitResult[];
  152967. /**
  152968. * Triggered when new babylon (transformed) hit test results are available
  152969. */
  152970. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152971. /**
  152972. * Creates a new instance of the (legacy version) hit test feature
  152973. * @param _xrSessionManager an instance of WebXRSessionManager
  152974. * @param options options to use when constructing this feature
  152975. */
  152976. constructor(_xrSessionManager: WebXRSessionManager,
  152977. /**
  152978. * options to use when constructing this feature
  152979. */
  152980. options?: IWebXRLegacyHitTestOptions);
  152981. /**
  152982. * execute a hit test with an XR Ray
  152983. *
  152984. * @param xrSession a native xrSession that will execute this hit test
  152985. * @param xrRay the ray (position and direction) to use for ray-casting
  152986. * @param referenceSpace native XR reference space to use for the hit-test
  152987. * @param filter filter function that will filter the results
  152988. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152989. */
  152990. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152991. /**
  152992. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152993. * @param event the (select) event to use to select with
  152994. * @param referenceSpace the reference space to use for this hit test
  152995. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152996. */
  152997. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152998. /**
  152999. * attach this feature
  153000. * Will usually be called by the features manager
  153001. *
  153002. * @returns true if successful.
  153003. */
  153004. attach(): boolean;
  153005. /**
  153006. * detach this feature.
  153007. * Will usually be called by the features manager
  153008. *
  153009. * @returns true if successful.
  153010. */
  153011. detach(): boolean;
  153012. /**
  153013. * Dispose this feature and all of the resources attached
  153014. */
  153015. dispose(): void;
  153016. protected _onXRFrame(frame: XRFrame): void;
  153017. private _onHitTestResults;
  153018. private _onSelect;
  153019. }
  153020. }
  153021. declare module BABYLON {
  153022. /**
  153023. * Options used for hit testing (version 2)
  153024. */
  153025. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  153026. /**
  153027. * Do not create a permanent hit test. Will usually be used when only
  153028. * transient inputs are needed.
  153029. */
  153030. disablePermanentHitTest?: boolean;
  153031. /**
  153032. * Enable transient (for example touch-based) hit test inspections
  153033. */
  153034. enableTransientHitTest?: boolean;
  153035. /**
  153036. * Offset ray for the permanent hit test
  153037. */
  153038. offsetRay?: Vector3;
  153039. /**
  153040. * Offset ray for the transient hit test
  153041. */
  153042. transientOffsetRay?: Vector3;
  153043. /**
  153044. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  153045. */
  153046. useReferenceSpace?: boolean;
  153047. }
  153048. /**
  153049. * Interface defining the babylon result of hit-test
  153050. */
  153051. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  153052. /**
  153053. * The input source that generated this hit test (if transient)
  153054. */
  153055. inputSource?: XRInputSource;
  153056. /**
  153057. * Is this a transient hit test
  153058. */
  153059. isTransient?: boolean;
  153060. /**
  153061. * Position of the hit test result
  153062. */
  153063. position: Vector3;
  153064. /**
  153065. * Rotation of the hit test result
  153066. */
  153067. rotationQuaternion: Quaternion;
  153068. /**
  153069. * The native hit test result
  153070. */
  153071. xrHitResult: XRHitTestResult;
  153072. }
  153073. /**
  153074. * The currently-working hit-test module.
  153075. * Hit test (or Ray-casting) is used to interact with the real world.
  153076. * For further information read here - https://github.com/immersive-web/hit-test
  153077. *
  153078. * Tested on chrome (mobile) 80.
  153079. */
  153080. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  153081. /**
  153082. * options to use when constructing this feature
  153083. */
  153084. readonly options: IWebXRHitTestOptions;
  153085. private _tmpMat;
  153086. private _tmpPos;
  153087. private _tmpQuat;
  153088. private _transientXrHitTestSource;
  153089. private _xrHitTestSource;
  153090. private initHitTestSource;
  153091. /**
  153092. * The module's name
  153093. */
  153094. static readonly Name: string;
  153095. /**
  153096. * The (Babylon) version of this module.
  153097. * This is an integer representing the implementation version.
  153098. * This number does not correspond to the WebXR specs version
  153099. */
  153100. static readonly Version: number;
  153101. /**
  153102. * When set to true, each hit test will have its own position/rotation objects
  153103. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  153104. * the developers will clone them or copy them as they see fit.
  153105. */
  153106. autoCloneTransformation: boolean;
  153107. /**
  153108. * Triggered when new babylon (transformed) hit test results are available
  153109. */
  153110. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  153111. /**
  153112. * Use this to temporarily pause hit test checks.
  153113. */
  153114. paused: boolean;
  153115. /**
  153116. * Creates a new instance of the hit test feature
  153117. * @param _xrSessionManager an instance of WebXRSessionManager
  153118. * @param options options to use when constructing this feature
  153119. */
  153120. constructor(_xrSessionManager: WebXRSessionManager,
  153121. /**
  153122. * options to use when constructing this feature
  153123. */
  153124. options?: IWebXRHitTestOptions);
  153125. /**
  153126. * attach this feature
  153127. * Will usually be called by the features manager
  153128. *
  153129. * @returns true if successful.
  153130. */
  153131. attach(): boolean;
  153132. /**
  153133. * detach this feature.
  153134. * Will usually be called by the features manager
  153135. *
  153136. * @returns true if successful.
  153137. */
  153138. detach(): boolean;
  153139. /**
  153140. * Dispose this feature and all of the resources attached
  153141. */
  153142. dispose(): void;
  153143. protected _onXRFrame(frame: XRFrame): void;
  153144. private _processWebXRHitTestResult;
  153145. }
  153146. }
  153147. declare module BABYLON {
  153148. /**
  153149. * Configuration options of the anchor system
  153150. */
  153151. export interface IWebXRAnchorSystemOptions {
  153152. /**
  153153. * a node that will be used to convert local to world coordinates
  153154. */
  153155. worldParentNode?: TransformNode;
  153156. /**
  153157. * If set to true a reference of the created anchors will be kept until the next session starts
  153158. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  153159. */
  153160. doNotRemoveAnchorsOnSessionEnded?: boolean;
  153161. }
  153162. /**
  153163. * A babylon container for an XR Anchor
  153164. */
  153165. export interface IWebXRAnchor {
  153166. /**
  153167. * A babylon-assigned ID for this anchor
  153168. */
  153169. id: number;
  153170. /**
  153171. * Transformation matrix to apply to an object attached to this anchor
  153172. */
  153173. transformationMatrix: Matrix;
  153174. /**
  153175. * The native anchor object
  153176. */
  153177. xrAnchor: XRAnchor;
  153178. /**
  153179. * if defined, this object will be constantly updated by the anchor's position and rotation
  153180. */
  153181. attachedNode?: TransformNode;
  153182. }
  153183. /**
  153184. * An implementation of the anchor system for WebXR.
  153185. * For further information see https://github.com/immersive-web/anchors/
  153186. */
  153187. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  153188. private _options;
  153189. private _lastFrameDetected;
  153190. private _trackedAnchors;
  153191. private _referenceSpaceForFrameAnchors;
  153192. private _futureAnchors;
  153193. /**
  153194. * The module's name
  153195. */
  153196. static readonly Name: string;
  153197. /**
  153198. * The (Babylon) version of this module.
  153199. * This is an integer representing the implementation version.
  153200. * This number does not correspond to the WebXR specs version
  153201. */
  153202. static readonly Version: number;
  153203. /**
  153204. * Observers registered here will be executed when a new anchor was added to the session
  153205. */
  153206. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  153207. /**
  153208. * Observers registered here will be executed when an anchor was removed from the session
  153209. */
  153210. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  153211. /**
  153212. * Observers registered here will be executed when an existing anchor updates
  153213. * This can execute N times every frame
  153214. */
  153215. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  153216. /**
  153217. * Set the reference space to use for anchor creation, when not using a hit test.
  153218. * Will default to the session's reference space if not defined
  153219. */
  153220. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  153221. /**
  153222. * constructs a new anchor system
  153223. * @param _xrSessionManager an instance of WebXRSessionManager
  153224. * @param _options configuration object for this feature
  153225. */
  153226. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  153227. private _tmpVector;
  153228. private _tmpQuaternion;
  153229. private _populateTmpTransformation;
  153230. /**
  153231. * Create a new anchor point using a hit test result at a specific point in the scene
  153232. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153233. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153234. *
  153235. * @param hitTestResult The hit test result to use for this anchor creation
  153236. * @param position an optional position offset for this anchor
  153237. * @param rotationQuaternion an optional rotation offset for this anchor
  153238. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153239. */
  153240. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  153241. /**
  153242. * Add a new anchor at a specific position and rotation
  153243. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  153244. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  153245. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153246. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153247. *
  153248. * @param position the position in which to add an anchor
  153249. * @param rotationQuaternion an optional rotation for the anchor transformation
  153250. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  153251. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153252. */
  153253. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  153254. /**
  153255. * detach this feature.
  153256. * Will usually be called by the features manager
  153257. *
  153258. * @returns true if successful.
  153259. */
  153260. detach(): boolean;
  153261. /**
  153262. * Dispose this feature and all of the resources attached
  153263. */
  153264. dispose(): void;
  153265. protected _onXRFrame(frame: XRFrame): void;
  153266. /**
  153267. * avoiding using Array.find for global support.
  153268. * @param xrAnchor the plane to find in the array
  153269. */
  153270. private _findIndexInAnchorArray;
  153271. private _updateAnchorWithXRFrame;
  153272. private _createAnchorAtTransformation;
  153273. }
  153274. }
  153275. declare module BABYLON {
  153276. /**
  153277. * Options used in the plane detector module
  153278. */
  153279. export interface IWebXRPlaneDetectorOptions {
  153280. /**
  153281. * The node to use to transform the local results to world coordinates
  153282. */
  153283. worldParentNode?: TransformNode;
  153284. /**
  153285. * If set to true a reference of the created planes will be kept until the next session starts
  153286. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  153287. */
  153288. doNotRemovePlanesOnSessionEnded?: boolean;
  153289. }
  153290. /**
  153291. * A babylon interface for a WebXR plane.
  153292. * A Plane is actually a polygon, built from N points in space
  153293. *
  153294. * Supported in chrome 79, not supported in canary 81 ATM
  153295. */
  153296. export interface IWebXRPlane {
  153297. /**
  153298. * a babylon-assigned ID for this polygon
  153299. */
  153300. id: number;
  153301. /**
  153302. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  153303. */
  153304. polygonDefinition: Array<Vector3>;
  153305. /**
  153306. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  153307. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  153308. */
  153309. transformationMatrix: Matrix;
  153310. /**
  153311. * the native xr-plane object
  153312. */
  153313. xrPlane: XRPlane;
  153314. }
  153315. /**
  153316. * The plane detector is used to detect planes in the real world when in AR
  153317. * For more information see https://github.com/immersive-web/real-world-geometry/
  153318. */
  153319. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  153320. private _options;
  153321. private _detectedPlanes;
  153322. private _enabled;
  153323. private _lastFrameDetected;
  153324. /**
  153325. * The module's name
  153326. */
  153327. static readonly Name: string;
  153328. /**
  153329. * The (Babylon) version of this module.
  153330. * This is an integer representing the implementation version.
  153331. * This number does not correspond to the WebXR specs version
  153332. */
  153333. static readonly Version: number;
  153334. /**
  153335. * Observers registered here will be executed when a new plane was added to the session
  153336. */
  153337. onPlaneAddedObservable: Observable<IWebXRPlane>;
  153338. /**
  153339. * Observers registered here will be executed when a plane is no longer detected in the session
  153340. */
  153341. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153342. /**
  153343. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153344. * This can execute N times every frame
  153345. */
  153346. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153347. /**
  153348. * construct a new Plane Detector
  153349. * @param _xrSessionManager an instance of xr Session manager
  153350. * @param _options configuration to use when constructing this feature
  153351. */
  153352. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153353. /**
  153354. * detach this feature.
  153355. * Will usually be called by the features manager
  153356. *
  153357. * @returns true if successful.
  153358. */
  153359. detach(): boolean;
  153360. /**
  153361. * Dispose this feature and all of the resources attached
  153362. */
  153363. dispose(): void;
  153364. protected _onXRFrame(frame: XRFrame): void;
  153365. private _init;
  153366. private _updatePlaneWithXRPlane;
  153367. /**
  153368. * avoiding using Array.find for global support.
  153369. * @param xrPlane the plane to find in the array
  153370. */
  153371. private findIndexInPlaneArray;
  153372. }
  153373. }
  153374. declare module BABYLON {
  153375. /**
  153376. * Options interface for the background remover plugin
  153377. */
  153378. export interface IWebXRBackgroundRemoverOptions {
  153379. /**
  153380. * Further background meshes to disable when entering AR
  153381. */
  153382. backgroundMeshes?: AbstractMesh[];
  153383. /**
  153384. * flags to configure the removal of the environment helper.
  153385. * If not set, the entire background will be removed. If set, flags should be set as well.
  153386. */
  153387. environmentHelperRemovalFlags?: {
  153388. /**
  153389. * Should the skybox be removed (default false)
  153390. */
  153391. skyBox?: boolean;
  153392. /**
  153393. * Should the ground be removed (default false)
  153394. */
  153395. ground?: boolean;
  153396. };
  153397. /**
  153398. * don't disable the environment helper
  153399. */
  153400. ignoreEnvironmentHelper?: boolean;
  153401. }
  153402. /**
  153403. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153404. */
  153405. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153406. /**
  153407. * read-only options to be used in this module
  153408. */
  153409. readonly options: IWebXRBackgroundRemoverOptions;
  153410. /**
  153411. * The module's name
  153412. */
  153413. static readonly Name: string;
  153414. /**
  153415. * The (Babylon) version of this module.
  153416. * This is an integer representing the implementation version.
  153417. * This number does not correspond to the WebXR specs version
  153418. */
  153419. static readonly Version: number;
  153420. /**
  153421. * registered observers will be triggered when the background state changes
  153422. */
  153423. onBackgroundStateChangedObservable: Observable<boolean>;
  153424. /**
  153425. * constructs a new background remover module
  153426. * @param _xrSessionManager the session manager for this module
  153427. * @param options read-only options to be used in this module
  153428. */
  153429. constructor(_xrSessionManager: WebXRSessionManager,
  153430. /**
  153431. * read-only options to be used in this module
  153432. */
  153433. options?: IWebXRBackgroundRemoverOptions);
  153434. /**
  153435. * attach this feature
  153436. * Will usually be called by the features manager
  153437. *
  153438. * @returns true if successful.
  153439. */
  153440. attach(): boolean;
  153441. /**
  153442. * detach this feature.
  153443. * Will usually be called by the features manager
  153444. *
  153445. * @returns true if successful.
  153446. */
  153447. detach(): boolean;
  153448. /**
  153449. * Dispose this feature and all of the resources attached
  153450. */
  153451. dispose(): void;
  153452. protected _onXRFrame(_xrFrame: XRFrame): void;
  153453. private _setBackgroundState;
  153454. }
  153455. }
  153456. declare module BABYLON {
  153457. /**
  153458. * Options for the controller physics feature
  153459. */
  153460. export class IWebXRControllerPhysicsOptions {
  153461. /**
  153462. * Should the headset get its own impostor
  153463. */
  153464. enableHeadsetImpostor?: boolean;
  153465. /**
  153466. * Optional parameters for the headset impostor
  153467. */
  153468. headsetImpostorParams?: {
  153469. /**
  153470. * The type of impostor to create. Default is sphere
  153471. */
  153472. impostorType: number;
  153473. /**
  153474. * the size of the impostor. Defaults to 10cm
  153475. */
  153476. impostorSize?: number | {
  153477. width: number;
  153478. height: number;
  153479. depth: number;
  153480. };
  153481. /**
  153482. * Friction definitions
  153483. */
  153484. friction?: number;
  153485. /**
  153486. * Restitution
  153487. */
  153488. restitution?: number;
  153489. };
  153490. /**
  153491. * The physics properties of the future impostors
  153492. */
  153493. physicsProperties?: {
  153494. /**
  153495. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153496. * Note that this requires a physics engine that supports mesh impostors!
  153497. */
  153498. useControllerMesh?: boolean;
  153499. /**
  153500. * The type of impostor to create. Default is sphere
  153501. */
  153502. impostorType?: number;
  153503. /**
  153504. * the size of the impostor. Defaults to 10cm
  153505. */
  153506. impostorSize?: number | {
  153507. width: number;
  153508. height: number;
  153509. depth: number;
  153510. };
  153511. /**
  153512. * Friction definitions
  153513. */
  153514. friction?: number;
  153515. /**
  153516. * Restitution
  153517. */
  153518. restitution?: number;
  153519. };
  153520. /**
  153521. * the xr input to use with this pointer selection
  153522. */
  153523. xrInput: WebXRInput;
  153524. }
  153525. /**
  153526. * Add physics impostor to your webxr controllers,
  153527. * including naive calculation of their linear and angular velocity
  153528. */
  153529. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153530. private readonly _options;
  153531. private _attachController;
  153532. private _controllers;
  153533. private _debugMode;
  153534. private _delta;
  153535. private _headsetImpostor?;
  153536. private _headsetMesh?;
  153537. private _lastTimestamp;
  153538. private _tmpQuaternion;
  153539. private _tmpVector;
  153540. /**
  153541. * The module's name
  153542. */
  153543. static readonly Name: string;
  153544. /**
  153545. * The (Babylon) version of this module.
  153546. * This is an integer representing the implementation version.
  153547. * This number does not correspond to the webxr specs version
  153548. */
  153549. static readonly Version: number;
  153550. /**
  153551. * Construct a new Controller Physics Feature
  153552. * @param _xrSessionManager the corresponding xr session manager
  153553. * @param _options options to create this feature with
  153554. */
  153555. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153556. /**
  153557. * @hidden
  153558. * enable debugging - will show console outputs and the impostor mesh
  153559. */
  153560. _enablePhysicsDebug(): void;
  153561. /**
  153562. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153563. * @param xrController the controller to add
  153564. */
  153565. addController(xrController: WebXRInputSource): void;
  153566. /**
  153567. * attach this feature
  153568. * Will usually be called by the features manager
  153569. *
  153570. * @returns true if successful.
  153571. */
  153572. attach(): boolean;
  153573. /**
  153574. * detach this feature.
  153575. * Will usually be called by the features manager
  153576. *
  153577. * @returns true if successful.
  153578. */
  153579. detach(): boolean;
  153580. /**
  153581. * Get the headset impostor, if enabled
  153582. * @returns the impostor
  153583. */
  153584. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153585. /**
  153586. * Get the physics impostor of a specific controller.
  153587. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153588. * @param controller the controller or the controller id of which to get the impostor
  153589. * @returns the impostor or null
  153590. */
  153591. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153592. /**
  153593. * Update the physics properties provided in the constructor
  153594. * @param newProperties the new properties object
  153595. */
  153596. setPhysicsProperties(newProperties: {
  153597. impostorType?: number;
  153598. impostorSize?: number | {
  153599. width: number;
  153600. height: number;
  153601. depth: number;
  153602. };
  153603. friction?: number;
  153604. restitution?: number;
  153605. }): void;
  153606. protected _onXRFrame(_xrFrame: any): void;
  153607. private _detachController;
  153608. }
  153609. }
  153610. declare module BABYLON {
  153611. /**
  153612. * The motion controller class for all microsoft mixed reality controllers
  153613. */
  153614. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153615. protected readonly _mapping: {
  153616. defaultButton: {
  153617. valueNodeName: string;
  153618. unpressedNodeName: string;
  153619. pressedNodeName: string;
  153620. };
  153621. defaultAxis: {
  153622. valueNodeName: string;
  153623. minNodeName: string;
  153624. maxNodeName: string;
  153625. };
  153626. buttons: {
  153627. "xr-standard-trigger": {
  153628. rootNodeName: string;
  153629. componentProperty: string;
  153630. states: string[];
  153631. };
  153632. "xr-standard-squeeze": {
  153633. rootNodeName: string;
  153634. componentProperty: string;
  153635. states: string[];
  153636. };
  153637. "xr-standard-touchpad": {
  153638. rootNodeName: string;
  153639. labelAnchorNodeName: string;
  153640. touchPointNodeName: string;
  153641. };
  153642. "xr-standard-thumbstick": {
  153643. rootNodeName: string;
  153644. componentProperty: string;
  153645. states: string[];
  153646. };
  153647. };
  153648. axes: {
  153649. "xr-standard-touchpad": {
  153650. "x-axis": {
  153651. rootNodeName: string;
  153652. };
  153653. "y-axis": {
  153654. rootNodeName: string;
  153655. };
  153656. };
  153657. "xr-standard-thumbstick": {
  153658. "x-axis": {
  153659. rootNodeName: string;
  153660. };
  153661. "y-axis": {
  153662. rootNodeName: string;
  153663. };
  153664. };
  153665. };
  153666. };
  153667. /**
  153668. * The base url used to load the left and right controller models
  153669. */
  153670. static MODEL_BASE_URL: string;
  153671. /**
  153672. * The name of the left controller model file
  153673. */
  153674. static MODEL_LEFT_FILENAME: string;
  153675. /**
  153676. * The name of the right controller model file
  153677. */
  153678. static MODEL_RIGHT_FILENAME: string;
  153679. profileId: string;
  153680. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153681. protected _getFilenameAndPath(): {
  153682. filename: string;
  153683. path: string;
  153684. };
  153685. protected _getModelLoadingConstraints(): boolean;
  153686. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153687. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153688. protected _updateModel(): void;
  153689. }
  153690. }
  153691. declare module BABYLON {
  153692. /**
  153693. * The motion controller class for oculus touch (quest, rift).
  153694. * This class supports legacy mapping as well the standard xr mapping
  153695. */
  153696. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153697. private _forceLegacyControllers;
  153698. private _modelRootNode;
  153699. /**
  153700. * The base url used to load the left and right controller models
  153701. */
  153702. static MODEL_BASE_URL: string;
  153703. /**
  153704. * The name of the left controller model file
  153705. */
  153706. static MODEL_LEFT_FILENAME: string;
  153707. /**
  153708. * The name of the right controller model file
  153709. */
  153710. static MODEL_RIGHT_FILENAME: string;
  153711. /**
  153712. * Base Url for the Quest controller model.
  153713. */
  153714. static QUEST_MODEL_BASE_URL: string;
  153715. profileId: string;
  153716. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153717. protected _getFilenameAndPath(): {
  153718. filename: string;
  153719. path: string;
  153720. };
  153721. protected _getModelLoadingConstraints(): boolean;
  153722. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153723. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153724. protected _updateModel(): void;
  153725. /**
  153726. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153727. * between the touch and touch 2.
  153728. */
  153729. private _isQuest;
  153730. }
  153731. }
  153732. declare module BABYLON {
  153733. /**
  153734. * The motion controller class for the standard HTC-Vive controllers
  153735. */
  153736. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153737. private _modelRootNode;
  153738. /**
  153739. * The base url used to load the left and right controller models
  153740. */
  153741. static MODEL_BASE_URL: string;
  153742. /**
  153743. * File name for the controller model.
  153744. */
  153745. static MODEL_FILENAME: string;
  153746. profileId: string;
  153747. /**
  153748. * Create a new Vive motion controller object
  153749. * @param scene the scene to use to create this controller
  153750. * @param gamepadObject the corresponding gamepad object
  153751. * @param handedness the handedness of the controller
  153752. */
  153753. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153754. protected _getFilenameAndPath(): {
  153755. filename: string;
  153756. path: string;
  153757. };
  153758. protected _getModelLoadingConstraints(): boolean;
  153759. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153760. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153761. protected _updateModel(): void;
  153762. }
  153763. }
  153764. declare module BABYLON {
  153765. /**
  153766. * A cursor which tracks a point on a path
  153767. */
  153768. export class PathCursor {
  153769. private path;
  153770. /**
  153771. * Stores path cursor callbacks for when an onchange event is triggered
  153772. */
  153773. private _onchange;
  153774. /**
  153775. * The value of the path cursor
  153776. */
  153777. value: number;
  153778. /**
  153779. * The animation array of the path cursor
  153780. */
  153781. animations: Animation[];
  153782. /**
  153783. * Initializes the path cursor
  153784. * @param path The path to track
  153785. */
  153786. constructor(path: Path2);
  153787. /**
  153788. * Gets the cursor point on the path
  153789. * @returns A point on the path cursor at the cursor location
  153790. */
  153791. getPoint(): Vector3;
  153792. /**
  153793. * Moves the cursor ahead by the step amount
  153794. * @param step The amount to move the cursor forward
  153795. * @returns This path cursor
  153796. */
  153797. moveAhead(step?: number): PathCursor;
  153798. /**
  153799. * Moves the cursor behind by the step amount
  153800. * @param step The amount to move the cursor back
  153801. * @returns This path cursor
  153802. */
  153803. moveBack(step?: number): PathCursor;
  153804. /**
  153805. * Moves the cursor by the step amount
  153806. * If the step amount is greater than one, an exception is thrown
  153807. * @param step The amount to move the cursor
  153808. * @returns This path cursor
  153809. */
  153810. move(step: number): PathCursor;
  153811. /**
  153812. * Ensures that the value is limited between zero and one
  153813. * @returns This path cursor
  153814. */
  153815. private ensureLimits;
  153816. /**
  153817. * Runs onchange callbacks on change (used by the animation engine)
  153818. * @returns This path cursor
  153819. */
  153820. private raiseOnChange;
  153821. /**
  153822. * Executes a function on change
  153823. * @param f A path cursor onchange callback
  153824. * @returns This path cursor
  153825. */
  153826. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153827. }
  153828. }
  153829. declare module BABYLON {
  153830. /** @hidden */
  153831. export var blurPixelShader: {
  153832. name: string;
  153833. shader: string;
  153834. };
  153835. }
  153836. declare module BABYLON {
  153837. /** @hidden */
  153838. export var pointCloudVertexDeclaration: {
  153839. name: string;
  153840. shader: string;
  153841. };
  153842. }
  153843. // Mixins
  153844. interface Window {
  153845. mozIndexedDB: IDBFactory;
  153846. webkitIndexedDB: IDBFactory;
  153847. msIndexedDB: IDBFactory;
  153848. webkitURL: typeof URL;
  153849. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153850. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153851. WebGLRenderingContext: WebGLRenderingContext;
  153852. MSGesture: MSGesture;
  153853. CANNON: any;
  153854. AudioContext: AudioContext;
  153855. webkitAudioContext: AudioContext;
  153856. PointerEvent: any;
  153857. Math: Math;
  153858. Uint8Array: Uint8ArrayConstructor;
  153859. Float32Array: Float32ArrayConstructor;
  153860. mozURL: typeof URL;
  153861. msURL: typeof URL;
  153862. VRFrameData: any; // WebVR, from specs 1.1
  153863. DracoDecoderModule: any;
  153864. setImmediate(handler: (...args: any[]) => void): number;
  153865. }
  153866. interface HTMLCanvasElement {
  153867. requestPointerLock(): void;
  153868. msRequestPointerLock?(): void;
  153869. mozRequestPointerLock?(): void;
  153870. webkitRequestPointerLock?(): void;
  153871. /** Track wether a record is in progress */
  153872. isRecording: boolean;
  153873. /** Capture Stream method defined by some browsers */
  153874. captureStream(fps?: number): MediaStream;
  153875. }
  153876. interface CanvasRenderingContext2D {
  153877. msImageSmoothingEnabled: boolean;
  153878. }
  153879. interface MouseEvent {
  153880. mozMovementX: number;
  153881. mozMovementY: number;
  153882. webkitMovementX: number;
  153883. webkitMovementY: number;
  153884. msMovementX: number;
  153885. msMovementY: number;
  153886. }
  153887. interface Navigator {
  153888. mozGetVRDevices: (any: any) => any;
  153889. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153890. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153891. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153892. webkitGetGamepads(): Gamepad[];
  153893. msGetGamepads(): Gamepad[];
  153894. webkitGamepads(): Gamepad[];
  153895. }
  153896. interface HTMLVideoElement {
  153897. mozSrcObject: any;
  153898. }
  153899. interface Math {
  153900. fround(x: number): number;
  153901. imul(a: number, b: number): number;
  153902. }
  153903. interface WebGLRenderingContext {
  153904. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153905. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153906. vertexAttribDivisor(index: number, divisor: number): void;
  153907. createVertexArray(): any;
  153908. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153909. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153910. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153911. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153912. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153913. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153914. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153915. // Queries
  153916. createQuery(): WebGLQuery;
  153917. deleteQuery(query: WebGLQuery): void;
  153918. beginQuery(target: number, query: WebGLQuery): void;
  153919. endQuery(target: number): void;
  153920. getQueryParameter(query: WebGLQuery, pname: number): any;
  153921. getQuery(target: number, pname: number): any;
  153922. MAX_SAMPLES: number;
  153923. RGBA8: number;
  153924. READ_FRAMEBUFFER: number;
  153925. DRAW_FRAMEBUFFER: number;
  153926. UNIFORM_BUFFER: number;
  153927. HALF_FLOAT_OES: number;
  153928. RGBA16F: number;
  153929. RGBA32F: number;
  153930. R32F: number;
  153931. RG32F: number;
  153932. RGB32F: number;
  153933. R16F: number;
  153934. RG16F: number;
  153935. RGB16F: number;
  153936. RED: number;
  153937. RG: number;
  153938. R8: number;
  153939. RG8: number;
  153940. UNSIGNED_INT_24_8: number;
  153941. DEPTH24_STENCIL8: number;
  153942. MIN: number;
  153943. MAX: number;
  153944. /* Multiple Render Targets */
  153945. drawBuffers(buffers: number[]): void;
  153946. readBuffer(src: number): void;
  153947. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153948. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153949. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153950. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153951. // Occlusion Query
  153952. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153953. ANY_SAMPLES_PASSED: number;
  153954. QUERY_RESULT_AVAILABLE: number;
  153955. QUERY_RESULT: number;
  153956. }
  153957. interface WebGLProgram {
  153958. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153959. }
  153960. interface EXT_disjoint_timer_query {
  153961. QUERY_COUNTER_BITS_EXT: number;
  153962. TIME_ELAPSED_EXT: number;
  153963. TIMESTAMP_EXT: number;
  153964. GPU_DISJOINT_EXT: number;
  153965. QUERY_RESULT_EXT: number;
  153966. QUERY_RESULT_AVAILABLE_EXT: number;
  153967. queryCounterEXT(query: WebGLQuery, target: number): void;
  153968. createQueryEXT(): WebGLQuery;
  153969. beginQueryEXT(target: number, query: WebGLQuery): void;
  153970. endQueryEXT(target: number): void;
  153971. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153972. deleteQueryEXT(query: WebGLQuery): void;
  153973. }
  153974. interface WebGLUniformLocation {
  153975. _currentState: any;
  153976. }
  153977. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153978. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153979. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153980. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153981. interface WebGLRenderingContext {
  153982. readonly RASTERIZER_DISCARD: number;
  153983. readonly DEPTH_COMPONENT24: number;
  153984. readonly TEXTURE_3D: number;
  153985. readonly TEXTURE_2D_ARRAY: number;
  153986. readonly TEXTURE_COMPARE_FUNC: number;
  153987. readonly TEXTURE_COMPARE_MODE: number;
  153988. readonly COMPARE_REF_TO_TEXTURE: number;
  153989. readonly TEXTURE_WRAP_R: number;
  153990. readonly HALF_FLOAT: number;
  153991. readonly RGB8: number;
  153992. readonly RED_INTEGER: number;
  153993. readonly RG_INTEGER: number;
  153994. readonly RGB_INTEGER: number;
  153995. readonly RGBA_INTEGER: number;
  153996. readonly R8_SNORM: number;
  153997. readonly RG8_SNORM: number;
  153998. readonly RGB8_SNORM: number;
  153999. readonly RGBA8_SNORM: number;
  154000. readonly R8I: number;
  154001. readonly RG8I: number;
  154002. readonly RGB8I: number;
  154003. readonly RGBA8I: number;
  154004. readonly R8UI: number;
  154005. readonly RG8UI: number;
  154006. readonly RGB8UI: number;
  154007. readonly RGBA8UI: number;
  154008. readonly R16I: number;
  154009. readonly RG16I: number;
  154010. readonly RGB16I: number;
  154011. readonly RGBA16I: number;
  154012. readonly R16UI: number;
  154013. readonly RG16UI: number;
  154014. readonly RGB16UI: number;
  154015. readonly RGBA16UI: number;
  154016. readonly R32I: number;
  154017. readonly RG32I: number;
  154018. readonly RGB32I: number;
  154019. readonly RGBA32I: number;
  154020. readonly R32UI: number;
  154021. readonly RG32UI: number;
  154022. readonly RGB32UI: number;
  154023. readonly RGBA32UI: number;
  154024. readonly RGB10_A2UI: number;
  154025. readonly R11F_G11F_B10F: number;
  154026. readonly RGB9_E5: number;
  154027. readonly RGB10_A2: number;
  154028. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  154029. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  154030. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  154031. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  154032. readonly DEPTH_COMPONENT32F: number;
  154033. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  154034. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  154035. 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;
  154036. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  154037. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  154038. readonly TRANSFORM_FEEDBACK: number;
  154039. readonly INTERLEAVED_ATTRIBS: number;
  154040. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  154041. createTransformFeedback(): WebGLTransformFeedback;
  154042. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  154043. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  154044. beginTransformFeedback(primitiveMode: number): void;
  154045. endTransformFeedback(): void;
  154046. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  154047. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154048. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154049. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  154050. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  154051. }
  154052. interface ImageBitmap {
  154053. readonly width: number;
  154054. readonly height: number;
  154055. close(): void;
  154056. }
  154057. interface WebGLQuery extends WebGLObject {
  154058. }
  154059. declare var WebGLQuery: {
  154060. prototype: WebGLQuery;
  154061. new(): WebGLQuery;
  154062. };
  154063. interface WebGLSampler extends WebGLObject {
  154064. }
  154065. declare var WebGLSampler: {
  154066. prototype: WebGLSampler;
  154067. new(): WebGLSampler;
  154068. };
  154069. interface WebGLSync extends WebGLObject {
  154070. }
  154071. declare var WebGLSync: {
  154072. prototype: WebGLSync;
  154073. new(): WebGLSync;
  154074. };
  154075. interface WebGLTransformFeedback extends WebGLObject {
  154076. }
  154077. declare var WebGLTransformFeedback: {
  154078. prototype: WebGLTransformFeedback;
  154079. new(): WebGLTransformFeedback;
  154080. };
  154081. interface WebGLVertexArrayObject extends WebGLObject {
  154082. }
  154083. declare var WebGLVertexArrayObject: {
  154084. prototype: WebGLVertexArrayObject;
  154085. new(): WebGLVertexArrayObject;
  154086. };
  154087. // Type definitions for WebVR API
  154088. // Project: https://w3c.github.io/webvr/
  154089. // Definitions by: six a <https://github.com/lostfictions>
  154090. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  154091. interface VRDisplay extends EventTarget {
  154092. /**
  154093. * Dictionary of capabilities describing the VRDisplay.
  154094. */
  154095. readonly capabilities: VRDisplayCapabilities;
  154096. /**
  154097. * z-depth defining the far plane of the eye view frustum
  154098. * enables mapping of values in the render target depth
  154099. * attachment to scene coordinates. Initially set to 10000.0.
  154100. */
  154101. depthFar: number;
  154102. /**
  154103. * z-depth defining the near plane of the eye view frustum
  154104. * enables mapping of values in the render target depth
  154105. * attachment to scene coordinates. Initially set to 0.01.
  154106. */
  154107. depthNear: number;
  154108. /**
  154109. * An identifier for this distinct VRDisplay. Used as an
  154110. * association point in the Gamepad API.
  154111. */
  154112. readonly displayId: number;
  154113. /**
  154114. * A display name, a user-readable name identifying it.
  154115. */
  154116. readonly displayName: string;
  154117. readonly isConnected: boolean;
  154118. readonly isPresenting: boolean;
  154119. /**
  154120. * If this VRDisplay supports room-scale experiences, the optional
  154121. * stage attribute contains details on the room-scale parameters.
  154122. */
  154123. readonly stageParameters: VRStageParameters | null;
  154124. /**
  154125. * Passing the value returned by `requestAnimationFrame` to
  154126. * `cancelAnimationFrame` will unregister the callback.
  154127. * @param handle Define the hanle of the request to cancel
  154128. */
  154129. cancelAnimationFrame(handle: number): void;
  154130. /**
  154131. * Stops presenting to the VRDisplay.
  154132. * @returns a promise to know when it stopped
  154133. */
  154134. exitPresent(): Promise<void>;
  154135. /**
  154136. * Return the current VREyeParameters for the given eye.
  154137. * @param whichEye Define the eye we want the parameter for
  154138. * @returns the eye parameters
  154139. */
  154140. getEyeParameters(whichEye: string): VREyeParameters;
  154141. /**
  154142. * Populates the passed VRFrameData with the information required to render
  154143. * the current frame.
  154144. * @param frameData Define the data structure to populate
  154145. * @returns true if ok otherwise false
  154146. */
  154147. getFrameData(frameData: VRFrameData): boolean;
  154148. /**
  154149. * Get the layers currently being presented.
  154150. * @returns the list of VR layers
  154151. */
  154152. getLayers(): VRLayer[];
  154153. /**
  154154. * Return a VRPose containing the future predicted pose of the VRDisplay
  154155. * when the current frame will be presented. The value returned will not
  154156. * change until JavaScript has returned control to the browser.
  154157. *
  154158. * The VRPose will contain the position, orientation, velocity,
  154159. * and acceleration of each of these properties.
  154160. * @returns the pose object
  154161. */
  154162. getPose(): VRPose;
  154163. /**
  154164. * Return the current instantaneous pose of the VRDisplay, with no
  154165. * prediction applied.
  154166. * @returns the current instantaneous pose
  154167. */
  154168. getImmediatePose(): VRPose;
  154169. /**
  154170. * The callback passed to `requestAnimationFrame` will be called
  154171. * any time a new frame should be rendered. When the VRDisplay is
  154172. * presenting the callback will be called at the native refresh
  154173. * rate of the HMD. When not presenting this function acts
  154174. * identically to how window.requestAnimationFrame acts. Content should
  154175. * make no assumptions of frame rate or vsync behavior as the HMD runs
  154176. * asynchronously from other displays and at differing refresh rates.
  154177. * @param callback Define the eaction to run next frame
  154178. * @returns the request handle it
  154179. */
  154180. requestAnimationFrame(callback: FrameRequestCallback): number;
  154181. /**
  154182. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  154183. * Repeat calls while already presenting will update the VRLayers being displayed.
  154184. * @param layers Define the list of layer to present
  154185. * @returns a promise to know when the request has been fulfilled
  154186. */
  154187. requestPresent(layers: VRLayer[]): Promise<void>;
  154188. /**
  154189. * Reset the pose for this display, treating its current position and
  154190. * orientation as the "origin/zero" values. VRPose.position,
  154191. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  154192. * updated when calling resetPose(). This should be called in only
  154193. * sitting-space experiences.
  154194. */
  154195. resetPose(): void;
  154196. /**
  154197. * The VRLayer provided to the VRDisplay will be captured and presented
  154198. * in the HMD. Calling this function has the same effect on the source
  154199. * canvas as any other operation that uses its source image, and canvases
  154200. * created without preserveDrawingBuffer set to true will be cleared.
  154201. * @param pose Define the pose to submit
  154202. */
  154203. submitFrame(pose?: VRPose): void;
  154204. }
  154205. declare var VRDisplay: {
  154206. prototype: VRDisplay;
  154207. new(): VRDisplay;
  154208. };
  154209. interface VRLayer {
  154210. leftBounds?: number[] | Float32Array | null;
  154211. rightBounds?: number[] | Float32Array | null;
  154212. source?: HTMLCanvasElement | null;
  154213. }
  154214. interface VRDisplayCapabilities {
  154215. readonly canPresent: boolean;
  154216. readonly hasExternalDisplay: boolean;
  154217. readonly hasOrientation: boolean;
  154218. readonly hasPosition: boolean;
  154219. readonly maxLayers: number;
  154220. }
  154221. interface VREyeParameters {
  154222. /** @deprecated */
  154223. readonly fieldOfView: VRFieldOfView;
  154224. readonly offset: Float32Array;
  154225. readonly renderHeight: number;
  154226. readonly renderWidth: number;
  154227. }
  154228. interface VRFieldOfView {
  154229. readonly downDegrees: number;
  154230. readonly leftDegrees: number;
  154231. readonly rightDegrees: number;
  154232. readonly upDegrees: number;
  154233. }
  154234. interface VRFrameData {
  154235. readonly leftProjectionMatrix: Float32Array;
  154236. readonly leftViewMatrix: Float32Array;
  154237. readonly pose: VRPose;
  154238. readonly rightProjectionMatrix: Float32Array;
  154239. readonly rightViewMatrix: Float32Array;
  154240. readonly timestamp: number;
  154241. }
  154242. interface VRPose {
  154243. readonly angularAcceleration: Float32Array | null;
  154244. readonly angularVelocity: Float32Array | null;
  154245. readonly linearAcceleration: Float32Array | null;
  154246. readonly linearVelocity: Float32Array | null;
  154247. readonly orientation: Float32Array | null;
  154248. readonly position: Float32Array | null;
  154249. readonly timestamp: number;
  154250. }
  154251. interface VRStageParameters {
  154252. sittingToStandingTransform?: Float32Array;
  154253. sizeX?: number;
  154254. sizeY?: number;
  154255. }
  154256. interface Navigator {
  154257. getVRDisplays(): Promise<VRDisplay[]>;
  154258. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  154259. }
  154260. interface Window {
  154261. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  154262. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  154263. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  154264. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154265. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154266. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  154267. }
  154268. interface Gamepad {
  154269. readonly displayId: number;
  154270. }
  154271. type XRSessionMode =
  154272. | "inline"
  154273. | "immersive-vr"
  154274. | "immersive-ar";
  154275. type XRReferenceSpaceType =
  154276. | "viewer"
  154277. | "local"
  154278. | "local-floor"
  154279. | "bounded-floor"
  154280. | "unbounded";
  154281. type XREnvironmentBlendMode =
  154282. | "opaque"
  154283. | "additive"
  154284. | "alpha-blend";
  154285. type XRVisibilityState =
  154286. | "visible"
  154287. | "visible-blurred"
  154288. | "hidden";
  154289. type XRHandedness =
  154290. | "none"
  154291. | "left"
  154292. | "right";
  154293. type XRTargetRayMode =
  154294. | "gaze"
  154295. | "tracked-pointer"
  154296. | "screen";
  154297. type XREye =
  154298. | "none"
  154299. | "left"
  154300. | "right";
  154301. type XREventType =
  154302. | "devicechange"
  154303. | "visibilitychange"
  154304. | "end"
  154305. | "inputsourceschange"
  154306. | "select"
  154307. | "selectstart"
  154308. | "selectend"
  154309. | "squeeze"
  154310. | "squeezestart"
  154311. | "squeezeend"
  154312. | "reset";
  154313. interface XRSpace extends EventTarget {
  154314. }
  154315. interface XRRenderState {
  154316. depthNear?: number;
  154317. depthFar?: number;
  154318. inlineVerticalFieldOfView?: number;
  154319. baseLayer?: XRWebGLLayer;
  154320. }
  154321. interface XRInputSource {
  154322. handedness: XRHandedness;
  154323. targetRayMode: XRTargetRayMode;
  154324. targetRaySpace: XRSpace;
  154325. gripSpace: XRSpace | undefined;
  154326. gamepad: Gamepad | undefined;
  154327. profiles: Array<string>;
  154328. }
  154329. interface XRSessionInit {
  154330. optionalFeatures?: string[];
  154331. requiredFeatures?: string[];
  154332. }
  154333. interface XRSession {
  154334. addEventListener: Function;
  154335. removeEventListener: Function;
  154336. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  154337. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  154338. requestAnimationFrame: Function;
  154339. end(): Promise<void>;
  154340. renderState: XRRenderState;
  154341. inputSources: Array<XRInputSource>;
  154342. // hit test
  154343. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154344. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154345. // legacy AR hit test
  154346. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154347. // legacy plane detection
  154348. updateWorldTrackingState(options: {
  154349. planeDetectionState?: { enabled: boolean; }
  154350. }): void;
  154351. }
  154352. interface XRReferenceSpace extends XRSpace {
  154353. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154354. onreset: any;
  154355. }
  154356. type XRPlaneSet = Set<XRPlane>;
  154357. type XRAnchorSet = Set<XRAnchor>;
  154358. interface XRFrame {
  154359. session: XRSession;
  154360. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154361. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154362. // AR
  154363. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154364. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154365. // Anchors
  154366. trackedAnchors?: XRAnchorSet;
  154367. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154368. // Planes
  154369. worldInformation: {
  154370. detectedPlanes?: XRPlaneSet;
  154371. };
  154372. }
  154373. interface XRViewerPose extends XRPose {
  154374. views: Array<XRView>;
  154375. }
  154376. interface XRPose {
  154377. transform: XRRigidTransform;
  154378. emulatedPosition: boolean;
  154379. }
  154380. interface XRWebGLLayerOptions {
  154381. antialias?: boolean;
  154382. depth?: boolean;
  154383. stencil?: boolean;
  154384. alpha?: boolean;
  154385. multiview?: boolean;
  154386. framebufferScaleFactor?: number;
  154387. }
  154388. declare var XRWebGLLayer: {
  154389. prototype: XRWebGLLayer;
  154390. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154391. };
  154392. interface XRWebGLLayer {
  154393. framebuffer: WebGLFramebuffer;
  154394. framebufferWidth: number;
  154395. framebufferHeight: number;
  154396. getViewport: Function;
  154397. }
  154398. declare class XRRigidTransform {
  154399. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154400. position: DOMPointReadOnly;
  154401. orientation: DOMPointReadOnly;
  154402. matrix: Float32Array;
  154403. inverse: XRRigidTransform;
  154404. }
  154405. interface XRView {
  154406. eye: XREye;
  154407. projectionMatrix: Float32Array;
  154408. transform: XRRigidTransform;
  154409. }
  154410. interface XRInputSourceChangeEvent {
  154411. session: XRSession;
  154412. removed: Array<XRInputSource>;
  154413. added: Array<XRInputSource>;
  154414. }
  154415. interface XRInputSourceEvent extends Event {
  154416. readonly frame: XRFrame;
  154417. readonly inputSource: XRInputSource;
  154418. }
  154419. // Experimental(er) features
  154420. declare class XRRay {
  154421. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154422. origin: DOMPointReadOnly;
  154423. direction: DOMPointReadOnly;
  154424. matrix: Float32Array;
  154425. }
  154426. declare enum XRHitTestTrackableType {
  154427. "point",
  154428. "plane"
  154429. }
  154430. interface XRHitResult {
  154431. hitMatrix: Float32Array;
  154432. }
  154433. interface XRTransientInputHitTestResult {
  154434. readonly inputSource: XRInputSource;
  154435. readonly results: Array<XRHitTestResult>;
  154436. }
  154437. interface XRHitTestResult {
  154438. getPose(baseSpace: XRSpace): XRPose | undefined;
  154439. // When anchor system is enabled
  154440. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154441. }
  154442. interface XRHitTestSource {
  154443. cancel(): void;
  154444. }
  154445. interface XRTransientInputHitTestSource {
  154446. cancel(): void;
  154447. }
  154448. interface XRHitTestOptionsInit {
  154449. space: XRSpace;
  154450. entityTypes?: Array<XRHitTestTrackableType>;
  154451. offsetRay?: XRRay;
  154452. }
  154453. interface XRTransientInputHitTestOptionsInit {
  154454. profile: string;
  154455. entityTypes?: Array<XRHitTestTrackableType>;
  154456. offsetRay?: XRRay;
  154457. }
  154458. interface XRAnchor {
  154459. anchorSpace: XRSpace;
  154460. delete(): void;
  154461. }
  154462. interface XRPlane {
  154463. orientation: "Horizontal" | "Vertical";
  154464. planeSpace: XRSpace;
  154465. polygon: Array<DOMPointReadOnly>;
  154466. lastChangedTime: number;
  154467. }